Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Adafruit_FT6206.h>
- #include <Adafruit_ILI9341.h>
- #include <Adafruit_GFX.h>
- /* Defines */
- #define TFT_CS 10
- #define TFT_DC 9
- Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
- extern uint8_t SmallFont[];
- extern uint8_t BigFont[];
- /*
- short pageId = 0;
- int buttons[MAX_BUTTONS][5];
- short bCount = 0;
- short startGameButton = -1;
- */
- int x = 50;
- int y = 0;
- int mode = 0;
- int angle = 0;
- void setup() {
- Serial.begin(9600);
- tft.begin();
- tft.fillScreen(ILI9341_BLACK);
- }
- void loop() {
- tft.fillRect(x,y,2,2,0xffff);
- if(mode == 1) tft.fillRect(x,y++,2,2,0xffff);
- else if(mode == 3) tft.fillRect(x,y--,2,2,0xffff);
- else if(mode == 2) tft.fillRect(x--,y,2,2,0xffff);
- else if(mode == 4) tft.fillRect(x++,y,2,2,0xffff);
- if (Serial.available() > 0) {
- // read the incoming byte:
- byte incomingByte = Serial.read();
- int tempmode = 0;
- if(incomingByte == 'a')Serial.println("hey1"), tempmode = 1;
- else if(incomingByte == 'd')Serial.println("hey2"), tempmode = 3;
- else if(incomingByte == 'w') Serial.println("hey3"),tempmode = 2;
- else if(incomingByte == 's') Serial.println("hey4"),tempmode = 4;
- }
- delay(200);
- /*tft.fillScreen(ILI9341_BLACK);
- PrintText(50,y++);
- delay(10);*/
- }
- void PrintText(int x,int y) {
- tft.setCursor(x,y);
- tft.setTextColor(ILI9341_WHITE);
- tft.setTextSize(3);
- tft.println("Blue Wins");
- }
- /*
- void drawHomeScreen() {
- pageId = 1;
- myGLCD.setBackColor(0,0,0);
- PrintText("CatchMe",CENTER, 10,255,255,255,BigFont);
- startGameButton = CreateButton("Start Game",25,25,100,50, 255,255,255 , 0,0,0);
- }
- void PrintText(text[], x,y,r = 255,g = 255,b = 255, font[] = SmallFont) {
- myGLCD.setColor(r,g,b);
- myGLCD.setFont(font);
- myGLCD.print(text,x,y);
- }
- short CreateButton(text[], x,y, width,height, boxr = 255, boxg = 255,boxb = 255, r = 255, g = 255, b = 255) {
- myGLCD.setColor(boxr, boxg, boxb);
- myGLCD.fillRoundRect (x, y, width, height);
- myGLCD.setFont(BigFont);
- myGLCD.setBackColor(r, g, b);
- myGLCD.print(text, x, y);
- buttons[bCount][0] = x;
- buttons[bCount][1] = y;
- buttons[bCount][2] = width;
- buttons[bCount][3] = height;
- buttons[bCount][4] = pageId;
- return bCount++;
- }
- void loop() {
- if (myTouch.dataAvailable()) {
- myTouch.read();
- x=myTouch.getX(); // X coordinate where the screen has been pressed
- y=myTouch.getY(); // Y coordinates where the screen has been pressed
- short pressedButton = -1;
- for(short i = 0;i < MAX_BUTTONS;i++) {
- if(buttons[i][4] != pageId)
- continue;
- if(x >= buttons[i][0] && x <= (buttons[i][0] + buttons[i][2]) && y >= buttons[i][1] && y <= (buttons[i][1] + buttons[i][3])) {
- pressedButton = i;
- break;
- }
- }
- switch(pressedButton) {
- case startGameButton: {
- // Start Game
- }
- }
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement