Browse Source

Batt voltage to display

pblac 2 years ago
parent
commit
b70a5c1be9
4 changed files with 10 additions and 2 deletions
  1. 1 1
      soft/Makefile
  2. 6 0
      soft/display.c
  3. 2 1
      soft/display.h
  4. 1 0
      soft/working_modes.c

+ 1 - 1
soft/Makefile

@@ -27,7 +27,7 @@ DEFS	= F_CPU=7372800
 ADEFS	=
 
 ### Warning contorls
-WARNINGS = all extra
+WARNINGS = all extra no-array-bounds
 
 ### Output directory
 OBJDIR = obj

+ 6 - 0
soft/display.c

@@ -137,6 +137,11 @@ void disp_func_coord(__attribute__ ((unused)) unsigned char changed) {
 	xsprintf(disp.line2, PSTR("%3.6f%c"), (location.lon < 0)?(-location.lon):location.lon, (location.lon < 0)?'W':'E');
 }
 
+void disp_func_voltage(__attribute__ ((unused)) unsigned char changed) {
+	strcpy_P(disp.line1, PSTR("Batt. voltage"));
+	xsprintf(disp.line2, PSTR("%1.2fV"), System.bat_volt);
+}
+
 void disp_func_ele_sat(__attribute__ ((unused)) unsigned char changed) {
 	if (System.location_valid == LOC_INVALID) {
 		strcpy_P(disp.line1, PSTR("ele = ???"));
@@ -163,6 +168,7 @@ void (*__flash const disp_funcs[])(unsigned char) = {
 	[DISPLAY_STATE_MAIN_DEFAULT] = disp_func_main_default,
 	[DISPLAY_STATE_COORD] = disp_func_coord,
 	[DISPLAY_STATE_ELE_SAT] = disp_func_ele_sat,
+	[DISPLAY_STATE_VOLTAGE] = disp_func_voltage,
 	[DISPLAY_STATE_MAIN_MENU] = disp_func_main_menu,
 };
 

+ 2 - 1
soft/display.h

@@ -11,7 +11,8 @@
 #define DISPLAY_STATE_MAIN_DEFAULT	8
 #define DISPLAY_STATE_COORD	9
 #define DISPLAY_STATE_ELE_SAT	10
-#define DISPLAY_STATE_MAIN_MENU	11
+#define DISPLAY_STATE_VOLTAGE	11
+#define DISPLAY_STATE_MAIN_MENU	12
 
 void display_refresh(unsigned char newstate);
 void display_state(unsigned char newstate);

+ 1 - 0
soft/working_modes.c

@@ -10,6 +10,7 @@ __flash const unsigned char main_display_modes[] = {
 	DISPLAY_STATE_MAIN_DEFAULT,
 	DISPLAY_STATE_COORD,
 	DISPLAY_STATE_ELE_SAT,
+	DISPLAY_STATE_VOLTAGE,
 };
 
 void change_display_mode(signed char dir) {