Commit 7029ead3 authored by Sven Greiner's avatar Sven Greiner

[WIP] Accumulate short presses

This allows to directly enter a specific complex mode without switching
between various intermediate modes (e.g. ramping/frozen or level
increment) by accumulating fast presses for 400 ms and performing the
action only after that time.

The downside is that mode changes (next level in fixed mode or ramp
freezing) is also delayed. When entering config mode the light does not
turn off anymore.

This way of switching modes might allow some more optimization of the
event handling, but probably not with such minimal differences betweeen
both implementations. On the other hand it makes mode transitions much
more pleasant to the eye (actual usability to be evaluated).
parent 84b2a318
......@@ -18,6 +18,7 @@
// Optional features
#define BATTCHECK
#define LOW_VOLTAGE_PROTECTION
#define DELAY_EVENT
#include <avr/io.h>
#include <util/delay.h>
......@@ -296,9 +297,11 @@ ISR(TIM0_OVF_vect) {
++ticks;
}
#ifndef DELAY_EVENT
if (ticks == 4) { // ~440 ms
fast_presses = 0;
}
#endif // ifndef DELAY_EVENT
}
/**
......@@ -366,6 +369,12 @@ int main(void) {
fast_presses = 10;
}
#ifdef DELAY_EVENT
set_level(output);
delay_10ms(40);
// TODO Delaying here prevents the light from turning off when entering config mode
#endif // ifdef DELAY_EVENT
// Input handling
if (options.fixed_mode) {
switch (fast_presses) {
......@@ -419,6 +428,10 @@ int main(void) {
set_level(output);
#ifdef DELAY_EVENT
fast_presses = 0;
#endif // ifdef DELAY_EVENT
while (1) {
switch (state) {
case kDefault:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment