buttons: initialize mcu buttons based on inverted state

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2019-07-05 19:30:30 -04:00 committed by KevinOConnor
parent e19a41d0dd
commit 0f1d42466b
2 changed files with 6 additions and 4 deletions

View File

@ -49,8 +49,9 @@ class MCU_buttons:
rest_ticks = self.mcu.seconds_to_clock(QUERY_TIME) rest_ticks = self.mcu.seconds_to_clock(QUERY_TIME)
self.mcu.add_config_cmd( self.mcu.add_config_cmd(
"buttons_query oid=%d clock=%d" "buttons_query oid=%d clock=%d"
" rest_ticks=%d retransmit_count=%d" % ( " rest_ticks=%d retransmit_count=%d invert=%d" % (
self.oid, clock, rest_ticks, RETRANSMIT_COUNT), is_init=True) self.oid, clock, rest_ticks, RETRANSMIT_COUNT,
self.invert), is_init=True)
self.mcu.register_response(self.handle_buttons_state, self.mcu.register_response(self.handle_buttons_state,
"buttons_state", self.oid) "buttons_state", self.oid)
def handle_buttons_state(self, params): def handle_buttons_state(self, params):

View File

@ -102,7 +102,7 @@ command_buttons_query(uint32_t *args)
sched_del_timer(&b->time); sched_del_timer(&b->time);
b->time.waketime = args[1]; b->time.waketime = args[1];
b->rest_ticks = args[2]; b->rest_ticks = args[2];
b->pressed = b->last_pressed = 0; b->pressed = b->last_pressed = args[4];
b->ack_count = b->report_count = 0; b->ack_count = b->report_count = 0;
b->retransmit_state = BF_ACKED; b->retransmit_state = BF_ACKED;
b->retransmit_count = args[3]; b->retransmit_count = args[3];
@ -113,7 +113,8 @@ command_buttons_query(uint32_t *args)
sched_add_timer(&b->time); sched_add_timer(&b->time);
} }
DECL_COMMAND(command_buttons_query, DECL_COMMAND(command_buttons_query,
"buttons_query oid=%c clock=%u rest_ticks=%u retransmit_count=%c"); "buttons_query oid=%c clock=%u rest_ticks=%u retransmit_count=%c"
" invert=%c");
void void
command_buttons_ack(uint32_t *args) command_buttons_ack(uint32_t *args)