Add support for the shift flag draft

Sun, 25 Oct 2020 23:00:17 +0100

author
David Douard <david.douard@sdf3.org>
date
Sun, 25 Oct 2020 23:00:17 +0100
changeset 36
a6c7292742a0
parent 35
b2dca6b935bb
child 37
07e8ca2bdf6d

Add support for the shift flag

src/main.cpp file | annotate | diff | comparison | revisions
--- a/src/main.cpp	Sun Oct 25 22:45:24 2020 +0100
+++ b/src/main.cpp	Sun Oct 25 23:00:17 2020 +0100
@@ -72,35 +72,35 @@
 		KP_C4
 };
 
-/* mapping (RxC)
-	 0x2 0x00:  View
-	 0x1 0x01:  Mon
-	 3x3 0x02:  Sto/Rcl
-	 0x0 0x03:  Scan
-	 1x2 0x04:  Alarm
-	 1x1 0x05:  Mx+B
-	 1x0 0x06:  Measure
-	 2x0 0x07:  Interval
-	 3x2 0x08:  Card Reset
-	 3x1 0x09:  Close
-	 3x0 0x0A:  Open
-	 0x3 0x0B:  Read
-	 2x3 0x0C:  Shift
-	 1x3 0x0D:  Write
-	 0x4 0x0E:  Left
-	 1x4 0x0F:  Right
-	 2x2 0x10:  Advanced
-	 2x1 0x11:  Step
+/* key mapping
+   RxC   code   name
+	 0x2   0x00   View
+	 0x1   0x01   Mon
+	 3x3   0x02   Sto/Rcl
+	 0x0   0x03   Scan
+	 1x2   0x04   Alarm
+	 1x1   0x05   Mx+B
+	 1x0   0x06   Measure
+	 2x0   0x07   Interval
+	 3x2   0x08   Card Reset
+	 3x1   0x09   Close
+	 3x0   0x0A   Open
+	 0x3   0x0B   Read
+	 2x3   0x0C   Shift
+	 1x3   0x0D   Write
+	 0x4   0x0E   Left
+	 1x4   0x0F   Right
+	 2x2   0x10   Advanced
+	 2x1   0x11   Step
 */
 
-uint8_t kp_mapping[KP_NROWS][KP_NCOLS] = { // [row][column]
+uint8_t kp_mapping[KP_NROWS][KP_NCOLS] = {
 		{0x03, 0x01, 0x00, 0x0B, 0x0E},
 		{0x06, 0x05, 0x04, 0x0D, 0x0F},
 		{0x07, 0x11, 0x10, 0x0C, 0xFF},
 		{0x0A, 0x09, 0x08, 0x02, 0xFF}
 };
 
-
 void kp_cb(uint8_t row, uint8_t col);
 void kr_cb(uint8_t row, uint8_t col);
 
@@ -770,6 +770,8 @@
 
 				printf("CMD[%d] %02X", (int)cmd.id, cmd.cmd);
 
+				// 0x00: main display
+				// 0x0C: channel display
 				if ((cmd.cmd == 0x00) || (cmd.cmd == 0x0C))
 					printf(": '%s'\r\n", cmd.value);
 				else {
@@ -778,7 +780,20 @@
 						printf("%02x ", cmd.value[i]);
 					printf("\r\n");
 				}
-				show(cmd.cmd, cmd.value, cmd.size);
+
+				if (cmd.cmd == 0x01) {
+          // clear a flag
+					if (cmd.value[0] == 0x0E) {
+            // clear the Shift flag
+						shift = false;
+					}
+				} else if (cmd.cmd == 0x86) {
+          // shutdown
+					// TODO
+				} else {
+          // display related commands
+					show(cmd.cmd, cmd.value, cmd.size);
+				}
 #if defined(HAS_LED)
 				led = 0;
 #endif

mercurial