C (Programmiersprache) – die besten Beiträge

Wie weiße Linien auf Display bei Arduino UNO entfernen?

Ich habe mir das "LAFVIN 3.5 inch TFT LCD Touch Display Shield Module 480x320 SPI Serial ILI9488 with Touch Pen Compatible with Arduino" (Link Unten) gekauft und wollte es mit dem Arduino Uno ansteuern. Da ich in dem Bereich noch eher unerfahren bin und zu diesem speziellen Display keinerlei Daten online sind, habe ich ChatGPT gebeten einen Testcode dafür zu schreiben:

#include <TFT_eSPI.h>
#include <SPI.h>

TFT_eSPI tft = TFT_eSPI(); // Verwende die Setup-Datei

void setup() {
 tft.init();
 tft.setRotation(1); // 0-3
 tft.fillScreen(TFT_BLACK);
 tft.setTextColor(TFT_WHITE, TFT_BLACK);
 tft.setTextSize(2);
 tft.setCursor(50, 100);
 tft.println("LAFVIN ILI9488 Test!");
 delay(2000);
 // Farbtest
 tft.fillScreen(TFT_RED);
 delay(500);
 tft.fillScreen(TFT_GREEN);
 delay(500);
 tft.fillScreen(TFT_BLUE);
 delay(500);
 tft.fillScreen(TFT_BLACK);
}

void loop() {
 tft.drawCircle(random(320), random(240), random(10, 30), TFT_YELLOW);
 delay(100);
}

Die KI meinte noch ich soll die User_Select.h-Datei in der TFT_eSPI-Librarie mit dem folgenden Text ersetzen:

#define ILI9488_DRIVER
#define TFT_CS  10
#define TFT_DC  9
#define TFT_RST 8
#define TFT_MOSI 11
#define TFT_SCLK 13
#define TFT_MISO 12
#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_FONT6
#define LOAD_FONT7
#define LOAD_FONT8
#define LOAD_GFXFF
#define SPI_FREQUENCY 20000000

Der Sketch scheint zu funktionieren (macht was es soll etwas verblast im Hintergrund) allerdings sind im Vordergrund 2 weiße Linien, die sich über das ganze Display ziehen. Alles ist richtig verkabelt:

VCC -5V GND -GND CS- D10 RESET- D8 DC / RS- D9 SDI / MOSI-D11 SCK -D13 LED -5V (über 100Ω) T_CLK - D13 (geteilt) T_CS- D6 T_DIN - D11 (geteilt) T_DO -D12 T_IRQ -Nicht nötig SDO / MISO - D12

An der Hardware kann es auch nicht liegen, da es beim Neustart des Codes, das Display komplett grün färbt, ohne Linien.

Kann mir da jemand bitte helfen?

Link:

https://www.amazon.de/LAFVIN-3-5-inch-TFT-Compatible/dp/B0CQ86T4S9?crid=20WS4KEIOKM1W&dib=eyJ2IjoiMSJ9.J68Ud1C-2nuVCTfL1PxAptfxyB7uGufPDC4iW-x7GS-26tlMEMiJWmaDdIMuBL-Se6Eh-sHANAYNWQYHJhBrouXdfH1srpKN22RU_T9E7FIn-AA_DYVxtWLkYixHTD1oQY_8O0hoYSwvCIusxjze4ckHNoM2NzshzWsuIdxs0nqjFzmtI4-8U-1GqxbEJLwwUbOQ-Yw19sTBZWwVlOBFXWjHIw4QmAE-5DDASf0kEeLT7ktosacJVZEpZsTudJL-zTZzUi4sDUoopEOggP1cY-2F4R5JAbM9ulQB0ehxA3k.pRKfnBU0tCah9ij3m03vj538RU03jJpVmE7MyP249EU&dib_tag=se&keywords=arduino%2Bdisplay&qid=1747677201&refinements=p_36%3A-1700&rnid=82947031&sprefix=arduino%2Bdi%2Caps%2C108&sr=8-11&th=1

Bild zum Beitrag
programmieren, Arduino, C, C (Programmiersprache), Arduino Uno, Arduino IDE

verständinsproblem addressausgabe dynamische Liste?

Hallo,

ich habe eine Liste in C erstellt, dies scheint wohl zu funktionieren, allerdings habe ich ein Problem mit der Ausgabe der Adresse der einzelnen Elemente in der Liste

Zunächst rufe ich für alle Files die Funktion "appenFileName_v" auf.
zum schluss rufe ich dann noch einmal die Funktion: "printList_v" auf um zu überprüfen ob alle elemente vorhanden sind

struct fileList_ts
{
  char* name;
  struct fileList_ts* next;
};
static struct fileList_ts* fileList_ps = NULL;
static void appendFileName_v(char* value)
{
  struct fileList_ts *newElement_ps;
  if (fileList_ps == NULL) // check if there is already an element in the list
  {
    if((fileList_ps = malloc(sizeof(struct fileList_ts))) == NULL)
    {
      ESP_LOGE(TAG, "no free memory for starting list");
    }
    else
    {
      ESP_LOGI(TAG, "address fileList_ps: %p", &fileList_ps);
      fileList_ps->name = (char *)malloc(strlen(value) + 1);
      strcpy(fileList_ps->name, value);
      fileList_ps->next = NULL;
    }
  }
  else
  {
    newElement_ps = fileList_ps; // point to first element
    while(newElement_ps->next != NULL) // go to last element
    {
      newElement_ps = newElement_ps->next;
    }
    if((newElement_ps->next = malloc(sizeof(struct fileList_ts))) == NULL) // reserve memory for the new element
    {
      ESP_LOGE(TAG, "no free memory for the new element");
    }
    else
    {
      newElement_ps = newElement_ps->next; // point to new memory
      newElement_ps->name = (char *)malloc(strlen(value) + 1);
      ESP_LOGI(TAG, "address newElement: %p", &newElement_ps);
      strcpy(newElement_ps->name, value);
      newElement_ps->next = NULL;
    }
  }
}

static void printList_v(void)
{
    struct fileList_ts *pointer = fileList_ps;
    while(pointer != NULL) {
        ESP_LOGI(TAG, "printList: %p %s", &pointer, pointer->name);
        pointer = pointer->next;
   }
}


Die Ausgabe ist dann wie folg:

I (634) SD_CARD: address fileList_ps: 0x3ffb2fbc  SYSTEM~1
I (634) SD_CARD: address newElement: 0x3ffb8f10  HELLO.TXT
I (634) SD_CARD: address newElement: 0x3ffb8f10  FOO.TXT
I (634) SD_CARD: address newElement: 0x3ffb8f10  DREIECK.BMP
I (644) SD_CARD: address newElement: 0x3ffb8f10  DREIECK.PNG
I (644) SD_CARD: address newElement: 0x3ffb8f10  KREUZ.BMP
I (664) SD_CARD: address newElement: 0x3ffb8f10  TEST.BMP
I (664) SD_CARD: address newElement: 0x3ffb8f10  TEST2.BMP
I (664) SD_CARD: printList: 0x3ffb8f10 SYSTEM~1
I (664) SD_CARD: printList: 0x3ffb8f10 HELLO.TXT
I (674) SD_CARD: printList: 0x3ffb8f10 FOO.TXT
I (674) SD_CARD: printList: 0x3ffb8f10 DREIECK.BMP
I (674) SD_CARD: printList: 0x3ffb8f10 DREIECK.PNG
I (694) SD_CARD: printList: 0x3ffb8f10 KREUZ.BMP
I (694) SD_CARD: printList: 0x3ffb8f10 TEST.BMP
I (694) SD_CARD: printList: 0x3ffb8f10 TEST2.BMP

Die Namen sind also alle in der Liste drinn. Nur wundert es mich, dass die Adresse überall die selbe ist.

Code, Programmiersprache, Liste, C (Programmiersprache)

ESP32 Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled?

Hallo,

ich habe ein Problem mit meinem Code auf einem ESP32.
ich habe einen array von struct, welchen ich beschreiben möchte:

file_1.c

typedef struct{
  uint8_t green;
  uint8_t red;
  uint8_t blue;
}ledStrip_ts;
... ... ...
static ledStrip_ts lightbar_as[100];
... ... ...
      if (true == getPixelData_b(&graphicData_s.numOfCols_u32, &graphicData_s.numOfRows_u32, (uint8_t*)&lightbar_as[0]))... ... ...  

file_2.c:

bool getPixelData_b(uint32_t* numOfCols_pu32, uint32_t* numOfRows_pu32, uint8_t* pixelData_pu8)
{
.... .... ....
                bmpColorData_ps = bmpGetGraphicData_v(numOfCols_pu32, numOfRows_pu32);
                ESP_LOGI(TAG, "%p    numOfCols_pu32: %lu  numOfRows_pu32: %lu", bmpColorData_ps, *numOfCols_pu32, *numOfRows_pu32);
... ... ...
                uint32_t counter1 = 0;
                uint32_t counter2 = 0;
                uint32_t counter3 = 0;
                uint32_t y = 0;
                for(uint32_t x=0; x<(*numOfRows_pu32); x++)
                {
                    for(y=0; y<(*numOfCols_pu32); y++)
                    {
                        pixelData_pu8[counter1++] = bmpColorData_ps[counter2].green;
                        pixelData_pu8[counter1++] = bmpColorData_ps[counter2].red;
                        pixelData_pu8[counter1++] = bmpColorData_ps[counter2].blue;
                        ESP_LOGI(TAG, "r: 0x%02X    g: 0x%02X    b: 0x%02X", pixelData_pu8[counter3+1], pixelData_pu8[counter3], pixelData_pu8[counter3+2]);
                        counter2++;
                        counter3+=3;
                    }
                    counter2 += (4 - (y%4));    // Compression = 0 (BI_RGB): Bilddaten sind unkomprimiert, bedeutet
                                                // "Jede Bildzeile ist durch rechtsseitiges Auffüllen mit Nullen auf ein 
                                                // ganzzahliges Vielfaches von 4 Bytes ausgerichtet." (Wikipedia)
                }
... ... ...

Laut Ausgabe (und das ist richtig, sind es 14x14 pixel.
105 Elemente werden geschrieben, dann bekomme ich den Error.
Doch eigentlich ist mein Buffer doch 100 Elemente * 3 Byte (uint8_t red, green, blue). Also 300 Byte.

Als Ausgabe bekomme ich dann:

I (1414) GRAPHIC: r: 0xFF    g: 0xFF    b: 0xFF
I (1414) GRAPHIC: r: 0xFF    g: 0xFF    b: 0xED
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.


Core  0 register dump:
PC      : 0x400d836e  PS      : 0x00060730  A0      : 0x800d7e4e  A1      : 0x3ffbcf70
A2      : 0x3ffb2e38  A3      : 0x0000013b  A4      : 0x3ffb2e3c  A5      : 0x00000007
A6      : 0x00000077  A7      : 0x0000013b  A8      : 0x0000013d  A9      : 0x3ffb2f74
A10     : 0x00000165  A11     : 0x3ffb2f78  A12     : 0xc0ee0164  A13     : 0x00000586
A14     : 0x3f403a78  A15     : 0x000000ff  SAR     : 0x00000004  EXCCAUSE: 0x0000001c
EXCVADDR: 0xc0ee0164  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffd




Backtrace: 0x400d836b:0x3ffbcf70 0x400d7e4b:0x3ffbcfc0 0x400d7f3c:0x3ffbcff0 0x40088075:0x3ffbd020
--- 0x400d836e: getPixelData_b at C:/Projekte/ESP32/leuchtstab/main/graphic.c:101


--- 0x400014fd: strlen in ROM
--- 0x4000150d: strlen in ROM


--- 0x400d836b: getPixelData_b at C:/Projekte/ESP32/leuchtstab/main/graphic.c:101
--- 0x400d7e4b: lightbarExec_v at C:/Projekte/ESP32/leuchtstab/main/lightbar.c:116
--- 0x400d7f3c: lightbarTask_v at C:/Projekte/ESP32/leuchtstab/main/lightbar.c:184 (discriminator 1)
--- 0x40088075: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.4/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139

Wenn ich nur ein 3x2 pixel bild nehme, funktioniert es ohne probleme.

Code, C (Programmiersprache), ESP32

Meistgelesene Beiträge zum Thema C (Programmiersprache)