v3.0.2 - Updated example 19 for STM32F boards

--- examples/Scheduler_example19_Dynamic_Tasks/Scheduler_example19_Dynamic_Tasks.ino
+++ examples/Scheduler_example19_Dynamic_Tasks/Scheduler_example19_Dynamic_Tasks.ino
@@ -3,6 +3,8 @@
     Test case:
       Main task runs every 100 milliseconds 100 times and in 50% cases generates a task object
       which runs 1 to 10 times with 100 ms to 5 s interval, and then destroyed.
+      Garbage collection deletes all the tasks which have finished (enabled in their respective
+      OnDisable methods)

       This sketch uses the following libraries:
        - FreeMemory library: https://github.com/McNeight/MemoryFree
@@ -34,8 +36,8 @@
 void GC();

 // Statis task
-Task tMain(100*TASK_MILLISECOND, 100, &MainLoop, &ts, true);
-Task tGarbageCollection(TASK_IMMEDIATE, TASK_FOREVER, &GC, &ts, false);
+Task tMain(100 * TASK_MILLISECOND, 100, &MainLoop, &ts, true);
+Task tGarbageCollection(200 * TASK_MILLISECOND, TASK_FOREVER, &GC, &ts, false);

 void Iteration();
@@ -43,7 +45,7 @@
 void OnDisable();

 int noOfTasks = 0;
-QueueArray <(Task*)> toDelete;
+QueueArray <Task*> toDelete;

 void MainLoop() {
   Serial.print(millis()); Serial.print("\t");
@@ -58,9 +60,9 @@
     Task *t = new Task(p, j, Iteration, &ts, false, OnEnable, OnDisable);

     Serial.print(F("Generated a new task:\t")); Serial.print(t->getId()); Serial.print(F("\tInt, Iter = \t"));
-    Serial.print(p); Serial.print(", "); Serial.print(j);
-	Serial.print(F("\tFree mem=")); Serial.print(freeMemory());
-	Serial.print(F("\tNo of tasks=")); Serial.println(++noOfTasks);
+    Serial.print(p); Serial.print(", "); Serial.print(j);
+    Serial.print(F("\tFree mem=")); Serial.print(freeMemory());
+    Serial.print(F("\tNo of tasks=")); Serial.println(++noOfTasks);
     t->enable();
   }
   else {
@@ -90,9 +92,7 @@
   tGarbageCollection.enableIfNot();

   Serial.print(millis()); Serial.print("\t");
-  Serial.print("Task N"); Serial.print(tid); Serial.println(F("\tfinished");
-  Serial.ptint("and destroyed.\tFree mem="));
-  Serial.print(freeMemory());Serial.print(F("\tNo of tasks=")); Serial.println(--noOfTasks);
+  Serial.print("Task N"); Serial.print(tid); Serial.println(F("\tfinished"));
 }

 /**
@@ -106,23 +106,23 @@

   Serial.println(F("Dynamic Task Creation/Destruction Example"));
   Serial.println();
-
-  Serial.print(F("Free mem=")); Serial.print(freeMemory());
+
+  Serial.print(F("Free mem=")); Serial.print(freeMemory());
   Serial.print(F("\tNo of tasks=")); Serial.println(noOfTasks);
   Serial.println();
 }

 void GC() {
-	if ( toDelete.isEmpty() ) {
-		tGarbageCollection.disable();
-		return;
-	}
-	Task *t = toDelete.pop();
-    Serial.print(millis()); Serial.print("\t");
-    Serial.print("Task N"); Serial.print(t->getId()); Serial.println(F("\tdestroyed");
-    Serial.ptint("Free mem=")); Serial.print(freeMemory());
-	Serial.print(F("\tNo of tasks=")); Serial.println(--noOfTasks);
-	delete t;
+  if ( toDelete.isEmpty() ) {
+    tGarbageCollection.disable();
+    return;
+  }
+  Task *t = toDelete.pop();
+  Serial.print(millis()); Serial.print("\t");
+  Serial.print("Task N"); Serial.print(t->getId()); Serial.println(F("\tdestroyed"));
+  Serial.print("Free mem="); Serial.print(freeMemory());
+  Serial.print(F("\tNo of tasks=")); Serial.println(--noOfTasks);
+  delete t;
 }

 void loop() {
@@ -130,445 +130,3 @@
 }

-
-/* Output on Arduino Uno:
- *
- *  Compile:
-
-Sketch uses 5312 bytes (16%) of program storage space. Maximum is 32256 bytes.
-Global variables use 282 bytes (13%) of dynamic memory, leaving 1766 bytes for local variables. Maximum is 2048 bytes.
-
- * Execution:
-
-Dynamic Task Creation/Destruction Example
-
-Free mem=1758  No of tasks=0
-
-1 MainLoop run: 1.  Generated a new task: 2 Int, Iter =   421, 3  Free mem=1701 No of tasks=1
-8 Task N2 current iteration: 1
-100 MainLoop run: 2.  Generated a new task: 3 Int, Iter =   4099, 9 Free mem=1656 No of tasks=2
-102 Task N3 current iteration: 1
-200 MainLoop run: 3.  Skipped generating a task
-300 MainLoop run: 4.  Generated a new task: 4 Int, Iter =   1795, 1 Free mem=1611 No of tasks=3
-302 Task N4 current iteration: 1
-305 Task N4 finished and destroyed. Free mem=1613 No of tasks=2
-400 MainLoop run: 5.  Skipped generating a task
-429 Task N2 current iteration: 2
-500 MainLoop run: 6.  Skipped generating a task
-600 MainLoop run: 7.  Skipped generating a task
-700 MainLoop run: 8.  Generated a new task: 5 Int, Iter =   4623, 7 Free mem=1611 No of tasks=3
-702 Task N5 current iteration: 1
-800 MainLoop run: 9.  Generated a new task: 6 Int, Iter =   4987, 4 Free mem=1566 No of tasks=4
-802 Task N6 current iteration: 1
-850 Task N2 current iteration: 3
-850 Task N2 finished and destroyed. Free mem=1568 No of tasks=3
-900 MainLoop run: 10. Generated a new task: 7 Int, Iter =   600, 4  Free mem=1566 No of tasks=4
-902 Task N7 current iteration: 1
-1000  MainLoop run: 11. Skipped generating a task
-1100  MainLoop run: 12. Generated a new task: 8 Int, Iter =   2530, 1 Free mem=1521 No of tasks=5
-1102  Task N8 current iteration: 1
-1105  Task N8 finished and destroyed. Free mem=1523 No of tasks=4
-1200  MainLoop run: 13. Skipped generating a task
-1300  MainLoop run: 14. Generated a new task: 9 Int, Iter =   2215, 7 Free mem=1521 No of tasks=5
-1302  Task N9 current iteration: 1
-1400  MainLoop run: 15. Skipped generating a task
-1500  MainLoop run: 16. Skipped generating a task
-1502  Task N7 current iteration: 2
-1600  MainLoop run: 17. Skipped generating a task
-1700  MainLoop run: 18. Skipped generating a task
-1800  MainLoop run: 19. Skipped generating a task
-1900  MainLoop run: 20. Skipped generating a task
-2000  MainLoop run: 21. Generated a new task: 10  Int, Iter =   189, 10 Free mem=1476 No of tasks=6
-2002  Task N10  current iteration: 1
-2100  MainLoop run: 22. Generated a new task: 11  Int, Iter =   2898, 9 Free mem=1431 No of tasks=7
-2102  Task N7 current iteration: 3
-2105  Task N11  current iteration: 1
-2191  Task N10  current iteration: 2
-2200  MainLoop run: 23. Generated a new task: 12  Int, Iter =   1691, 6 Free mem=1386 No of tasks=8
-2202  Task N12  current iteration: 1
-2300  MainLoop run: 24. Generated a new task: 13  Int, Iter =   1448, 7 Free mem=1341 No of tasks=9
-2304  Task N13  current iteration: 1
-2380  Task N10  current iteration: 3
-2400  MainLoop run: 25. Generated a new task: 14  Int, Iter =   3919, 7 Free mem=1296 No of tasks=10
-2403  Task N14  current iteration: 1
-2500  MainLoop run: 26. Generated a new task: 15  Int, Iter =   3745, 5 Free mem=1251 No of tasks=11
-2503  Task N15  current iteration: 1
-2569  Task N10  current iteration: 4
-2600  MainLoop run: 27. Skipped generating a task
-2700  MainLoop run: 28. Skipped generating a task
-2702  Task N7 current iteration: 4
-2702  Task N7 finished and destroyed. Free mem=1253 No of tasks=10
-2758  Task N10  current iteration: 5
-2800  MainLoop run: 29. Generated a new task: 16  Int, Iter =   2144, 1 Free mem=1251 No of tasks=11
-2803  Task N16  current iteration: 1
-2806  Task N16  finished and destroyed. Free mem=1253 No of tasks=10
-2900  MainLoop run: 30. Generated a new task: 17  Int, Iter =   4618, 10  Free mem=1251 No of tasks=11
-2904  Task N17  current iteration: 1
-2947  Task N10  current iteration: 6
-3000  MainLoop run: 31. Skipped generating a task
-3100  MainLoop run: 32. Generated a new task: 18  Int, Iter =   2885, 6 Free mem=1206 No of tasks=12
-3103  Task N18  current iteration: 1
-3136  Task N10  current iteration: 7
-3200  MainLoop run: 33. Skipped generating a task
-3300  MainLoop run: 34. Skipped generating a task
-3325  Task N10  current iteration: 8
-3400  MainLoop run: 35. Skipped generating a task
-3500  MainLoop run: 36. Generated a new task: 19  Int, Iter =   2250, 4 Free mem=1161 No of tasks=13
-3503  Task N19  current iteration: 1
-3514  Task N10  current iteration: 9
-3518  Task N9 current iteration: 2
-3600  MainLoop run: 37. Skipped generating a task
-3700  MainLoop run: 38. Generated a new task: 20  Int, Iter =   1689, 7 Free mem=1116 No of tasks=14
-3703  Task N10  current iteration: 10
-3706  Task N20  current iteration: 1
-3709  Task N10  finished and destroyed. Free mem=1118 No of tasks=13
-3750  Task N13  current iteration: 2
-3800  MainLoop run: 39. Generated a new task: 21  Int, Iter =   2607, 5 Free mem=1116 No of tasks=14
-3803  Task N21  current iteration: 1
-3893  Task N12  current iteration: 2
-3900  MainLoop run: 40. Generated a new task: 22  Int, Iter =   1390, 6 Free mem=1071 No of tasks=15
-3903  Task N22  current iteration: 1
-4000  MainLoop run: 41. Generated a new task: 23  Int, Iter =   3340, 8 Free mem=1026 No of tasks=16
-4003  Task N23  current iteration: 1
-4100  MainLoop run: 42. Skipped generating a task
-4200  MainLoop run: 43. Skipped generating a task
-4201  Task N3 current iteration: 2
-4300  MainLoop run: 44. Skipped generating a task
-4400  MainLoop run: 45. Generated a new task: 24  Int, Iter =   4083, 2 Free mem=981  No of tasks=17
-4403  Task N24  current iteration: 1
-4500  MainLoop run: 46. Generated a new task: 25  Int, Iter =   4510, 1 Free mem=936  No of tasks=18
-4503  Task N25  current iteration: 1
-4506  Task N25  finished and destroyed. Free mem=938  No of tasks=17
-4600  MainLoop run: 47. Generated a new task: 26  Int, Iter =   4782, 10  Free mem=936  No of tasks=18
-4603  Task N26  current iteration: 1
-4700  MainLoop run: 48. Generated a new task: 27  Int, Iter =   641, 6  Free mem=891  No of tasks=19
-4702  Task N27  current iteration: 1
-4800  MainLoop run: 49. Generated a new task: 28  Int, Iter =   695, 5  Free mem=846  No of tasks=20
-4802  Task N28  current iteration: 1
-4900  MainLoop run: 50. Generated a new task: 29  Int, Iter =   3520, 3 Free mem=801  No of tasks=21
-4903  Task N29  current iteration: 1
-5000  MainLoop run: 51. Generated a new task: 30  Int, Iter =   3091, 9 Free mem=756  No of tasks=22
-5002  Task N11  current iteration: 2
-5006  Task N30  current iteration: 1
-5100  MainLoop run: 52. Skipped generating a task
-5198  Task N13  current iteration: 3
-5200  MainLoop run: 53. Skipped generating a task
-5293  Task N22  current iteration: 2
-5300  MainLoop run: 54. Generated a new task: 31  Int, Iter =   4359, 9 Free mem=711  No of tasks=23
-5303  Task N31  current iteration: 1
-5325  Task N5 current iteration: 2
-5343  Task N27  current iteration: 2
-5392  Task N20  current iteration: 2
-5400  MainLoop run: 55. Generated a new task: 32  Int, Iter =   837, 4  Free mem=666  No of tasks=24
-5403  Task N32  current iteration: 1
-5497  Task N28  current iteration: 2
-5501  MainLoop run: 56. Generated a new task: 33  Int, Iter =   274, 8  Free mem=621  No of tasks=25
-5505  Task N33  current iteration: 1
-5584  Task N12  current iteration: 3
-5600  MainLoop run: 57. Generated a new task: 34  Int, Iter =   923, 7  Free mem=576  No of tasks=26
-5603  Task N34  current iteration: 1
-5700  MainLoop run: 58. Generated a new task: 35  Int, Iter =   1007, 8 Free mem=531  No of tasks=27
-5703  Task N35  current iteration: 1
-5732  Task N9 current iteration: 3
-5753  Task N19  current iteration: 2
-5778  Task N33  current iteration: 2
-5789  Task N6 current iteration: 2
-5800  MainLoop run: 59. Skipped generating a task
-5900  MainLoop run: 60. Generated a new task: 36  Int, Iter =   608, 4  Free mem=486  No of tasks=28
-5903  Task N36  current iteration: 1
-5984  Task N27  current iteration: 3
-5988  Task N18  current iteration: 2
-6000  MainLoop run: 61. Generated a new task: 37  Int, Iter =   4043, 3 Free mem=441  No of tasks=29
-6003  Task N37  current iteration: 1
-6052  Task N33  current iteration: 3
-6100  MainLoop run: 62. Skipped generating a task
-6192  Task N28  current iteration: 3
-6200  MainLoop run: 63. Skipped generating a task
-6239  Task N32  current iteration: 2
-6248  Task N15  current iteration: 2
-6300  MainLoop run: 64. Skipped generating a task
-6322  Task N14  current iteration: 2
-6326  Task N33  current iteration: 4
-6400  MainLoop run: 65. Skipped generating a task
-6410  Task N21  current iteration: 2
-6500  MainLoop run: 66. Skipped generating a task
-6510  Task N36  current iteration: 2
-6525  Task N34  current iteration: 2
-6600  MainLoop run: 67. Skipped generating a task
-6600  Task N33  current iteration: 5
-6625  Task N27  current iteration: 4
-6646  Task N13  current iteration: 4
-6683  Task N22  current iteration: 3
-6700  MainLoop run: 68. Generated a new task: 38  Int, Iter =   1907, 9 Free mem=396  No of tasks=30
-6703  Task N38  current iteration: 1
-6709  Task N35  current iteration: 2
-6800  MainLoop run: 69. Skipped generating a task
-6874  Task N33  current iteration: 6
-6887  Task N28  current iteration: 4
-6900  MainLoop run: 70. Generated a new task: 39  Int, Iter =   2697, 1 Free mem=351  No of tasks=31
-6903  Task N39  current iteration: 1
-6906  Task N39  finished and destroyed. Free mem=353  No of tasks=30
-7000  MainLoop run: 71. Generated a new task: 40  Int, Iter =   2849, 4 Free mem=351  No of tasks=31
-7003  Task N40  current iteration: 1
-7076  Task N32  current iteration: 3
-7081  Task N20  current iteration: 3
-7100  MainLoop run: 72. Skipped generating a task
-7118  Task N36  current iteration: 3
-7148  Task N33  current iteration: 7
-7200  MainLoop run: 73. Skipped generating a task
-7266  Task N27  current iteration: 5
-7275  Task N12  current iteration: 4
-7300  MainLoop run: 74. Generated a new task: 41  Int, Iter =   4466, 4 Free mem=306  No of tasks=32
-7303  Task N41  current iteration: 1
-7343  Task N23  current iteration: 2
-7400  MainLoop run: 75. Skipped generating a task
-7422  Task N33  current iteration: 8
-7422  Task N33  finished and destroyed. Free mem=308  No of tasks=31
-7448  Task N34  current iteration: 3
-7500  MainLoop run: 76. Generated a new task: 42  Int, Iter =   2133, 3 Free mem=306  No of tasks=32
-7503  Task N42  current iteration: 1
-7522  Task N17  current iteration: 2
-7582  Task N28  current iteration: 5
-7582  Task N28  finished and destroyed. Free mem=308  No of tasks=31
-7600  MainLoop run: 77. Skipped generating a task
-7700  MainLoop run: 78. Skipped generating a task
-7716  Task N35  current iteration: 3
-7726  Task N36  current iteration: 4
-7726  Task N36  finished and destroyed. Free mem=353  No of tasks=30
-7800  MainLoop run: 79. Generated a new task: 43  Int, Iter =   4113, 6 Free mem=351  No of tasks=31
-7803  Task N43  current iteration: 1
-7898  Task N11  current iteration: 3
-7900  MainLoop run: 80. Skipped generating a task
-7907  Task N27  current iteration: 6
-7907  Task N27  finished and destroyed. Free mem=353  No of tasks=30
-7913  Task N32  current iteration: 4
-7913  Task N32  finished and destroyed. Free mem=398  No of tasks=29
-7947  Task N9 current iteration: 4
-8000  MainLoop run: 81. Skipped generating a task
-8003  Task N19  current iteration: 3
-8073  Task N22  current iteration: 4
-8093  Task N30  current iteration: 2
-8094  Task N13  current iteration: 5
-8100  MainLoop run: 82. Skipped generating a task
-8200  MainLoop run: 83. Generated a new task: 44  Int, Iter =   3389, 1 Free mem=396  No of tasks=30
-8203  Task N44  current iteration: 1
-8206  Task N44  finished and destroyed. Free mem=398  No of tasks=29
-8300  MainLoop run: 84. Generated a new task: 45  Int, Iter =   3548, 10  Free mem=396  No of tasks=30
-8303  Task N3 current iteration: 3
-8306  Task N45  current iteration: 1
-8371  Task N34  current iteration: 4
-8400  MainLoop run: 85. Skipped generating a task
-8422  Task N29  current iteration: 2
-8485  Task N24  current iteration: 2
-8485  Task N24  finished and destroyed. Free mem=398  No of tasks=29
-8500  MainLoop run: 86. Generated a new task: 46  Int, Iter =   4962, 2 Free mem=396  No of tasks=30
-8503  Task N46  current iteration: 1
-8600  MainLoop run: 87. Skipped generating a task
-8609  Task N38  current iteration: 2
-8700  MainLoop run: 88. Skipped generating a task
-8723  Task N35  current iteration: 4
-8770  Task N20  current iteration: 4
-8800  MainLoop run: 89. Skipped generating a task
-8873  Task N18  current iteration: 3
-8900  MainLoop run: 90. Skipped generating a task
-8966  Task N12  current iteration: 5
-9000  MainLoop run: 91. Skipped generating a task
-9017  Task N21  current iteration: 3
-9100  MainLoop run: 92. Skipped generating a task
-9200  MainLoop run: 93. Skipped generating a task
-9294  Task N34  current iteration: 5
-9300  MainLoop run: 94. Skipped generating a task
-9385  Task N26  current iteration: 2
-9400  MainLoop run: 95. Generated a new task: 47  Int, Iter =   3556, 9 Free mem=351  No of tasks=31
-9403  Task N47  current iteration: 1
-9463  Task N22  current iteration: 5
-9500  MainLoop run: 96. Generated a new task: 48  Int, Iter =   1226, 3 Free mem=306  No of tasks=32
-9503  Task N48  current iteration: 1
-9542  Task N13  current iteration: 6
-9600  MainLoop run: 97. Generated a new task: 49  Int, Iter =   2850, 9 Free mem=261  No of tasks=33
-9603  Task N49  current iteration: 1
-9635  Task N42  current iteration: 2
-9661  Task N31  current iteration: 2
-9700  MainLoop run: 98. Skipped generating a task
-9730  Task N35  current iteration: 5
-9800  MainLoop run: 99. Generated a new task: 50  Int, Iter =   2782, 10  Free mem=216  No of tasks=34
-9803  Task N50  current iteration: 1
-9851  Task N40  current iteration: 2
-9900  MainLoop run: 100.  Skipped generating a task
-9948  Task N5 current iteration: 3
-9993  Task N15  current iteration: 3
-10045 Task N37  current iteration: 2
-10162 Task N9 current iteration: 5
-10217 Task N34  current iteration: 6
-10241 Task N14  current iteration: 3
-10253 Task N19  current iteration: 4
-10253 Task N19  finished and destroyed. Free mem=218  No of tasks=33
-10459 Task N20  current iteration: 5
-10516 Task N38  current iteration: 3
-10657 Task N12  current iteration: 6
-10657 Task N12  finished and destroyed. Free mem=263  No of tasks=32
-10683 Task N23  current iteration: 3
-10728 Task N48  current iteration: 2
-10737 Task N35  current iteration: 6
-10776 Task N6 current iteration: 3
-10796 Task N11  current iteration: 4
-10853 Task N22  current iteration: 6
-10853 Task N22  finished and destroyed. Free mem=308  No of tasks=31
-10990 Task N13  current iteration: 7
-10990 Task N13  finished and destroyed. Free mem=353  No of tasks=30
-11140 Task N34  current iteration: 7
-11140 Task N34  finished and destroyed. Free mem=398  No of tasks=29
-11184 Task N30  current iteration: 3
-11624 Task N21  current iteration: 4
-11744 Task N35  current iteration: 7
-11758 Task N18  current iteration: 4
-11768 Task N41  current iteration: 2
-11768 Task N42  current iteration: 3
-11769 Task N42  finished and destroyed. Free mem=443  No of tasks=28
-11851 Task N45  current iteration: 2
-11915 Task N43  current iteration: 2
-11942 Task N29  current iteration: 3
-11942 Task N29  finished and destroyed. Free mem=488  No of tasks=27
-11954 Task N48  current iteration: 3
-11954 Task N48  finished and destroyed. Free mem=533  No of tasks=26
-12140 Task N17  current iteration: 3
-12148 Task N20  current iteration: 6
-12377 Task N9 current iteration: 6
-12399 Task N3 current iteration: 4
-12423 Task N38  current iteration: 4
-12452 Task N49  current iteration: 2
-12585 Task N50  current iteration: 2
-12700 Task N40  current iteration: 3
-12751 Task N35  current iteration: 8
-12751 Task N35  finished and destroyed. Free mem=578  No of tasks=25
-12958 Task N47  current iteration: 2
-13464 Task N46  current iteration: 2
-13464 Task N46  finished and destroyed. Free mem=623  No of tasks=24
-13694 Task N11  current iteration: 5
-13739 Task N15  current iteration: 4
-13837 Task N20  current iteration: 7
-13837 Task N20  finished and destroyed. Free mem=668  No of tasks=23
-14020 Task N31  current iteration: 3
-14023 Task N23  current iteration: 4
-14088 Task N37  current iteration: 3
-14088 Task N37  finished and destroyed. Free mem=713  No of tasks=22
-14160 Task N14  current iteration: 4
-14167 Task N26  current iteration: 3
-14231 Task N21  current iteration: 5
-14231 Task N21  finished and destroyed. Free mem=758  No of tasks=21
-14275 Task N30  current iteration: 4
-14330 Task N38  current iteration: 5
-14571 Task N5 current iteration: 4
-14592 Task N9 current iteration: 7
-14592 Task N9 finished and destroyed. Free mem=803  No of tasks=20
-14643 Task N18  current iteration: 5
-15302 Task N49  current iteration: 3
-15367 Task N50  current iteration: 3
-15399 Task N45  current iteration: 3
-15549 Task N40  current iteration: 4
-15549 Task N40  finished and destroyed. Free mem=848  No of tasks=19
-15763 Task N6 current iteration: 4
-15763 Task N6 finished and destroyed. Free mem=893  No of tasks=18
-16028 Task N43  current iteration: 3
-16234 Task N41  current iteration: 3
-16237 Task N38  current iteration: 6
-16498 Task N3 current iteration: 5
-16514 Task N47  current iteration: 3
-16592 Task N11  current iteration: 6
-16758 Task N17  current iteration: 4
-17363 Task N23  current iteration: 5
-17366 Task N30  current iteration: 5
-17483 Task N15  current iteration: 5
-17483 Task N15  finished and destroyed. Free mem=938  No of tasks=17
-17528 Task N18  current iteration: 6
-17528 Task N18  finished and destroyed. Free mem=983  No of tasks=16
-18079 Task N14  current iteration: 5
-18144 Task N38  current iteration: 7
-18149 Task N50  current iteration: 4
-18152 Task N49  current iteration: 4
-18379 Task N31  current iteration: 4
-18947 Task N45  current iteration: 4
-18949 Task N26  current iteration: 4
-19194 Task N5 current iteration: 5
-19490 Task N11  current iteration: 7
-20051 Task N38  current iteration: 8
-20070 Task N47  current iteration: 4
-20141 Task N43  current iteration: 4
-20457 Task N30  current iteration: 6
-20597 Task N3 current iteration: 6
-20700 Task N41  current iteration: 4
-20700 Task N41  finished and destroyed. Free mem=1028 No of tasks=15
-20703 Task N23  current iteration: 6
-20931 Task N50  current iteration: 5
-21002 Task N49  current iteration: 5
-21376 Task N17  current iteration: 5
-21958 Task N38  current iteration: 9
-21958 Task N38  finished and destroyed. Free mem=1073 No of tasks=14
-21998 Task N14  current iteration: 6
-22388 Task N11  current iteration: 8
-22495 Task N45  current iteration: 5
-22738 Task N31  current iteration: 5
-23548 Task N30  current iteration: 7
-23626 Task N47  current iteration: 5
-23713 Task N50  current iteration: 6
-23731 Task N26  current iteration: 5
-23817 Task N5 current iteration: 6
-23852 Task N49  current iteration: 6
-24043 Task N23  current iteration: 7
-24254 Task N43  current iteration: 5
-24696 Task N3 current iteration: 7
-25286 Task N11  current iteration: 9
-25286 Task N11  finished and destroyed. Free mem=1118 No of tasks=13
-25917 Task N14  current iteration: 7
-25917 Task N14  finished and destroyed. Free mem=1163 No of tasks=12
-25994 Task N17  current iteration: 6
-26043 Task N45  current iteration: 6
-26496 Task N50  current iteration: 7
-26639 Task N30  current iteration: 8
-26702 Task N49  current iteration: 7
-27097 Task N31  current iteration: 6
-27182 Task N47  current iteration: 6
-27383 Task N23  current iteration: 8
-27383 Task N23  finished and destroyed. Free mem=1208 No of tasks=11
-28367 Task N43  current iteration: 6
-28367 Task N43  finished and destroyed. Free mem=1253 No of tasks=10
-28440 Task N5 current iteration: 7
-28440 Task N5 finished and destroyed. Free mem=1298 No of tasks=9
-28513 Task N26  current iteration: 6
-28795 Task N3 current iteration: 8
-29277 Task N50  current iteration: 8
-29552 Task N49  current iteration: 8
-29591 Task N45  current iteration: 7
-29730 Task N30  current iteration: 9
-29730 Task N30  finished and destroyed. Free mem=1343 No of tasks=8
-30612 Task N17  current iteration: 7
-30738 Task N47  current iteration: 7
-31456 Task N31  current iteration: 7
-32059 Task N50  current iteration: 9
-32402 Task N49  current iteration: 9
-32402 Task N49  finished and destroyed. Free mem=1388 No of tasks=7
-32894 Task N3 current iteration: 9
-32894 Task N3 finished and destroyed. Free mem=1433 No of tasks=6
-33139 Task N45  current iteration: 8
-33295 Task N26  current iteration: 7
-34294 Task N47  current iteration: 8
-34841 Task N50  current iteration: 10
-34841 Task N50  finished and destroyed. Free mem=1478 No of tasks=5
-35230 Task N17  current iteration: 8
-35815 Task N31  current iteration: 8
-36687 Task N45  current iteration: 9
-37850 Task N47  current iteration: 9
-37850 Task N47  finished and destroyed. Free mem=1523 No of tasks=4
-38077 Task N26  current iteration: 8
-39848 Task N17  current iteration: 9
-40174 Task N31  current iteration: 9
-40174 Task N31  finished and destroyed. Free mem=1568 No of tasks=3
-40235 Task N45  current iteration: 10
-40235 Task N45  finished and destroyed. Free mem=1613 No of tasks=2
-42859 Task N26  current iteration: 9
-44466 Task N17  current iteration: 10
-44466 Task N17  finished and destroyed. Free mem=1658 No of tasks=1
-47641 Task N26  current iteration: 10
-47641 Task N26  finished and destroyed. Free mem=1703 No of tasks=0
-
- */


Update Wrench-Mask-BLE_Unicorn-Hat-HD.ino

Moving Byte Masks into a separate header file to make it easier to read the code.


Fix typo, require 1 second button hold for blinding LEDs

--- TiLDA_MKe/examples/PersonalisedBadge/PersonalisedBadge.ino
+++ TiLDA_MKe/examples/PersonalisedBadge/PersonalisedBadge.ino
@@ -24,7 +24,6 @@
   // See if there were any button changes
   tilda.buttons.poll();

-  // Display some text on the GLCD
   tilda.glcd.firstPage();
   do
   {
@@ -43,7 +42,7 @@
     tilda.glcd.setFont(u8g_font_6x10);
     tilda.glcd.setFontPosTop();
     tilda.glcd.drawStr(0, 60, "Code");
-    tilda.glcd.drawStr(0, 70, "moneky,");
+    tilda.glcd.drawStr(0, 70, "monkey,");
     tilda.glcd.drawStr(0, 80, "electronics");
     tilda.glcd.drawStr(0, 90, "engineer,");
     tilda.glcd.drawStr(0, 100, "mad");
@@ -66,6 +65,10 @@

     // Toggle LEDs on B
     case BUTTON_B:
+      // Require a 1 second press to turn on, any length press to turn off
+      if(!torch && (time < 1000))
+        break;
+
       torch = !torch;

       if(torch)


LoaderTest: Look better at sync signals for Gigatron status

--- LoaderTest/LoaderTest.ino
+++ LoaderTest/LoaderTest.ino
@@ -92,15 +92,18 @@

 bool detectGigatron()
 {
-  unsigned long timeout = millis() + 200;
-  int mask = 0xf;
-
-  while (mask != 0 && millis() < timeout) {
-    int state = (PINB >> PORTB3) & 3; // capture PORTB3 and PORTB4
-    mask &= ~(1 << state);
-  }
-
-  return mask ? false : true;
+  unsigned long timeout = millis() + 85;
+  long T[] = {0, 0, 0, 0};
+
+  // Sample the sync signals coming out of the controller port
+  while (millis() < timeout)
+    T[(PINB >> PORTB3) & 3]++; // capture PORTB3 and PORTB4
+
+  float S = T[0] + T[1] + T[2] + T[3];
+  float vSync = (T[0] + T[1]) / ( 8 * S / 521); // Gigatron VGA
+  float hSync = (T[0] + T[2]) / (96 * S / 800); // Default VGA
+
+  return 0.95 <= vSync && vSync <= 1.20 && 0.95 <= hSync && hSync <= 1.05;
 }

 void doCommand(char line[])


Fixing Manual_FHT File Issue_2

Fixing Manual_FHT File Issue_2


Stops using Serial.parseInt to resolve a timing issue.

Serial.parseInt waits up to 1s for user input before returning.
aintnobodygottimeforthat.

Also updates trigger polling code slightly to avoid throwing away trigger
events when we run late. Previously if trigcnt >= 10, we make it 10, which
means that if trigcnt is 12, we need another 8 triggers before triggering
again. The new method, which subtracts 10 from tigcnt, means we run on the
20th trigger as expected.

Note of course we expect to never be so late as to miss 2x_DIVIDER number of
triggers, in which case this code triggers a consecutive scans.

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -5,8 +5,8 @@
  * The software responds to the following serial commands:
  *
  * - r:  read all 4 channels, return results immediately via serial
- * - sN: performs N scans of all 4 channels. Results are stored until p is
- *       issued.
+ * - sN.: performs N scans of all 4 channels. Results are stored until p is
+ *       issued. Note the full stop, this is required!
  * - p: prints the buffer, used to retrive values from sN
  */

@@ -68,9 +68,9 @@
   Waits for BUSY to go high
   */
 inline void wait_busy() {
-  while(digitalRead(_BUSY) == LOW) {
-    digitalWrite(_LED, ~digitalRead(_BUSY));
-  }
+  digitalWrite(_LED, LOW);
+  while(digitalRead(_BUSY) == LOW);
+  digitalWrite(_LED, HIGH);
 }

 /**
@@ -135,7 +135,17 @@
     Serial.print(read_analog(3));Serial.print(" ");
     Serial.print(read_analog(0));Serial.println();
   } else if (c == 's') {
-    int nscans = Serial.parseInt();
+    // XXX we don't use parseInt beause it takes a second to complete waiting
+    // for more user input
+    uint16_t nscans = 0;
+    while (c != '.') {
+      c = Serial.read();
+      if (c >= '0') {
+        c -= '0';
+        nscans *= 10;
+        nscans += c;
+      }
+    }
     scan_channels(nscans);
   } else if (c == 'p') {
     for (int idx = 0; idx < writepos; idx += 4) {
@@ -164,7 +174,7 @@

   while (nscans) {
     if (trigcnt>=_DIVIDER) {
-      trigcnt = 0;
+      trigcnt -= _DIVIDER;
       if (writepos < _BUF_SIZE) {
         buf[writepos+0] = read_analog(1);
         buf[writepos+1] = read_analog(2);


more print logging.

more print logging.

git-svn-id: d8bfcd070c2c81762cca1b3912331324182919ba@19233 0d6f1817-ed0e-0410-87c9-987e46238f29

--- zimodem/zprint.ino
+++ zimodem/zprint.ino
@@ -118,6 +118,8 @@
   if(!parseWebUrl((uint8_t *)vbuf+2,&hostIp,&req,&port,&doSSL))
     return ZERROR;
   current = new WiFiClientNode(hostIp,port,doSSL?FLAG_SECURE:0);
+  rawLogPrintf("\r\nPrint Request to host=%s, port=%d\r\n",hostIp,port);
+  rawLogPrintf("Print Request is /%s\r\n",req);
   if(!current->isConnected())
   {
     delete current;
@@ -125,7 +127,6 @@
   }
   char portStr[10];
   sprintf(portStr,"%d",port);
-
   // send the request and http headers:
   sprintf(pbuf,"POST /%s HTTP/1.1\r\n",req);
   writeStr(pbuf);


Revert "arduino code"

Revert "arduino code"

This reverts commit e635205f64325d379a9d765b8801b13b1cbf8645.

--- arduino/medox/medox.ino
+++ arduino/medox/medox.ino
@@ -5,20 +5,20 @@
 ////////////////////////////////////////////////////////////

 //Arduino Pins definition
-//Up-Down stepper
-#define    upPin1       2
-#define    upPin2       3
-#define    upPin3       4
-#define    upPin4       5
-//Rotation stepper
-#define    roPin1       6
-#define    roPin2       7
-#define    roPin3       8
-#define    roPin4       9
+//stepper-1
+#define    stepper11       2
+#define    stepper12       3
+#define    stepper13       4
+#define    stepper14       5
+//stepper-2
+#define    stepper21       6
+#define    stepper22       7
+#define    stepper23       8
+#define    stepper24       9
 //other outputs
 #define    drawer         10
 #define    warehouse      11
-#define    pump          12
+#define    relay          12
 //sensors
 #define    infrared        13
 #define    current         A0
@@ -27,42 +27,23 @@

 #define    doorDelay        1000
 #define    warehouseDelay   1000
-#define    roMotorDelay   10
-#define    upMotorDelay   3
-#define    i72   10
-#define    j72   8
-#define    iup   50
-#define    jup   8
-

 //variables definition
 char  serialData; //for storing serial string
 float tempFloat = 0; //for saving sensor data temporary
 int billCount = 0; //for storing bill count added by ISR

-int i,j;
-
-/// using half step mode
-int seq[8][4]={1,0,0,0,
-               1,1,0,0,
-               0,1,0,0,
-               0,1,1,0,
-               0,0,1,0,
-               0,0,1,1,
-               0,0,0,1,
-               1,0,0,1 };
-
 void setup() {
   //Setting input/output Pins
   //outputs
-  pinMode(  upPin1,  OUTPUT);
-  pinMode(  upPin2,  OUTPUT);
-  pinMode(  upPin3,  OUTPUT);
-  pinMode(  upPin4,  OUTPUT);
-  pinMode(  roPin1,  OUTPUT);
-  pinMode(  roPin2,  OUTPUT);
-  pinMode(  roPin3,  OUTPUT);
-  pinMode(  roPin4,  OUTPUT);
+  pinMode(  stepper11,  OUTPUT);
+  pinMode(  stepper12,  OUTPUT);
+  pinMode(  stepper13,  OUTPUT);
+  pinMode(  stepper14,  OUTPUT);
+  pinMode(  stepper21,  OUTPUT);
+  pinMode(  stepper22,  OUTPUT);
+  pinMode(  stepper23,  OUTPUT);
+  pinMode(  stepper24,  OUTPUT);
   pinMode(  drawer,     OUTPUT);
   pinMode(  warehouse,  OUTPUT);
   pinMode(  relay,      OUTPUT);
@@ -156,55 +137,3 @@
 void counter() {
   billCount = billCount + 1;
 }
-
-//Dispensing functions
-//up down motor control
-void moveUp(){
-  for(i=0;i<iup;i++){
-    for(j=0;j<jup;j++){
-      digitalWrite(upPin1,seq[j][0]);
-      digitalWrite(upPin2,seq[j][1]);
-      digitalWrite(upPin3,seq[j][2]);
-      digitalWrite(upPin4,seq[j][3]);
-      delay(upMotorDelay);
-    }
-  }
-}
-void moveDown(){
-  for(i=0;i<iup;i++){
-    for(j=jup;j>0;j--){
-      digitalWrite(upPin1,seq[j][0]);
-      digitalWrite(upPin2,seq[j][1]);
-      digitalWrite(upPin3,seq[j][2]);
-      digitalWrite(upPin4,seq[j][3]);
-      delay(upMotorDelay);
-    }
-  }
-}
-
-//// stop motors
-void roMotorStop(){
-  digitalWrite(roPin1,LOW);
-  digitalWrite(roPin2,LOW);
-  digitalWrite(roPin3,LOW);
-  digitalWrite(roPin4,LOW);
-}
-void upMotorStop(){
-  digitalWrite(upPin1,LOW);
-  digitalWrite(upPin2,LOW);
-  digitalWrite(upPin3,LOW);
-  digitalWrite(upPin4,LOW);
-}
-
-/// use to move 72 degree
-void medicineMove(){
-  for(i=0;i<i72;i++){
-    for(j=0;j<j72;j++){
-      digitalWrite(roPin1,seq[j][0]);
-      digitalWrite(roPin2,seq[j][1]);
-      digitalWrite(roPin3,seq[j][2]);
-      digitalWrite(roPin4,seq[j][3]);
-      delay(roMotorDelay);
-    }
-  }
-}


pressed/released and open/close variables names changed

--- zamek.ino
+++ zamek.ino
@@ -31,14 +31,15 @@

 EthernetUDP udp;

-const bool open = true;
-const bool close = false;
-
-bool previousDoorState = close;
+const bool DOOR_OPENED = true;
+const bool DOOR_CLOSED = false;
+
+const bool BUTTON_PRESSED = false;
+const bool BUTTON_RELEASED = true;
+
+bool previousDoorState = DOOR_CLOSED;
 bool previousButtonState = true;

-const bool pressed = false;
-const bool released = true;

 int doorEvent = 0;

@@ -162,7 +163,7 @@
 	{
 		unsigned long time = millis() - buttonEvent;

-		if (button == released)
+		if (button == BUTTON_RELEASED)
 		{
 			// force door unlock in case of staying in wrong state
 			if (time > 15000)
@@ -181,7 +182,7 @@

 				if (isDoorLocked)
 					unlockDoor();
-				else if (previousDoorState == close)
+				else if (previousDoorState == DOOR_CLOSED)
 					lockDoor();
 			}
 		}
@@ -189,7 +190,7 @@
 		buttonEvent = millis();
 		previousButtonState = button;
 	}
-	if (button == pressed)
+	if (button == BUTTON_PRESSED)
 	{
 		unsigned long t = millis() - buttonEvent;
 		if (t >= 15000 && t <= 15100)
@@ -215,14 +216,14 @@
 		reedToDebounce = false;
 		// sending notification about door state
 		char buf[12];
-		int len = snprintf(buf, 12, "^%d|%08ld", door == close ? 0 : 1, time);
+		int len = snprintf(buf, 12, "^%d|%08ld", door == DOOR_CLOSED ? 0 : 1, time);
 		udpSendPacket(buf, len);

-		if (door == close)
+		if (door == DOOR_CLOSED)
 		{
 			lockDoor();
 		}
-		if (door == open)
+		if (door == DOOR_OPENED)
 		{
 			// when door are opened during locking time, unlock door, but only
 			// within specific time since locking started (to prevent from opening


use a different LED (13) for boot-signal

--- cmdMULTIsens/src/sketch.ino
+++ cmdMULTIsens/src/sketch.ino
@@ -14,6 +14,7 @@

 // An LED is connected to pin 3
 #define ActivityLED 3
+#define BootLED 13

 // measurement pin of DHT22 is connected to digital pin 4
 #define Dht22Pin 4
@@ -64,7 +65,8 @@
 void setup()
 {
   pinMode(ActivityLED, OUTPUT);     // An LED to signal activity
-  digitalWrite(ActivityLED, HIGH);  // Turn the LED on during setup()
+  pinMode(BootLED, OUTPUT);         // An LED to signal reboot
+  digitalWrite(BootLED, HIGH);      // Turn the LED on during setup()
   Serial.begin(9600);               // Initialise serialport
   Serial.print("... ");
   tmp36.begin();                    // Initialise TMP36 sensor
@@ -76,7 +78,7 @@
   }
   delay(2000);                      // Wait 2s for all sensors to come online
   Serial.println(" cmdMULTIsens ready !");   // Print banner
-  digitalWrite(ActivityLED, LOW);   // Turn off the LED at end of setup()
+  digitalWrite(BootLED, LOW);       // Turn off the LED at end of setup()
 }

 int serialRX()


Update i2c_datatest.ino

Update i2c_datatest.ino

--- code/i2c_datatest.ino
+++ code/i2c_datatest.ino
@@ -6,7 +6,7 @@
   Wire.begin();

   Wire.beginTransmission(SENSOR_ADDR);
-  Wire.write(SENSOR_ADDR);  // POWER register
+  Wire.write(0x6b);  // POWER register
   Wire.write(0x00);     // dont sleep
   Wire.endTransmission(true);


Registration, buzz, bad roll detection, idle pong display

--- sketch/CurieDice/CurieDice.ino
+++ sketch/CurieDice/CurieDice.ino
@@ -86,7 +86,6 @@
 BLEUnsignedCharCharacteristic diceCommandCharacteristic("0x2A9F", BLERead|BLEWrite|BLENotify);

 boolean gConnect = false;
-//int16_t   diceId = 1;
 unsigned char diceId = 1;
 uint16_t  seqNum = 0;
 uint16_t nextSeqNum() {
@@ -94,24 +93,48 @@
   return seqNum;
 }
 bool rollSent = false;
-
+bool registered = false;
 // ************* IMU **************************************************
 int16_t vraw[10]; // raw readings from IMU and info for sending via BLE
                   // [0:5]=AxAyAzGxGyGz, [6]=movement, [7]=stillMs, [8]=diceId, [9]=seqNum
 int vprev[6];     // previous reading

+#define MOVE_THRESHOLD  32
+#define GOOD_ROLL       4
 int16_t movement=0;
+int16_t maxMove[6];
+int16_t moves=0;
 unsigned long stillBegin;
 unsigned long stillMillis=0;   // number of sequential zero movements

+
+void idleShow()
+{
+  static int imask = 0x1;
+  static int dir = 1;
+  static int prev = 0;
+  if (stillMillis < 5000) return;
+  int p = stillMillis/150;
+  if (p!=prev) {
+    prev = p;
+    if (imask==0x01) dir = 1;
+    if (imask==0x80) dir = 0;
+    if (dir) imask = imask << 1;
+    else imask = imask >> 1;
+    dispLed(0xff,0x000,0);
+    dispLed(imask,0xff0,0);
+  }
+}

 int16_t imuRead() {
   for (int i=0; i<6; i++) vprev[i] = vraw[i];
   CurieImu.getMotion6(&vraw[0], &vraw[1], &vraw[2], &vraw[3], &vraw[4], &vraw[5]);
   movement = 0;
+
   for (int i=0; i<6; i++) {
     int m = (abs(vprev[i]-vraw[i])) >> 8;
     if (m>movement) movement = m;
+    if (maxMove[i]==0 && m>MOVE_THRESHOLD) { maxMove[i]=m; moves++;}
   }
   // movement is 8 bits
   int mask = 0x0;
@@ -119,7 +142,7 @@
   for (int i=0; i<8; i++) {
     if (movement > (t<<i)) mask = (mask << 1) | 1;
   }
-  if (movement==0) {
+  if (movement==0) { // no movement
     if (stillMillis==0) {
       stillBegin = millis();
       stillMillis = 1;
@@ -128,31 +151,54 @@
     else {
       stillMillis = millis() - stillBegin;
       if (stillMillis > 250) {
-        int a = vraw[0]>>8;
-        int b = vraw[1]>>8;
-        int c = vraw[2]>>8;
-        unsigned char roll=0;
-        if (a>0x1d && a<0x3d && b>-10 && b<13 && c>0x12 && c<0x32)
-          {roll=1; dispLed(0x1,0x0f0, 30);}
-        else if (a>0x13 && a<0x37 && b>-13 && b<13 && c>(signed char)0xb3 && c<(signed char)0xd6)
-          {roll=2; dispLed(0x3, 0x0f0, 30);}
-        else if (a>(signed char)0xee && a<10 && b>(signed char)0xb1 && b<(signed char)0xd1 && c>(signed char)0xe6 && c<10)
-          {roll=3; dispLed(0x7, 0x0f0, 30);}
-        else if (a>(signed char)0xed && a<10 && b>0x30 && b<0x50 && c>(signed char)0xeb && c<10)
-          {roll=4; dispLed(0x17, 0x0f0, 30);}
-        else if (a>(signed char)0xc5 && a<(signed char)0xe0 && b>-10 && b<10 && c>0x1a && c<0x36)
-          {roll=5; dispLed(0x37, 0x0f0, 30);}
-        else if (a>(signed char)0xbb && a<(signed char)0xdb && b>-10 && b<10 && c>(signed char)0xbb && c<(signed char)0xdb)
-          {roll=6; dispLed(0x77, 0x0f0, 30);}
-        if (roll!=0 && !rollSent)
-        {
-          diceRollCharacteristic.setValue((diceId << 4) | roll);
-          rollSent = true;
+        if (moves < GOOD_ROLL) {
+          dispLed(0xff, 0x000, 0);
+          dispLed(0xff, 0xf00, 0);
+          moves=0;
+          for (int i=0; i<6; i++) maxMove[i]=0;
+        }
+        else if (!rollSent) {
+          int a = vraw[0]>>8;
+          int b = vraw[1]>>8;
+          int c = vraw[2]>>8;
+          unsigned char roll=0;
+          int disp=0;
+          if (a>0x1d && a<0x3d && b>-10 && b<13 && c>0x12 && c<0x32)
+            {roll=1; dispLed(0x1,0x0f0, 30);}
+          else if (a>0x13 && a<0x37 && b>-13 && b<13 && c>(signed char)0xb3 && c<(signed char)0xd6)
+            {roll=2; disp=0x3;}
+          else if (a>(signed char)0xee && a<10 && b>(signed char)0xb1 && b<(signed char)0xd1 && c>(signed char)0xe6 && c<10)
+            {roll=3; disp=0x7;}
+          else if (a>(signed char)0xed && a<10 && b>0x30 && b<0x50 && c>(signed char)0xeb && c<10)
+            {roll=4; disp=0x17;}
+          else if (a>(signed char)0xc5 && a<(signed char)0xe0 && b>-10 && b<10 && c>0x1a && c<0x36)
+            {roll=5; disp=0x37;}
+          else if (a>(signed char)0xbb && a<(signed char)0xdb && b>-10 && b<10 && c>(signed char)0xbb && c<(signed char)0xdb)
+            {roll=6; disp=0x77;}
+          if (roll!=0) {
+            dispLed(disp, 0x0f0, 50);
+            diceRollCharacteristic.setValue((diceId << 4) | roll);
+            rollSent = true;
+          }
+          else
+          {
+            moves=0;
+            for (int i=0; i<6; i++) maxMove[i]=0;
+          }
+        } else { // rollSent
+          idleShow();
         }
       }
     }
   }
-  else stillMillis=0;
+  else
+  {
+    if (rollSent==true) {
+      moves=0;
+      for (int i=0; i<6; i++) maxMove[i]=0;
+    }
+    stillMillis=0;
+  }

   SERIAL_PRINT(movement);
   SERIAL_PRINT("\t");
@@ -177,11 +223,34 @@
   return movement;
 }

+unsigned char readDiceId()
+{
+  int a12 = digitalRead(12);
+  int a11 = digitalRead(11);
+  int a10 = digitalRead(10);
+  int a = (a12<<2)|(a11<<1)|a10;
+  switch (a) {
+    case 7: diceId = 0; break;
+    case 3: diceId = 1; break;
+    case 5: diceId = 2; break;
+    case 6:
+    default: diceId = 3; break;
+  }
+  return diceId;
+}

 const int ledPin = 13;      // activity LED pin
 boolean blinkState = false; // state of the LED
 // ************* setup **************************************************
 void setup() {
+  // diceId read pins
+  pinMode(12, INPUT_PULLUP);
+  pinMode(11, INPUT_PULLUP);
+  pinMode(10, INPUT_PULLUP);
+
+  // onboard LED
+  pinMode(ledPin, OUTPUT);
+
   pinMode(VIBE_PIN, OUTPUT);
   digitalWrite(VIBE_PIN,0);

@@ -197,7 +266,7 @@

   dispLed(0x01, 0xff0, 0);      // 0 - yellow BLE setup

-// *********** BLE **************************************
+// *********** BLE Setup **************************************
   /* Set a local name for the BLE device
      This name will appear in advertising packets
      and can be used by remote devices to identify this BLE device
@@ -210,17 +279,14 @@
   blePeripheral.setEventHandler(BLEConnected, connectHandler);
   blePeripheral.setEventHandler(BLEDisconnected, disconnectHandler);
   diceCommandCharacteristic.setEventHandler(BLEWritten, commandHandler);
-
-  //diceRollCharacteristic.setValue((unsigned char *)vraw,20);
-
-
   blePeripheral.begin();
   SERIAL_PRINTLN("Bluetooth device active, waiting for connections...");

-  dispLed(0x01, 0x0f0, 0);      // 0 - green BLE setup done
-
-  dispLed(0x02, 0xff0, 0);      // 1 - yellow IMU setup
-
+  dispLed(0x01, 0x0f0, 500);      // 0 - green BLE setup done
+
+  dispLed(0x02, 0xff0, 500);      // 1 - yellow IMU setup
+
+  // *************** IMU Setup ***************************************
   // initialize device
   SERIAL_PRINTLN("Initializing IMU device...");
   CurieImu.initialize();
@@ -247,56 +313,20 @@
   SERIAL_PRINT(CurieImu.getYGyroOffset());
   SERIAL_PRINT("\t"); // 0
   SERIAL_PRINT(CurieImu.getZGyroOffset());
-
-  // To manually configure offset compensation values,
-  // use the following methods instead of the autoCalibrate...() methods below
-  //    CurieImu.setXGyroOffset(220);
-  //    CurieImu.setYGyroOffset(76);
-  //    CurieImu.setZGyroOffset(-85);
-  //    CurieImu.setXAccelOffset(-76);
-  //    CurieImu.setYAccelOffset(-235);
-  //    CurieImu.setZAccelOffset(168);
-
-  dispLed(0x02, 0x00f, 0);      // 1 - blue IMU - orient dice for calibration
-
-  //SERIAL_PRINTLN("About to calibrate. Make sure your board is stable and upright");
-  //delay(5000);
-
-  //// The board must be resting in a horizontal position for
-  //// the following calibration procedure to work correctly!
-  //SERIAL_PRINT("Starting Gyroscope calibration...");
-  //CurieImu.autoCalibrateGyroOffset();
-  //SERIAL_PRINTLN(" Done");
-  //SERIAL_PRINT("Starting Acceleration calibration...");
-  //CurieImu.autoCalibrateXAccelOffset(0);
-  //CurieImu.autoCalibrateYAccelOffset(0);
-  //CurieImu.autoCalibrateZAccelOffset(1);
-  //SERIAL_PRINTLN(" Done");
-
-  //SERIAL_PRINTLN("Internal sensor offsets AFTER calibration...");
-  //SERIAL_PRINT(CurieImu.getXAccelOffset());
-  //SERIAL_PRINT("\t"); // -76
-  //SERIAL_PRINT(CurieImu.getYAccelOffset());
-  //SERIAL_PRINT("\t"); // -2359
-  //SERIAL_PRINT(CurieImu.getZAccelOffset());
-  //SERIAL_PRINT("\t"); // 1688
-  //SERIAL_PRINT(CurieImu.getXGyroOffset());
-  //SERIAL_PRINT("\t"); // 0
-  //SERIAL_PRINT(CurieImu.getYGyroOffset());
-  //SERIAL_PRINT("\t"); // 0
-  //SERIAL_PRINTLN(CurieImu.getZGyroOffset());
-
-  //SERIAL_PRINTLN("Enabling Gyroscope/Acceleration offset compensation");
+
+  dispLed(0x02, 0x00f, 200);      // 1 - blue IMU - orient dice for calibration
+
   CurieImu.setGyroOffsetEnabled(true);
   CurieImu.setAccelOffsetEnabled(true);

-  // configure Arduino LED for activity indicator
-  pinMode(ledPin, OUTPUT);
-
   dispLed(0x02, 0x0f0, 0);      // 1 - green IMU setup done
-
+  readDiceId();
+
+  for (int i=0; i<6; i++) maxMove[i]=0;
   ledLapse = millis();
 }
+
+

 void atten(int16_t *a, int len, int shiftBy)
 {
@@ -322,26 +352,39 @@
   digitalWrite(13, LOW);
 }

+#define COMMAND_REGISTER      1
+#define COMMAND_REGISTER_ACK  2
+#define COMMAND_BUZZ          5
+
 void commandHandler(BLECentral &central, BLECharacteristic &characteristic)
 {
-  int cmd = diceCommandCharacteristic.value();
+  int cvalue = diceCommandCharacteristic.value();
+  switch(cvalue) {
+    case COMMAND_REGISTER_ACK: registered = true; break;
+    case COMMAND_BUZZ:
+      digitalWrite(VIBE_PIN,1);
+      delay(50);
+      digitalWrite(VIBE_PIN,0);
+      delay(50);
+      digitalWrite(VIBE_PIN,1);
+      delay(50);
+      digitalWrite(VIBE_PIN,0);
+      break;
+  }
+}
+
+void registerDice() {
+  diceCommandCharacteristic.setValue((diceId << 4) | COMMAND_REGISTER);
 }

 void loop() {
-  blePeripheral.poll();       // current implementation just does delay(1);
+  BLECentral central = blePeripheral.central();
+  if (central && central.connected() && !registered) {
+    registerDice();
+  }

   imuRead();

-  //if (gConnect) {
-  //  SERIAL_PRINT("Sending: ");
-  //  vraw[6] = (int16_t) movement;
-  //  int16_t stillDur = (stillMillis>32000)? 32000 : stillMillis;
-  //  vraw[7] = stillDur;
-  //  vraw[8] = diceId;
-  //  vraw[9] = nextSeqNum();
-  //  diceRollCharacteristic.setValue((unsigned char*) vraw, 20);
-  //}
-
   delay(50);
   if ((millis()-ledLapse) > 1000) {
     ledLapse = millis();


Refactored into more logical function groups

--- FreezerScreamer.ino
+++ FreezerScreamer.ino
@@ -32,61 +32,62 @@
 OneWire ds = OneWire(D4);  // 1-wire signal on pin D4

 unsigned long lastUpdate = 0;
-int msDelayInterval = 5000;
+int msConversionDelayInterval = 1000;
+int msAdditionalDelayInterval = 4000;
+int msTotalDelayInterval = msConversionDelayInterval +  msAdditionalDelayInterval;
 int msfiveMinutes = 300000;
 int msOneHour = 3600000;

 float lowFahrenheitThreshhold = -5.0;
 int lowThreshExceededCounter = 0;
-int numLowTempViolations = msfiveMinutes/msDelayInterval;
+int numLowTempViolations = msfiveMinutes/msTotalDelayInterval;

 float highFahrenheitThreshhold1 = 25.0;
 float highFahrenheitThreshhold2 = 30.0;
 int highThreshExceededCounter = 0;

 int numHighTempViolations_level1 = 2;
-int numHighTempViolations_level2 = msfiveMinutes/msDelayInterval;
-int numHighTempViolations_level3 = msOneHour/msDelayInterval;
+int numHighTempViolations_level2 = msfiveMinutes/msTotalDelayInterval;
+int numHighTempViolations_level3 = msOneHour/msTotalDelayInterval;

 double fahrenheitTemp = 0.0;
+float celsiusTemp;
 char publishString[40];

 void setup() {
   Serial.begin(9600);
   Time.zone(-8);
+  Particle.variable("fahrenTemp", &fahrenheitTemp, DOUBLE);
   // Set up 'power' pins, comment out if not used!
   /*pinMode(D3, OUTPUT);
   pinMode(D5, OUTPUT);
   digitalWrite(D3, LOW);
   digitalWrite(D5, HIGH);*/
-  Particle.variable("fahrenTemp", &fahrenheitTemp, DOUBLE);
 }

 bool inViolationForExactDuration(int counter, int numAllowedViolations) {
-    return counter == numAllowedViolations;
+  return counter == numAllowedViolations;
 }

 void publishViolationEvent(int numViolations, char* eventName) {
-    int secondsInViolation = numViolations * (msDelayInterval/1000);
-    sprintf(publishString,"%.2f", fahrenheitTemp);
-    Particle.publish(eventName, publishString);
-}
-
-double calcFahrenheitFromCelsius(float celsius){
+  sprintf(publishString,"%.2f", fahrenheitTemp);
+  Particle.publish(eventName, publishString);
+}
+
+double calcFahrenheitFromCelsius(float celsius) {
   return celsius * 1.8 + 32.0;
 }

 // up to here, it is the same as the address acanner
 // we need a few more variables for this example

-void loop(void) {
+void readCelsiusTemp(float* celsius) {
   byte i;
   byte present = 0;
   byte type_s;
   byte data[12];
   byte addr[8];
-  float celsius;

   if ( !ds.search(addr)) {
     /*Serial.println("No more addresses.");*/
@@ -153,7 +154,7 @@
   // you could also communicate with other devices if you like but you would need
   // to already know their address to select them.

-  delay(msDelayInterval);     // maybe 750ms is enough, maybe not, wait 1 sec for conversion
+  delay(msConversionDelayInterval);     // maybe 750ms is enough, maybe not, wait 1 sec for conversion

   // we might do a ds.depower() (parasite) here, but the reset will take care of it.

@@ -202,7 +203,7 @@
         // "count remain" gives full 12 bit resolution
         raw = (raw & 0xFFF0) + 12 - data[6];
       }
-      celsius = (float)raw * 0.0625;
+      *celsius = (float)raw * 0.0625;
       break;
     case 0:
       // at lower res, the low bits are undefined, so let's zero them
@@ -210,21 +211,25 @@
       if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
       if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
       // default is 12 bit resolution, 750 ms conversion time
-      celsius = (float)raw * 0.0625;
+      *celsius = (float)raw * 0.0625;
       break;

     case 2:
       data[1] = (data[1] >> 3) & 0x1f;
       if (data[2] > 127) {
-        celsius = (float)data[2] - ((float)data[1] * .03125);
+        *celsius = (float)data[2] - ((float)data[1] * .03125);
       }else{
-        celsius = (float)data[2] + ((float)data[1] * .03125);
+        *celsius = (float)data[2] + ((float)data[1] * .03125);
       }
   }

-  fahrenheitTemp = calcFahrenheitFromCelsius(celsius);//celsius * 1.8 + 32.0;
+  return;
+}
+
+void checkFreezerScreamerConditions() {
+
   Serial.print("Temp: ");
-  Serial.print(celsius);
+  Serial.print(celsiusTemp);
   Serial.print(" C, ");
   Serial.print(fahrenheitTemp);
   Serial.println(" F");
@@ -263,3 +268,15 @@
     lowThreshExceededCounter = 0;
   }
 }
+
+float getCelsiusTemp() {
+  return celsiusTemp;
+}
+
+void loop(void) {
+  readCelsiusTemp(&celsiusTemp);
+  fahrenheitTemp = calcFahrenheitFromCelsius(getCelsiusTemp());
+  checkFreezerScreamerConditions();
+
+  delay(msAdditionalDelayInterval);
+}


timer interrupt added

timer interrupt added

--- ray-gfx.ino
+++ ray-gfx.ino
@@ -3,6 +3,7 @@
 #include <Adafruit_GFX.h>
 #include <Adafruit_SSD1306.h>
 #include <avr/pgmspace.h>
+#include <TimerOne.h>

 #define D(x)

@@ -92,6 +93,9 @@
 void movePlayer(Player *player);
 void drawDottedLine(int16_t x, int16_t y0, int16_t y1);
 void drawLine(int16_t x, int16_t y0, int16_t y1);
+void timer_IRQ();
+
+volatile uint8_t timer_flag = 0;

 void setup()  {
   D(Serial.begin(9600));
@@ -99,6 +103,9 @@
   pinMode(UP_BUTTON, INPUT_PULLUP);
   pinMode(LEFT_BUTTON, INPUT_PULLUP);
   pinMode(RIGHT_BUTTON, INPUT_PULLUP);
+
+  Timer1.initialize(50000);
+  Timer1.attachInterrupt(timer_IRQ);

   display.begin(SSD1306_SWITCHCAPVCC, I2C_ADDRESS);  // initialize with the I2C addr 0x3C (for the 128x64)
   display.clearDisplay();
@@ -117,8 +124,18 @@
   doRayCasting(&player);
   display.display();
   while (1) {
-    movePlayer(&player);
-  }
+    if (timer_flag) {
+      display.clearDisplay();
+      movePlayer(&player);
+      doRayCasting(&player);
+      display.display();
+      timer_flag = 0;
+    }
+  }
+}
+
+void timer_IRQ(){
+  timer_flag = 1;
 }

 void rotatePlayer(Player *player, uint8_t right) {
@@ -138,34 +155,21 @@
     double nextStepX = player->dirX * STEP_SIZE;
     double nextStepY = player->dirY * STEP_SIZE;

-  if (pgm_read_byte(&level_map[int(player->y)][int(player->x + nextStepX)]) == 0) {
-      player->x += nextStepX;
-   }
-
-  if (pgm_read_byte(&level_map[int(player->y + nextStepY)][int(player->x)]) == 0) {
-      player->y += nextStepY;
-   }
-    // D(Serial.print("palyer x,y"));
-    // D(Serial.print(player->x));
-    // D(Serial.print(","));
-    // D(Serial.println(player->y));
-    display.clearDisplay();
-    doRayCasting(player);
-    display.display();
+    if (pgm_read_byte(&level_map[int(player->y)][int(player->x + nextStepX)]) == 0) {
+        player->x += nextStepX;
+     }
+
+    if (pgm_read_byte(&level_map[int(player->y + nextStepY)][int(player->x)]) == 0) {
+        player->y += nextStepY;
+     }
   }

   if (digitalRead(LEFT_BUTTON) == 0) {
     rotatePlayer(player, LEFT);
-    display.clearDisplay();
-    doRayCasting(player);
-    display.display();
   }

   if (digitalRead(RIGHT_BUTTON) == 0) {
     rotatePlayer(player, RIGHT);
-    display.clearDisplay();
-    doRayCasting(player);
-    display.display();
   }
 }


Pins ajustes for PCB rev. A

Pins ajustes for PCB rev. A

--- Firmware/R2-Quadcopter/R2-Quadcopter.ino
+++ Firmware/R2-Quadcopter/R2-Quadcopter.ino
@@ -40,7 +40,7 @@
 ////////////////////////////////////////////////////////////////////////
 void calcSignal0() {
   last_interrupt_time0 = micros();
-  if (digitalRead(A0) == HIGH) {
+  if (digitalRead(A4) == HIGH) {
     chrono_start0 = micros();
   }
   else {
@@ -53,7 +53,7 @@

 void calcSignal1() {
   last_interrupt_time1 = micros();
-  if (digitalRead(A1) == HIGH) {
+  if (digitalRead(A0) == HIGH) {
     chrono_start1 = micros();
   }
   else {
@@ -66,7 +66,7 @@

 void calcSignal2() {
   last_interrupt_time2 = micros();
-  if (digitalRead(A2) == HIGH) {
+  if (digitalRead(A1) == HIGH) {
     chrono_start2 = micros();
   }
   else {
@@ -79,7 +79,7 @@

 void calcSignal3() {
   last_interrupt_time3 = micros();
-  if (digitalRead(A3) == HIGH) {
+  if (digitalRead(A2) == HIGH) {
     chrono_start3 = micros();
   }
   else {
@@ -92,7 +92,7 @@

 void calcSignal4() {
   last_interrupt_time4 = micros();
-  if (digitalRead(A4) == HIGH) {
+  if (digitalRead(A3) == HIGH) {
     chrono_start4 = micros();
   }
   else {
@@ -264,11 +264,11 @@
   bno.setExtCrystalUse(true);

   //RX init
-  attachInterrupt(A0, calcSignal0, CHANGE);
-  attachInterrupt(A1, calcSignal1, CHANGE);
-  attachInterrupt(A2, calcSignal2, CHANGE);
-  attachInterrupt(A3, calcSignal3, CHANGE);
-  attachInterrupt(A4, calcSignal4, CHANGE);
+  attachInterrupt(A4, calcSignal0, CHANGE);
+  attachInterrupt(A0, calcSignal1, CHANGE);
+  attachInterrupt(A1, calcSignal2, CHANGE);
+  attachInterrupt(A2, calcSignal3, CHANGE);
+  attachInterrupt(A3, calcSignal4, CHANGE);

   //Motors init
   esc_1.attach(MOTOR_PIN_FRONT_RIGHT, 1000, 2000);
@@ -349,6 +349,6 @@
     Proportional_yaw, Integral_yaw, Derivative_yaw = 0;
   }

-  print_motors();
+  print_rx();
   delay(4);
 }


Reducing source code.

Reducing source code.

--- examples/VWI/CosaVWIclient/CosaVWIclient.ino
+++ examples/VWI/CosaVWIclient/CosaVWIclient.ino
@@ -37,7 +37,6 @@
 #include "Cosa/VWI/Codec/ManchesterCodec.hh"
 #include "Cosa/VWI/Codec/BitstuffingCodec.hh"
 #include "Cosa/VWI/Codec/Block4B5BCodec.hh"
-#include "Cosa/Trace.hh"
 #include "Cosa/RTC.hh"
 #include "Cosa/Watchdog.hh"

@@ -49,10 +48,10 @@
 BitstuffingCodec codec;

 // Network configuration
-const uint32_t ADDR = 0xC05A0001;
+const uint32_t ADDR = 0xc05a0001UL;
 const uint16_t SPEED = 4000;

-// Virtual Wire Interface Transmitter and Receiver
+// Virtual Wire Interface Transceiver
 #if defined(__ARDUINO_TINYX5__)
 VWI::Transceiver trx(Board::D0, Board::D1, &codec);
 #else
@@ -68,6 +67,12 @@
 struct sample_t {
   uint16_t luminance;
   uint16_t temperature;
+
+  sample_t(uint16_t lum, uint16_t temp)
+  {
+    luminance = lum;
+    temperature = temp;
+  }
 };

 const uint8_t STAT_CMD = 2;
@@ -77,23 +82,20 @@
   uint16_t resent;
   uint16_t received;
   uint16_t failed;
+
+  void update(int8_t nr)
+  {
+    sent += 1;
+    if (nr <= 0)
+      failed += 1;
+    else if (nr > 1)
+      resent += (nr - 1);
+  }
 };

-// Counters
-uint16_t sent = 0;
-uint16_t resent = 0;
-uint16_t received = 0;
-uint16_t failed = 0;
+// Statistics
+stat_t stat;

-void update(int8_t nr)
-{
-  sent += 1;
-  if (nr <= 0)
-    failed += 1;
-  else if (nr > 1)
-    resent += (nr - 1);
-}
-
 void setup()
 {
   // Start watchdog for delay
@@ -108,24 +110,17 @@
 void loop()
 {
   // Send message with luminance and temperature
-  sample_t sample;
-  sample.luminance = luminance.sample();
-  sample.temperature = temperature.sample();
+  sample_t sample(luminance.sample(), temperature.sample());
   int8_t nr = trx.send(&sample, sizeof(sample), SAMPLE_CMD);
-  update(nr);
+  stat.update(nr);

-  // Send message with battery voltage and statistics every 10 messages
-  if (sent % 10 == 0) {
-    stat_t stat;
+  // Send message with battery voltage and statistics every 15 messages
+  if (stat.sent % 15 == 0) {
     stat.voltage = AnalogPin::bandgap(1100);
-    stat.sent = sent;
-    stat.resent = resent;
-    stat.received = received;
-    stat.failed = failed;
     nr = trx.send(&stat, sizeof(stat), STAT_CMD);
-    update(nr);
+    stat.update(nr);
   }

   // Take a nap
-  MSLEEP(200);
+  SLEEP(1);
 }


Add support for the Handbrake

Add support for the Handbrake

--- fanatec_standalone_shifter_and_handbrake.ino
+++ fanatec_standalone_shifter_and_handbrake.ino
@@ -1,8 +1,17 @@
+// To compile select:
+// - Tools -> Board -> Teensy LC
+//
+// Then:
+// If you want to debug and enable serial communication:
+// - Tools -> USB Type -> Serial / Keyboard / Mouse / Joystick
+// else
+// - Tools -> USB Type -> Keyboard / Mouse / Joystick
+
 //#define DEBUG

-#define PIN_X 1
-#define PIN_Y 2
-#define PIN_Z 0
+#define PIN_SHIFTER_X 1
+#define PIN_SHIFTER_Y 2
+#define PIN_HANDBRAKE 3

 #define GEAR_1 1
 #define GEAR_2 2
@@ -23,8 +32,8 @@

 int get_current_gear() {
-  int x = analogRead(PIN_X);
-  int y = analogRead(PIN_Y);
+  int x = analogRead(PIN_SHIFTER_X);
+  int y = analogRead(PIN_SHIFTER_Y);

   if (y > 1000) {
     if (x < 100) {
@@ -49,7 +58,7 @@

   }

-  if (y < 65) {
+  if (y < 150) {
     if (x < 300) {
       return GEAR_6;
     }
@@ -67,21 +76,17 @@
 }

 void debug() {
-  Serial.print("x: ");
-  Serial.print(analogRead(PIN_X));
-  Serial.print(" y: ");
-  Serial.print(analogRead(PIN_Y));
-  Serial.print(" z: ");
-  Serial.println(analogRead(PIN_Z));
+  Serial.print("shifter x: ");
+  Serial.print(analogRead(PIN_SHIFTER_X));
+  Serial.print(" shifter y: ");
+  Serial.print(analogRead(PIN_SHIFTER_Y));
+  Serial.print(" handbrake: ");
+  Serial.println(analogRead(PIN_HANDBRAKE));
 }

-void loop() {
+void poll_shifter() {
   int gear = get_current_gear();
-
-  #ifdef DEBUG
-  debug();
-  #endif
-
+
   if (gear != 0) {
     Joystick.button(gear, 1);
     Joystick.send_now();
@@ -90,12 +95,38 @@

     Joystick.button(gear, 0);
     Joystick.send_now();
-
+
     while (get_current_gear() != 0) {
       delay(5);
     }
-  }
+  }
+}
+
+void poll_handbrake() {
+  int minBrakeValue = 60; // I got these values printing idle and max brake values
+  int maxBrakeValue = 160;
+  int rawBrake = analogRead(PIN_HANDBRAKE);

+  if (rawBrake > maxBrakeValue) {
+    rawBrake = maxBrakeValue;
+  } else if (rawBrake < minBrakeValue) {
+    rawBrake = minBrakeValue;
+  }
+
+  int normalizedBrake = (rawBrake - minBrakeValue) * (1024 / (maxBrakeValue-minBrakeValue));
+
+  Joystick.X(normalizedBrake);
+  Joystick.send_now();
+}
+
+void loop() {
+  #ifdef DEBUG
+  debug();
+  #endif
+
+  pollShifter();
+  pollHandbrake();
+
   delay(5);
 }


Stop breaking shit, Malthe

Stop breaking shit, Malthe

--- gatherer/gatherer.ino
+++ gatherer/gatherer.ino
@@ -144,7 +144,7 @@
   send_data_field_float("Lat", gps.location.lat(), 6);

   //Print Longitude
-  send_data_field_float("Lng", gps.location.lng(), 6);
+  send_data_field_float("Long", gps.location.lng(), 6);

   //Print  Satellites
   send_data_field("Sat", String(gps.satellites.value()));


output ctrl char representation to display

--- BinaryKeyboard.ino
+++ BinaryKeyboard.ino
@@ -230,8 +230,17 @@
 			display.setCursor(0, 0);
 			display.setTextSize(1);
 			display.print("Last: ");
-			display.print(lastPrinted);
-		}
+            if (lastPrinted > 0 && lastPrinted < 32)
+            {
+                display.print('^');
+                display.print((char)(lastPrinted + 64)); // Use uppercase representation (e.g. ^A instead of ^a)
+
+            }
+            else
+            {
+                display.print(lastPrinted);
+            }
+        }

 		// minimalist style
 		display.setTextSize(2);


update positionfunctions

update positionfunctions

--- SensorShirt/PositionFunctions.ino
+++ SensorShirt/PositionFunctions.ino
@@ -0,0 +1,3 @@
+/*
+  Helper functions for position
+*/


Update charlieplexing_low_power_flasher.ino

Add LDR code

--- examples/charlieplexing_low_power_flasher.ino
+++ examples/charlieplexing_low_power_flasher.ino
@@ -12,6 +12,8 @@
 #include "LowPower.h"   // RocketScream library so so we can use low-power sleep for timing delays
 #include "charlieplexing.h"  //Charlieplexing library for a six LED display

+const int lightThreshold = 200;  // LDR values > 200 indicate it's not dark out anymore
+const int LDRinputpin = 0;  // make this a constant, so if we have to change it later, it'll be easy

 void setup()
 {
@@ -25,7 +27,9 @@
 void loop()   // Let's do this thing
 {

-  for(;;)   // this might be redundant with the void loop() above -- test later when I'm not waiting at the airport...
+  //for(;;)   // this might be redundant with the void loop() above -- test later when I'm not waiting at the airport...
+
+while(analogRead(A0) < lightThreshold)  // if the LDR value is < lightThreshold, it's night so we flash the LEDs
   {
     setLED(1);    // turn LED 1 on; low-pwr sleep for 60mS
     //delay(65);
@@ -144,7 +148,11 @@
     LowPower.idle(SLEEP_1S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_OFF,
                 SPI_OFF, USART0_OFF, TWI_OFF);

-  }   // let's do another flash cycle because the for(;;) loop runs forever
+  }   // do another flash cycle if the LDR says it's still dark out
+
+  // if the LDR says it's light, nap 8 seconds and check again

+  LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_OFF,
+                SPI_OFF, USART0_OFF, TWI_OFF);

-}   // end of the void loop()
+}   // end of the void loop(), go back and do it again...


Fix an off-by-one bug in the way we load clock values

--- code/MotorController/MotorController.ino
+++ code/MotorController/MotorController.ino
@@ -12,7 +12,7 @@
 // Based on LCDi2cNHD
 #include "LCDserNHD.h"

-const char* versionString = "3.1.1";
+const char* versionString = "3.1.2";

 const int CLOCKWISE = 1;
 const int COUNTER_CLOCKWISE = 0;
@@ -43,7 +43,7 @@
 const int potentiometerCeiling = 1000;
 const float gearRatio = 2.0;
 // ATMega328P has 1024 bytes of EEPROM and we're addressing it as DWORDS
-const uint32_t* maximumEepromAddress = (uint32_t*)1024 - 1;
+const uint32_t* eepromSize = (uint32_t*)1024;

 // Switches using the Bounce library for debouncing
 Bounce onOffSwitch = Bounce();
@@ -359,7 +359,7 @@
   lcd.print(secondsOfOperation);

   lcd.setCursor(1, 0);
-  lcd.print(F("LOC: "));
+  lcd.print(F("NEXT LOC: "));
   lcd.print((uint32_t)nextClockBufferLocation);
 }

@@ -396,8 +396,10 @@
 {
   secondsOfOperation = 0;
   uint32_t clockValue = 0;
-
-  for (nextClockBufferLocation = 0; nextClockBufferLocation <= maximumEepromAddress; nextClockBufferLocation++)
+
+  // Read through the EEPROM buffer looking for a place where either we read a value smaller than
+  // the previous one we read or we read an uninitialized value or we get to the end of the EEPROM
+  for (nextClockBufferLocation = 0; nextClockBufferLocation < eepromSize; nextClockBufferLocation++)
   {
     clockValue = eeprom_read_dword(nextClockBufferLocation);
     if (clockValue >= secondsOfOperation && clockValue < 0xFFFFFFFF)
@@ -410,16 +412,13 @@
     }
   }

-  // If the final value we read was an actual clock value, we want to
-  // write the next clock value in the next available slot, otherwise
-  // we want to overwrite this uninitialized slot
-  if (clockValue < 0xFFFFFFFF)
-  {
-    nextClockBufferLocation++;
-    if (nextClockBufferLocation > maximumEepromAddress)
-    {
-      nextClockBufferLocation = 0;
-    }
+  // If we stopped because we read a smaller value or an uninitialized
+  // value, then the write pointer is already set to the next place we
+  // want to write to. If we stopped because we ran out of EEPROM then
+  // wrap the write pointer back around to the beginning.
+  if (nextClockBufferLocation >= eepromSize)
+  {
+    nextClockBufferLocation = 0;
   }
 }

@@ -427,7 +426,7 @@
 {
   eeprom_write_dword(nextClockBufferLocation, secondsOfOperation);
   nextClockBufferLocation++;
-  if (nextClockBufferLocation > maximumEepromAddress)
+  if (nextClockBufferLocation >= eepromSize)
   {
     nextClockBufferLocation = 0;
   }
@@ -435,7 +434,7 @@

 void ResetClock()
 {
-  for (uint32_t* x = 0; x <= maximumEepromAddress; x++)
+  for (uint32_t* x = 0; x < eepromSize; x++)
   {
     eeprom_write_dword(x, 0xFFFFFFFF);
   }


change baud on VCM

change baud on VCM

--- html/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino
+++ html/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino
@@ -22,7 +22,7 @@

 void setup()
 {
-  Serial.begin(9600);
+  Serial.begin(115200);
 }

 void loop()


Switch to digital(Read|Write)Fast; add 0 command that blinks the led

--- teensy/snes_controller_emu.ino
+++ teensy/snes_controller_emu.ino
@@ -25,7 +25,8 @@
 volatile bool multitap = false;
 #endif

-void setup() {
+void setup()
+{
 	pinMode(PIN_LED, OUTPUT);
 	digitalWrite(PIN_LED, HIGH);

@@ -33,22 +34,22 @@
 	pinMode(PIN_1_CLOCK, INPUT_PULLUP);
 	pinMode(PIN_1_LATCH, INPUT_PULLUP);
 	pinMode(PIN_1_DATA0, OUTPUT);
-	digitalWrite(PIN_1_CLOCK, HIGH);
-	digitalWrite(PIN_1_LATCH, HIGH);
-	digitalWrite(PIN_1_DATA0, HIGH);
+	digitalWriteFast(PIN_1_CLOCK, HIGH);
+	digitalWriteFast(PIN_1_LATCH, HIGH);
+	digitalWriteFast(PIN_1_DATA0, HIGH);

 	// setup pins for port 2
 	pinMode(PIN_2_CLOCK, INPUT_PULLUP);
 	pinMode(PIN_2_LATCH, INPUT_PULLUP);
 	pinMode(PIN_2_DATA0, OUTPUT);
-	digitalWrite(PIN_2_CLOCK, HIGH);
-	digitalWrite(PIN_2_LATCH, HIGH);
-	digitalWrite(PIN_2_DATA0, HIGH);
+	digitalWriteFast(PIN_2_CLOCK, HIGH);
+	digitalWriteFast(PIN_2_LATCH, HIGH);
+	digitalWriteFast(PIN_2_DATA0, HIGH);

 #ifdef MULTITAP
 	pinMode(PIN_2_DATA1, OUTPUT);
 	pinMode(PIN_2_PP, INPUT);
-	digitalWrite(PIN_2_DATA1, HIGH);
+	digitalWriteFast(PIN_2_DATA1, HIGH);
 	// digitalWrite(PIN_2_PP, HIGH);
 #endif

@@ -72,6 +73,17 @@

 void loop()
 {
+	// if(digitalReadFast(PIN_1_LATCH) == HIGH)
+	// {
+	// 	while(digitalReadFast(PIN_1_LATCH) == HIGH);
+	// 	for(int i = 0; i < 16; i++)
+	// 	{
+	// 		while(digitalReadFast(PIN_1_CLOCK) == HIGH);
+	// 		set_output(PIN_1_DATA0, 0);
+	// 		set_output(PIN_2_DATA0, 1);
+	// 		while(digitalReadFast(PIN_1_CLOCK) == LOW);
+	// 	}
+	// }
 	if(Serial.available() > 2)
 	{
 		uint8_t command = Serial.read();
@@ -83,9 +95,21 @@
 		{
 			switch(high)
 			{
+				case 0: // connected
+					for(int i = 0; i < 3; i++)
+					{
+						digitalWrite(PIN_LED, LOW);
+						delay(250);
+						digitalWrite(PIN_LED, HIGH);
+						delay(250);
+					}
+					digitalWrite(PIN_LED, HIGH);
+					break;
+
 				case 1: // multitap
 					multitap = low == 1 ? true : false;
 					break;
+
 				case 2:
 					switch(low)
 					{
@@ -113,7 +137,7 @@

 void isr_on_1_latch()
 {
-	if(digitalRead(PIN_1_LATCH) == HIGH)
+	if(digitalReadFast(PIN_1_LATCH) == HIGH)
 	{
 		isr_on_1_latch_rising();
 	}
@@ -143,7 +167,7 @@
 	set_output(PIN_1_DATA0, 0, 0x8000);
 	set_output(PIN_2_DATA0, 1, 0x8000);
 #ifdef MULTITAP
-	if(multitap) digitalWrite(PIN_2_DATA1, LOW);
+	if(multitap) digitalWriteFast(PIN_2_DATA1, LOW);
 #endif
 }

@@ -161,7 +185,7 @@

 void isr_on_clock()
 {
-	if(digitalRead(PIN_1_LATCH) == HIGH) return;
+	if(digitalReadFast(PIN_1_LATCH) == HIGH) return;

 	bool more1 = clock_finish(PIN_1_DATA0, 0);
 	bool more2 = clock_finish(PIN_2_DATA0, 1);
@@ -171,7 +195,7 @@

 void isr_on_clock_2()
 {
-	if(digitalRead(PIN_2_PP) == HIGH) return;
+	if(digitalReadFast(PIN_2_PP) == HIGH) return;
 	bool more2 = clock_finish(PIN_2_DATA0, 1);
 	if(more2)
 		on_clock();
@@ -181,7 +205,7 @@
 {
 	if(clock_pulses[port] >= 0 && clock_pulses[port] >= CLOCK_MAX)
 	{
-		digitalWrite(pin, LOW);
+		digitalWriteFast(pin, LOW);
 		return false;
 	}
 	return true;
@@ -197,7 +221,7 @@
 	{
 		uint8_t data0, data1;

-		bool pp_low = digitalRead(PIN_2_PP) == LOW;
+		bool pp_low = digitalReadFast(PIN_2_PP) == LOW;
 		bool pp = multitap && pp_low;

 		if(pp)
@@ -213,7 +237,7 @@

 		set_output(PIN_2_DATA0, data0);
 		bits[data0] >>= 1;
-		if(digitalRead(PIN_1_LATCH) == LOW)
+		if(digitalReadFast(PIN_1_LATCH) == LOW)
 		{
 			set_output(PIN_2_DATA1, data1);
 			bits[data1] >>= 1;
@@ -237,5 +261,5 @@
 inline void set_output(uint8_t pin, uint8_t port, uint32_t bits)
 {
 	uint16_t output = buttons[port] & bits;
-	digitalWrite(pin, output != 0 ? LOW : HIGH);
+	digitalWriteFast(pin, output != 0 ? LOW : HIGH);
 }


[FW] Properly init 7-segment display.

[FW] Properly init 7-segment display.

--- firmware/MultiRomVC4000/MultiRomVC4000.ino
+++ firmware/MultiRomVC4000/MultiRomVC4000.ino
@@ -30,6 +30,7 @@
 unsigned blinkTimeHigh = 500;
 unsigned blinkTimeLow  = 500;
 TM1637Display display(DISPLAY_CLK, DISPLAY_DIO);
+byte displayInitData[] = {0, 0, 0, 0};

 void setup() {
   pinMode(SD_CS, OUTPUT);
@@ -44,7 +45,8 @@
   // Isolate MultiROM from console bus
   disableVCBus();

-  // Enable 7-segment display
+  // Init and enable 7-segment display
+  display.setSegments(displayInitData);
   display.setBrightness(0x0f);

   // Wait for user selecting a ROM number


saving

saving

--- examples/BoardWithWifi/BoardWithWifi.ino
+++ examples/BoardWithWifi/BoardWithWifi.ino
@@ -8,16 +8,15 @@
   // Notify the board we want to use accel data
   // board.useAccel(true);

+  board.iWifi.rx = true;
+  board.iWifi.tx = true;

-  // board.wifi.active = true;
-  // board.wifi.rx = false;
-  board.iWifi.tx = true;
+  board.curSampleRate = board.SAMPLE_RATE_2000;

   // Bring up the OpenBCI Board
   board.begin();

   // Change the sample rate
-  board.setSampleRate(board.SAMPLE_RATE_500);
   board.iSerial0.tx = false;

   board.timeSynced = true;


update

update

--- src/Firmware.ino
+++ src/Firmware.ino
@@ -18,7 +18,7 @@
 struct MotionState
 {
     uint8_t power = 0;
-    uint8_t speed = 1;
+    uint8_t speed = 100;
     uint8_t acceleration = 1;
     long targetPosition[NUM_AXIS];
 };
@@ -50,16 +50,17 @@
     long targetPosition[NUM_AXIS];
     long startPosition[NUM_AXIS];
     long timerCount = 0;
-    long time = 6250;
-    long maxTime = 6250;
-    long minTime = 125;
+    long time = 2500;
+    long defaultTime = 2500;
+    long maxTime = 1250;
+    long minTime = 25;
     PlannerPoint points[POINTS_COUNT];
     MotionState states[STATES_COUNT];
     MotionState state;
     CommandState command;
     String commands[COMMANDS_COUNT];
     uint8_t power = 0;
-    uint8_t speed = 1;
+    uint8_t speed = 100;
     uint8_t acceleration = 1;
     uint8_t statesIndex = 0;
     uint8_t cmdsIndex = 0;
@@ -79,7 +80,7 @@
     initTimer();
     for (int i = 0; i < NUM_AXIS; i++)
     {
-        steppers[i].setMicroStep(16);
+        steppers[i].setMicroStep(8);
         steppers[i].enableOutputs();
     }
     Serial.println("opened");
@@ -240,7 +241,8 @@
 #endif
     _sys.startPosition[0] = x;
     _sys.startPosition[1] = y;
-    addMotion(0, x, y, _sys.acceleration);
+    _sys.time = _sys.defaultTime;
+    addMotion(x, y, 0, _sys.speed, _sys.acceleration);
 }
 void lineTo(long x, long y)
 {
@@ -250,15 +252,18 @@
     str += x;
     str += ",";
     str += y;
+    str += ",";
+    str += _sys.speed;
     Serial.println(str);
 #endif
-    addMotion(_sys.power, x, y, _sys.acceleration);
-}
-void addMotion(long x, long y, uint8_t power, uint8_t accelaration)
+    addMotion(x, y, _sys.power, _sys.speed, _sys.acceleration);
+}
+void addMotion(long x, long y, uint8_t power, uint8_t speed, uint8_t accelaration)
 {
     MotionState s;
     s.power = power;
     s.acceleration = accelaration;
+    s.speed = speed;
     s.targetPosition[0] = x;
     s.targetPosition[1] = y;
     if (_sys.statesIndex > STATES_COUNT - 1)
@@ -401,6 +406,8 @@
     shiftPlanned();
     calcPlanned();
     unlockTimer();
+    _sys.minTime = fmax(25, 25 / (_sys.points[0].speed / 100));
+    _sys.maxTime = fmin(_sys.defaultTime, _sys.defaultTime / (_sys.points[0].exitSpeed / 50));
 }
 void waitingPushPoint()
 {
@@ -410,7 +417,7 @@
         {
             break;
         }
-        delay(1);
+        delay(5);
         // #ifdef DEBUG
         //         String str = "waiting:";
         //         str += _sys.statesIndex;
@@ -535,7 +542,7 @@
     _sys.currentPosition[0] += dir ? 1 : -1;
     _sys.points[0].delta[0]--;
     _sys.points[0].totalCount--;
-    steppers[0].step(true);
+    steppers[0].step(dir);
 }
 void stepY(bool dir)
 {
@@ -573,7 +580,11 @@
         {
             if (_sys.time > _sys.minTime)
             {
-                _sys.time -= 1;
+                _sys.time -= 5;
+                if (_sys.time < _sys.minTime)
+                {
+                    _sys.time = _sys.minTime;
+                }
             }
             break;
         }
@@ -581,7 +592,7 @@
         {
             if (_sys.time < _sys.maxTime)
             {
-                _sys.time += 1;
+                _sys.time += 5;
             }
             break;
         }


More comments

More comments

--- examples/LCDKeyPadShieldAndRadioTEA5767Demo/LCDKeyPadShieldAndRadioTEA5767Demo.ino
+++ examples/LCDKeyPadShieldAndRadioTEA5767Demo/LCDKeyPadShieldAndRadioTEA5767Demo.ino
@@ -42,10 +42,13 @@
 #define MENU_LINES 8
 #define MENU_TEXT  16

-// Arduino pins
-int backLightPin = 10;
-int upDownPin = 11;
-int incPin = 12;
+// Arduino pin for backlight intensity control
+#define BACKLIGHT_PIN 10
+
+// Arduino pins connected to digital potentiometers
+// for volume control
+#define UPDOWN_PIN    11
+#define INC_PIN       12

 // Predefined stations array
 float defaultStations[16] = {88.1, 89.1, 89.7, 91.3, 92.5, 93.7, 94.7, 95.3, 96.1, 98.5, 100.1, 100.9, 101.7, 102.1, 102.9, 103.3};
@@ -53,9 +56,10 @@
 float stations[16] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
 // Keep the current station index
 byte stationIndex = 0;
-
+// Keep the application state where the execution
+// is trapped so a specific set of menu items is shown to the user
 byte applicationState = 0;
-
+// Index of the menu item current selected
 byte selectedMenuItem = 0;
 float selectedStation;
 boolean isStandByOn = false;
@@ -65,10 +69,10 @@
 int lcd_key = 0;

 char menu[MENU_DEPTH][MENU_LINES][MENU_TEXT] = {
-                       {{" Mute"}, {" Search"}, {" Fine search"}, {" Register statn"}, {" Configuration"}, {" Stand by"}, {" Load deflt stn"}, {" Exit"}},
-                       {{" Search level"}, {" Backlit inten."}, {" Exit"}},
-                       {{" Low"}, {" Medium"}, {" High"}, {"Exit"}}
-                      };
+   {{" Mute"}, {" Search"}, {" Fine search"}, {" Register statn"}, {" Configuration"}, {" Stand by"}, {" Load deflt stn"}, {" Exit"}},
+   {{" Search level"}, {" Backlit inten."}, {" Exit"}},
+   {{" Low"}, {" Medium"}, {" High"}, {"Exit"}}
+  };

 byte searchLevel;
 byte backlightIntensity;
@@ -80,7 +84,7 @@
   }
 }

-int read_LCD_buttons(){
+int read_LCD_buttons() {
   int adc_key_in = analogRead(0);
   if (adc_key_in > 1000) return btnNONE;
   if (adc_key_in < 50) return btnRIGHT;
@@ -140,24 +144,24 @@

 void loadBacklightIntensity() {
   backlightIntensity = EEPROM.read(3);
-  analogWrite(backLightPin, backlightIntensity);
+  analogWrite(BACKLIGHT_PIN, backlightIntensity);
 }

 void setupVolume() {
   // Lowest volume
-  digitalWrite(upDownPin, LOW);
+  digitalWrite(UPDOWN_PIN, LOW);
   for (int i = 0 ; i < 100 ; i++) {
-    digitalWrite(incPin, LOW);
+    digitalWrite(INC_PIN, LOW);
     delay(1);
-    digitalWrite(incPin, HIGH);
+    digitalWrite(INC_PIN, HIGH);
     delay(1);
   }
   // Pleasant level
-  digitalWrite(upDownPin, HIGH);
+  digitalWrite(UPDOWN_PIN, HIGH);
   for (int i = 0 ; i < 15 ; i++) {
-    digitalWrite(incPin, LOW);
+    digitalWrite(INC_PIN, LOW);
     delay(1);
-    digitalWrite(incPin, HIGH);
+    digitalWrite(INC_PIN, HIGH);
     delay(1);
   }
 }
@@ -198,13 +202,13 @@
 }

 void setup(){
-  pinMode(backLightPin, OUTPUT);
-  pinMode(upDownPin, OUTPUT);
-  pinMode(incPin, OUTPUT);
-
-  digitalWrite(upDownPin, HIGH);
-  digitalWrite(incPin, HIGH);
-  analogWrite(backLightPin, 255);
+  pinMode(BACKLIGHT_PIN, OUTPUT);
+  pinMode(UPDOWN_PIN, OUTPUT);
+  pinMode(INC_PIN, OUTPUT);
+
+  digitalWrite(UPDOWN_PIN, HIGH);
+  digitalWrite(INC_PIN, HIGH);
+  analogWrite(BACKLIGHT_PIN, 255);

   lcd.begin(16, 2);
   lcd.setCursor(6,0);
@@ -289,7 +293,7 @@
     //Necessary to elliminate noise while turning the radio back on
     delay(150);
     radio.turnTheSoundBackOn();
-    analogWrite(backLightPin, backlightIntensity);
+    analogWrite(BACKLIGHT_PIN, backlightIntensity);

     lcd.clear();
     lcd.setCursor(0,0);
@@ -344,7 +348,7 @@
           case 7: {
             if ((backlightIntensity + 10) <= 255) {
               backlightIntensity += 10;
-              analogWrite(backLightPin, backlightIntensity);
+              analogWrite(BACKLIGHT_PIN, backlightIntensity);
               EEPROM.write(3, backlightIntensity);
             }
             break;
@@ -400,7 +404,7 @@
           case 7: {
             if ((backlightIntensity - 10) >= 20) {
               backlightIntensity -= 10;
-              analogWrite(backLightPin, backlightIntensity);
+              analogWrite(BACKLIGHT_PIN, backlightIntensity);
               EEPROM.write(3, backlightIntensity);
             }
             break;
@@ -417,10 +421,10 @@
         switch (applicationState) {
           //Volume UP
           case 0: {
-            digitalWrite(upDownPin, HIGH);
-            digitalWrite(incPin, LOW);
+            digitalWrite(UPDOWN_PIN, HIGH);
+            digitalWrite(INC_PIN, LOW);
             delay(DELAY_VOLUME_TRANSITION);
-            digitalWrite(incPin, HIGH);
+            digitalWrite(INC_PIN, HIGH);
             delay(DELAY_VOLUME_TRANSITION);
             break;
           }
@@ -482,10 +486,10 @@
         switch (applicationState) {
           //Volume DOWN
           case 0: {
-            digitalWrite(upDownPin, LOW);
-            digitalWrite(incPin, LOW);
+            digitalWrite(UPDOWN_PIN, LOW);
+            digitalWrite(INC_PIN, LOW);
             delay(DELAY_VOLUME_TRANSITION);
-            digitalWrite(incPin, HIGH);
+            digitalWrite(INC_PIN, HIGH);
             delay(DELAY_VOLUME_TRANSITION);
             break;
           }
@@ -652,7 +656,7 @@
                 lcd.clear();

                 radio.setStandByOn();
-                analogWrite(backLightPin, 0);
+                analogWrite(BACKLIGHT_PIN, 0);

                 isStandByOn = true;
                 break;


latest arduino software for pushing notifications via buttons

--- arduino/pusher/pusher.ino
+++ arduino/pusher/pusher.ino
@@ -26,10 +26,9 @@
   ethernetConnecting();
   Ethernet.begin(mac,ip);
   delay(1000); //Give time to initialize before connecting
-  if(pushMessage("arduino_test_channel", "arduino_event_register", "success"))
-    ethernetSucceeded();
-  else
+  while(!pushMessage("arduino_test_channel", "arduino_event_register", "success"))
     ethernetFailed();
+  ethernetSucceeded();

   for(int i = 0; i < 7; i++)
     pinMode(buttonPin[i], INPUT);
@@ -51,11 +50,17 @@

+
+
+
+
+
+
 void readButtons()
 {
   for(int i = 0; i < 7; i++)
   {
-    if(digitalRead(buttonPin[i]) == HIGH)
+    if(digitalRead(buttonPin[i]) == LOW)
     {
       if(buttonCountDown[i] == 0)
       {


Added comments

Added comments

--- examples/knight_rider3/knight_rider3.ino
+++ examples/knight_rider3/knight_rider3.ino
@@ -7,9 +7,10 @@
 Factory factory;

 void setup() {
-  factory
-    .add( sweep.begin( 4, 5, 6, 7, 8, 9 ).speed( 50 ) )
-    .add( button.begin( 2 ).onPress( sweep, sweep.EVT_TOGGLE ) );
+  // Create a sweep machine and add it to the factory
+  factory.add( sweep.begin( 4, 5, 6, 7, 8, 9 ).speed( 50 ) );
+  // Create a button machine link it to the sweep machine and add it to the factory
+  factory.add( button.begin( 2 ).onPress( sweep, sweep.EVT_TOGGLE ) );
 }

 void loop() {


fixed upper wall collision detection

fixed upper wall collision detection

--- oledPong/oledPong.ino
+++ oledPong/oledPong.ino
@@ -46,7 +46,7 @@
 #define PADDLE_LMID 8

 #define SPD0 0
-#define SPD1 48
+#define SPD1 40

 #define PADDLE_XL 0
 #define PADDLE_XR 126
@@ -61,10 +61,10 @@
 uint8_t movementVal;
 uint16_t scoreR;
 uint16_t scoreL;
-uint8_t bodX;
-uint8_t bodY;
-uint8_t lastBodX = 64;
-uint8_t lastBodY = 32;
+uint8_t ballX;
+uint8_t ballY;
+uint8_t lastballX = 64;
+uint8_t lastballY = 32;
 uint8_t direct = START;
 uint8_t lastDirection;
 uint8_t rndDirection;
@@ -72,9 +72,9 @@
 void assignDirection(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g, uint8_t h) {
   movementVal = 0;
   lastDirection = direct;
-  lastBodX = bodX;
-  lastBodY = bodY;
-   if (lastDirection == a) {direct = b;}
+  lastballX = ballX;
+  lastballY = ballY;
+  if (lastDirection == a) {direct = b;}
   else if (lastDirection == c) {direct = d;}
   else if (lastDirection == e) {direct = f;}
   else if (lastDirection == g) {direct = h;}
@@ -89,58 +89,56 @@

 void movement(uint8_t i, uint8_t num) {
   if (direct == START) {
-    lastBodX = 64;
-    lastBodY = 32;
+    lastballX = 64;
+    lastballY = 32;
   }
   if (i == UP_RIGHT) {
-    bodX = lastBodX + map(movementVal, SPD0, SPD1, 0, 128);
-    bodY = lastBodY - map(movementVal, SPD0, SPD1, 0, num);
+    ballX = lastballX + map(movementVal, SPD0, SPD1, 0, 128);
+    ballY = lastballY - map(movementVal, SPD0, SPD1, 0, num);
   } else if (i == UP_LEFT) {
-    bodX = lastBodX - map(movementVal, SPD0, SPD1, 0, 128);
-    bodY = lastBodY - map(movementVal, SPD0, SPD1, 0, num);
+    ballX = lastballX - map(movementVal, SPD0, SPD1, 0, 128);
+    ballY = lastballY - map(movementVal, SPD0, SPD1, 0, num);
   } else if (i == DOWN_RIGHT) {
-    bodX = lastBodX + map(movementVal, SPD0, SPD1, 0, 128);
-    bodY = lastBodY + map(movementVal, SPD0, SPD1, 0, num);
+    ballX = lastballX + map(movementVal, SPD0, SPD1, 0, 128);
+    ballY = lastballY + map(movementVal, SPD0, SPD1, 0, num);
   } else if (i == DOWN_LEFT) {
-    bodX = lastBodX - map(movementVal, SPD0, SPD1, 0, 128);
-    bodY = lastBodY + map(movementVal, SPD0, SPD1, 0, num);
+    ballX = lastballX - map(movementVal, SPD0, SPD1, 0, 128);
+    ballY = lastballY + map(movementVal, SPD0, SPD1, 0, num);
   }
-  u8g.drawPixel(bodX, bodY);
+  u8g.drawPixel(ballX, ballY);
   checkCollision();
 }

 void checkCollision() {
-  if ( ((bodY >= paddleR) && (bodY <= paddleR + 2)) && (bodX >= PADDLE_XR)) { //Right Paddle TOP
+  if ( ((ballY >= paddleR) && (ballY <= paddleR + 2)) && (ballX >= PADDLE_XR)) { //Right Paddle TOP
     assignDirection(UP_RIGHT, UP_LEFT, UP_RIGHTS, UP_LEFT, DOWN_RIGHT, DOWN_LEFT, DOWN_RIGHTS, DOWN_LEFT);
-  } else if ( ((bodY >= paddleR + 3) && (bodY <= paddleR + 3)) && (bodX >= PADDLE_XR)) { //Right Paddle TOP-MIDDLE
+  } else if ( ((ballY >= paddleR + 3) && (ballY <= paddleR + 3)) && (ballX >= PADDLE_XR)) { //Right Paddle TOP-MIDDLE
     assignDirection(UP_RIGHT, UP_LEFTS, UP_RIGHTS, UP_LEFTS, DOWN_RIGHT, DOWN_LEFTS, DOWN_RIGHTS, DOWN_LEFTS);
-  } else if ( ((bodY >= paddleR + 4) && (bodY <= paddleR + 5)) && (bodX >= PADDLE_XR)) { //Right Paddle BOTTOM
+  } else if ( ((ballY >= paddleR + 4) && (ballY <= paddleR + 5)) && (ballX >= PADDLE_XR)) { //Right Paddle BOTTOM
     assignDirection(UP_RIGHT, UP_LEFT, UP_RIGHTS, UP_LEFT, DOWN_RIGHT, DOWN_LEFT, DOWN_RIGHTS, DOWN_LEFT);
-  } else if ( ((bodY >= paddleL) && (bodY <= paddleL + 2)) && ((bodX >= PADDLE_XL + 1) && (bodX <= PADDLE_XL + 3)) ) { //Left Paddle TOP
+  } else if ( ((ballY >= paddleL) && (ballY <= paddleL + 2)) && ((ballX >= PADDLE_XL + 1) && (ballX <= PADDLE_XL + 3)) ) { //Left Paddle TOP
     assignDirection(UP_LEFT, UP_RIGHT, UP_LEFTS, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT, DOWN_LEFTS, DOWN_RIGHT);
-  } else if ( ((bodY >= paddleL + 3) && (bodY <= paddleL + 3)) && ((bodX >= PADDLE_XL + 1) && (bodX <= PADDLE_XL + 3)) ) { //Left Paddle TOP-MIDDLE
+  } else if ( ((ballY >= paddleL + 3) && (ballY <= paddleL + 3)) && ((ballX >= PADDLE_XL + 1) && (ballX <= PADDLE_XL + 3)) ) { //Left Paddle TOP-MIDDLE
     assignDirection(UP_LEFT, UP_RIGHTS, UP_LEFTS, UP_RIGHTS, DOWN_LEFT, DOWN_RIGHTS, DOWN_LEFTS, DOWN_RIGHTS);
-  } else if ( ((bodY >= paddleL + 4) && (bodY <= paddleL + 5)) && ((bodX >= PADDLE_XL + 1) && (bodX <= PADDLE_XL + 3)) ) { //Left Paddle BOTTOM
+  } else if ( ((ballY >= paddleL + 4) && (ballY <= paddleL + 5)) && ((ballX >= PADDLE_XL + 1) && (ballX <= PADDLE_XL + 3)) ) { //Left Paddle BOTTOM
     assignDirection(UP_LEFT, UP_RIGHT, UP_LEFTS, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT, DOWN_LEFTS, DOWN_RIGHT);
-  } else if (bodX >= 128) { //Right wall
+  } else if (ballX >= 128) { //Right wall
     rndDirection = random(2, 6);
     direct = START;
     movementVal = 0;
-    lastBodX = bodX;
-    lastBodY = bodY;
+    lastballX = ballX;
+    lastballY = ballY;
     scoreL++;
-  } else if (bodX <= 0) { //Left wall
+  } else if (ballX <= 0) { //Left wall
     rndDirection = random(2, 6);
     direct = START;
     movementVal = 0;
-    lastBodX = bodX;
-    lastBodY = bodY;
+    lastballX = ballX;
+    lastballY = ballY;
     scoreR++;
-  } else if (bodY <= 0) { //Upper wall
-    bodY = 0;
+  } else if (ballY <= 1) { //Upper wall
     assignDirection(UP_RIGHT, DOWN_RIGHT, UP_LEFT, DOWN_LEFT, UP_RIGHTS, DOWN_RIGHTS, UP_LEFTS, DOWN_LEFTS);
-  } else if (bodY >= 64) { //Bottom wall
-    bodY = 64;
+  } else if (ballY >= 64) { //Bottom wall
     assignDirection(DOWN_RIGHT, UP_RIGHT, DOWN_LEFT, UP_LEFT, DOWN_RIGHTS, UP_RIGHTS, DOWN_LEFTS, UP_LEFTS);
   }
 }
@@ -164,15 +162,15 @@

   checkCollision();
   u8g.setFont(u8g_font_helvB08);
-  /*u8g.setPrintPos(27, 35);
-  u8g.print(direct);*/
+  u8g.setPrintPos(27, 35);
+  u8g.print(movementVal);

   u8g.setPrintPos(32, 15);
   u8g.print(scoreL);
   u8g.setPrintPos(80, 15);
   u8g.print(scoreR);

-  u8g.drawPixel(bodX, bodY);
+  u8g.drawPixel(ballX, ballY);
   u8g.drawBox(64, 0, 1, 64);
   u8g.drawBox(PADDLE_XL, paddleL, 2, 5);
   u8g.drawBox(PADDLE_XR, paddleR, 2, 5);


Sorta does stuff!!!

Sorta does stuff!!!

--- src/main/arduino/Motion/Motion.ino
+++ src/main/arduino/Motion/Motion.ino
@@ -14,28 +14,15 @@
   Wire.onRequest(requestEvent);
   lcd.begin();
   lcd.clear_screen();
+  lcd.set_brightness(0x77);
+  lcd.set_cursor(1, 5);
+  lcd.print("Pathfinder");
+  lcd.set_cursor(2, 7);
+  lcd.print("Online");
 }

 void loop() {
-  lcd.set_brightness(0x00);
-  delay(1000);
-  lcd.set_brightness(0x22);
-  delay(1000);
-  lcd.set_brightness(0x44);
-  delay(1000);
-  lcd.set_brightness(0xFF);
-  delay(1000);
-
-  lcd.set_cursor(1, 5);
-  lcd.print("Hello!");
-  delay(1000);
-  lcd.set_cursor(2, 10);
-  lcd.print("Howdy!");
-  delay(1000);
-  lcd.blink_cursor();
-  delay(1000);
-  lcd.disable_cursor();
-  lcd.clear_screen();
+  delay(100);
 }

 void requestEvent() {
@@ -43,8 +30,12 @@
 }

 void receiveEvent(int howMany) {
+  lcd.clear_screen();
   while (1 < Wire.available()) { // loop through all but the last
     char c = Wire.read(); // receive byte as a character
+    lcd.print("%c", c);
   }
   int x = Wire.read();    // receive byte as an integer
+
+  lcd.print("%d", x);
 }


BasicStepping:  Added setDirection calls and changed the comments.

--- examples/BasicStepping/BasicStepping.ino
+++ examples/BasicStepping/BasicStepping.ino
@@ -1,11 +1,16 @@
-/* This example shows how to detect and automatically recover
-from various errors that can occur when using the AMIS-30543,
-including an interruption of the motor power supply.
+/* This example shows basic use of the AMIS-30543 stepper motor
+driver.

-Before using this example, be sure to change the parameter to
-setCurrentMilliamps to an appropriate current limit for your
-system.  Also, see this library's documentation for information
-about how to connect the driver:
+It shows how to initialize the dirver, set the current limit, set
+the micro-stepping mode, and enable the driver.  It shows how to
+send pulses to the step pin to get the driver to take steps and
+how to switch directions over SPI.  (The DIR pin is not used and
+does not need to be connected.)
+
+Before using this example, be sure to change the
+setCurrentMilliamps line to have an appropriate current limit for
+your system.  Also, see this library's documentation for
+information about how to connect the driver:

     http://pololu.github.io/amis-30543-arduino/
 */
@@ -27,12 +32,36 @@
   stepper.init(amisSlaveSelect);
   stepper.resetSettings();
   stepper.setCurrentMilliamps(245);
+  stepper.setStepMode(32);
   stepper.enableDriver();
 }

 void loop()
 {
-  // The NXT minimum high pulse width is 2 microseconds.
+  // Step in the default direction 1000 times.
+  stepper.setDirection(0);
+  for (unsigned int x = 0; x < 1000; x++)
+  {
+    step();
+  }
+
+  // Wait for 300 ms.
+  delay(300);
+
+  // Step in the other direction 1000 times.
+  stepper.setDirection(1);
+  for (unsigned int x = 0; x < 1000; x++)
+  {
+    step();
+  }
+
+  // Wait for 300 ms.
+  delay(300);
+}
+
+void step()
+{
+  // Send a pulse on the NXT/STEP pin to tell the driver to take one step.
   digitalWrite(amisStepPin, HIGH);
   delayMicroseconds(3);
   digitalWrite(amisStepPin, LOW);


Fixing CS5490_Basics

Fixing CS5490_Basics

- Avoid using pin 13 for Software Serial
- Leonardo Compatibility improve
- Less decimal places

--- examples/CS5490_Basics/CS5490_Basics.ino
+++ examples/CS5490_Basics/CS5490_Basics.ino
@@ -1,7 +1,7 @@

 #include<CS5490.h>

-#define rx 13
+#define rx 11
 #define tx 12

 /* Choose your board */
@@ -19,6 +19,8 @@
   line.begin(600);
   //Initializing communication arduino/PC to show results in Monitor Serial
   Serial.begin(115200);
+  // wait for serial port to connect. Needed for Leonardo only
+  while (!Serial);
 }

 void loop() {
@@ -27,7 +29,7 @@
   double bar = line.getTime();

   Serial.print("The Line to Sample Frequency Ratio is: ");
-  Serial.println( foo , 10 ); //10 is the number of decimal places
+  Serial.println( foo , 5 ); //5 is the number of decimal places

   Serial.print("The System Time is: ");
   Serial.println( bar );


Added more sounds

Added more sounds

--- module/module.ino
+++ module/module.ino
@@ -68,7 +68,7 @@
 	// -----------------------------------------------------------------------
 	// Analyze response packet and data
 	if (!isValidResponse) {
-		//soundFeedback(isReject);
+		playDeath();
 		getStringFromMem(readUnsuccessful);
 	}
 	// These statements run if a valid RFID tag is detected


8bit mode for simple test

8bit mode for simple test

--- arduino/test/test.ino
+++ arduino/test/test.ino
@@ -6,33 +6,33 @@
 #include "lib_StringBuffer.h"

 TinyScreen display = TinyScreen(0);
-RenderBuffer<uint16_t,20> buffer;
+RenderBuffer<uint8_t,20> buffer;

 void setup() {
   Wire.begin();
   display.begin();
   display.setFlip(0);
   display.setBrightness(8);
-  display.setBitDepth(1);
+  display.setBitDepth(0);
 }
 uint16_t rgb565[] = {0xffff,0xf,0xf0,0xffff};
-Texture<uint16_t> _tex((uint8_t*) rgb565, TextureType::rgb565sram, 2,2, 0xffff);
+Texture<uint8_t> _tex((uint8_t*) rgb565, TextureType::rgb565sram, 2,2, 0xffff);

 void loop(void) {
     static unsigned long t = millis();
     unsigned long t2 = millis();

-    buffer.drawText(stringBuffer.start()->put(t2-t)->put("ms")->get(),2,2,RGB565(255,255,255), &virtualDJ_5ptFontInfo);
-    buffer.drawText(stringBuffer.start()->put(t2-t)->put("ms")->get(),2,22,RGB565(255,0,0), &virtualDJ_5ptFontInfo);
-    buffer.drawText(stringBuffer.start()->put(t2-t)->put("ms")->get(),2,32,RGB565(0,255,0), &virtualDJ_5ptFontInfo);
-    buffer.drawText(stringBuffer.start()->put(t2-t)->put("ms")->get(),2,42,RGB565(0,0,255), &virtualDJ_5ptFontInfo);
+    buffer.drawText(stringBuffer.start()->put(t2-t)->put("ms")->get(),2,2,buffer.rgb(255,255,255), &virtualDJ_5ptFontInfo);
+    buffer.drawText(stringBuffer.start()->put(t2-t)->put("ms")->get(),2,22,buffer.rgb(255,0,0), &virtualDJ_5ptFontInfo);
+    buffer.drawText(stringBuffer.start()->put(t2-t)->put("ms")->get(),2,32,buffer.rgb(0,255,0), &virtualDJ_5ptFontInfo);
+    buffer.drawText(stringBuffer.start()->put(t2-t)->put("ms")->get(),2,42,buffer.rgb(0,0,255), &virtualDJ_5ptFontInfo);

     static uint16_t cnt = 0;
     cnt+=1;
-    buffer.drawText(stringBuffer.start()->put(cnt)->put("rgb")->get(),42,2,RGB565(cnt,cnt,cnt), &virtualDJ_5ptFontInfo);
-    buffer.drawText(stringBuffer.start()->put(cnt)->put("r")->get(),42,22,RGB565(cnt,0,0), &virtualDJ_5ptFontInfo);
-    buffer.drawText(stringBuffer.start()->put(cnt)->put("g")->get(),42,32,RGB565(0,cnt,0), &virtualDJ_5ptFontInfo);
-    buffer.drawText(stringBuffer.start()->put(cnt)->put("b")->get(),42,42,RGB565(0,0,cnt), &virtualDJ_5ptFontInfo);
+    buffer.drawText(stringBuffer.start()->put(cnt)->put("rgb")->get(),42,2,buffer.rgb(cnt,cnt,cnt), &virtualDJ_5ptFontInfo);
+    buffer.drawText(stringBuffer.start()->put(cnt)->put("r")->get(),42,22,buffer.rgb(cnt,0,0), &virtualDJ_5ptFontInfo);
+    buffer.drawText(stringBuffer.start()->put(cnt)->put("g")->get(),42,32,buffer.rgb(0,cnt,0), &virtualDJ_5ptFontInfo);
+    buffer.drawText(stringBuffer.start()->put(cnt)->put("b")->get(),42,42,buffer.rgb(0,0,cnt), &virtualDJ_5ptFontInfo);
     buffer.drawRect(60,10,8,8)->filledRect(cnt);
     buffer.drawRect(40,4,14,14)->sprite(&_tex);
     t = t2;


Added reference to issue #60.

Added reference to issue #60.

--- examples/RPN_NRPN/RPN_NRPN.ino
+++ examples/RPN_NRPN/RPN_NRPN.ino
@@ -8,6 +8,9 @@
 The complexity of this example resides in the fact that keeping a state
 of all the 16384 * 2 RPN/NRPN values would not fit in memory.
 As we're only interested in a few of them, we use a separate state map.
+
+If you'd like to go further, have a look at this thread:
+https://github.com/FortySevenEffects/arduino_midi_library/issues/60
 */

 template<class State, byte MsbSelectCCNumber, byte LsbSelectCCNumber>


Update i2c_datatest.ino

Update i2c_datatest.ino

--- code/i2c_datatest.ino
+++ code/i2c_datatest.ino
@@ -14,7 +14,7 @@
 }

 void loop(){
-  Wire.beginTransmission(MPU_addr);
+  Wire.beginTransmission(SENSOR_ADDR);
   Wire.write(0x3B);  // begin from 0x3b
   Wire.endTransmission(false);


Set I2C speed done

Set I2C speed done

--- arduino/PaddleFish/PaddleFish.ino
+++ arduino/PaddleFish/PaddleFish.ino
@@ -151,10 +151,15 @@
               char buffer[6];
               if (receiveBytes(6,buffer))
               {
-                unsigned long i2c_speed = buffer[0]<<24 | buffer[1]<<16 | buffer[2]<<8 | buffer[3];
+                unsigned long i2c_speed = 0;
+                unsigned int n1 = ((buffer[0]<<8) + buffer[1]) & 0xFFFF;
+                unsigned int n2 = ((buffer[2]<<8) + buffer[3]) & 0xFFFF;
+                //i2c_speed = (unsigned long)(((unsigned long)(((unsigned long)buffer[1]<<16) + ((unsigned long)buffer[0]<<24)) + (buffer[3]) + (buffer[2]<<8)) & 0xFFFFFFFF);
+                i2c_speed = (((unsigned long)n1)<<16);
+                i2c_speed += n2;
                 lwi2c.i2c_set_speed(i2c_speed);

-                commOK();
+                commOK();
                 startReceive = false;
                 receivedCmd = CMD_NULL;
               } else


Fix library includes

Fix library includes

--- examples/WorldClockDemo/WorldClockDemo.ino
+++ examples/WorldClockDemo/WorldClockDemo.ino
@@ -26,10 +26,10 @@
 #include <ESP8266WiFi.h>
 #include <Ticker.h>
 #include <JsonListener.h>
-#include "SSD1306Wire.h"
-#include "OLEDDisplayUi.h"
-#include "Wire.h"
-#include "WorldClockClient.h"
+#include <SSD1306Wire.h>
+#include <OLEDDisplayUi.h>
+#include <Wire.h>
+#include <WorldClockClient.h>
 #include "icons.h"
 #include "fonts.h"


implemented LCD 16x2 handler

implemented LCD 16x2 handler

--- ksp-gegi/ksp-gegi.ino
+++ ksp-gegi/ksp-gegi.ino
@@ -1,11 +1,15 @@

 #include <Arduino.h>
+#include <Wire.h>
+// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
+#include <LiquidCrystal_I2C.h> // Using version 1.2.1

 // dł kabelków 15-20cm
 // diody LED: niebieskie (bez rezystora, krótka nóżka) do GND, białe (z rezystorem, długa nóżka) do pinu
 // potencjometr: niebieski z czarną kreską do GND, biały do +5V, niebieski do pinu A0 / A1
 // przełączniki2: niebieski do GND, biały do pinu, wszystkie zamontowane tak, aby niebieski był w środku, biały na dole, a niepodłączone u góry (wtedy gałka w górę==załączenie)
 // przełączniki3: środkowy (ciemny) do GND, boczne do pinów
+// LCD: SDA->A4, SCL->A5

 // przepisać tablice+npins jako klasę?
 // to: oraz array.size() zamiast nPins http://hackaday.com/2015/11/13/code-craft-embedding-c-timing-virtual-functions/
@@ -33,6 +37,10 @@
 // analog control output
 const uint8_t nAOutPins = 1;
 const uint8_t aOutPins[] = {10};	// vmeter: g-force
+
+// Set the pins on the I2C chip used for LCD connections:
+//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
+LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

 // serial port
 #define SERIAL_SPEED 9600
@@ -61,6 +69,11 @@
   Serial.println("I");
   // start blink counter
   lastBlink = millis();
+  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight
+  lcd.setCursor(0,0);
+  lcd.print("KSP-Gegi");
+  lcd.setCursor(0,1);
+  lcd.print("Ready for action");
 }

 void updateAnalogPin(uint8_t id) {
@@ -145,6 +158,26 @@
 	}
 }

+// commands like ^P{line:0,1}={text0..15}$ (consume all characters until end of the line)
+void handleSerialInputLCD() {
+    uint8_t id=0, c;
+    id = Serial.parseInt();  // skip '='
+	if (id==0 || id==1) {
+		lcd.setCursor(0,id);
+		c = -1;
+		while (c!='\r' && c!='\n') {
+			if (Serial.available()>0) {
+				c = Serial.read();
+			} else {
+				c = -1;
+			}
+			if (c>0) {
+				lcd.write(c);
+			}
+		}
+	}
+}
+
 void checkSerialInput() {
   uint8_t c;
   if (Serial.available()>0) {
@@ -154,6 +187,9 @@
 	}
 	if (c == 'A') {
 	  handleSerialInputAnalogOut();
+	}
+	if (c == 'P') {
+	  handleSerialInputLCD();
 	}
   }
 }