瀏覽代碼

Print a counter

Show the bug when displaying numbers which can be 1 or 2 digits.

Modulo 20.
Expected : 18 -> 19 -> 0 -> 1
Seen : 18 -> 19 -> 09 -> 19
DricomDragon 5 年之前
父節點
當前提交
5916fa1529
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      prog/sources/setup-loop.cpp

+ 8 - 0
prog/sources/setup-loop.cpp

@@ -11,6 +11,9 @@ bool actionDone[5];
 DigitalPort LED[5];
 DigitalPort BUTTON[5];
 
+// Counter
+uint32_t counter(0);
+
 void setup (USER_MODE) {
 	// Start
 	digitalWrite(L0_LED, true);
@@ -59,10 +62,15 @@ void loop (USER_MODE) {
 		if (!buttonReleased[i] && !actionDone[i]) {
 			digitalToggle(LED[i]);
 			actionDone[i] = true;
+			counter ++;
+			counter %= 20;
 
 			// Show action on LCD
 			gotoLineColumn(MODE_ 1, 13 - i);
 			printChar(MODE_ '1');
+
+			gotoLineColumn(MODE_ 2, 12);
+			printUnsigned(MODE_ counter);
 		}
 	}
 }