TFT-LCD ansteuern, abfragen

Ohne viel zu machen, eine RTC programmieren und damit über Mosfet den Ardu einschalten, wenn Messung fertig, werte in die RTC schreiben danach wider abschalten.
Die RTC 3221 braucht bei 5 Volt: 3.6 mA (mit LED) / 0.64 mA (LED entfernt) und bei 3.3 Volt: 1.8 mA (mit LED) / 0.36 mA (LED entfernt).
Dadurch kann man sich viel Arbeit sparen.

Dann wird die Messung aber nur zu vordefinierten Zeiten starten, sie soll aber auch zu einem beliebigen Zeitpunkt von Hand ausgelöst werden.
Fraglich ist auch, ob der RTC entsprechend viele Zeitpunkte zulässt.

Irgend eine Lösung findet sich ....

cu

Du meinst wahrscheinlich die DS3231?

Warum machst du mit dem Display solche Klimmzüge, nur weil du es hast ?
Ein SPI-2,4"-TFT ist doch nicht so teuer, das man sich das noch leisten kann ?
Den Controller lässt du immer an der Spannung, evtl. im Sleep und holst den per Taste oder sonst was aus dem Sleep und schaltest das Display ein. Dein jetziges TFT kannst du doch für andere Projekt (die kommen sicher) noch nutzen.

Ja meinte die 3231.

Was meinst Du damit?
Weshalb das Ganze nicht läuft wollte ich schon rausfinden, was ich ja auch geschafft habe. Jetzt lerne und probiere ich ....

Das ist der Grundgedanke, den ich verfolge.

Redest Du hier jetzt von einem "harten" ein-, ausschalten über VCC oder von software gesteuertem? Der 9341 z.B. hat den Befehl display off, da bin ich noch am suchen, wie ich den ins Register kriege.

SPI wollte ich, weil ich da mit dem Uno ausgekommen wäre, aber da wird es wie gesagt speichermäßig eng.
Und wenn schon ein größerer Controller mit mehr Speicher, warum dann nicht nutzen.
Wahrscheinlich wird es eh daher ein etwas größeres Display, da ich, wenn ich es programmiertechnisch schaffe :thinking: eine etwas komplexere grafische Anzeige (heißt ein paar Spielereien :grinning:) mit einbinden will.

cu

Naja, weil diese Kombi nicht gerade stromsparend ist.
Im Display zieht den meisten Strom die Led und die kann man separat ausschalten.
Als Controller empfehle ich dann einen ESP8266 oder ESP32. Je nach Bedarf.
Beide haben genug Speicher und zudem noch WiFi.

Ja, Strom ist ein Problem, denn messe ich noch in echt. Aber wenn das Display die meiste Zeit aus ist und der Controller im sleep ....
Auf das Display schaut man im Normalfall 2-3 mal am Tag wenn die Ressourcen zu Ende gehen, vorher so gut wie nie. Und die Messung reicht auch alle 5 Minuten, lediglich wenn die Batteriespannungen kritisch werden sollte man öfter messen. Dann sollte man aber auch etwas dagegen tun.

Ich habe einen Beitrag gefunden, in der jemand den sleep-Befehl auf ein 2,8"-Display gebracht hat (leider nicht beschrieben wie) , aber das hat m.E. auch nur vier LED für die Hintergrundbeleuchtung. Die Werte für das Display, 57mA mit, 44mA ohne Hintergrundbeleuchtung -> 13mA Ersparnis. Wäre natürlich bei sechs LED etwas mehr.

Kennt jemand den Hintergrund?
Mein Mega 2560 ist heute angekommen, das Display soll ja damit laufen.
Es geht um die AdafruitTFTLCD-Bibliothek, auf die AZ-Delivery ja verweist.
Die Einträge in der pin_magic.h

// LCD Data Bit :   7   6   5   4   3   2   1   0
// Uno dig. pin :   7   6   5   4   3   2   9   8
// Uno port/pin : PD7 PD6 PD5 PD4 PD3 PD2 PB1 PB0
// Mega dig. pin:  29  28  27  26  25  24  23  22
// Mega port/pin: PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 (one contiguous PORT)

habe ich angepasst.

// LCD Data Bit :   7   6   5   4   3   2   1   0
// Uno dig. pin :   7   6   5   4   3   2   9   8
// Uno port/pin : PD7 PD6 PD5 PD4 PD3 PD2 PB1 PB0
// Mega dig. pin:   7   6   5   4   3   2   9   8
// Mega port/pin: PH4 PH3 PE3 PG5 PE5 PE4 PH6 PH5 (one contiguous PORT)

Geht natürlich trotzdem nicht, vermutlich wegen der kleinen Bemerkung dahinter, die steht nur beim Mega 2560?
Anscheinend kann man bei dem die Ports nicht frei zuordnen ...
Da eine freie Verdrahtung nicht vorgesehen ist .... :grinning:

cu

Da ich dein TFT nicht habe, nicht verwende, kann ich nicht helfen.
@fony kann da sicher mehr zu sagen.

Die Zuordnung der Datenpins sollte doch nichts mit einem speziellen Display zu tun haben?
Ich würde das Problem im Controller (eher nicht) oder der Bibliothek vermuten.

Wenn es ein Problem des Controllers wäre würde sich das doch sicher auf alles mit 8-Bit-Datenbus auswirken, schwer vorstellbar.

cu

Was meinst Du wie verbreitet ein 8Bit-Datenbus bei Microconrtollern ist?

Gruß Tommy

Wenn das deine Logik ist, meine ist es nicht.
Ich kann nur über Teile eine Aussage machen, die ich selbst kenne.
Das gilt auch für die nicht vorhandene Library.

Damit ist es für mich klar, wie du urteilst.

Ja hat er leider nicht für die LED das display off mach nur den Bildschirm schwarz oder grau deshalb wir von mir bekannten Lib nicht benutzt. Die LED am Display ist sofort an 5v und GND. Den für ein und ausschalten muss ein Transistor drauf auf der Platine sein was wenigstens bei meinem ist nicht der fall.
So schlau war ich auch schon :wink:

So in 2Std klemme ich den 2.4 an Mega, aber so wie geschrieben hat er mir probleme gemacht deshalb liegt er in der Ecke draufgeklemmt auf ein Nano, ist ja die gleiche MCU wie bei Uno deshalb muxt er nicht herum.

Darum geht es doch nicht ...
Sondern um Steckboards für die Arduinos, die eben dieses Problem haben, das die Datenpins "gemischt" sind. Die würden dann auf dem Mega 2560 nicht laufen.

Aber da es kein Problem des Controllers ist ..... :grinning:
Die Bibliothek des LCD-Wiki verwendet die gleiche Pinfolge wie beim UNO.

Naja, was ist mit display_off/on, (0x28, 0x29)?

Wieso, ich denke Du nutzt LCDWIKI_KBV?

class LCDWIKI_KBV:public LCDWIKI_GUI
{
	public:
	LCDWIKI_KBV(uint16_t model,uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t reset);
	LCDWIKI_KBV(int16_t wid,int16_t heg,uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t reset);
	void Init_LCD(void);
	void reset(void);
	void start(uint16_t ID);
	void Draw_Pixe(int16_t x, int16_t y, uint16_t color);
	void Write_Cmd(uint16_t cmd);
	void Write_Data(uint16_t data);
	void Write_Cmd_Data(uint16_t cmd, uint16_t data);

WriteCMD sollte doch passen, um einen Wert ins Register zu schreiben?

Was ich gleich mal teste ...

cu

Geh mall unter LCDWIKI_KBV, dort ist eine Datei lcd_mode die must du bearbeiten.
Meine will mall wider nicht auf beiden Mega, mit keiner Lib ist mir aber Wurst

Du redest jetzt vom reinen funktionieren?
Das ist aber nötig, keine Ahnung was das soll. Schaut man die Beispiele an steht dort schon eindeutig:

//Set the pins to the correct ones for your development shield or breakout board.
//when using the BREAKOUT BOARD only and using these 8 data lines to the LCD,
//pin usage as follow:
//             CS  CD  WR  RD  RST  D0  D1  D2  D3  D4  D5  D6  D7
//Arduino Uno  A3  A2  A1  A0  A4   8   9   2   3   4   5   6   7
//Arduino Mega A3  A2  A1  A0  A4   8   9   2   3   4   5   6   7

Völlig identische Pinbelegung zwischen UNO und MEGA.

Bezüglich Strom sparen, mit MCUFRIEND kann ich in das Register schreiben, allerdings gibt es keinen sichtbaren Unterschied zwischen sleep und off :thinking:, die Displaybeleuchtung bleibt an :grimacing:.

cu

Hab doch geschrieben ohne Transistor auf der Platine geht nicht. wie soll der ILI den ausschalten?
Ist doch nur Grafikchip und hat keine Leistungtransistoren drauf :wink:
Habe mein Bist zum laufen gebracht auf Mega damit ohne Angabe was für Treiber drauf ist, sucht sich selber den Treiber im Setup



#include <MCUFRIEND_kbv.h>
#include <Adafruit_GFX.h>    // Core graphics library


// wiring with UNO or Mega2560:
//--------------POWER Pins--------------------------------
//   5V  connects to DC 5V
//   GND connects to Ground
//   3V3 do not need to connect(NC)
//--------------LCD Display Pins--------------------------
//   LCD_RD   connects to Analog pin A0  
//   LCD_WR   connects to Analog pin A1  
//   LCD_RS   connects to Analog pin A2  
//   LCD_CS   connects to Analog pin A3  
//   LCD_RST  connects to Analog pin A4  
//   LCD_D0   connects to digital pin 8  
//   LCD_D1   connects to digital pin 9  
//   LCD_D2   connects to digital pin 2
//   LCD_D3   connects to digital pin 3
//   LCD_D4   connects to digital pin 4
//   LCD_D5   connects to digital pin 5
//   LCD_D6   connects to digital pin 6
//   LCD_D7   connects to digital pin 7
//--------------SD-card fuction Pins ----------------------
//This Connection Only for UNO, Do not support Mega2560
//because they use different Hardware-SPI Pins
//SD_SS    connects to digital pin 10
//SD_DI    connects to digital pin 11
//SD_DO    connects to digital pin 12
//SD_SCK   connects to digital pin 13

                       //RESET 
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
#define LCD_CS A3   // Chip Select goes to Analog 3
#define LCD_CD A2  // Command/Data goes to Analog 2
#define LCD_WR A1  // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

// Assign human-readable names to some common 16-bit color values:
#define  BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


MCUFRIEND_kbv tft;




unsigned long testFillScreen() {
  unsigned long start = micros();
  tft.fillScreen(BLACK);
  delay(300);
  tft.fillScreen(RED);delay(300);
  
  tft.fillScreen(GREEN);delay(300);
  tft.fillScreen(BLUE);delay(300);
  tft.fillScreen(BLACK);delay(300);
  tft.fillScreen(YELLOW);delay(300);
  return micros() - start;
}

unsigned long testText() {
  tft.fillScreen(BLACK);
  unsigned long start = micros();
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(YELLOW); tft.setTextSize(2);
  tft.println(1234.56);
  tft.setTextColor(RED);    tft.setTextSize(3);
  tft.println(0xDEADBEEF, HEX);
  tft.println();
  tft.setTextColor(GREEN);
  tft.setTextSize(5);
  tft.println("Groop");
  tft.setTextSize(2);
  tft.println("I implore thee,");
  tft.setTextSize(1);
  tft.println("my foonting turlingdromes.");
  tft.println("And hooptiously drangle me");
  tft.println("with crinkly bindlewurdles,");
  tft.println("Or I will rend thee");
  tft.println("in the gobberwarts");
  tft.println("with my blurglecruncheon,");
  tft.println("see if I don't!");
  return micros() - start;
}

unsigned long testLines(uint16_t color) {
  unsigned long start, t;
  int           x1, y1, x2, y2,
                w = tft.width(),
                h = tft.height();

  tft.fillScreen(BLACK);

  x1 = y1 = 0;
  y2    = h - 1;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = w - 1;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t     = micros() - start; // fillScreen doesn't count against timing

  tft.fillScreen(BLACK);

  x1    = w - 1;
  y1    = 0;
  y2    = h - 1;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = 0;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t    += micros() - start;

  tft.fillScreen(BLACK);

  x1    = 0;
  y1    = h - 1;
  y2    = 0;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = w - 1;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t    += micros() - start;

  tft.fillScreen(BLACK);

  x1    = w - 1;
  y1    = h - 1;
  y2    = 0;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = 0;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);

  return micros() - start;
}

unsigned long testFastLines(uint16_t color1, uint16_t color2) {
  unsigned long start;
  int           x, y, w = tft.width(), h = tft.height();

  tft.fillScreen(BLACK);
  start = micros();
  for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
  for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);

  return micros() - start;
}

unsigned long testRects(uint16_t color) {
  unsigned long start;
  int           n, i, i2,
                cx = tft.width()  / 2,
                cy = tft.height() / 2;

  tft.fillScreen(BLACK);
  n     = min(tft.width(), tft.height());
  start = micros();
  for(i=2; i<n; i+=6) {
    i2 = i / 2;
    tft.drawRect(cx-i2, cy-i2, i, i, color);
  }

  return micros() - start;
}

unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
  unsigned long start, t = 0;
  int           n, i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(BLACK);
  n = min(tft.width(), tft.height());
  for(i=n; i>0; i-=6) {
    i2    = i / 2;
    start = micros();
    tft.fillRect(cx-i2, cy-i2, i, i, color1);
    t    += micros() - start;
    // Outlines are not included in timing results
    tft.drawRect(cx-i2, cy-i2, i, i, color2);
  }

  return t;
}

unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;

  tft.fillScreen(BLACK);
  start = micros();
  for(x=radius; x<w; x+=r2) {
    for(y=radius; y<h; y+=r2) {
      tft.fillCircle(x, y, radius, color);
    }
  }

  return micros() - start;
}

unsigned long testCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int           x, y, r2 = radius * 2,
                w = tft.width()  + radius,
                h = tft.height() + radius;

  // Screen is not cleared for this one -- this is
  // intentional and does not affect the reported time.
  start = micros();
  for(x=0; x<w; x+=r2) {
    for(y=0; y<h; y+=r2) {
      tft.drawCircle(x, y, radius, color);
    }
  }

  return micros() - start;
}

unsigned long testTriangles() {
  unsigned long start;
  int           n, i, cx = tft.width()  / 2 - 1,
                      cy = tft.height() / 2 - 1;

  tft.fillScreen(BLACK);
  n     = min(cx, cy);
  start = micros();
  for(i=0; i<n; i+=5) {
    tft.drawTriangle(
      cx    , cy - i, // peak
      cx - i, cy + i, // bottom left
      cx + i, cy + i, // bottom right
      tft.color565(0, 0, i));
  }

  return micros() - start;
}

unsigned long testFilledTriangles() {
  unsigned long start, t = 0;
  int           i, cx = tft.width()  / 2 - 1,
                   cy = tft.height() / 2 - 1;

  tft.fillScreen(BLACK);
  start = micros();
  for(i=min(cx,cy); i>10; i-=5) {
    start = micros();
    tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(0, i, i));
    t += micros() - start;
    tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(i, i, 0));
  }

  return t;
}

unsigned long testRoundRects() {
  unsigned long start;
  int           w, i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(BLACK);
  w     = min(tft.width(), tft.height());
  start = micros();
  for(i=0; i<w; i+=6) {
    i2 = i / 2;
    tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
  }

  return micros() - start;
}

unsigned long testFilledRoundRects() {
  unsigned long start;
  int           i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(BLACK);
  start = micros();
  for(i=min(tft.width(), tft.height()); i>20; i-=6) {
    i2 = i / 2;
    tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
  }

  return micros() - start;
}
void setup(void) {
   Serial.begin(9600);
  Serial.println(F("TFT LCD test"));

  tft.reset();
}
void loop(void) {
  uint16_t identifier = tft.readID();
  if(identifier == 0x9325) {
    Serial.println(F("Found ILI9325 LCD driver"));
  } else if(identifier == 0x9328) {
    Serial.println(F("Found ILI9328 LCD driver"));
  } else if(identifier == 0x4535) {
    Serial.println(F("Found LGDP4535 LCD driver"));
  }else if(identifier == 0x7575) {
    Serial.println(F("Found HX8347G LCD driver"));
  } else if(identifier == 0x9595) {
    Serial.println(F("Found HX8347-I LCD driver"));
  } else if(identifier == 0x4747) {
    Serial.println(F("Found HX8347-D LCD driver"));
  } else if(identifier == 0x8347) {
    Serial.println(F("Found HX8347-A LCD driver"));
  }else if(identifier == 0x9341) {
    Serial.println(F("Found ILI9341 LCD driver"));
  }else if(identifier == 0x7783) {
    Serial.println(F("Found ST7781 LCD driver"));
  }else if(identifier == 0x8230) {
    Serial.println(F("Found UC8230 LCD driver"));  
  }else if(identifier == 0x8357) {
    Serial.println(F("Found HX8357D LCD driver"));
  } else if(identifier==0x0101){     
      identifier=0x9341;
      Serial.println(F("Found 0x9341 LCD driver"));
  }else if(identifier==0x7793){     
       Serial.println(F("Found ST7793 LCD driver"));
  }else if(identifier==0xB509){     
       Serial.println(F("Found R61509 LCD driver"));
  }else if(identifier==0x9486){     
       Serial.println(F("Found ILI9486 LCD driver"));
  }else if(identifier==0x9488){     
       Serial.println(F("Found ILI9488 LCD driver"));
  }else {
    Serial.print(F("Unknown LCD driver chip: "));
    Serial.println(identifier, HEX);
    Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
    Serial.println(F("  #define USE_ADAFRUIT_SHIELD_PINOUT"));
    Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
    Serial.println(F("If using the breakout board, it should NOT be #defined!"));
    Serial.println(F("Also if using the breakout, double-check that all wiring"));
    Serial.println(F("matches the tutorial."));
    identifier=0x9486; 
  }
  tft.begin(identifier); 

  Serial.println(F("Benchmark                Time (microseconds)"));

  Serial.print(F("Screen fill              "));
  Serial.println(testFillScreen());
  delay(500);

  Serial.print(F("Text                     "));
  Serial.println(testText());
  delay(3000);

  Serial.print(F("Lines                    "));
  Serial.println(testLines(CYAN));
  delay(500);

  Serial.print(F("Horiz/Vert Lines         "));
  Serial.println(testFastLines(RED, BLUE));
  delay(500);

  Serial.print(F("Rectangles (outline)     "));
  Serial.println(testRects(GREEN));
  delay(500);

  Serial.print(F("Rectangles (filled)      "));
  Serial.println(testFilledRects(YELLOW, MAGENTA));
  delay(500);

  Serial.print(F("Circles (filled)         "));
  Serial.println(testFilledCircles(10, MAGENTA));

  Serial.print(F("Circles (outline)        "));
  Serial.println(testCircles(10, WHITE));
  delay(500);

  Serial.print(F("Triangles (outline)      "));
  Serial.println(testTriangles());
  delay(500);

  Serial.print(F("Triangles (filled)       "));
  Serial.println(testFilledTriangles());
  delay(500);

  Serial.print(F("Rounded rects (outline)  "));
  Serial.println(testRoundRects());
  delay(500);

  Serial.print(F("Rounded rects (filled)   "));
  Serial.println(testFilledRoundRects());
  delay(500);

  Serial.println(F("Done!"));



  for(uint8_t rotation=0; rotation<4; rotation++) {
    tft.setRotation(rotation);
    testText();
    delay(2000);
  }
}

Naja, wenn der Hersteller im Datenblatt einen Befehl display_off hinterlegt sollte das auch funktionieren.
Wenn ich mir die Chips auf den Arduino-Boards ansehe ist da kein optischer Unterschied zu den Chips auf dem Display, und die können problemlos LED steuern (20mA). Die Displaybeleuchtung zieht ca. 45mA, das sollte also keines Leistungstransistors benötigen.

Hatte ich ja geschrieben, ist ein Problem der Adafruit, LCDWIKI und MCUFRIEND haben das Problem nicht.

Welche Pins verwendet Dein Display für den Touchscreen, hier war ja mein Hauptproblem?

Eigenartig ist auch, das die Kalibrierungsprogramme von LCDWIKI und MCUFRIEND unterschiedliche Werte bringen, ein Beispiel von LCDWIKI funktioniert nur mit den Werten von MCUFRIEND.

Durch die graphischen Spielereien werde ich wahrscheinlich ein 3,5"-Display nehmen, es soll ja auch gut erkennbar sein. Hat den Vorteil SPI und die Hintergrundbeleuchtung hat einen eigenen Pin, kann also seperat ausgeschaltet werden.

cu

Touch habe nicht probiert, ist aber egall mit welcher Lib hauptsache es tut, ich schreibe immer im sketch was für Lib benutzt wird,und bei komplizieten sachen kommen die Libs in Sketchordner ist doppelt gemoppelt, machr aber nichts, Festplatten kosten nix, und dir parr Kb verkraften die noch :laughing:

Um vollen spaß mit dem 3,5 haben ist ein ESP32 zu empfehlen mit der TFTeSPI Lib.
Die anderen == vom Oli Kraus (Ucglib), LCDWiki und Henning Karlsen (UTFT) sind nicht so schnell, wen es um viel zeichnen geht dann TFTeSPI und LCDWiki haben vollen umfang von Werkzeugen.
Mus dir Danke sagen, wegen Unterbrechung um dir Antwort schreiben habe herausgefunden warum mein TFT nicht funktionierte mit anderem ESP32 das Ding hatte ein kurzen zw GND und MOSI, kurze Behandlung mit Lötkolben --> Problem behoben :wink: