- Mon Aug 29, 2016 11:53 am
#54073
/// the esp12e USES qio FOR THE PROGRAM FLASH
/// the places GOPI10 and GPIO9 as unavailable
/// unless the flash inside the can is removed and pins 3 and 7 lifted
/// pin 3 is wired to 7 and then to 3.3v
/// pads 3 and 7 are connected to GPIO9 and GPIO10
/// since GPIO9 and GPIO10 are now free and then set the FLASH to DIO mode
//// QIO will now not work
/// DIO mode is now needed to flash the arduino IDE NodeMCU v1 12E board
/// +--------+
/// _CS |1 8| 3.3v
/// DO |2 7| _HOLD
/// _WP |3 6| CLK
/// GND |4 5| DI
/// +--------+
/// 25Q32 4m byte flash
The libraries used
#include <SPI.h>
#include <SD.h>
#include <Ticker.h>
#include <Adafruit_ILI9341esp.h>
#include <Adafruit_GFX.h>
#include <XPT2046.h>
#define TFT_DC 2
#define TFT_CS 15
#define Touch_CS 4
#define Touch_IRQ 5
#define SD_CS 9
// For esp8266 chipSelect 9 is GPIO9 SD2 needs flash 3 7 pins lifting
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
XPT2046 touch(Touch_CS, Touch_IRQ);
Adafruit_GFX_Button buttons[3]; //// declare button array
In setup code somewhat like this snippet ( it is not all the code in setup but could help you see what is needed for your code)
pinMode(SD_CS,FUNCTION_3); //// needed since GPIO9 is function 3
pinMode(SD_CS, OUTPUT);
//// deselect all SPI devices ( helps with a clean start of the SPI common bus)
digitalWrite(SD_CS,HIGH);
digitalWrite(TFT_CS ,HIGH);
digitalWrite(Touch_CS ,HIGH);
Serial.begin(115200);
delay(1000);
tft.begin();
touch.begin(tft.width(), tft.height()); // Must be done before setting rotation defined in <Adafruit_ILI9341esp.h>
tft.setRotation(0);
scrollAddress(0);
setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA); //// lines from the top , lines from the bottom
Serial.println();
Serial.println("controller ILI9341 with XPT2046 touch 2.8in LCD");
Serial.print("tftx ="); Serial.print(tft.width()); Serial.print(" tfty ="); Serial.println(tft.height());
// Replace these for your screen module
touch.setCalibration(208, 1752, 1760, 203);
///initButton(&tft, 100, 100, 70, 40, ILI9341_DARKCYAN, ILI9341_BLUE, ILI9341_GREENYELLOW, "Clear", 2)
/// x y w h outline color fill color text color font size
buttons[0].initButton(&tft, 30, 300, 50, 40, ILI9341_DARKCYAN, ILI9341_BLUE, ILI9341_GREENYELLOW, "File", 1);
buttons[1].initButton(&tft, 120, 300, 50, 40, ILI9341_DARKCYAN, ILI9341_BLUE, ILI9341_GREENYELLOW, "Clear", 1);
buttons[2].initButton(&tft, 210, 300, 50, 40, ILI9341_DARKCYAN, ILI9341_BLUE, ILI9341_GREENYELLOW, "E-Mail", 1);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(0,0);
tft.setTextColor(ILI9341_WHITE,ILI9341_BLACK);
tft.setTextSize(1);
tft.println("\nInitializing SD card");
if (!SD.begin( SD_CS)) //// note hangs here if SD not present or not even wired.
{
tft.println("Card failed, or not present");
// don't do anything more:
SD_card_present=false;
}
if(SD_card_present==true)
{
tft.println("card initialized.");
}