ELEC2645 (2018/19) / Mbed 2 deprecated henririgby98

Dependencies:   mbed

Revision:
2:794ed187ffcd
Parent:
1:c9d346de3a66
Child:
4:d744920089ea
diff -r c9d346de3a66 -r 794ed187ffcd main.cpp
--- a/main.cpp	Mon Mar 25 09:27:55 2019 +0000
+++ b/main.cpp	Sat May 04 15:49:46 2019 +0000
@@ -1,24 +1,46 @@
-/* ELEC2645 
-Embedded Systems Project 
-School of Electronic & Electrical Engineering
-University of Leeds 
- 
-Name: Henri Rigby
-Username: henririgby98 
-Student ID Number: 201198821
-Date: 18/03/2019
- */
-
-#include "mbed.h"
-
-DigitalOut gpo(D0);
-DigitalOut led(LED_RED);
-
-int main()
-{
-    while (true) {
-        gpo = !gpo; // toggle pin
-        led = !led; // toggle led
-        wait(0.2f);
-    }
-}
\ No newline at end of file
+
+#include "mbed.h"
+#include "Gamepad.h"
+#include "N5110.h"
+
+//                  y     x     button
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+Gamepad pad;
+int sprite[8][11] =   {
+    { 0,0,1,0,0,0,0,0,1,0,0 },
+    { 0,0,0,1,0,0,0,1,0,0,0 },
+    { 0,0,1,1,1,1,1,1,1,0,0 },
+    { 0,1,1,0,1,1,1,0,1,1,0 },
+    { 1,1,1,1,1,1,1,1,1,1,1 },
+    { 1,0,1,1,1,1,1,1,1,0,1 },
+    { 1,0,1,0,0,0,0,0,1,0,1 },
+    { 0,0,0,1,1,0,1,1,0,0,0 },
+};
+
+int main() {
+    
+    lcd.init();
+    pad.init();      
+    lcd.setContrast(0.6);
+    
+    float SUM_x = WIDTH/2-6;
+    float SUM_y = HEIGHT/2-4;
+    
+    while(1) {
+        
+        lcd.normalMode();      // normal colour mode
+        lcd.setBrightness(0.9); // put LED backlight on 50%
+
+        lcd.clear();
+        pad.get_mapped_coord();
+        Vector2D mapped_coord = pad.get_mapped_coord();
+        SUM_x = SUM_x + (mapped_coord.x*7);
+        SUM_y = SUM_y - (mapped_coord.y*7);
+        
+        wait(0.0001);
+        lcd.drawSprite(SUM_x,SUM_y,8,11,(int *)sprite); 
+        lcd.refresh();
+    }
+    
+    
+}