src/display.h

changeset 44
b3c3d54d2c7c
parent 37
07e8ca2bdf6d
child 46
a4a007b3c42e
--- a/src/display.h	Sun Nov 01 22:16:33 2020 +0100
+++ b/src/display.h	Sun Nov 01 22:21:19 2020 +0100
@@ -8,6 +8,15 @@
 #include "SSD1322.h"
 #include "hp34comm.h"
 
+//typedef enum {
+#define FMT_ASCII  0x01
+#define FMT_HEX    0x02
+#define FMT_BITS   0x04
+#define FMT_FLAGS  0x08
+#define FMT_IGNORE 0x80
+	//} dsp_format_t;
+
+
 typedef struct _DSP
 {
 	uint8_t cmd;
@@ -22,11 +31,13 @@
 	char buffer[MAX_BUFF+1];
 } DSP;
 
+
+
 static DSP table[] =
-{
-		{ 0x00, 0xF, 0x0,  0,  0, 0x01, MAX_BUFF, 245, Mono19x27}, // main display
-		{ 0x0C, 0xF, 0x0,196, 34, 0x01, 3,        45,  Mono15x22}, // channels display
-		{ 0x0A, 0xF, 0x0,  0, 57, 0x08, 4,        0, Terminal6x8}, // flags + bits
+{       // cmd,  fg, bg,  x0, y0,       fmt,  maxsize, width, font
+		{ 0x00, 0xF, 0x0,  0,  0, FMT_ASCII, MAX_BUFF, 245, Mono19x27}, // main display
+		{ 0x0C, 0xF, 0x0,196, 34, FMT_ASCII, 3,        45,  Mono15x22}, // channels display
+		{ 0x0A, 0xF, 0x0,  0, 57, FMT_FLAGS, 4,        0, Terminal6x8}, // flags + bits
 };
 
 // 9x10
@@ -79,47 +90,47 @@
 
 static const FLAG flags[] =
 {
-    // flag, zone, x0, y0, reverse, msg, icon
+    // flag, x0, y0, reverse, msg, icon
     // right-side icons area
-		{ 0x00, 246, 0,  false, NULL, icon_alarm}, // F1.0
-    { 0x01, 246, 11, false, NULL, icon_curve}, // F1.1
-
-    // F1.2 == Channel frame
-    { 0x03, 197, 27, false, "Channel"},  // F1.3
-    // F1.7 == Alarm frame
+	// flag is the bit index in the 4 bytes viewed as a 32bits value
+    { 0x00, 246, 0,  false, NULL, icon_alarm}, // F1.0  01 00 00 00
+    { 0x01, 246, 11, false, NULL, icon_curve}, // F1.1  02 00 00 00
+                                               // F1.2  04 00 00 00 - Channel frame
+    { 0x03, 197, 27, false, "CHANNEL"},        // F1.3  08 00 00 00
+                                               // F1.7  80 00 00 00 - Alarm frame
+    { 0x1c, 0,  28+8,  false, "MON"},          // F4.4  00 00 00 10
+    { 0x1b, 0,  28+16, false, "VIEW"},         // F4.3  00 00 00 08
+    { 0x1d, 0,  28,    true, "SCAN"},          // F4.5  00 00 00 20
+    { 0x1e, 0,  28+25, true, "CONFIG"},        // F4.6  00 00 00 40
 
-    { 0x34, 0,  28+8,  false, "MON"},    // F4.4
-    { 0x33, 0,  28+16, false, "VIEW"},   // F4.3
-    { 0x35, 0,  28,    true, "SCAN"},   // F4.5
-    { 0x36, 0,  28+25, true, "CONFIG"},    // F4.6
+    { 0x1a, 40, 52,    false, "*"},            // F4.2  00 00 00 04
+    { 0x19, 50, 52,    false, "ADRS"},         // F4.1  00 00 00 02
+    { 0x18, 80, 52,    false, "RMT"},          // F4.0  00 00 00 01
+    { 0x17, 104, 52,   true, "ERROR"},         // F3.7  00 00 80 00
 
-    { 0x32, 40, 52,    false, "*"},      // F4.2
-    { 0x31, 50, 52,    false, "ADRS"},   // F4.1
-    { 0x30, 80, 52,    false, "RMT"},    // F4.0
-    { 0x27, 104, 52,   true, "ERROR"},    // F3.7
+    { 0x16, 140, 52,   false, "EXT"},          // F3.6  00 00 40 00
+    { 0x15, 164, 52,   false, "ONCE"},         // F3.5  00 00 20 00
 
-    { 0x26, 140, 52,   false, "EXT"},    // F3.6
-    { 0x25, 164, 52,   false, "ONCE"},   // F3.5
-
-    { 0x23, 104, 28+16, false, "MEM"},    // F3.3
+    { 0x13, 104, 28+16, false, "MEM"},         // F3.3  00 00 08 00
 
 
     // col 5
-    { 0x14, 244, 22,  false, "4W"},     // F2.4
-    { 0x15, 244, 30,  false, "OC"},     // F2.5
-    { 0x22, 129, 28+16, false, "LAST"},   // F3.2
-    { 0x21, 129, 28+16, false, "MIN"},    // F3.1
-    { 0x20, 129, 28+16, false, "MAX"},    // F3.0
-    { 0x17, 129, 28+16, false, "AVG"},    // F2.7
+    { 0x0c, 244, 22,  false, "4W"},            // F2.4  00 10 00 00
+    { 0x0d, 244, 30,  false, "OC"},            // F2.5  00 20 00 00
+    { 0x12, 129, 28+16, false, "LAST"},        // F3.2  00 00 04 00
+    { 0x11, 129, 28+16, false, "MIN"},         // F3.1  00 00 02 00
+    { 0x10, 129, 28+16, false, "MAX"},         // F3.0  00 00 01 00
+    { 0x0f, 129, 28+16, false, "AVG"},         // F2.7  00 80 00 00
 
-    { 0x05, 154+0,  17+10, false, "Alarm"},  // F1.5
-    { 0x06, 154+0,  17+20, false, "H"},      // F1.6
-    { 0x13, 154+6,  17+20, false, "1"},      // F2.3
-    { 0x10, 154+12, 17+20, false, "2"},      // F2.0
-    { 0x12, 154+18, 17+20, false, "3"},      // F2.2
-    { 0x11, 154+24, 17+20, false, "4"},      // F2.1
-    { 0x04, 154+30, 17+20, false, "L"},      // F1.4
+    { 0x05, 154+0,  17+10, false, "Alarm"},    // F1.5  20 00 00 00
+    { 0x06, 154+0,  17+20, false, "H"},        // F1.6  40 00 00 00
+    { 0x0b, 154+6,  17+20, false, "1"},        // F2.3  00 08 00 00
+    { 0x08, 154+12, 17+20, false, "2"},        // F2.0  00 01 00 00
+    { 0x0a, 154+18, 17+20, false, "3"},        // F2.2  00 04 00 00
+    { 0x09, 154+24, 17+20, false, "4"},        // F2.1  00 02 00 00
+    { 0x04, 154+30, 17+20, false, "L"},        // F1.4  00 10 00 00
 
+	{ 0x80, 224, 54, true, "SHIFT"},   // not an actual command, managed by the front panel
 };
 
 static const FRAME zones[] =
@@ -154,7 +165,15 @@
 
 	void test_dsp();
 	void show(uint8_t, const char*, uint8_t);
+	void dimm_char(uint8_t);
 	void show_splashscreen();
+	void show_byescreen();
+	void set_flag(uint8_t flag, bool show);
+	void show_flag(uint8_t flag) {set_flag(flag, true);};
+	void hide_flag(uint8_t flag) {set_flag(flag, false);};
+	void shift_on() {set_flag(0x80, true);};
+	void shift_off() {set_flag(0x80, false);};
+
 
 private:
 	uint8_t must_refresh;

mercurial