Change screens if both left and right are pressed
This commit is contained in:
		@ -10,7 +10,7 @@ bool STWButtonController::sample(uint8_t &key) {
 | 
			
		||||
  ButtonMessage msg;
 | 
			
		||||
  if (tx_queue_receive(&gui_button_queue, &msg, TX_NO_WAIT) == TX_SUCCESS) {
 | 
			
		||||
    switch (msg.kind) {
 | 
			
		||||
    case UMK_BTN_RELEASED:
 | 
			
		||||
    case UMK_BTN_PRESSED:
 | 
			
		||||
      key = KEY_BTN1 + msg.number;
 | 
			
		||||
      break;
 | 
			
		||||
    case UMK_ENC_CW: {
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,7 @@ void ui_thread_entry(ULONG _) {
 | 
			
		||||
  uint32_t button_press_times[NUM_BUTTONS] = {HAL_GetTick()};
 | 
			
		||||
 | 
			
		||||
  while (1) {
 | 
			
		||||
    int press_event = -1;
 | 
			
		||||
    for (int i = 0; i < NUM_BUTTONS; i++) {
 | 
			
		||||
      GPIO_PinState state = HAL_GPIO_ReadPin(button_ports[i], button_pins[i]);
 | 
			
		||||
      if (state != button_states[i]) {
 | 
			
		||||
@ -27,13 +28,18 @@ void ui_thread_entry(ULONG _) {
 | 
			
		||||
        if (state == GPIO_PIN_SET &&
 | 
			
		||||
            now - button_press_times[i] >= BUTTON_MIN_INTERVAL) {
 | 
			
		||||
          // Button press event!
 | 
			
		||||
          press_event = i;
 | 
			
		||||
          button_press_times[i] = now;
 | 
			
		||||
          ButtonMessage msg = {.kind = UMK_BTN_RELEASED, .number = i};
 | 
			
		||||
          ButtonMessage msg = {.kind = UMK_BTN_PRESSED, .number = i};
 | 
			
		||||
          tx_queue_send(&gui_button_queue, &msg, TX_NO_WAIT);
 | 
			
		||||
        }
 | 
			
		||||
        button_states[i] = state;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if ((press_event == 1 || press_event == 2) && button_states[1] &&
 | 
			
		||||
        button_states[2]) {
 | 
			
		||||
      tx_event_flags_set(&gui_update_events, GUI_UPDATE_NEXT_SCREEN, TX_OR);
 | 
			
		||||
    }
 | 
			
		||||
    vehicle_broadcast_buttons(button_states);
 | 
			
		||||
    // Release so other threads can get scheduled
 | 
			
		||||
    tx_thread_sleep(1);
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user