The library comes with a clear memory function, could I just do a update for each part manually instead of calling the do all version?
Now to buttons. I added all the extra buttons to the settings file and I have buttons.h included in both my sketch and the display file. I then drew up a routine to display a green square then when I hit a button it's supposed to turn blue. But I can't get it to work.
- Code: Select all
#include <SPI.h>
#include <TFT_ILI93XX.h>
#include "Buttons.h"
Buttons buttons;
Teensy3.x and Arduino's
You are using 4 wire SPI here, so:
MOSI: 11//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
MISO: 12//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
SCK: 13//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
ESP8266-----------------------------------
Use:
#define __CS 16 //(D0)
#define __DC 5 //(D1)
#define __RST 4 //(D2)
SCLK:D5
MOSI:D7
*/
#define __CS1 10
#define __DC 9
/*
Teensy 3.x can use: 2,6,10,15,20,21,22,23
Arduino's 8 bit: any
DUE: check arduino site
If you do not use reset, tie it to +3V3
*/
//Display display;
uint8_t errorCode = 0;
TFT_ILI93XX tft = TFT_ILI93XX(__CS1, __DC);
const byte green_square[] PROGMEM ={16,16,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,};
const byte blue_square[] PROGMEM ={16,16,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,};
const byte red_square[] PROGMEM ={16,16,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,};
const byte yellow_square[] PROGMEM ={16,16,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,};
void setup() {
Serial.begin(38400);
long unsigned debug_start = millis();
while (!Serial && ((millis() - debug_start) <= 5000));
Serial.println("serial ok, testing lib...");
tft.begin();
//the following it's mainly for Teensy
//it will help you to understand if you have choosed the
//wrong combination of pins!
errorCode = tft.getErrorCode();
if (errorCode != 0) {
Serial.print("Init error! ");
if (bitRead(errorCode, 0)) Serial.print("MOSI or SCLK pin mismach!\n");
if (bitRead(errorCode, 1)) Serial.print("CS or DC pin mismach!\n");
}
else {
Serial.println("Inited");
}
}
// the loop routine runs over and over again forever
void loop(){
//updates the gamebuino (the display, the sound, the auto backlight... everything)
//returns true when it's time to render a new frame (20 times/second)
//if(gb.update()){
//prints Hello World! on the screen
// gb.display.drawBitmap(0,0,room_1);
// gb.display.setColor(BLACK);{
tft.drawBitmap1(70,70,green_square, 16,16,GREEN);
//}
//gb.display.setColor(GRAY);{
//gb.display.drawBitmap(player_x,player_y,sever_front_2);
if(buttons.repeat(BTN_L,1)){
//gb.display.setColor(BLACK);{
tft.drawBitmap1(70,70,blue_square,16,16 ,BLUE);
//}
//gb.display.setColor(GRAY);{
// gb.display.drawBitmap(player_x,player_y,sever_rear_2);
//}
// player_y = player_y - 1;}
//if(player_y <= 0){
// player_y = 0;}
//}
}
}