X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fvidtime%2Fao_vidtime.c;h=e9f8b218ced6f1a6aa9f6bc429f1a9538ee485f1;hb=3ed101d634968666cd3ee2d8c49737970caf406b;hp=e7f2c2191ae9508826a2824502e82da6fb479896;hpb=06dac6551418ba817798c187f198b9b00c1dda74;p=fw%2Faltos diff --git a/src/vidtime/ao_vidtime.c b/src/vidtime/ao_vidtime.c index e7f2c219..e9f8b218 100644 --- a/src/vidtime/ao_vidtime.c +++ b/src/vidtime/ao_vidtime.c @@ -24,33 +24,25 @@ static uint8_t vidtime_monitor; static void vidtime(void) { + uint8_t old = 0, got; + ao_exti_enable(AO_SENSOR_PORT, AO_SENSOR_PIN); for (;;) { while (!vidtime_monitor) ao_sleep(&vidtime_monitor); - ao_sleep(&sensor_value); - printf("%d\n", sensor_value); + while ((got = sensor_value) == old) + ao_sleep(&sensor_value); + printf("%d\n", got); flush(); + old = got; } } static void sensor_interrupt(void) { - uint8_t new = ao_gpio_get(AO_SENSOR_PORT, AO_SENSOR_PIN, foo); - -#if 0 - if (new) - ao_exti_set_mode(AO_SENSOR_PORT, AO_SENSOR_PIN, - AO_EXTI_MODE_FALLING); - else - ao_exti_set_mode(AO_SENSOR_PORT, AO_SENSOR_PIN, - AO_EXTI_MODE_RISING); -#endif - if (new != sensor_value) { - sensor_value = new; - ao_wakeup(&sensor_value); - } + sensor_value = ao_gpio_get(AO_SENSOR_PORT, AO_SENSOR_PIN, foo); + ao_wakeup(&sensor_value); } static struct ao_task vidtime_task; @@ -71,9 +63,9 @@ ao_init_vidtime(void) static void ao_set_vidtime(void) { - ao_cmd_decimal(); + uint16_t r = ao_cmd_decimal(); if (ao_cmd_status == ao_cmd_success) { - vidtime_monitor = ao_cmd_lex_i != 0; + vidtime_monitor = r != 0; ao_wakeup(&vidtime_monitor); } }