Kostya B. / Mbed 2 deprecated ADNS3080_LCD

Dependencies:   BSP_DISCO_F429ZI LCD_DISCO_F429ZI mbed

Fork of ADNS3080_HelloWorld by ryosuke yumoto

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "ADNS3080.h"
00003 #include "LCD_DISCO_F429ZI.h"
00004 
00005 ADNS3080 OptFlow(PE_6, PE_5, PE_2, PE_4);//MOSI, MISO, SCLK, NCS
00006 Serial pc(USBTX, USBRX);
00007 
00008 LCD_DISCO_F429ZI lcd;
00009 
00010 int main() {
00011 
00012     pc.printf("Test ADNS3080\n\r");
00013     
00014     pc.printf("prodID is %x\n\r", OptFlow.getProdID());
00015     pc.printf("RevID is %x\n\r", OptFlow.getRevID());
00016     pc.printf("InverProdID is %x\n\r", OptFlow.getInverProdID());
00017     pc.printf("configuration is %x\n\r", OptFlow.getConfiguration_bits()); 
00018     
00019     uint8_t text[30];
00020     BSP_LCD_SetFont(&Font20);
00021     sprintf((char*)text, "prodID1 is %x", OptFlow.getProdID());
00022     lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);   
00023     
00024     int x=0, y=0, dx=0, dy=0;
00025     while(1){
00026         OptFlow.getMotion();
00027         dx = OptFlow.getDelta_X();
00028         dy = OptFlow.getDelta_Y();
00029         x += dx;
00030         y += dy; 
00031         pc.printf("%4d, %4d, (%d,%d)\n\r", dx, dy, x, y);
00032 
00033         sprintf((char*)text, "(dx,dy)=%4d,%4d", dx, dy);
00034         lcd.DisplayStringAt(0, LINE(1), (uint8_t *)&text, LEFT_MODE);   
00035         sprintf((char*)text, "(x,y)=%4d,%4d", x, y);
00036         lcd.DisplayStringAt(0, LINE(2), (uint8_t *)&text, LEFT_MODE);   
00037 
00038         wait(0.01); 
00039     }
00040 }