@@ -80,7 +80,7 @@ void l2_low_pass_filter_battery_voltage_current_power(void);
8080void update_menu_flashing_state (void );
8181void calc_battery_soc_watts_hour (void );
8282void l2_calc_odometer (void );
83- static void l2_automatic_power_off_management (void );
83+ static void automatic_power_off_management (void );
8484void brake (void );
8585void walk_assist_state (void );
8686void wheel_speed (void );
@@ -109,6 +109,7 @@ void change_graph(void);
109109void lcd_init (void )
110110{
111111 bafang_500C_lcd_init ();
112+ lcd_set_backlight_intensity (20 ); // need otherwise no image will be shownbefore this
112113 UG_FillScreen (C_BLACK );
113114
114115 lcd_configurations_screen_init ();
@@ -195,6 +196,7 @@ void lcd_clock(void)
195196 graphs_clock_2 ();
196197 }
197198
199+ automatic_power_off_management ();
198200 power_off_management ();
199201
200202 // must be reset after a full cycle of lcd_clock()
@@ -965,43 +967,44 @@ void l2_calc_odometer(void)
965967// }
966968}
967969
968- static void l2_automatic_power_off_management (void )
970+ static void automatic_power_off_management (void )
969971{
970- // static uint8_t ui8_lcd_power_off_time_counter_minutes = 0;
971- // static uint16_t ui16_lcd_power_off_time_counter = 0;
972- //
973- // if(configuration_variables.ui8_lcd_power_off_time_minutes != 0)
974- // {
975- // // see if we should reset the automatic power off minutes counter
976- // if ((l3_vars.ui16_wheel_speed_x10 > 0) || // wheel speed > 0
977- // (l3_vars.ui8_battery_current_x5 > 0) || // battery current > 0
978- // (l3_vars.ui8_braking) || // braking
979- // buttons_get_events()) // any button active
980- // {
981- // ui16_lcd_power_off_time_counter = 0;
982- // ui8_lcd_power_off_time_counter_minutes = 0;
983- // }
984- //
985- // // increment the automatic power off minutes counter
986- // ui16_lcd_power_off_time_counter++;
987- //
988- // // check if we should power off the LCD
989- // if(ui16_lcd_power_off_time_counter >= (10 * 60)) // 1 minute passed
990- // {
991- // ui16_lcd_power_off_time_counter = 0;
992- //
993- // ui8_lcd_power_off_time_counter_minutes++;
994- // if(ui8_lcd_power_off_time_counter_minutes >= configuration_variables.ui8_lcd_power_off_time_minutes)
995- // {
996- // lcd_power_off(1);
997- // }
998- // }
999- // }
1000- // else
1001- // {
1002- // ui16_lcd_power_off_time_counter = 0;
1003- // ui8_lcd_power_off_time_counter_minutes = 0;
1004- // }
972+ static uint8_t ui8_lcd_power_off_time_counter_minutes = 0 ;
973+ static uint16_t ui16_lcd_power_off_time_counter = 0 ;
974+
975+ if (l3_vars .ui8_lcd_power_off_time_minutes != 0 )
976+ {
977+ // see if we should reset the automatic power off minutes counter
978+ if ((l3_vars .ui16_wheel_speed_x10 > 0 ) || // wheel speed > 0
979+ (l3_vars .ui8_battery_current_x5 > 0 ) || // battery current > 0
980+ (l3_vars .ui8_braking ) || // braking
981+ buttons_get_events ()) // any button active
982+ {
983+ ui16_lcd_power_off_time_counter = 0 ;
984+ ui8_lcd_power_off_time_counter_minutes = 0 ;
985+ }
986+
987+ // increment the automatic power off minutes counter
988+ ui16_lcd_power_off_time_counter ++ ;
989+
990+ // check if we should power off the LCD
991+ if (ui16_lcd_power_off_time_counter >= (50 * 60 )) // 1 minute passed
992+ {
993+ ui16_lcd_power_off_time_counter = 0 ;
994+
995+ ui8_lcd_power_off_time_counter_minutes ++ ;
996+ if (ui8_lcd_power_off_time_counter_minutes >= l3_vars .ui8_lcd_power_off_time_minutes )
997+ {
998+ lcd_power_off (1 );
999+ }
1000+ }
1001+ }
1002+ // keep automatic_power_off_management disabled
1003+ else
1004+ {
1005+ ui16_lcd_power_off_time_counter = 0 ;
1006+ ui8_lcd_power_off_time_counter_minutes = 0 ;
1007+ }
10051008}
10061009
10071010void update_menu_flashing_state (void )
0 commit comments