ELEC2645 (2018/19) / Mbed 2 deprecated el16y2m

Dependencies:   mbed

Revision:
0:4ada39fe4ffc
Child:
1:7a3eed610fea
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Mar 31 18:45:25 2019 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+#include "Image.h"
+#include "Rotate.h"
+#include "Gamepad.h"
+#define PI 3.1415
+
+Image Image;
+
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+
+
+Rotate Rotate;
+
+InterruptIn A(PTB9);
+
+void A_isr();
+
+void init_K64F();
+
+volatile int g_A_flag = 0;
+
+int main()
+{
+    // first need to initialise display
+    lcd.init();
+    // change set contrast in range 0.0 to 1.0
+    // 0.4 appears to be a good starting point
+    lcd.setContrast(0.5);
+    A.mode(PullDown);
+    A.rise(&A_isr);
+    // since SW2 has an external pull-up, we should disable to internal pull-down
+    // resistor that is enabled by default using InterruptIn
+    Rotate.return_flag=1;
+    Rotate.return_angle=PI;
+    
+    while(1) {
+        int detector=A.read();
+        // these are default settings so not strictly needed
+        lcd.normalMode();      // normal colour mode
+        lcd.setBrightness(0.4); // put LED backlight on 50%
+        // x origin, y origin, rows, cols, sprite
+        if(g_A_flag) {
+            detector=1;
+        }
+
+        switch(detector) {
+            case 0 :
+                lcd.clear();
+                lcd.printString("Misery Miner!",0,0);
+                lcd.refresh();
+                wait(0.1);
+                break;
+            case 1 :
+                Rotate.rotate(lcd,Image, Rotate.return_angle, PI, Rotate.return_flag);
+                 //printf("f%", Rotate.return_angle);
+                 break;
+        }
+    }
+}
+
+void A_isr()
+{
+    g_A_flag = 1;
+}
+