Reorganize the display + improvements for dimmed flags draft

Thu, 12 Nov 2020 20:26:35 +0100

author
David Douard <david.douard@sdf3.org>
date
Thu, 12 Nov 2020 20:26:35 +0100
changeset 53
74e85b34d26b
parent 52
098124b730eb
child 54
f6774bd0d570

Reorganize the display + improvements for dimmed flags

- the whole upper zone is now dediacated to the main character line
- make sure eash flag has a dedicated non-overlaping area
- improve support for dimmed flags (not yet properly functionning since this
dimm state is actually stateful, so some major refactorings are needed to
properly handle this).

src/display.cpp file | annotate | diff | comparison | revisions
src/display.h file | annotate | diff | comparison | revisions
src/main.cpp file | annotate | diff | comparison | revisions
--- a/src/display.cpp	Tue Nov 10 22:24:03 2020 +0100
+++ b/src/display.cpp	Thu Nov 12 20:26:35 2020 +0100
@@ -180,11 +180,15 @@
 					{
 						nbyte = flags[l].flag / 8;
 						nbit = flags[l].flag % 8;
+						if (flags[l].dimm)
+							color = fgcolor/4;
+						else
+							color = fgcolor;
 
 						if (intxt[nbyte] & (1 << nbit))
 						{  // draw the flag, possibly reversed fg/bg
-							foreground(flags[l].reverse ? bgcolor : fgcolor);
-							background(flags[l].reverse ? fgcolor : bgcolor);
+							foreground(flags[l].reverse ? bgcolor : color);
+							background(flags[l].reverse ? color : bgcolor);
 						}
 						else
 						{  // erase the flag
@@ -237,16 +241,17 @@
 void Display::set_flag(uint8_t flag, bool show, bool dimm)
 {
 	uint8_t i;
-	uint8_t bgcolor = 0x00, fgcolor = 0xFF;
+	uint8_t bgcolor = 0x00, fgcolor = 0x0F;
 
 	if (dimm)
-		fgcolor /= 2;
+		fgcolor = fgcolor / 4;
 
 	for (uint8_t l=0; l<(sizeof(flags)/sizeof(flags[0])); ++l)
 	{
 		if (flag == flags[l].flag)
 		{
-
+			set_font((unsigned char*)Terminal6x8);
+			::printf("  %s flag %x %s\n", show ? "show": "hide", flag, dimm ? "dimmed":"bright");
 			if (show)
 			{
 				foreground(flags[l].reverse ? bgcolor : fgcolor);
@@ -260,7 +265,8 @@
 			if (flags[l].msg != NULL)
 			{ // flag is a string
 				locate(flags[l].x, flags[l].y);
-				set_font((unsigned char*)Terminal6x8);
+				::printf("Move cursor at %dx%d\n", flags[l].x, flags[l].y);
+				::printf("  using fgcolor=%x\n", fgcolor);
 				this->printf(flags[l].msg);}
 			else
 			{ // flag is an icon
@@ -305,7 +311,7 @@
 	ThisThread::sleep_for(3ms);
 	cls();
 	printf("TEST DSP #3\r\n");
-
+	/*
 	for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++)
 	{
 		z = &zones[i];
@@ -313,7 +319,7 @@
 		locate(z->x0+1, z->y0+1);
 		this->printf("%d", i);
 	}
-
+	*/
 	/*
 		for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++)
 		{
--- a/src/display.h	Tue Nov 10 22:24:03 2020 +0100
+++ b/src/display.h	Thu Nov 12 20:26:35 2020 +0100
@@ -32,12 +32,11 @@
 } DSP;
 
 
-
 static DSP table[] =
 {       // 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
+	{ 0x00, 0xF, 0x0,  0,  0, FMT_ASCII, MAX_BUFF, 255, Mono19x27}, // main display
+	{ 0x0C, 0xF, 0x0,194, 38, FMT_ASCII, 3,        45,  Mono15x22}, // channels display
+	{ 0x0A, 0xF, 0x0,  0, 57, FMT_FLAGS, 4,        0, Terminal6x8}, // flags + bits
 };
 
 // 9x10
@@ -75,86 +74,89 @@
 	uint8_t x;
 	uint8_t y;
 	bool reverse;
+	bool dimm;
 	const char* msg;
 	const unsigned char* icon;
 } FLAG;
 
 typedef struct _FRAME
 {
-	uint16_t flag;
+	uint8_t flag;
 	uint8_t x0;
 	uint8_t y0;
 	uint8_t x1;
 	uint8_t y1;
 } FRAME;
 
+
+
 static const FLAG flags[] =
 {
-    // flag, x0, y0, reverse, msg, icon
+    // flag, x0, y0, reverse, dimm, msg, icon
     // right-side icons area
 	// 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
+    { 0x00, 246, 27,  false, false, NULL, icon_alarm}, // F1.0  01 00 00 00
+    { 0x01, 246, 38, false, 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
+    { 0x03, 195, 29, false, 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
+    { 0x1c, 0,  38,  false, false, "MON"},          // F4.4  00 00 00 10
+    { 0x1b, 0,  47,  false, false, "VIEW"},         // F4.3  00 00 00 08
+    { 0x1d, 0,  29,  true, false,  "SCAN"},          // F4.5  00 00 00 20
+    { 0x1e, 0,  56,  true, false,  "CONFIG"},        // F4.6  00 00 00 40
 
-    { 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
+    { 0x1a, 40,  56,   false, false, "*"},            // F4.2  00 00 00 04
+    { 0x19, 50,  56,   false, false, "ADRS"},         // F4.1  00 00 00 02
+    { 0x18, 80,  56,   false, false, "RMT"},          // F4.0  00 00 00 01
+    { 0x17, 104, 56,   true, false, "ERROR"},         // F3.7  00 00 80 00
 
-    { 0x16, 140, 52,   false, "EXT"},          // F3.6  00 00 40 00
-    { 0x15, 164, 52,   false, "ONCE"},         // F3.5  00 00 20 00
+    { 0x16, 86, 38,   false, false, "EXT"},          // F3.6  00 00 40 00
+    { 0x15, 60, 38,   false, false, "ONCE"},         // F3.5  00 00 20 00
 
-    { 0x13, 104, 28+16, false, "MEM"},         // F3.3  00 00 08 00
+    { 0x13, 40, 38,   false, false, "MEM"},         // F3.3  00 00 08 00
 
 
     // col 5
-    { 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
+    { 0x0c, 244, 47,  false, false, "4W"},            // F2.4  00 10 00 00
+    { 0x0d, 244, 56,  false, false, "OC"},            // F2.5  00 20 00 00
+
+    { 0x12, 40,  47, false, true, "LAST"},        // F3.2  00 00 04 00
+    { 0x11, 66,  47, false, true, "MIN"},         // F3.1  00 00 02 00
+    { 0x10, 86,  47, false, true, "MAX"},         // F3.0  00 00 01 00
+    { 0x0f, 106, 47, false, true, "AVG"},         // F2.7  00 80 00 00
 
-    { 0x05, 154+0,  17+10, false, "Alarm"},    // F1.5  20 00 00 00
-    { 0x08, 154+0,  17+20, false, "H"},        // F1.6  40 00 00 00
-    { 0x07, 154+6,  17+20, false, "1"},        // F2.3  00 08 00 00
-    { 0x06, 154+12, 17+20, false, "2"},        // F2.0  00 01 00 00
-    { 0x04, 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
-    { 0x0a, 154+30, 17+20, false, "L"},        // F1.4  00 10 00 00
+    { 0x05, 152+0,  29, false, false, "Alarm"},    // F1.5  20 00 00 00
+    { 0x08, 152+0,  39, false, false, "H"},        // F1.6  40 00 00 00
+    { 0x07, 152+6,  39, false, false, "1"},        // F2.3  00 08 00 00
+    { 0x06, 152+12, 39, false, false, "2"},        // F2.0  00 01 00 00
+    { 0x04, 152+18, 39, false, false, "3"},        // F2.2  00 04 00 00
+    { 0x09, 152+24, 39, false, false, "4"},        // F2.1  00 02 00 00
+    { 0x0a, 152+30, 39, false, false, "L"},        // F1.4  00 10 00 00
 
-	{ 0x80, 224, 54, true, "SHIFT"},   // not an actual command, managed by the front panel
+	{ 0x80, 152, 56, true, false, "SHIFT"},   // not an actual command, managed by the front panel
 };
 
-static const FRAME zones[] =
-{ // flag, x0, y0, x1, y1
-    { 0x001, 0,   0, 245, 27}, // main display area
-    { 0x002, 246, 0, 255, 27}, // right notif area
-    { 0x004, 208, 35, 254, 62}, // channels display area
-    { 0x008, 160, 28, 202, 54}, // alarms area
-    { 0x010, 0,   28, 32,  54}, // flags col1
-    { 0x020, 33,  28, 70,  54}, // flags col2
-    { 0x040, 71,  28, 103, 54}, // flags col3
-    { 0x080, 104, 28, 128, 54}, // flags col4
-    { 0x100, 129, 28, 159, 54}, // flags col5
-
-//    { 0x8000, 0, 55, 255, 63}, // flags bits display area
-};
 
 static const FRAME frames[] =
 {
-    { 0x02, 194, 30, 243, 53}, // F1.2 - channel frame
-    { 0x0b, 151, 30, 192, 46}, // F1.7 - alarm frame
+    { 0x02, 192, 32, 240, 60}, // F1.2 - channel frame
+    { 0x0b, 149, 32, 190, 50}, // F1.7 - alarm frame
 };
 
 
+typedef enum {
+	FLAG_OFF,
+	FLAG_ON,
+	FLAG_DIM
+} flag_status_t;
+
+typedef struct _FLAG_STATUS
+{
+	uint8_t flag;
+	flag_status_t status;
+} FLAG_STATUS;
+
+
 class Display: public SSD1322
 {
 public:
--- a/src/main.cpp	Tue Nov 10 22:24:03 2020 +0100
+++ b/src/main.cpp	Thu Nov 12 20:26:35 2020 +0100
@@ -408,7 +408,7 @@
 		  dsp->hide_flag(cmd.value[0]);
 		} else if (cmd.cmd == 0x08) {
 		  // set a flag dimmed
-			dsp->show_flag(cmd.value[0], true, true);
+		  dsp->set_flag(cmd.value[0], true, true);
 		} else if (cmd.cmd == 0x09) {
 		  // set a flag bright
           dsp->set_flag(cmd.value[0], true, false);

mercurial