diff options
| author | Keith Packard <keithp@keithp.com> | 2018-05-16 22:05:26 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2018-05-16 22:06:12 -0700 | 
| commit | 5a26df7db9453bf0596f729a23efb90e5e8a63c7 (patch) | |
| tree | cdf4d26b9a30eead0728bfd36bd85b0c19bcf4a6 /src | |
| parent | 06dac6551418ba817798c187f198b9b00c1dda74 (diff) | |
altos/vidtime: Check for value change in normal code, not irq
This makes sure each value change is reported to the user.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/vidtime/ao_vidtime.c | 24 | 
1 files changed, 8 insertions, 16 deletions
diff --git a/src/vidtime/ao_vidtime.c b/src/vidtime/ao_vidtime.c index e7f2c219..1b9b9e1c 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;  | 
