Support switch touching
This commit is contained in:
+27
-6
@@ -269,6 +269,7 @@ static void print_4bin_rev(char* out_str, uint8_t n) {
|
||||
static void debug_switches(void) {
|
||||
clean_bomb();
|
||||
uint8_t switch_state = 0xFF;
|
||||
uint8_t switch_touch_state = 0xFF;
|
||||
uint8_t button_state = 0xFF;
|
||||
|
||||
char bin_buf[5] = {0};
|
||||
@@ -279,32 +280,51 @@ static void debug_switches(void) {
|
||||
SwitchKey switch_;
|
||||
while (1) {
|
||||
if (get_pressed_button(&button)) {
|
||||
sprintf(buf, "Button Pressed: %d ", button);
|
||||
sprintf(buf, "Button Pressed: %d ", button);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_released_button(&button)) {
|
||||
sprintf(buf, "Button Released: %d ", button);
|
||||
sprintf(buf, "Button Released: %d", button);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_flipped_down_switch(&switch_)) {
|
||||
sprintf(buf, "Switch Down: %d ", switch_);
|
||||
sprintf(buf, "Switch Down: %d ", switch_);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_flipped_up_switch(&switch_)) {
|
||||
sprintf(buf, "Switch Up: %d ", switch_);
|
||||
sprintf(buf, "Switch Up: %d ", switch_);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_switch_touch_pressed(&switch_)) {
|
||||
sprintf(buf, "Switch Touch: %d ", switch_);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_switch_touch_released(&switch_)) {
|
||||
sprintf(buf, "Switch Un-touch: %d", switch_);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
|
||||
uint8_t new_switch_touch_state = get_switch_touch_state();
|
||||
if (new_switch_touch_state != switch_touch_state) {
|
||||
switch_touch_state = new_switch_touch_state;
|
||||
print_4bin_rev(bin_buf, switch_touch_state);
|
||||
sprintf(buf, "t: %s", bin_buf);
|
||||
lcd_print(1, 0, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
|
||||
uint8_t new_switch_state = get_switch_state();
|
||||
if (new_switch_state != switch_state) {
|
||||
switch_state = new_switch_state;
|
||||
print_4bin_rev(bin_buf, switch_state);
|
||||
sprintf(buf, "s: %s", bin_buf);
|
||||
lcd_print(1, 0, buf);
|
||||
lcd_print(1, 1, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
|
||||
@@ -313,9 +333,10 @@ static void debug_switches(void) {
|
||||
button_state = new_button_state;
|
||||
print_4bin_rev(bin_buf, button_state);
|
||||
sprintf(buf, "b: %s", bin_buf);
|
||||
lcd_print(1, 1, buf);
|
||||
lcd_print(1, 2, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
|
||||
|
||||
if (get_pressed_keypad(&key) && key == KeypadKey::pound) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user