This code isn't ready to release but I thought it might be useful:
https://github.com/ctimmer/iot-logger/t ... emperature
For testing:
Using powercontrol.py, remove all classes except Globals and PlugInTemplate.
Remove references to the display.
Code: Select all
#----
#---- PlugIn control set up
#----
global_data = Globals (poll_ms=100) # 0.10 second poll
#----
#---- plugin poll array - determines which plugin''s are polled and polling order
#----
poll_array = [
#ReadInput (global_data) , # Button input, turns on or off
#LedDisplay (global_data) , # LED blink
#Buzzer (global_data) , # buzzer on/off
PlugInTemplate (global_data) # demo
]
#----
#---- Start polling
#----
try :
while global_data.running () :
for plugin in poll_array : # poll each plugin
plugin.poll_it ()
global_data.poll_wait () # wait for next poll cycle
except : #Exception as e :
print ("poll_it: exception")
#print (e)
finally :
print ("Poll_It: completed")
#----
#---- plugin shutdown
#----
print ("plugins shutdown")
for plugin in poll_array :
#print ("mod shutdown", plugin.__class__)
try :
plugin.shutdown ()
except :
print ("plugin shutdown", plugin.__class__, "exception")
Notice that no timers are used.
The poll_ms parameter determines how often the poll loop is executed
PlugInTemplate shows the way to configure how often the plug in is active
self.global_data.message_set provides communication between the plugins
Sorry for the lack of documentation but this is in development. Feel free to ask any questions
Curt