diff --git a/stm-firmware/include/reflow-controller/rotary-encoder.h b/stm-firmware/include/reflow-controller/rotary-encoder.h index a82e8e8..706cb32 100644 --- a/stm-firmware/include/reflow-controller/rotary-encoder.h +++ b/stm-firmware/include/reflow-controller/rotary-encoder.h @@ -39,4 +39,6 @@ int32_t rotary_encoder_get_change_val(void); void rotary_encoder_stop(void); +void rotary_encoder_zero(void); + #endif /* __ROTARY_ENCODER_H__ */ diff --git a/stm-firmware/main.c b/stm-firmware/main.c index 623558e..312551e 100644 --- a/stm-firmware/main.c +++ b/stm-firmware/main.c @@ -224,6 +224,8 @@ int main() pid_init(&pid, 0.1, 0.1, 4.0, 0.0, 100.0, 40.0, 0.25); pid_zero(&pid); + snprintf(&disp[2][0], 17, " \xBC\xCF\xAF\xC0 Reflow"); + while (1) { sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted); @@ -249,7 +251,7 @@ int main() else 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); } @@ -266,14 +268,21 @@ int main() } 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(); oven_driver_set_power(rot > 100U ? 100U : rot); /* TODO: handle gui */ - snprintf(&disp[1][0], 17, "Rotary: %u", (unsigned int)rot); - snprintf(&disp[2][0], 17, "Button: %s", (button == BUTTON_SHORT ? "SHORT" : (button == BUTTON_LONG ? "LONG" : ""))); + snprintf(&disp[1][0], 17, "Rot: %u %s", (unsigned int)rot, (button == BUTTON_SHORT ? "SHORT" : (button == BUTTON_LONG ? "LONG" : ""))); handle_shell_uart_input(shell_handle); diff --git a/stm-firmware/rotary-encoder.c b/stm-firmware/rotary-encoder.c index 6b7c1a4..d079b50 100644 --- a/stm-firmware/rotary-encoder.c +++ b/stm-firmware/rotary-encoder.c @@ -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->AHB1ENR, BITMASK_TO_BITNO(ROTARY_ENCODER_RCC_MASK)); } + +void rotary_encoder_zero(void) +{ + ROTARY_ENCODER_TIMER->CNT = 0UL; +}