浏览代码

Add option to reset counters when opening new file
Fix settings arrows

k4be 1 年之前
父节点
当前提交
a424baba0d
共有 7 个文件被更改,包括 115 次插入113 次删除
  1. 91 20
      soft/UC1601S-I2C.c
  2. 0 88
      soft/UC1601S-I2C.h
  3. 5 0
      soft/main.c
  4. 7 0
      soft/menu.c
  5. 4 4
      soft/menu.h
  6. 6 0
      soft/settings.c
  7. 2 1
      soft/settings.h

+ 91 - 20
soft/UC1601S-I2C.c

@@ -104,27 +104,98 @@ __flash const unsigned char FontLookup [][5] = {
 	{ 0xfe, 0xfb, 0xfb, 0xfb, 0xfe },	// 2/3 \x83
 	{ 0xfe, 0xe3, 0xe3, 0xe3, 0xfe },	// 1/3 \x84
 	{ 0xfe, 0x83, 0x83, 0x83, 0xfe },	// 0/3 \x85
+	{ 0x10, 0x20, 0x7e, 0x20, 0x10 },	// ↓ \x86
+	{ 0x08, 0x04, 0x7e, 0x04, 0x08 },	// ↑ \x87
 };
-/*
-__flash const unsigned char custom_chars[] = {
-	0b00000, /* 0x01 down arrow *//*
-	0b00100,
-	0b00100,
-	0b00100,
-	0b10101,
-	0b01110,
-	0b00100,
-	0b00000,
-	
-	0b00000, /* 0x02 up arrow *//*
-	0b00100,
-	0b01110,
-	0b10101,
-	0b00100,
-	0b00100,
-	0b00100,
-	0b00000,
-};*/
+
+static inline void uc1601s_set_column_address(unsigned char addr) {
+	uc1601s_write_command(UC1601S_CA30 | (addr&0x0f));
+	uc1601s_write_command(UC1601S_CA74 | (addr>>4));
+}
+
+static inline void uc1601s_set_temp_compensation(unsigned char tc) {
+	tc &= 0x3;
+	uc1601s_write_command(UC1601S_TC | tc);
+}
+
+static inline void uc1601s_set_power_control(unsigned char pc) {
+	pc &= 0x7;
+	uc1601s_write_command(UC1601S_PC | pc);
+}
+
+static inline void uc1601s_set_scroll_line(unsigned char sl) {
+	sl &= 0x3f;
+	uc1601s_write_command(UC1601S_SL | sl);
+}
+
+static inline void uc1601s_set_page_address(unsigned char pa) {
+	pa &= 0x0f;
+	uc1601s_write_command(UC1601S_PA | pa);
+}
+
+static inline void uc1601s_set_vbias(unsigned char pm) {
+	uc1601s_write_command(UC1601S_PM);
+	uc1601s_write_command(pm);
+}
+
+static inline void uc1601s_set_partial_display(unsigned char lc) {
+	lc &= 0x1;
+	uc1601s_write_command(UC1601S_LC4 | lc);
+}
+
+static inline void uc1601s_set_ram_address(unsigned char ac) {
+	ac &= 0x3;
+	uc1601s_write_command(UC1601S_AC | ac);
+}
+
+static inline void uc1601_set_frame_rate(unsigned char lc) {
+	lc &= 0x1;
+	uc1601s_write_command(UC1601S_LC3 | lc);
+}
+
+static inline void uc1601s_set_all_pixel_on(unsigned char dc) {
+	dc &= 0x1;
+	uc1601s_write_command(UC1601S_DC1 | dc);
+}
+
+static inline void uc1601s_set_inverse_display(unsigned char dc) {
+	dc &= 0x1;
+	uc1601s_write_command(UC1601S_DC0 | dc);
+}
+
+static inline void uc1601s_set_display_enable(unsigned char dc) {
+	dc &= 0x1;
+	uc1601s_write_command(UC1601S_DC2 | dc);
+}
+
+static inline void uc1601s_set_lcd_mapping(unsigned char lc) {
+	lc &= 0x6;
+	uc1601s_write_command(UC1601S_LC21 | lc);
+}
+
+static inline void uc1601s_system_reset(void) {
+	uc1601s_write_command(UC1601S_SYSTEMRESET);
+}
+
+static inline void uc1601s_set_lcd_bias_ratio(unsigned char br) {
+	br &= 0x3;
+	uc1601s_write_command(UC1601S_BR | br);
+}
+
+static inline void uc1601s_set_com_end(unsigned char cen) {
+	uc1601s_write_command(UC1601S_CEN);
+	uc1601s_write_command(cen);
+}
+
+static inline void uc1601s_set_partial_display_start(unsigned char dst) {
+	uc1601s_write_command(UC1601S_DST);
+	uc1601s_write_command(dst);
+}
+
+static inline void uc1601s_set_partial_display_end(unsigned char den) {
+	uc1601s_write_command(UC1601S_DEN);
+	uc1601s_write_command(den);
+}
 
 void uc1601s_write_command(unsigned char cmd) {
 	expander_set_bit_no_send(UC1601S_CD_PORT, UC1601S_CD, 0);

+ 0 - 88
soft/UC1601S-I2C.h

@@ -59,91 +59,3 @@ void LCD_WriteText(const char *t);
 void LCD_WriteChar(char c);
 #define LCD_WriteData(c) LCD_WriteChar(c)
 
-static inline void uc1601s_set_column_address(unsigned char addr) {
-	uc1601s_write_command(UC1601S_CA30 | (addr&0x0f));
-	uc1601s_write_command(UC1601S_CA74 | (addr>>4));
-}
-
-static inline void uc1601s_set_temp_compensation(unsigned char tc) {
-	tc &= 0x3;
-	uc1601s_write_command(UC1601S_TC | tc);
-}
-
-static inline void uc1601s_set_power_control(unsigned char pc) {
-	pc &= 0x7;
-	uc1601s_write_command(UC1601S_PC | pc);
-}
-
-static inline void uc1601s_set_scroll_line(unsigned char sl) {
-	sl &= 0x3f;
-	uc1601s_write_command(UC1601S_SL | sl);
-}
-
-static inline void uc1601s_set_page_address(unsigned char pa) {
-	pa &= 0x0f;
-	uc1601s_write_command(UC1601S_PA | pa);
-}
-
-static inline void uc1601s_set_vbias(unsigned char pm) {
-	uc1601s_write_command(UC1601S_PM);
-	uc1601s_write_command(pm);
-}
-
-static inline void uc1601s_set_partial_display(unsigned char lc) {
-	lc &= 0x1;
-	uc1601s_write_command(UC1601S_LC4 | lc);
-}
-
-static inline void uc1601s_set_ram_address(unsigned char ac) {
-	ac &= 0x3;
-	uc1601s_write_command(UC1601S_AC | ac);
-}
-
-static inline void uc1601_set_frame_rate(unsigned char lc) {
-	lc &= 0x1;
-	uc1601s_write_command(UC1601S_LC3 | lc);
-}
-
-static inline void uc1601s_set_all_pixel_on(unsigned char dc) {
-	dc &= 0x1;
-	uc1601s_write_command(UC1601S_DC1 | dc);
-}
-
-static inline void uc1601s_set_inverse_display(unsigned char dc) {
-	dc &= 0x1;
-	uc1601s_write_command(UC1601S_DC0 | dc);
-}
-
-static inline void uc1601s_set_display_enable(unsigned char dc) {
-	dc &= 0x1;
-	uc1601s_write_command(UC1601S_DC2 | dc);
-}
-
-static inline void uc1601s_set_lcd_mapping(unsigned char lc) {
-	lc &= 0x6;
-	uc1601s_write_command(UC1601S_LC21 | lc);
-}
-
-static inline void uc1601s_system_reset(void) {
-	uc1601s_write_command(UC1601S_SYSTEMRESET);
-}
-
-static inline void uc1601s_set_lcd_bias_ratio(unsigned char br) {
-	br &= 0x3;
-	uc1601s_write_command(UC1601S_BR | br);
-}
-
-static inline void uc1601s_set_com_end(unsigned char cen) {
-	uc1601s_write_command(UC1601S_CEN);
-	uc1601s_write_command(cen);
-}
-
-static inline void uc1601s_set_partial_display_start(unsigned char dst) {
-	uc1601s_write_command(UC1601S_DST);
-	uc1601s_write_command(dst);
-}
-
-static inline void uc1601s_set_partial_display_end(unsigned char den) {
-	uc1601s_write_command(UC1601S_DEN);
-	uc1601s_write_command(den);
-}

+ 5 - 0
soft/main.c

@@ -314,12 +314,15 @@ static inline void auto_pause_process(void) {
 
 void reset_counters(void) {
 	System.distance = 0;
+	System.time_start = 0;
 	System.current_pause_start = 0;
 	System.pause_time = 0;
 }
 
 time_t get_pause_time(void) {
 	time_t res = System.pause_time;
+	if (System.current_pause_start < System.time_start)
+		System.current_pause_start = System.time_start; /* disallow negative pause time */
 	if (is_paused() && System.current_pause_start)
 		res += utc - System.current_pause_start;
 	return res;
@@ -486,6 +489,8 @@ int main (void)
 					System.open_new_file = 0;
 					if (!System.tracking_paused)
 						tracking_pause(TRACKING_PAUSE_CMD_PAUSE, 0);
+					if (get_flag(CONFFLAG_RESET_ON_NEW_FILE))
+						reset_counters();
 				}
 				if (!System.tracking_paused)
 					already_logging = 1; /* to avoid pausing on any reset caused by some error */

+ 7 - 0
soft/menu.c

@@ -8,10 +8,17 @@ unsigned char __menu_num; // Menu stack variables
 struct menu_struct __menu_data[DATA_NUM];
 __flash const char _NULL_STRING[] = "(NULL)";
 
+#ifdef LCD_GRAPHIC
+void make_arrows(void) {
+	strcat_P(disp.line2, HAVE_NEXT_SETTING_POSITION?PSTR(" \x86"):PSTR("  ")); /* down arrow */
+	strcat_P(disp.line2, HAVE_PREV_SETTING_POSITION?PSTR(" \x87"):PSTR("  ")); /* up arrow */
+}
+#else
 void make_arrows(void) {
 	strcat_P(disp.line2, HAVE_NEXT_SETTING_POSITION?PSTR(" \x01"):PSTR("  ")); /* down arrow */
 	strcat_P(disp.line2, HAVE_PREV_SETTING_POSITION?PSTR(" \x02"):PSTR("  ")); /* up arrow */
 }
+#endif /* LCD_GRAPHIC */
 
 void settings_display_bool(unsigned char index) {
 	unsigned char val = get_flag(index);

+ 4 - 4
soft/menu.h

@@ -17,14 +17,14 @@
 #define MENU_DISPLAY_TYPE_U8_KMH	7
 
 #define menu_push(x) { if(__menu_num<DATA_NUM) __menu_data[__menu_num++] = x; } // stack commands
-#define menu_pop() --__menu_num
-#define menu_get() &__menu_data[__menu_num-1]
+#define menu_pop() (--__menu_num)
+#define menu_get() (&__menu_data[__menu_num-1])
 #define no_menu() (__menu_num == 0)
 
 #define DATA_NUM 3 // maximum menu depth
 
-#define HAVE_NEXT_SETTING_POSITION	0
-#define HAVE_PREV_SETTING_POSITION	0
+#define HAVE_NEXT_SETTING_POSITION	(menu_get()->ind < (menu_get()->num-1))
+#define HAVE_PREV_SETTING_POSITION	(menu_get()->ind > 0)
 
 struct menu_pos {
 	unsigned char type;

+ 6 - 0
soft/settings.c

@@ -120,6 +120,7 @@ __flash const char _msg_auto_pause_time[] = "Autopauza czas";
 __flash const char _msg_auto_pause_dist[] = "Autopauza odleg";
 __flash const char _msg_auto_pause_speed[] = "Autopau. predk.";
 __flash const char _msg_min_sats[] = "Minimum satelit";
+__flash const char _msg_reset_on_new_file[] = "Zeruj dystans";
 
 __flash const struct menu_pos settings_menu_list[] = {
 	{
@@ -152,6 +153,11 @@ __flash const struct menu_pos settings_menu_list[] = {
 		.name = _msg_auto_pause_speed,
 		.index = CONF_U8_AUTO_PAUSE_SPEED,
 	},
+	{
+		.type = MENU_TYPE_SETTING_BOOL,
+		.name = _msg_reset_on_new_file,
+		.index = CONFFLAG_RESET_ON_NEW_FILE,
+	},
 	{
 		.type = MENU_TYPE_SETTING_BOOL,
 		.name = _msg_disable_filters,

+ 2 - 1
soft/settings.h

@@ -17,8 +17,9 @@
 #define CONFFLAG_ENABLE_SBAS		1
 #define CONFFLAG_LOGGING_AFTER_BOOT	2
 #define CONFFLAG_AUTO_PAUSE			3
+#define CONFFLAG_RESET_ON_NEW_FILE	4
 
-#define CONFFLAG_LAST				3
+#define CONFFLAG_LAST				4
 
 /* GNSS modes */
 #define GNSS_MODE_GPS_GLONASS_GALILEO	0