Modifications

Sauter à la navigation Sauter à la recherche
478 octets ajoutés ,  29 avril 2025 à 20:32
Ligne 116 : Ligne 116 :  
Please note that once started, a watchdog cannot be disabled!
 
Please note that once started, a watchdog cannot be disabled!
   −
Most of microcontroler do have an hardware watchdog. Once the watchdog started (its timeout set), do not forget to update it (feed it) before it reach the timeout... otherwise it will reset the microcontroler.
+
Most of microcontroler do have an hardware watchdog. Once the watchdog started (set its timeout), you will have to ping it (feed it) before it reach the timeout... otherwise it will reset the microcontroler.
    
The example [https://github.com/mchobby/micropython-mydin/blob/main/examples/din_controlers/common/async-watchdog.py async-watchdog.py], visible here below, shows how to activate the watchdog. No need to call the {{fname|din.feed_watchdog()}} because it is already called at every execution cycle of the ''userloop'' .
 
The example [https://github.com/mchobby/micropython-mydin/blob/main/examples/din_controlers/common/async-watchdog.py async-watchdog.py], visible here below, shows how to activate the watchdog. No need to call the {{fname|din.feed_watchdog()}} because it is already called at every execution cycle of the ''userloop'' .
 +
 +
<syntaxhighlight lang="python">
 +
from mydin import configure
 +
from mydin.pico import Pico3Mod
 +
from mydin.backplane.relays import TwoRelay3Mod
 +
 +
din = configure( Pico3Mod, TwoRelay3Mod )
 +
 +
async def loop( din ):
 +
  din.leds[0].off()
 +
  # direct access to button state
 +
  while din.buttons[0].value()==0: # while pressed
 +
    din.leds[0].on()
 +
 +
 +
din.setup( setup=None, loop=loop )
 +
# Watchdog resets if loop() stay locked for 2 sec
 +
din.setup_watchdog( 2000 )
 +
din.run()
 +
</syntaxhighlight>
    
== Add scheduler task ==
 
== Add scheduler task ==
32 908

modifications

Menu de navigation