Help needed with tux.monitoring object & methods
Up to Scripts
Please,
Can someone right a simple python script using events & tux.monitoring ?
It will be very helpfull for me, after several tests I failed writing something correct 
To use the events, you've to link the tux.event.xxx to your own function.
For example, if you want to execute a function when the head button is pushed :
tux.event.on_head_bt_pushed = my_funct
def my_funct():
print 'The head button has been pushed !'
# When you quit your script :
tux.event.on_head_bt_pushed = None
You can have the list of the events with the command : tux.misc.doc(tux.event)
The monitoring function works like the events functions. If you want to monitor the light level, you have to insert your own function :
monitoring_id = tux.monitoring.insert(0x1B, my_function)
# 0x1B if for the light level. You can find all the OPCODE on the file /opt/tuxdroid/api/python/tuxapi_const.py
# in the 'status datas' section. (line 123)
def my_funct (self, args):
light_level = (args[0] * 256) + args[1]
print 'ight_level
# When you quit your script :
tux.monitoring.remove(monitoring_id)
You can also find the reference manual here : doc.tuxisalive.com/api or with the command help(tux).
I hope this will help you for your developments.
For example, if you want to execute a function when the head button is pushed :
tux.event.on_head_bt_pushed = my_funct
def my_funct():
print 'The head button has been pushed !'
# When you quit your script :
tux.event.on_head_bt_pushed = None
You can have the list of the events with the command : tux.misc.doc(tux.event)
The monitoring function works like the events functions. If you want to monitor the light level, you have to insert your own function :
monitoring_id = tux.monitoring.insert(0x1B, my_function)
# 0x1B if for the light level. You can find all the OPCODE on the file /opt/tuxdroid/api/python/tuxapi_const.py
# in the 'status datas' section. (line 123)
def my_funct (self, args):
light_level = (args[0] * 256) + args[1]
print 'ight_level
# When you quit your script :
tux.monitoring.remove(monitoring_id)
You can also find the reference manual here : doc.tuxisalive.com/api or with the command help(tux).
I hope this will help you for your developments.
Powered by
Ploneboard
