[main] remove explicit button test, leave LEDs on for the entire time
This commit is contained in:
parent
4f8fe7ba39
commit
8cd4d9b60e
|
@ -120,72 +120,6 @@ static void MX_I2S2_Init(void);
|
|||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
static void button_init_and_test(void)
|
||||
{
|
||||
// letting the buttons be tested
|
||||
display_write_data_seq("Fill any bar:");
|
||||
DISPLAY_SET_CURSOR(1, 5);
|
||||
display_write_data_seq("[-] [-----]");
|
||||
|
||||
size_t pressed_elements;
|
||||
|
||||
uint32_t sw_button_locations[5][2] = {
|
||||
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_11},
|
||||
{(uint32_t) GPIOA, (uint32_t) GPIO_PIN_15},
|
||||
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_9},
|
||||
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_6},
|
||||
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_8}
|
||||
};
|
||||
|
||||
do {
|
||||
HAL_Delay(100);
|
||||
pressed_elements = 0;
|
||||
|
||||
DISPLAY_SET_CURSOR(1, 6);
|
||||
|
||||
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0)) {
|
||||
pressed_elements |= 0x20;
|
||||
display_write_data_byte('*');
|
||||
} else {
|
||||
display_write_data_byte('-');
|
||||
}
|
||||
|
||||
DISPLAY_SET_CURSOR(1, 10);
|
||||
|
||||
for (size_t i = 0; i < 5; i++) {
|
||||
pressed_elements >>= 1;
|
||||
|
||||
size_t input = !HAL_GPIO_ReadPin((GPIO_TypeDef *) sw_button_locations[i][0], sw_button_locations[i][1]);
|
||||
|
||||
if (input) {
|
||||
pressed_elements |= 0x20;
|
||||
display_write_data_byte('*');
|
||||
} else {
|
||||
display_write_data_byte('-');
|
||||
}
|
||||
}
|
||||
} while (!(((pressed_elements & 0x1) == 0x1) || ((pressed_elements & 0x3E) == 0x3E)));
|
||||
|
||||
|
||||
// visual reaction to bar fill
|
||||
DISPLAY_SET_CURSOR(0, 0);
|
||||
display_write_data_seq("Release buttons");
|
||||
|
||||
GPIOD->ODR = 0x1000;
|
||||
HAL_Delay(300);
|
||||
GPIOD->ODR = 0x2000;
|
||||
HAL_Delay(300);
|
||||
GPIOD->ODR = 0x4000;
|
||||
HAL_Delay(300);
|
||||
GPIOD->ODR = 0x8000;
|
||||
HAL_Delay(300);
|
||||
|
||||
// waiting for all buttons to be released
|
||||
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
|
||||
GPIOD->ODR = 0x0000;
|
||||
HAL_Delay(200);
|
||||
}
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
|
@ -224,15 +158,10 @@ int main(void)
|
|||
MX_I2S2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
HAL_TIM_Base_Start(&htim2);
|
||||
TIM2->CNT = 0;
|
||||
HAL_TIM_Base_Stop(&htim2);
|
||||
|
||||
GPIOD->ODR = 0x1000;
|
||||
GPIOD->BSRR = 0x1000;
|
||||
display_init();
|
||||
|
||||
GPIOD->ODR = 0xF000;
|
||||
button_init_and_test();
|
||||
GPIOD->BSRR = 0xF000;
|
||||
|
||||
// perform all tests
|
||||
size_t successful_tests = 0;
|
||||
|
@ -280,7 +209,10 @@ int main(void)
|
|||
display_current_frame = 0;
|
||||
|
||||
DISPLAY_CLEAR;
|
||||
display_write_data_seq("All tests done!");
|
||||
if (successful_tests == LEN(executors))
|
||||
display_write_data_seq("All tests done!");
|
||||
else
|
||||
display_write_data_seq("Failures found!");
|
||||
|
||||
DISPLAY_SET_CURSOR(1, 2);
|
||||
display_write_data_seq("P:");
|
||||
|
|
Loading…
Reference in New Issue