![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Using an accelerometer to move a ball on an LED screen.
Revision 2:c6bf8599c398, committed 2016-01-20
- Comitter:
- bentogami
- Date:
- Wed Jan 20 22:00:15 2016 +0000
- Parent:
- 1:c436c1b8333b
- Commit message:
- Mission complete (for real)!
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jan 20 21:20:23 2016 +0000 +++ b/main.cpp Wed Jan 20 22:00:15 2016 +0000 @@ -9,7 +9,7 @@ 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 X = 120, Y = 160, oldY, oldX; int main() { accConfig(); @@ -26,18 +26,20 @@ myLCD.cls(); */ wait(1); + myLCD.circle(120,160,12,White); while(1) { //temporary code: - myLCD.circle(120,160,12,White); - myLCD.fillcircle(X,Y,6,Blue); + myLCD.fillcircle(oldX,oldY,6,Black); + myLCD.fillcircle(X,Y,6,Blue); + oldX = X; + oldY = Y; getAccel(data); pc.printf("x = %1.2fg\t y = %1.2fg\t z = %1.2fg \n\r", data[0], data[1], data[2]); //print if (((X + data[0]) < myLCD.width()-10) && (X + data[0]) > 10) X += data[0]*30; if ((Y + data[1]) < myLCD.height()-10 && (Y + data[1]) > 10) Y -= data[1]*30; - wait(0.02); - myLCD.cls(); + wait(0.002); //insert correct code here: