Piezo Vibration Sensor demo

Dependencies:   PCA9622_LED8x8 mbed

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Sun Aug 02 12:38:40 2015 +0000
Parent:
0:2f98d8d6ef4b
Commit message:
Add score notification blinking

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 2f98d8d6ef4b -r bcf6ab734086 main.cpp
--- a/main.cpp	Sun Jul 26 15:46:51 2015 +0000
+++ b/main.cpp	Sun Aug 02 12:38:40 2015 +0000
@@ -1,5 +1,5 @@
 /**
- *  MFT2015 demo : shake-shake-machine 
+ *  MFT2015 demo : shake-shake-machine
  *
  *  @author  Toyomasa WATARAI
  *  @version 1.0
@@ -20,23 +20,33 @@
 
 #define DURATION_TIME (5 * 1000) // n * milisecond
 
-void draw_number(int num);
+void draw_number(int num, int reverse=0);
 
-void draw_number(int num)
+void draw_number(int num, int reverse)
 {
     float   image[8][8];
     num %= 100;
 
     for (int x=0; x<8; x++)
-        for (int y=0; y<8; y++)
-            image[x][y] = 0.0f;
+        for (int y=0; y<8; y++) {
+            if (reverse)
+                image[x][y] = 0.5f;
+            else
+                image[x][y] = 0.0f;
+        }
 
     for (int i=0; i<5; i++) {
         for (int j=0; j<3; j++) {
             if (((font3x5[((num/10)*3) + j]) & (1<<(4-i))) != 0) {
-                image[i+1][j+1] = (float)0.5f;
+                if (reverse)
+                    image[i+1][j+1] = (float)0.0f;
+                else
+                    image[i+1][j+1] = (float)0.5f;
             } else {
-                image[i+1][j+1] = (float)0.0f;
+                if (reverse)
+                    image[i+1][j+1] = (float)0.5f;
+                else
+                    image[i+1][j+1] = (float)0.0f;
             }
         }
     }
@@ -44,9 +54,15 @@
     for (int i=0; i<5; i++) {
         for (int j=0; j<3; j++) {
             if (((font3x5[((num%10)*3) + j]) & (1<<(4-i))) != 0) {
-                image[i+1][j+5] = (float)0.5f;
+                if (reverse)
+                    image[i+1][j+5] = (float)0.0f;
+                else
+                    image[i+1][j+5] = (float)0.5f;
             } else {
-                image[i+1][j+5] = (float)0.0f;
+                if (reverse)
+                    image[i+1][j+5] = (float)0.5f;
+                else
+                    image[i+1][j+5] = (float)0.0f;
             }
         }
     }
@@ -107,10 +123,12 @@
     out.write(0.5f);
     wait(1);
     out.period(0);
-    
+
     while(1) {
-        draw_number(count);
+        draw_number(count, 0);
         wait(1);
-        
+        draw_number(count, 1);
+        wait(1);
+
     }
 }