diff --git a/src/controller/Makefile_linux b/src/controller/Makefile_linux index c7d17095..b11abcc6 100644 --- a/src/controller/Makefile_linux +++ b/src/controller/Makefile_linux @@ -29,14 +29,14 @@ MAINSRC = $(PNAME).c ELF_SECTIONS_TO_REMOVE = -R DATA -R INITIALIZED -R SSEG -R .debug_line -R .debug_loc -R .debug_abbrev -R .debug_info -R .debug_pubnames -R .debug_frame # These are the sources that must be compiled to .rel files: -EXTRASRCS = \ - $(SDIR)/stm8s_iwdg.c \ + EXTRASRCS = \ + $(SDIR)/stm8s_iwdg.c \ $(SDIR)/stm8s_itc.c \ $(SDIR)/stm8s_clk.c \ $(SDIR)/stm8s_gpio.c \ $(SDIR)/stm8s_uart2.c \ $(SDIR)/stm8s_tim1.c \ - $(SDIR)/stm8s_tim2.c \ + $(SDIR)/stm8s_tim2.c \ $(SDIR)/stm8s_tim3.c \ $(SDIR)/stm8s_exti.c \ $(SDIR)/stm8s_adc1.c \ @@ -63,9 +63,9 @@ ebike_app.h pins.h eeprom.h lights.h RELS = $(EXTRASRCS:.c=.rel) INCLUDES = -I$(IDIR) -I$(IDIR1) -I. -I../ -CFLAGS = -m$(PLATFORM) -Ddouble=float --std-c99 --nolospre +CFLAGS = -m$(PLATFORM) -Ddouble=float --std-c99 --nolospre ELF_FLAGS = --out-fmt-elf --debug -LIBS = +LIBS = # This just provides the conventional target name "all"; it is optional # Note: I assume you set PNAME via some means not exhibited in your original file @@ -81,7 +81,7 @@ $(PNAME): $(MAINSRC) $(RELS) # How to build any .rel file from its corresponding .c file # GNU would have you use a pattern rule for this, but that's GNU-specific %.rel: %.c $(HEADERS) -$(CC) -c $(INCLUDES) $(CFLAGS) $(ELF_FLAGS) $(LIBS) -o$< $< + $(CC) -c $(INCLUDES) $(CFLAGS) $(ELF_FLAGS) $(LIBS) -o$< $< # Suffixes appearing in suffix rules we care about. # Necessary because .rel is not one of the standard suffixes. @@ -130,4 +130,4 @@ clean: @rm -rf main.bin @rm -rf *.ihx @rm -rf *.hex - @echo "Done." + @echo "Done." \ No newline at end of file diff --git a/src/controller/Makefile_windows b/src/controller/Makefile_windows index 86def295..35dce60b 100644 --- a/src/controller/Makefile_windows +++ b/src/controller/Makefile_windows @@ -29,14 +29,14 @@ MAINSRC = $(PNAME).c ELF_SECTIONS_TO_REMOVE = -R DATA -R INITIALIZED -R SSEG -R .debug_line -R .debug_loc -R .debug_abbrev -R .debug_info -R .debug_pubnames -R .debug_frame # These are the sources that must be compiled to .rel files: -EXTRASRCS = \ - $(SDIR)/stm8s_iwdg.c \ + EXTRASRCS = \ + $(SDIR)/stm8s_iwdg.c \ $(SDIR)/stm8s_itc.c \ $(SDIR)/stm8s_clk.c \ $(SDIR)/stm8s_gpio.c \ $(SDIR)/stm8s_uart2.c \ $(SDIR)/stm8s_tim1.c \ - $(SDIR)/stm8s_tim2.c \ + $(SDIR)/stm8s_tim2.c \ $(SDIR)/stm8s_tim3.c \ $(SDIR)/stm8s_exti.c \ $(SDIR)/stm8s_adc1.c \ @@ -63,9 +63,9 @@ ebike_app.h pins.h eeprom.h lights.h RELS = $(EXTRASRCS:.c=.rel) INCLUDES = -I$(IDIR) -I$(IDIR1) -I. -I../ -CFLAGS = -m$(PLATFORM) -Ddouble=float --std-c99 --nolospre +CFLAGS = -m$(PLATFORM) -Ddouble=float --std-c99 --nolospre ELF_FLAGS = --out-fmt-ihx --debug -LIBS = +LIBS = # This just provides the conventional target name "all"; it is optional # Note: I assume you set PNAME via some means not exhibited in your original file @@ -96,4 +96,4 @@ hex: clean: @echo "Cleaning files..." @cmd /C clean.bat - @echo "Done." + @echo "Done." \ No newline at end of file diff --git a/src/display/KT-LCD3/Makefile_linux b/src/display/KT-LCD3/Makefile_linux index c1cb6bf0..ad775564 100644 --- a/src/display/KT-LCD3/Makefile_linux +++ b/src/display/KT-LCD3/Makefile_linux @@ -29,8 +29,8 @@ MAINSRC = $(PNAME).c ELF_SECTIONS_TO_REMOVE = -R DATA -R INITIALIZED -R SSEG -R .debug_line -R .debug_loc -R .debug_abbrev -R .debug_info -R .debug_pubnames -R .debug_frame # These are the sources that must be compiled to .rel files: -EXTRASRCS = \ - $(SDIR)/stm8s_iwdg.c \ + EXTRASRCS = \ + $(SDIR)/stm8s_iwdg.c \ $(SDIR)/stm8s_clk.c \ $(SDIR)/stm8s_gpio.c \ $(SDIR)/stm8s_adc1.c \ @@ -38,7 +38,7 @@ EXTRASRCS = \ $(SDIR)/stm8s_tim3.c \ $(SDIR)/stm8s_uart2.c \ $(SDIR)/stm8s_flash.c \ - $(SDIR1)/common.c \ + $(SDIR1)/common.c \ gpio.c \ ht162.c \ adc.c \ @@ -54,9 +54,9 @@ HEADERS = gpio.h main.h adc.h timers.h lcd.h uart.h eeprom.h ht162.h buttons.h p RELS = $(EXTRASRCS:.c=.rel) INCLUDES = -I$(IDIR) -I$(IDIR1) -I. -I../../ -CFLAGS = -m$(PLATFORM) -Ddouble=float --std-c99 --nolospre --opt-code-size +CFLAGS = -m$(PLATFORM) -Ddouble=float --std-c99 --nolospre --opt-code-size ELF_FLAGS = --out-fmt-elf --debug -LIBS = +LIBS = # This just provides the conventional target name "all"; it is optional # Note: I assume you set PNAME via some means not exhibited in your original file @@ -121,4 +121,4 @@ clean: @rm -rf main.bin @rm -rf *.ihx @rm -rf *.hex - @echo "Done." + @echo "Done." \ No newline at end of file diff --git a/src/display/KT-LCD3/Makefile_windows b/src/display/KT-LCD3/Makefile_windows index e56094af..ff8f88b6 100644 --- a/src/display/KT-LCD3/Makefile_windows +++ b/src/display/KT-LCD3/Makefile_windows @@ -29,8 +29,8 @@ MAINSRC = $(PNAME).c ELF_SECTIONS_TO_REMOVE = -R DATA -R INITIALIZED -R SSEG -R .debug_line -R .debug_loc -R .debug_abbrev -R .debug_info -R .debug_pubnames -R .debug_frame # These are the sources that must be compiled to .rel files: -EXTRASRCS = \ - $(SDIR)/stm8s_iwdg.c \ + EXTRASRCS = \ + $(SDIR)/stm8s_iwdg.c \ $(SDIR)/stm8s_clk.c \ $(SDIR)/stm8s_gpio.c \ $(SDIR)/stm8s_adc1.c \ @@ -54,9 +54,9 @@ HEADERS = gpio.h main.h adc.h timers.h lcd.h uart.h eeprom.h ht162.h buttons.h p RELS = $(EXTRASRCS:.c=.rel) INCLUDES = -I$(IDIR) -I$(IDIR1) -I. -I../../ -CFLAGS = -m$(PLATFORM) -Ddouble=float --std-c99 --nolospre +CFLAGS = -m$(PLATFORM) -Ddouble=float --std-c99 --nolospre ELF_FLAGS = --out-fmt-ihx --debug -LIBS = +LIBS = # This just provides the conventional target name "all"; it is optional # Note: I assume you set PNAME via some means not exhibited in your original file diff --git a/src/display/KT-LCD3/lcd.c b/src/display/KT-LCD3/lcd.c index 0a01ade2..81dbd8aa 100644 --- a/src/display/KT-LCD3/lcd.c +++ b/src/display/KT-LCD3/lcd.c @@ -123,8 +123,8 @@ static uint16_t ui16_estimated_range_since_power_on_x10 = 0; // wheel measurement variables -static uint8_t ui8_average_measured_wheel_speed_x10 = 0; -static uint8_t ui8_max_measured_wheel_speed_x10 = 0; +static uint16_t ui16_average_measured_wheel_speed_x10 = 0; +static uint16_t ui16_max_measured_wheel_speed_x10 = 0; // system functions @@ -753,8 +753,8 @@ void lcd_execute_menu_config_submenu_basic_setup(void) lcd_set_backlight_intensity(configuration_variables.ui8_lcd_backlight_off_brightness); break; - - + + case 8: // backlight night time brightness @@ -2036,12 +2036,12 @@ void temperature_field(void) if (configuration_variables.ui8_units_type) { // imperial - lcd_print (((float) ui8_average_measured_wheel_speed_x10/16), TEMPERATURE_FIELD, 1); + lcd_print (((float) ui16_average_measured_wheel_speed_x10/16), TEMPERATURE_FIELD, 1); } else { // metric - lcd_print (ui8_average_measured_wheel_speed_x10/10, TEMPERATURE_FIELD, 1); + lcd_print (ui16_average_measured_wheel_speed_x10/10, TEMPERATURE_FIELD, 1); } break; @@ -3034,12 +3034,12 @@ void odometer_field(void) if (configuration_variables.ui8_units_type) { // imperial - lcd_print(((float) ui8_average_measured_wheel_speed_x10 / 1.6), ODOMETER_FIELD, 1); + lcd_print(((float) ui16_average_measured_wheel_speed_x10 / 1.6), ODOMETER_FIELD, 1); } else { // metric - lcd_print(ui8_average_measured_wheel_speed_x10, ODOMETER_FIELD, 1); + lcd_print(ui16_average_measured_wheel_speed_x10, ODOMETER_FIELD, 1); } break; @@ -3056,18 +3056,18 @@ void odometer_field(void) if (configuration_variables.ui8_units_type) { // imperial - lcd_print(((float) ui8_max_measured_wheel_speed_x10 / 1.6), ODOMETER_FIELD, 1); + lcd_print((float) ui16_max_measured_wheel_speed_x10 / 1.6, ODOMETER_FIELD, 1); } else { // metric - lcd_print(ui8_max_measured_wheel_speed_x10, ODOMETER_FIELD, 1); + lcd_print(ui16_max_measured_wheel_speed_x10, ODOMETER_FIELD, 1); } break; // reset maximum measured wheel speed since power on case 1: - ui8_max_measured_wheel_speed_x10 = 0; + ui16_max_measured_wheel_speed_x10 = 0; break; // display nothing @@ -3152,21 +3152,14 @@ void odometer_field(void) void wheel_speed_field(void) { // check if wheel speed is higher than maximum measured wheel speed - if (motor_controller_data.ui16_wheel_speed_x10 > ui8_max_measured_wheel_speed_x10) + if (motor_controller_data.ui16_wheel_speed_x10 > ui16_max_measured_wheel_speed_x10) { // wheel speed is higher than maximum measured wheel speed so update variable - ui8_max_measured_wheel_speed_x10 = motor_controller_data.ui16_wheel_speed_x10; + ui16_max_measured_wheel_speed_x10 = motor_controller_data.ui16_wheel_speed_x10; } // calculate average wheel speed since power on in km/s - float average_measured_wheel_speed_x10_temp = (float) configuration_variables.ui16_distance_since_power_on_x10 / (float) ui16_seconds_since_power_on; - - // convert to km/h - average_measured_wheel_speed_x10_temp = average_measured_wheel_speed_x10_temp * 3600; - - // set calculated value to average wheel speed variable - ui8_average_measured_wheel_speed_x10 = average_measured_wheel_speed_x10_temp; - + ui16_average_measured_wheel_speed_x10 = ((uint32_t) configuration_variables.ui16_distance_since_power_on_x10 * 3600) / ui16_seconds_since_power_on; // show wheel speed only when we should not show odometer field number if (ui8_start_odometer_show_field_number == 0) @@ -3194,12 +3187,12 @@ void wheel_speed_field(void) if (configuration_variables.ui8_units_type) { - lcd_print(((float) ui8_average_measured_wheel_speed_x10 / 1.6), WHEEL_SPEED_FIELD, 1); + lcd_print(((float) ui16_average_measured_wheel_speed_x10 / 1.6), WHEEL_SPEED_FIELD, 1); lcd_enable_mph_symbol(1); } else { - lcd_print(ui8_average_measured_wheel_speed_x10, WHEEL_SPEED_FIELD, 1); + lcd_print(ui16_average_measured_wheel_speed_x10, WHEEL_SPEED_FIELD, 1); lcd_enable_kmh_symbol(1); } @@ -3212,12 +3205,12 @@ void wheel_speed_field(void) if (configuration_variables.ui8_units_type) { - lcd_print(((float) ui8_max_measured_wheel_speed_x10 / 1.6), WHEEL_SPEED_FIELD, 1); + lcd_print(((float) ui16_max_measured_wheel_speed_x10 / 1.6), WHEEL_SPEED_FIELD, 1); lcd_enable_mph_symbol(1); } else { - lcd_print(ui8_max_measured_wheel_speed_x10, WHEEL_SPEED_FIELD, 1); + lcd_print(ui16_max_measured_wheel_speed_x10, WHEEL_SPEED_FIELD, 1); lcd_enable_kmh_symbol(1); }