Bob the Pleo Forums
Pleo Stuff => Pleo Hardware/Software => PDK, Programming, and code => Topic started by: Getorix on December 23, 2009, 04:25:35 PM
-
TASK:
Make Pleo to behave according to the timer events.
SOLUTION:
First of all you have to put this into public init() function of sensors.p file:
set_timer_interval(1000); // Event every 1 second (1000ms)
Then you should add common sensor handler like:
new name[32];
switch (sensor)
{
case SENSOR_TIMER:
{
sensor_get_name(sensor, name);
printf("+ <on_sensor> %d, %s, %d\n", time, name, value);
// DO SOMETHING
printf("- <on_sensor> %d, %s, %d\n", time, name, value);
}
}
Finally you should disable timer in public close() function:
set_timer_interval(0); // Disable Timer
Enjoy
-
The code worked spot on, thank you so much, I will upload a newer version of the Christmas skit very soon :)