add mock buttons
This commit is contained in:
		@ -12,7 +12,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// TODO Remove for STW v2
 | 
					// TODO Remove for STW v2
 | 
				
			||||||
#define MOCK_NUM_BUTTONS 5
 | 
					#define MOCK_NUM_BUTTONS 5
 | 
				
			||||||
 | 
					#define MOCK_BUTTON_TICK_CHANGE 1000
 | 
				
			||||||
 | 
					uint32_t last_tick = 0;
 | 
				
			||||||
uint8_t mock_button_counter = 0;
 | 
					uint8_t mock_button_counter = 0;
 | 
				
			||||||
 | 
					// END TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ui_thread_entry(ULONG _) {
 | 
					void ui_thread_entry(ULONG _) {
 | 
				
			||||||
  GPIO_TypeDef *button_ports[NUM_BUTTONS] = {BTN1_GPIO_Port, BTN2_GPIO_Port,
 | 
					  GPIO_TypeDef *button_ports[NUM_BUTTONS] = {BTN1_GPIO_Port, BTN2_GPIO_Port,
 | 
				
			||||||
@ -50,16 +53,23 @@ void ui_thread_entry(ULONG _) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // TODO restore this for STW24-v2
 | 
					    // TODO restore this for STW24-v2
 | 
				
			||||||
    // vehicle_broadcast_buttons(button_states);
 | 
					    // vehicle_broadcast_buttons(button_states);
 | 
				
			||||||
    // Release so other threads can get scheduled
 | 
					    // END TODO
 | 
				
			||||||
    // tx_thread_sleep(1);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO (STW24) Remove for STW24-v2 !!
 | 
					    // TODO (STW24) Remove for STW24-v2 !!
 | 
				
			||||||
    GPIO_PinState mock_button_states[MOCK_NUM_BUTTONS] = {mock_button_states};
 | 
					    GPIO_PinState mock_button_states[MOCK_NUM_BUTTONS] = {mock_button_states};
 | 
				
			||||||
    mock_button_states[mock_button_counter] = GPIO_PIN_SET;
 | 
					    mock_button_states[mock_button_counter] = GPIO_PIN_SET;
 | 
				
			||||||
 | 
					    uint32_t now = HAL_GetTick();
 | 
				
			||||||
 | 
					    // Wait 1s before moving to the next button
 | 
				
			||||||
 | 
					    if (abs(now - last_tick) >= MOCK_BUTTON_TICK_CHANGE) {
 | 
				
			||||||
      mock_button_counter++;
 | 
					      mock_button_counter++;
 | 
				
			||||||
      mock_button_counter %= MOCK_NUM_BUTTONS;
 | 
					      mock_button_counter %= MOCK_NUM_BUTTONS;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    vehicle_broadcast_buttons(mock_button_states);
 | 
					    vehicle_broadcast_buttons(mock_button_states);
 | 
				
			||||||
    tx_thread_sleep(1000);
 | 
					    // END TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Release so other threads can get scheduled
 | 
				
			||||||
 | 
					    tx_thread_sleep(1);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user