• ESP32Forth, new listing: configurable timer for housekeeper

    From Marc Petremann@21:1/5 to All on Wed Jul 6 15:55:20 2022
    Hello,
    After blinking an LED per timer, let's see another use case. Here, we are going to manage a timer in an intelligent way, this to help a housemaid. This ESP32Forth example application combines timer management and hardware interrupts.
    https://github.com/MPETREMANN11/ESP32forth/blob/main/timers/configurable-timer.txt

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jos Ven@21:1/5 to All on Sat Jul 9 03:23:25 2022
    On 7 juli 2022 00:55:21 UTC+2 wrote mpetre:
    Hello,
    After blinking an LED per timer, let's see another use case. Here, we are going to manage a timer in an intelligent way, this to help a housemaid. This ESP32Forth example application combines timer management and hardware interrupts.
    https://github.com/MPETREMANN11/ESP32forth/blob/main/timers/configurable-timer.txt

    Also possible to blink a led:

    cr .( poll-timers.fth)

    0 [if]
    blinker is called every 10 ms and does not waste 2000 ms
    2 timers are used to switch the led on or off
    sysledoff sysledOn should be defined for your situation
    Notes:
    1. Do not use it in time-critical situations
    2. Uses ms@ for reading the current numer of milliseconds. ( - ms )
    [then]

    : start-timer ( timer - ) ms@ true rot 2! ;

    : tElapsed? ( ms-elapsed timer - flag )
    2@
    if + ms@ < \ Time elapsed?
    else 2drop false \ The timer is off
    then ;

    2variable tWaitLed2
    2variable tLed2-On
    2variable tLed2-Off

    #100 value MsOn
    #2000 value Msoff

    : sysledoff ( - ) cr ." sysledoff " ;
    : sysledOn ( - ) cr ." sysledOn " ;

    : BlinkLed ( - )
    MsOn tLed2-On tElapsed?
    if sysledoff tLed2-On off
    tLed2-Off start-timer
    else Msoff tLed2-Off tElapsed?
    if sysledOn tLed2-Off off
    tLed2-On start-timer
    then
    then ;

    : blinker ( - )
    #3000 tWaitLed2 tElapsed?
    if BlinkLed
    then ;

    : poll-app ( - )
    sysledOff
    tWaitLed2 start-timer
    tLed2-On start-timer
    tLed2-Off off
    begin blinker #10 ms key?
    until ;

    poll-app
    \ \s

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)