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

Title: Using SENSOR_TIMER
Post 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:
Code: [Select]
set_timer_interval(1000); // Event every 1 second (1000ms)
Then you should add common sensor handler like:
Code: [Select]
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:
Code: [Select]
set_timer_interval(0); // Disable Timer
Enjoy
Title: Re: Using SENSOR_TIMER
Post by: InmemoryofRomeo on December 25, 2009, 11:05:22 PM
The code worked spot on, thank you so much, I will upload a newer version of the Christmas skit very soon :)
SimplePortal 2.3.5 © 2008-2012, SimplePortal