Add further testing code for rotary encoder and lcd

This commit is contained in:
Mario Hüttel 2020-06-09 19:03:33 +02:00
parent 9615fdb39d
commit c63986e271
3 changed files with 19 additions and 3 deletions

View File

@ -39,4 +39,6 @@ int32_t rotary_encoder_get_change_val(void);
void rotary_encoder_stop(void); void rotary_encoder_stop(void);
void rotary_encoder_zero(void);
#endif /* __ROTARY_ENCODER_H__ */ #endif /* __ROTARY_ENCODER_H__ */

View File

@ -224,6 +224,8 @@ int main()
pid_init(&pid, 0.1, 0.1, 4.0, 0.0, 100.0, 40.0, 0.25); pid_init(&pid, 0.1, 0.1, 4.0, 0.0, 100.0, 40.0, 0.25);
pid_zero(&pid); pid_zero(&pid);
snprintf(&disp[2][0], 17, " \xBC\xCF\xAF\xC0 Reflow");
while (1) { while (1) {
sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted); sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted);
@ -249,7 +251,7 @@ int main()
else else
led_set(0, 0); led_set(0, 0);
snprintf(&disp[3][0], 17, "Temp: %s%.1f C", (temp_status == 0 ? "" : temp_status < 0 ? "<" : ">") snprintf(&disp[3][0], 17, "Temp: %s%.1f ""\xDF""C", (temp_status == 0 ? "" : temp_status < 0 ? "<" : ">")
, current_temp); , current_temp);
} }
@ -266,14 +268,21 @@ int main()
} }
button = button_read_event(); button = button_read_event();
if (button == BUTTON_SHORT_RELEASED) {
rotary_encoder_zero();
} else if (button == BUTTON_LONG_RELEASED) {
adc_pt1000_clear_error();
}
rot = rotary_encoder_get_abs_val(); rot = rotary_encoder_get_abs_val();
oven_driver_set_power(rot > 100U ? 100U : rot); oven_driver_set_power(rot > 100U ? 100U : rot);
/* TODO: handle gui */ /* TODO: handle gui */
snprintf(&disp[1][0], 17, "Rotary: %u", (unsigned int)rot); snprintf(&disp[1][0], 17, "Rot: %u %s", (unsigned int)rot, (button == BUTTON_SHORT ? "SHORT" : (button == BUTTON_LONG ? "LONG" : "")));
snprintf(&disp[2][0], 17, "Button: %s", (button == BUTTON_SHORT ? "SHORT" : (button == BUTTON_LONG ? "LONG" : "")));
handle_shell_uart_input(shell_handle); handle_shell_uart_input(shell_handle);

View File

@ -83,3 +83,8 @@ void rotary_encoder_stop(void)
rcc_manager_disable_clock(&RCC->APB1ENR, BITMASK_TO_BITNO(ROTARY_ENCODER_TIMER_RCC_MASK)); rcc_manager_disable_clock(&RCC->APB1ENR, BITMASK_TO_BITNO(ROTARY_ENCODER_TIMER_RCC_MASK));
rcc_manager_disable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(ROTARY_ENCODER_RCC_MASK)); rcc_manager_disable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(ROTARY_ENCODER_RCC_MASK));
} }
void rotary_encoder_zero(void)
{
ROTARY_ENCODER_TIMER->CNT = 0UL;
}