..

Dependencies:   ID12RFID TFTLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "ID12RFID.h"
00003 #include "hx8340bs.h"
00004 
00005 
00006 ID12RFID rfid(p10); // uart rx
00007 HX8340S_LCD lcd( p9, p14, p13, p11 ); //Screen initialization
00008  // HX8340S_LCD( PinName CS, PinName RESET, PinName SCL, PinName SDI, PinName BL = NC, backlight_t blType = Constant, float defaultBackLightLevel = 1.0 );
00009  
00010 int ReadX(PinName x1, PinName x2, PinName y1, PinName y2){
00011     
00012     int tempX;
00013     DigitalOut X1(x1);
00014     DigitalOut X2(x2);
00015     AnalogIn   Y1(y1);
00016     AnalogIn   Y2(y2);    
00017     
00018     X1=1;
00019     X2=0;
00020     printf("I am set for X\n");
00021     wait(10);
00022     printf("I am Measuring X\n");
00023     tempX=Y2;
00024     wait(10);
00025     
00026     return tempX;
00027     }
00028     
00029     
00030 int ReadY(PinName x1, PinName x2, PinName y1, PinName y2){
00031     int tempY;
00032     DigitalOut X1(X1);
00033     DigitalOut X2(X2);
00034     AnalogIn   Y1(y1);
00035     AnalogIn   Y2(y2);    
00036     
00037     X1=1;
00038     X2=0;
00039     tempY=Y1;
00040     
00041     return tempY;
00042     }
00043     
00044 
00045 int main() {
00046     printf("Hello World\n");
00047     // initialize display - place it in standard portrait mode and set background to black and
00048      //                      foreground to white color.
00049       lcd.Initialize();
00050       lcd.FillScreen(COLOR_RED);
00051       lcd.SetBackground(COLOR_BLUE);
00052       lcd.DrawRoundRect(20,20,60,60,COLOR_GREEN);
00053       // set current font to the smallest 8x12 pixels font.
00054       //lcd.SetFont( TerminusFont );
00055       // print something on the screen
00056       lcd.Print( "Hello, World!", CENTER, 25 ); // align text to center horizontally and use starndard colors
00057 
00058     while(1) {
00059         if(rfid.readable()) {
00060             printf("RFID Tag number : %d\n", rfid.read());             
00061         }
00062         if (ReadX(p15,p17,p18,p16)){
00063         printf("X Coordinate : %d\n", ReadX(p15,p17,p18,p16));
00064         }
00065     }
00066 }
00067 
00068 
00069 
00070     
00071 
00072     
00073 
00074