goma yam / Mbed 2 deprecated QEI_X1_LCD_test3

Dependencies:   QEI TextLCD USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
toucyy
Date:
Fri Aug 29 07:10:48 2014 +0000
Commit message:
test

Changed in this revision

QEI.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
USBDevice.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 b32c7162cd9a QEI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Fri Aug 29 07:10:48 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/toucyy/code/QEI/#ba892225df71
diff -r 000000000000 -r b32c7162cd9a TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Fri Aug 29 07:10:48 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#e4cb7ddee0d3
diff -r 000000000000 -r b32c7162cd9a USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Fri Aug 29 07:10:48 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/toucyy/code/USBDevice/#2d8d0b73e1ff
diff -r 000000000000 -r b32c7162cd9a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Aug 29 07:10:48 2014 +0000
@@ -0,0 +1,73 @@
+#include "mbed.h"
+#include "TextLCD.h"
+#include "QEI.h"
+#include "USBSerial.h"
+#define ROTATE_PER_REVOLUTIONS  48
+
+Ticker timer1;
+Ticker timer2;
+Serial pc(USBTX, USBRX); // tx, rx pc hyper terminal
+Serial device(p9, p10);  // tx, rx for opt fader xq
+TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7 lcd
+QEI wheel1(p16, p17, NC, ROTATE_PER_REVOLUTIONS, QEI::X4_ENCODING); //encoder
+QEI wheel2(p21, p22, NC, ROTATE_PER_REVOLUTIONS, QEI::X4_ENCODING); //encoder
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+//BusOut myleds(LED1, LED2, LED3, LED4);
+
+int buf,cfd,predata,pulse1,pulse2;
+
+void disp() {
+ lcd.locate(0,0);
+ lcd.printf("ec1:%03d ec2:%03d\n", pulse1,pulse2);
+ lcd.locate(0,1);
+ lcd.printf("cfd:%03d\n", cfd);  
+ //pc.printf("encoder1: %02d\n\r", pulse1);
+ //pc.printf("encoder2: %02d\n\r", pulse2);
+ //pc.printf("cfd:%03d\n\r", cfd);
+ led2=!led2; //check 
+ }
+ 
+ void encoder() {
+ pulse1 =  wheel1.getPulses()/4;
+ pulse2 =  wheel2.getPulses()/4;
+ led4=!led4; //check
+ }
+ 
+int main() {
+        device.format(7, Serial::None, 1);
+        device.baud(30400);
+        //pc.baud(921600);
+        pc.printf("Opt Feder X1");
+        lcd.printf("Opt Feder X1");
+        wait(1);
+        timer1.attach_us(&disp, 50000);   //100ms
+        timer2.attach_us(&encoder,10); //10ms
+    while(1) {  
+         led3=!led3;//check
+         if(device.readable()) {          
+            buf = device.getc();
+            if(buf == 127)
+            { //to aboid freeze issue at 127 not fixed.
+                buf = device.getc();
+            }
+            cfd = buf;
+            if(buf != predata)
+            {          
+                if(buf >= 3)
+                {
+                led1 = 1;
+                }
+                else{
+                led1 =0;
+                }
+                //cfd = buf;
+                predata = buf;
+                         
+            }//if(x1 != predata)
+            
+          }//if(device.readable())
+          }//while(1)                                
+}//main
\ No newline at end of file
diff -r 000000000000 -r b32c7162cd9a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Aug 29 07:10:48 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e