Aggiungo questo post perche il primo era troppo lungo quindi questo e il proseguo de primo post
in questo inoltre ho inserito una sezione che interroga il dipslay ed ho risposte !!!!!
ma display rimane bianco gtigio
Waveshare_ILI9486-master2 ********************************************************
#include "Arduino.h"
#include <GFXcanvas16T.h>
#include <ILI9486_SPI.h>
#include <test_canvas.h>
#include <SPI.h>
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#if defined ARDUINO_ESP32_DEV
#define LCD_CS 22
#define LCD_DC 21
#define LCD_RST 4 // 255 = unused, connect to 3.3V
#define TCH_CS 5
#define TCH_IRQ 34
#define SPI_MOSI 23
#define SPI_SCLK 18
#define SPI_MISO 19
#define TFT_BACKLIGHT_PIN 255 /* -via transistor- */
#define BOARD "ARDUINO_ESP32_DEV"
ILI9486_SPI tft(/*CS=10 oppure ss default pin cs*/LCD_CS , /*DC=*/ LCD_DC, /*RST=*/ LCD_RST);
#elif
#define BOARD "NO DEVICE"
#endif
#define LED_BUILTIN 2
void init_pin(){
/*pinMode(LCD_RST,OUTPUT);
digitalWrite(LCD_RST,HIGH);
pinMode(LCD_CS,OUTPUT);
digitalWrite(LCD_CS,HIGH);
pinMode(TCH_CS,OUTPUT);
digitalWrite(TCH_CS,HIGH);
*/
pinMode (LED_BUILTIN, OUTPUT);
}
void led_blink(int LED = 2, int time_blink =1000){
digitalWrite(LED, HIGH);
delay(time_blink);
digitalWrite(LED, LOW);
delay(time_blink);
}
void diag_reg(const __FlashStringHelper *name, uint8_t reg, uint8_t n)
{
uint8_t x = reg;
Serial.print(name);
Serial.print(" (0x");
Serial.print(x < 0x10 ? "0" : "");
Serial.print(x, HEX);
Serial.print("):");
SPI.transfer(reg);
for (int i = 0; i < n; i++) {
uint8_t x = SPI.transfer( i);
Serial.print(x < 0x10 ? " 0" : " ");
Serial.print(x, HEX);
}
Serial.println("");
}
void diag_show(void)
{
diag_reg(F("ILI9488_RDDID "), 0x04, 5);
diag_reg(F("ILI9488_RDIMGFMT "), 0x0A, 1);
diag_reg(F("ILI9488_RDMADCTL "), 0x0B, 1);
diag_reg(F("ILI9488_RDPIXFMT "), 0x0C, 1);
diag_reg(F("ILI9488_RDSELFDIAG "), 0x0F, 1);
diag_reg(F("ILI9488_DFUNCTR "), 0xb6, 5);
diag_reg(F("ILI9488_PWCTR1 "), 0xC0, 3);
diag_reg(F("ILI9488_VMCTR1 "), 0xC5, 3);
diag_reg(F("ILI9488_VMCTR2 "), 0xC7, 2);
diag_reg(F("NVM Status "), 0xD2, 3);
diag_reg(F("ID4 "), 0xD3, 4);
diag_reg(F("ILI9488_RDID1 "), 0xDA, 2);
diag_reg(F("ILI9488_RDID2 "), 0xDB, 2);
diag_reg(F("ILI9488_RDID3 "), 0xDC, 2);
diag_reg(F("PGAMCTRL(Positive Gamma Control) "), 0xE0, 16);
diag_reg(F("NGAMCTRL(Negative Gamma Correction)"), 0xE1, 16);
diag_reg(F("INTERFACE "), 0xf6, 4);
diag_reg(F("Read Display Brightness Value "), 0x52, 2);
diag_reg(F("Read Display Pixel Format "), 0x0C, 2);
diag_reg(F("Read display identification info "), 0x04, 4);
diag_reg(F("Read display identification info "), 0xD3, 4);
diag_reg(F("Read Number of the Errors on DSI "), 0x05, 4);
diag_reg(F("Read Display Self-Diagnostic Result "), 0x0F, 4);
}
void setup() {
init_pin();
Serial.begin(115200);
SPI.begin(SPI_SCLK ,SPI_MISO,SPI_MOSI,LCD_CS);
tft.writeLine(0,0,100,300,RED);
Serial.print("tft.height () ");
Serial.println(String(tft.height ()));
Serial.print("tft.width () ");
Serial.println(String(tft.width ()));
diag_show();
}
void loop() {
led_blink(LED_BUILTIN);
}
tft_espi (allego file di configurane )****************************************************
#include <TFT_eSPI.h> // Graphics and font library for ILI9341 driver chip
#include <SPI.h>
#define TFT_GREY 0x5AEB // New colour
TFT_eSPI tft = TFT_eSPI(); // Invoke library
void setup(void) {
Serial.begin(115200);
Serial.println("Start");
tft.init();
tft.setRotation(2);
}
void loop() {
// Fill screen with grey so we can see the effect of printing with and without
// a background colour defined
tft.fillScreen(TFT_BLACK);
Serial.println("tft.fillScreen(TFT_BLACK);");
// Set "cursor" at top left corner of display (0,0) and select font 2
// (cursor will move to next line automatically during printing with 'tft.println'
// or stay on the line is there is room for the text with tft.print)
tft.setCursor(0, 0, 2);
// Set the font colour to be white with a black background, set text size multiplier to 1
tft.setTextColor(TFT_YELLOW,TFT_BLACK);
tft.setTextSize(1);
// We can now plot text on screen using the "print" class
tft.println("Hello World!");
// Set the font colour to be yellow with no background, set to font 7
tft.setTextColor(TFT_YELLOW); tft.setTextFont(7);
tft.println(1234.56);
// Set the font colour to be red with black background, set to font 4
tft.setTextColor(TFT_RED,TFT_BLACK); tft.setTextFont(4);
//tft.println(3735928559L, HEX); // Should print DEADBEEF
// Set the font colour to be green with black background, set to font 4
tft.setTextColor(TFT_GREEN,TFT_BLACK);
tft.setTextFont(4);
tft.println("Groop");
tft.println("I implore thee,");
// Change to font 2
tft.setTextFont(2);
tft.println("my foonting turlingdromes.");
tft.println("And hooptiously drangle me");
tft.println("with crinkly bindlewurdles,");
// This next line is deliberately made too long for the display width to test
// automatic text wrapping onto the next line
tft.println("Or I will rend thee in the gobberwarts with my blurglecruncheon, see if I don't!");
// Test some print formatting functions
float fnumber = 123.45;
// Set the font colour to be blue with no background, set to font 4
tft.setTextColor(TFT_BLUE); tft.setTextFont(4);
tft.print("Float = "); tft.println(fnumber); // Print floating point number
tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary
tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal
delay(10000);
}
ili9386***************************************************************************
<XPT2046_Touchscreen.h> **********************************************************
+cod
ILI9341Test_002
allego codice
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#if defined ARDUINO_ESP32_DEV
#define LCD_CS 15
#define LCD_DC 2
#define LCD_RST 4 // 255 = unused, connect to 3.3V
#define TCH_CS 22
#define TCH_IRQ 34
#define SPI_MOSI 23
#define SPI_SCLK 18
#define SPI_MISO 19
#define TFT_BACKLIGHT_PIN 255 /* -via transistor- */
#define BOARD "ARDUINO_ESP32_DEV"
#elif
#define BOARD "NO DEVICE"
#endif
XPT2046_Touchscreen ts(TCH_CS, TCH_IRQ);
void setup() {
pinMode(LCD_RST,OUTPUT);
digitalWrite(LCD_RST,HIGH);
pinMode(TCH_CS,OUTPUT);
pinMode(LCD_CS,OUTPUT);
Serial.begin(115200);
ts.begin();
while (!Serial && (millis() <= 1000));
Serial.print(BOARD);
SPI.begin(SPI_SCLK,SPI_MISO,SPI_MOSI);
}
void loop() {
TS_Point p = ts.getPoint();
if (ts.touched()) {
Serial.print("Pressure = ");
Serial.println(p.z);
Serial.print(", x = ");
Serial.println(p.x);
Serial.print(", y = ");
Serial.println(p.y);
}
}