Chase Lake
/
TargetPracticeMiniProject
Using an accelerometer to move a ball on an LED screen.
main.cpp
- Committer:
- bentogami
- Date:
- 2016-01-14
- Revision:
- 0:708949ec9140
- Child:
- 1:c436c1b8333b
File content as of revision 0:708949ec9140:
#include "mbed.h" #include "ADXL.h" #include "Arial12x12.h" #include "Arial24x23.h" #include "ILI932x.h" Serial pc(USBTX, USBRX); float data[6]; PinName dataBus[]= {p30, p29, p28, p27, p26, p25, p24, p23}; ILI932x myLCD(BUS_8, dataBus, p15, p17, p16, p14, p20, "myLCD", 240, 320); // Bus 8 bit, bus pin array, CS, RST, DC, WR, RD, name, xpixels, ypixels char orient=4; int X = 120, Y = 160; int main() { accConfig(); myLCD.set_orientation(orient); //t.start(); myLCD.set_font((unsigned char*) Arial12x12); myLCD.background(Black); // set background to red myLCD.foreground(White); // set chars to black myLCD.cls(); // clear the screen myLCD.locate((myLCD.width()-7)/2,myLCD.height()/2); // from our view, first is yPos, second is xPos myLCD.printf("Target Practice\r\n"); wait(2); myLCD.cls(); while(1) { //temporary code: myLCD.circle(120,160,12,White); myLCD.fillcircle(X,Y,6,Green); getAccel(data); pc.printf("x = %+1.2fg\t y = %+1.2fg\n\r", data[0], data[1]); //print if (X < myLCD.width() && X > 0) X += data[0]/0.004; if (Y < myLCD.height() && Y > 0) Y += data[1]/0.004; wait(0.02); myLCD.cls(); //insert correct code here: } }