From e961770f6357b47356faac7b92e1578d3f82e18f Mon Sep 17 00:00:00 2001 From: Leon Date: Wed, 29 May 2019 07:39:34 +0200 Subject: [PATCH] Small changes --- src/controller/ebike_app.c | 3 +-- src/display/KT-LCD3/lcd.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/controller/ebike_app.c b/src/controller/ebike_app.c index acfe6d64..33070a9d 100755 --- a/src/controller/ebike_app.c +++ b/src/controller/ebike_app.c @@ -47,6 +47,7 @@ uint16_t ui16_pedal_power_x10; uint8_t ui8_pedal_human_power = 0; uint16_t ui16_adc_motor_temperatured_accumulated = 0; uint8_t ui8_m_adc_battery_target_current; +uint8_t ui8_tstr_state_machine = STATE_NO_PEDALLING; static uint8_t ui8_m_motor_enabled = 1; static uint8_t ui8_m_brake_is_set = 0; volatile uint8_t ui8_throttle = 0; @@ -1042,8 +1043,6 @@ static void read_pas_cadence(void) static void torque_sensor_read(void) { - static uint8_t ui8_tstr_state_machine = STATE_NO_PEDALLING; - // map value from 0 up to 255 // map value from 0 up to 255 ui8_torque_sensor_raw = (uint8_t) (map ( UI8_ADC_TORQUE_SENSOR, diff --git a/src/display/KT-LCD3/lcd.c b/src/display/KT-LCD3/lcd.c index a5396c95..02cad95c 100644 --- a/src/display/KT-LCD3/lcd.c +++ b/src/display/KT-LCD3/lcd.c @@ -1553,6 +1553,9 @@ void lcd_execute_menu_config_power (void) var_number_t lcd_var_number; uint16_t ui16_temp; + // because this click event can happen and will block the detection of button_onoff_long_click_event + buttons_clear_onoff_click_event (); + // enable change of variables ui8_lcd_menu_config_submenu_change_variable_enabled = 1; @@ -1587,7 +1590,7 @@ void lcd_execute_menu_config_power (void) // disable change of variables ui8_lcd_menu_config_submenu_change_variable_enabled = 0; - // save the updated variables on EEPROM + // save the updated variables to EEPROM eeprom_write_variables (); // change to main screen @@ -1738,12 +1741,13 @@ void time_measurement (void) void energy_data (void) { - static uint8_t ui8_execute_on_startup = 1; + static uint8_t ui8_executed_on_startup; // reset watt-hour value if battery voltage is over threshold set from user, only executed once during startup - if (ui8_execute_on_startup) + if (!ui8_executed_on_startup) { - ui8_execute_on_startup = 0; + ui8_executed_on_startup = 1; + if (((uint32_t) motor_controller_data.ui16_adc_battery_voltage * ADC_BATTERY_VOLTAGE_PER_ADC_STEP_X10000) > ((uint32_t) configuration_variables.ui16_battery_voltage_reset_wh_counter_x10 * 1000)) { configuration_variables.ui32_wh_x10_offset = 0; @@ -2046,14 +2050,14 @@ void offroad_mode (void) { static uint8_t offroad_mode_assist_symbol_state; static uint8_t offroad_mode_assist_symbol_state_blink_counter; - static uint8_t ui8_execute_on_startup = 1; + static uint8_t ui8_executed_on_startup; if (configuration_variables.ui8_offroad_feature_enabled) { // enable offroad mode if user has enabled offroad mode on startup - if (ui8_execute_on_startup) + if (!ui8_executed_on_startup) { - ui8_execute_on_startup = 0; + ui8_executed_on_startup = 1; if (configuration_variables.ui8_offroad_enabled_on_startup) {