@ -24,8 +24,8 @@ namespace Akela {
// --- state ---
// --- state ---
Key Leader : : sequence [ LEADER_MAX_SEQUENCE_LENGTH + 1 ] ;
Key Leader : : sequence [ LEADER_MAX_SEQUENCE_LENGTH + 1 ] ;
uint8_t Leader : : sequencePos ;
uint8_t Leader : : sequencePos ;
uint 8_t Leader : : timer ;
uint 32_t Leader : : startTime ;
uint 8_t Leader : : timeOut = 2 0;
uint 16_t Leader : : timeOut = 100 0;
const Leader : : dictionary_t * Leader : : dictionary ;
const Leader : : dictionary_t * Leader : : dictionary ;
// --- helpers ---
// --- helpers ---
@ -89,7 +89,7 @@ namespace Akela {
void
void
Leader : : reset ( void ) {
Leader : : reset ( void ) {
timer = 0 ;
s tartT ime = 0 ;
sequencePos = 0 ;
sequencePos = 0 ;
sequence [ 0 ] . raw = Key_NoKey . raw ;
sequence [ 0 ] . raw = Key_NoKey . raw ;
}
}
@ -119,6 +119,7 @@ namespace Akela {
if ( key_toggled_off ( keyState ) ) {
if ( key_toggled_off ( keyState ) ) {
// not active, but a leader key = start the sequence on key release!
// not active, but a leader key = start the sequence on key release!
startTime = millis ( ) ;
sequencePos = 0 ;
sequencePos = 0 ;
sequence [ sequencePos ] . raw = mappedKey . raw ;
sequence [ sequencePos ] . raw = mappedKey . raw ;
}
}
@ -137,7 +138,7 @@ namespace Akela {
return mappedKey ;
return mappedKey ;
}
}
timer = 0 ;
startTime = millis ( ) ;
sequence [ sequencePos ] . raw = mappedKey . raw ;
sequence [ sequencePos ] . raw = mappedKey . raw ;
actionIndex = lookup ( ) ;
actionIndex = lookup ( ) ;
@ -169,10 +170,7 @@ namespace Akela {
if ( ! isActive ( ) )
if ( ! isActive ( ) )
return ;
return ;
if ( timer < timeOut )
if ( ( millis ( ) - startTime ) > = timeOut )
timer + + ;
if ( timer > = timeOut )
reset ( ) ;
reset ( ) ;
}
}
} ;
} ;