LCD16x2,gy25,using Serial.getc()

Dependencies:   MPU6050 TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
iskenny4
Date:
Thu May 25 08:48:51 2017 +0000
Commit message:
LCD displays gy25's angles(z,x,y) with .getc()

Changed in this revision

MPU6050.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 88e974ab5621 MPU6050.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPU6050.lib	Thu May 25 08:48:51 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/Sissors/code/MPU6050/#5c63e20c50f3
diff -r 000000000000 -r 88e974ab5621 TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Thu May 25 08:48:51 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r 88e974ab5621 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 25 08:48:51 2017 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "TextLCD.h"
+
+TextLCD lcd(PA_0,PA_1,PA_4,PB_0,PC_1,PC_0); // RS, E, D4-D7
+Serial gy25(PA_9, PA_10, 115200);
+DigitalOut rw(PA_8); // RW
+
+int g[3];
+char rxC[8];
+
+void rxIRQ(){
+    rxC[0] = gy25.getc();
+    if (rxC[0] == 170) {
+        for (int i = 1; i < 8; i++) {
+            rxC[i] = gy25.getc();
+        }
+        if (rxC[7] == 85) {
+            for (int i = 0, j =1; i < 3; i++, j+=2) {
+                g[i] = (rxC[j]<<8 | rxC[j+1])/100;
+                if (g[i] > 475)
+                    g[i] = g[i] - 476 + 180;
+            }
+        }
+    }
+}
+
+int main()
+{
+    gy25.format(8,SerialBase::None,1);
+    lcd.cls();
+    lcd.printf("LCD work");
+    wait(1);
+    gy25.attach(rxIRQ, RawSerial::RxIrq);
+    while(1) {
+        lcd.locate(0,1);
+        lcd.printf("%d,%d,%d",g[0],g[1],g[2]);
+        wait(0.4);
+        lcd.cls();
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 88e974ab5621 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 25 08:48:51 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6
\ No newline at end of file