Restore official Waveshare display register init sequence and LEDC backlight driver to fix blank display screen
This commit is contained in:
@@ -3,9 +3,10 @@
|
|||||||
SPIClass LCDspi(FSPI);
|
SPIClass LCDspi(FSPI);
|
||||||
#define SPI_WRITE(_dat) LCDspi.transfer(_dat)
|
#define SPI_WRITE(_dat) LCDspi.transfer(_dat)
|
||||||
#define SPI_WRITE_Word(_dat) LCDspi.transfer16(_dat)
|
#define SPI_WRITE_Word(_dat) LCDspi.transfer16(_dat)
|
||||||
|
|
||||||
void SPI_Init()
|
void SPI_Init()
|
||||||
{
|
{
|
||||||
LCDspi.begin(EXAMPLE_PIN_NUM_SCLK,EXAMPLE_PIN_NUM_MISO,EXAMPLE_PIN_NUM_MOSI);
|
LCDspi.begin(EXAMPLE_PIN_NUM_SCLK, EXAMPLE_PIN_NUM_MISO, EXAMPLE_PIN_NUM_MOSI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LCD_WriteCommand(uint8_t Cmd)
|
void LCD_WriteCommand(uint8_t Cmd)
|
||||||
@@ -17,6 +18,7 @@ void LCD_WriteCommand(uint8_t Cmd)
|
|||||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, HIGH);
|
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, HIGH);
|
||||||
LCDspi.endTransaction();
|
LCDspi.endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LCD_WriteData(uint8_t Data)
|
void LCD_WriteData(uint8_t Data)
|
||||||
{
|
{
|
||||||
LCDspi.beginTransaction(SPISettings(SPIFreq, MSBFIRST, SPI_MODE0));
|
LCDspi.beginTransaction(SPISettings(SPIFreq, MSBFIRST, SPI_MODE0));
|
||||||
@@ -26,6 +28,7 @@ void LCD_WriteData(uint8_t Data)
|
|||||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, HIGH);
|
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, HIGH);
|
||||||
LCDspi.endTransaction();
|
LCDspi.endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LCD_WriteData_Word(uint16_t Data)
|
void LCD_WriteData_Word(uint16_t Data)
|
||||||
{
|
{
|
||||||
LCDspi.beginTransaction(SPISettings(SPIFreq, MSBFIRST, SPI_MODE0));
|
LCDspi.beginTransaction(SPISettings(SPIFreq, MSBFIRST, SPI_MODE0));
|
||||||
@@ -35,7 +38,8 @@ void LCD_WriteData_Word(uint16_t Data)
|
|||||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, HIGH);
|
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, HIGH);
|
||||||
LCDspi.endTransaction();
|
LCDspi.endTransaction();
|
||||||
}
|
}
|
||||||
void LCD_WriteData_nbyte(uint8_t* SetData,uint8_t* ReadData,uint32_t Size)
|
|
||||||
|
void LCD_WriteData_nbyte(uint8_t* SetData, uint8_t* ReadData, uint32_t Size)
|
||||||
{
|
{
|
||||||
LCDspi.beginTransaction(SPISettings(SPIFreq, MSBFIRST, SPI_MODE0));
|
LCDspi.beginTransaction(SPISettings(SPIFreq, MSBFIRST, SPI_MODE0));
|
||||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, LOW);
|
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, LOW);
|
||||||
@@ -54,6 +58,7 @@ void LCD_Reset(void)
|
|||||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_RST, HIGH);
|
digitalWrite(EXAMPLE_PIN_NUM_LCD_RST, HIGH);
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LCD_Init(void)
|
void LCD_Init(void)
|
||||||
{
|
{
|
||||||
pinMode(EXAMPLE_PIN_NUM_LCD_CS, OUTPUT);
|
pinMode(EXAMPLE_PIN_NUM_LCD_CS, OUTPUT);
|
||||||
@@ -62,192 +67,107 @@ void LCD_Init(void)
|
|||||||
Backlight_Init();
|
Backlight_Init();
|
||||||
SPI_Init();
|
SPI_Init();
|
||||||
|
|
||||||
// Reset LCD
|
LCD_Reset();
|
||||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_RST, LOW);
|
|
||||||
delay(10);
|
|
||||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_RST, HIGH);
|
|
||||||
delay(50);
|
|
||||||
|
|
||||||
//************* JD9853 Start Initial Sequence **********//
|
//************* Start Initial Sequence **********//
|
||||||
LCD_WriteCommand(0x11); // Sleep Out
|
LCD_WriteCommand(0x11);
|
||||||
delay(120);
|
delay(120);
|
||||||
|
LCD_WriteCommand(0x36);
|
||||||
LCD_WriteCommand(0xDF);
|
|
||||||
LCD_WriteData(0x98);
|
|
||||||
LCD_WriteData(0x53);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xB2);
|
|
||||||
LCD_WriteData(0x23);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xB7);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0x47);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0x6F);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xBB);
|
|
||||||
LCD_WriteData(0x1C);
|
|
||||||
LCD_WriteData(0x1A);
|
|
||||||
LCD_WriteData(0x55);
|
|
||||||
LCD_WriteData(0x73);
|
|
||||||
LCD_WriteData(0x63);
|
|
||||||
LCD_WriteData(0xF0);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xC0);
|
|
||||||
LCD_WriteData(0x44);
|
|
||||||
LCD_WriteData(0xA4);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xC1);
|
|
||||||
LCD_WriteData(0x16);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xC3);
|
|
||||||
LCD_WriteData(0x7D);
|
|
||||||
LCD_WriteData(0x07);
|
|
||||||
LCD_WriteData(0x14);
|
|
||||||
LCD_WriteData(0x06);
|
|
||||||
LCD_WriteData(0xCF);
|
|
||||||
LCD_WriteData(0x71);
|
|
||||||
LCD_WriteData(0x72);
|
|
||||||
LCD_WriteData(0x77);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xC4);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0xA0);
|
|
||||||
LCD_WriteData(0x79);
|
|
||||||
LCD_WriteData(0x0B);
|
|
||||||
LCD_WriteData(0x0A);
|
|
||||||
LCD_WriteData(0x16);
|
|
||||||
LCD_WriteData(0x79);
|
|
||||||
LCD_WriteData(0x0B);
|
|
||||||
LCD_WriteData(0x0A);
|
|
||||||
LCD_WriteData(0x16);
|
|
||||||
LCD_WriteData(0x82);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xC8);
|
|
||||||
const uint8_t c8_data[] = {
|
|
||||||
0x3F, 0x32, 0x29, 0x29, 0x27, 0x2B, 0x27, 0x28, 0x28, 0x26, 0x25, 0x17, 0x12, 0x0D, 0x04, 0x00,
|
|
||||||
0x3F, 0x32, 0x29, 0x29, 0x27, 0x2B, 0x27, 0x28, 0x28, 0x26, 0x25, 0x17, 0x12, 0x0D, 0x04, 0x00
|
|
||||||
};
|
|
||||||
for (int i = 0; i < 32; i++) {
|
|
||||||
LCD_WriteData(c8_data[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xD0);
|
|
||||||
LCD_WriteData(0x04);
|
|
||||||
LCD_WriteData(0x06);
|
|
||||||
LCD_WriteData(0x6B);
|
|
||||||
LCD_WriteData(0x0F);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xD7);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0x30);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xE6);
|
|
||||||
LCD_WriteData(0x14);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xDE);
|
|
||||||
LCD_WriteData(0x01);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xB7);
|
|
||||||
LCD_WriteData(0x03);
|
|
||||||
LCD_WriteData(0x13);
|
|
||||||
LCD_WriteData(0xEF);
|
|
||||||
LCD_WriteData(0x35);
|
|
||||||
LCD_WriteData(0x35);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xC1);
|
|
||||||
LCD_WriteData(0x14);
|
|
||||||
LCD_WriteData(0x15);
|
|
||||||
LCD_WriteData(0xC0);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xC2);
|
|
||||||
LCD_WriteData(0x06);
|
|
||||||
LCD_WriteData(0x3A);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xC4);
|
|
||||||
LCD_WriteData(0x72);
|
|
||||||
LCD_WriteData(0x12);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xBE);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xDE);
|
|
||||||
LCD_WriteData(0x02);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xE5);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0x02);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xE5);
|
|
||||||
LCD_WriteData(0x01);
|
|
||||||
LCD_WriteData(0x02);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xDE);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0x35);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0x3A);
|
|
||||||
LCD_WriteData(0x05);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0x2A);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0x22);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0xCD);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0x2B);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0x01);
|
|
||||||
LCD_WriteData(0x3F);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xDE);
|
|
||||||
LCD_WriteData(0x02);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xE5);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
LCD_WriteData(0x02);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0xDE);
|
|
||||||
LCD_WriteData(0x00);
|
|
||||||
|
|
||||||
LCD_WriteCommand(0x36); // Rotation control
|
|
||||||
if (HORIZONTAL)
|
if (HORIZONTAL)
|
||||||
LCD_WriteData(0x00);
|
LCD_WriteData(0x00);
|
||||||
else
|
else
|
||||||
LCD_WriteData(0x70);
|
LCD_WriteData(0x70);
|
||||||
|
|
||||||
LCD_WriteCommand(0x21); // Display Inversion On
|
LCD_WriteCommand(0x3A);
|
||||||
|
LCD_WriteData(0x05);
|
||||||
|
|
||||||
delay(10);
|
LCD_WriteCommand(0xB0);
|
||||||
LCD_WriteCommand(0x29); // Display On
|
LCD_WriteData(0x00);
|
||||||
|
LCD_WriteData(0xE8);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xB2);
|
||||||
|
LCD_WriteData(0x0C);
|
||||||
|
LCD_WriteData(0x0C);
|
||||||
|
LCD_WriteData(0x00);
|
||||||
|
LCD_WriteData(0x33);
|
||||||
|
LCD_WriteData(0x33);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xB7);
|
||||||
|
LCD_WriteData(0x35);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xBB);
|
||||||
|
LCD_WriteData(0x35);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xC0);
|
||||||
|
LCD_WriteData(0x2C);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xC2);
|
||||||
|
LCD_WriteData(0x01);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xC3);
|
||||||
|
LCD_WriteData(0x13);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xC4);
|
||||||
|
LCD_WriteData(0x20);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xC6);
|
||||||
|
LCD_WriteData(0x0F);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xD0);
|
||||||
|
LCD_WriteData(0xA4);
|
||||||
|
LCD_WriteData(0xA1);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xD6);
|
||||||
|
LCD_WriteData(0xA1);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xE0);
|
||||||
|
LCD_WriteData(0xF0);
|
||||||
|
LCD_WriteData(0x00);
|
||||||
|
LCD_WriteData(0x04);
|
||||||
|
LCD_WriteData(0x04);
|
||||||
|
LCD_WriteData(0x04);
|
||||||
|
LCD_WriteData(0x05);
|
||||||
|
LCD_WriteData(0x29);
|
||||||
|
LCD_WriteData(0x33);
|
||||||
|
LCD_WriteData(0x3E);
|
||||||
|
LCD_WriteData(0x38);
|
||||||
|
LCD_WriteData(0x12);
|
||||||
|
LCD_WriteData(0x12);
|
||||||
|
LCD_WriteData(0x28);
|
||||||
|
LCD_WriteData(0x30);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0xE1);
|
||||||
|
LCD_WriteData(0xF0);
|
||||||
|
LCD_WriteData(0x07);
|
||||||
|
LCD_WriteData(0x0A);
|
||||||
|
LCD_WriteData(0x0D);
|
||||||
|
LCD_WriteData(0x0B);
|
||||||
|
LCD_WriteData(0x07);
|
||||||
|
LCD_WriteData(0x28);
|
||||||
|
LCD_WriteData(0x33);
|
||||||
|
LCD_WriteData(0x3E);
|
||||||
|
LCD_WriteData(0x36);
|
||||||
|
LCD_WriteData(0x14);
|
||||||
|
LCD_WriteData(0x14);
|
||||||
|
LCD_WriteData(0x29);
|
||||||
|
LCD_WriteData(0x32);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0x21);
|
||||||
|
|
||||||
|
LCD_WriteCommand(0x11);
|
||||||
|
delay(120);
|
||||||
|
LCD_WriteCommand(0x29);
|
||||||
}
|
}
|
||||||
/******************************************************************************
|
|
||||||
function: Set the cursor position
|
|
||||||
parameter :
|
|
||||||
Xstart: Start uint16_t x coordinate
|
|
||||||
Ystart: Start uint16_t y coordinate
|
|
||||||
Xend : End uint16_t coordinates
|
|
||||||
Yend : End uint16_t coordinatesen
|
|
||||||
******************************************************************************/
|
|
||||||
void LCD_SetCursor(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend)
|
void LCD_SetCursor(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend)
|
||||||
{
|
{
|
||||||
if (HORIZONTAL) {
|
if (HORIZONTAL) {
|
||||||
// set the X coordinates
|
|
||||||
LCD_WriteCommand(0x2A);
|
LCD_WriteCommand(0x2A);
|
||||||
LCD_WriteData(Xstart >> 8);
|
LCD_WriteData(Xstart >> 8);
|
||||||
LCD_WriteData(Xstart + Offset_X);
|
LCD_WriteData(Xstart + Offset_X);
|
||||||
LCD_WriteData(Xend >> 8);
|
LCD_WriteData(Xend >> 8);
|
||||||
LCD_WriteData(Xend + Offset_X);
|
LCD_WriteData(Xend + Offset_X);
|
||||||
|
|
||||||
// set the Y coordinates
|
|
||||||
LCD_WriteCommand(0x2B);
|
LCD_WriteCommand(0x2B);
|
||||||
LCD_WriteData(Ystart >> 8);
|
LCD_WriteData(Ystart >> 8);
|
||||||
LCD_WriteData(Ystart + Offset_Y);
|
LCD_WriteData(Ystart + Offset_Y);
|
||||||
@@ -255,13 +175,12 @@ void LCD_SetCursor(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Ye
|
|||||||
LCD_WriteData(Yend + Offset_Y);
|
LCD_WriteData(Yend + Offset_Y);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// set the X coordinates
|
|
||||||
LCD_WriteCommand(0x2A);
|
LCD_WriteCommand(0x2A);
|
||||||
LCD_WriteData(Ystart >> 8);
|
LCD_WriteData(Ystart >> 8);
|
||||||
LCD_WriteData(Ystart + Offset_Y);
|
LCD_WriteData(Ystart + Offset_Y);
|
||||||
LCD_WriteData(Yend >> 8);
|
LCD_WriteData(Yend >> 8);
|
||||||
LCD_WriteData(Yend + Offset_Y);
|
LCD_WriteData(Yend + Offset_Y);
|
||||||
// set the Y coordinates
|
|
||||||
LCD_WriteCommand(0x2B);
|
LCD_WriteCommand(0x2B);
|
||||||
LCD_WriteData(Xstart >> 8);
|
LCD_WriteData(Xstart >> 8);
|
||||||
LCD_WriteData(Xstart + Offset_X);
|
LCD_WriteData(Xstart + Offset_X);
|
||||||
@@ -270,15 +189,7 @@ void LCD_SetCursor(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Ye
|
|||||||
}
|
}
|
||||||
LCD_WriteCommand(0x2C);
|
LCD_WriteCommand(0x2C);
|
||||||
}
|
}
|
||||||
/******************************************************************************
|
|
||||||
function: Refresh the image in an area
|
|
||||||
parameter :
|
|
||||||
Xstart: Start uint16_t x coordinate
|
|
||||||
Ystart: Start uint16_t y coordinate
|
|
||||||
Xend : End uint16_t coordinates
|
|
||||||
Yend : End uint16_t coordinates
|
|
||||||
color : Set the color
|
|
||||||
******************************************************************************/
|
|
||||||
void LCD_addWindow(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend, uint16_t* color)
|
void LCD_addWindow(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend, uint16_t* color)
|
||||||
{
|
{
|
||||||
uint16_t Show_Width = Xend - Xstart + 1;
|
uint16_t Show_Width = Xend - Xstart + 1;
|
||||||
@@ -293,19 +204,16 @@ void LCD_addWindow(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yen
|
|||||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, HIGH);
|
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, HIGH);
|
||||||
LCDspi.endTransaction();
|
LCDspi.endTransaction();
|
||||||
}
|
}
|
||||||
// backlight
|
|
||||||
void Backlight_Init(void)
|
void Backlight_Init(void)
|
||||||
{
|
{
|
||||||
pinMode(EXAMPLE_PIN_NUM_BK_LIGHT, OUTPUT);
|
ledcAttach(EXAMPLE_PIN_NUM_BK_LIGHT, Frequency, Resolution);
|
||||||
digitalWrite(EXAMPLE_PIN_NUM_BK_LIGHT, HIGH); // Set backlight to full brightness
|
ledcWrite(EXAMPLE_PIN_NUM_BK_LIGHT, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set_Backlight(uint8_t Light) //
|
void Set_Backlight(uint8_t Light)
|
||||||
{
|
{
|
||||||
pinMode(EXAMPLE_PIN_NUM_BK_LIGHT, OUTPUT);
|
if (Light > 100) Light = 100;
|
||||||
if (Light > 0) {
|
uint32_t duty = Light * 10;
|
||||||
digitalWrite(EXAMPLE_PIN_NUM_BK_LIGHT, HIGH);
|
ledcWrite(EXAMPLE_PIN_NUM_BK_LIGHT, duty);
|
||||||
} else {
|
|
||||||
digitalWrite(EXAMPLE_PIN_NUM_BK_LIGHT, LOW);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
|
|
||||||
#define SPIFreq 80000000
|
#define SPIFreq 80000000
|
||||||
#define EXAMPLE_PIN_NUM_MISO -1
|
#define EXAMPLE_PIN_NUM_MISO -1
|
||||||
#define EXAMPLE_PIN_NUM_MOSI 39
|
#define EXAMPLE_PIN_NUM_MOSI 45
|
||||||
#define EXAMPLE_PIN_NUM_SCLK 38
|
#define EXAMPLE_PIN_NUM_SCLK 40
|
||||||
#define EXAMPLE_PIN_NUM_LCD_CS 21
|
#define EXAMPLE_PIN_NUM_LCD_CS 42
|
||||||
#define EXAMPLE_PIN_NUM_LCD_DC 45
|
#define EXAMPLE_PIN_NUM_LCD_DC 41
|
||||||
#define EXAMPLE_PIN_NUM_LCD_RST 40
|
#define EXAMPLE_PIN_NUM_LCD_RST 39
|
||||||
#define EXAMPLE_PIN_NUM_BK_LIGHT 46
|
#define EXAMPLE_PIN_NUM_BK_LIGHT 48
|
||||||
#define Frequency 1000 // PWM frequencyconst
|
#define Frequency 1000 // PWM frequencyconst
|
||||||
#define Resolution 10
|
#define Resolution 10
|
||||||
|
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ int g_favoriteMemoryId = -1;
|
|||||||
|
|
||||||
// ── SD Init ───────────────────────────────────────────────────────────────────
|
// ── SD Init ───────────────────────────────────────────────────────────────────
|
||||||
void SD_Init() {
|
void SD_Init() {
|
||||||
if (!SD_MMC.setPins(SD_CLK_PIN, SD_CMD_PIN, SD_D0_PIN)) {
|
if (!SD_MMC.setPins(SD_CLK_PIN, SD_CMD_PIN, SD_D0_PIN, SD_D1_PIN, SD_D2_PIN, SD_D3_PIN)) {
|
||||||
printf("SD MMC: Pin change failed!\r\n");
|
printf("SD MMC: Pin change failed!\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!SD_MMC.begin("/sdcard", true, true)) {
|
if (!SD_MMC.begin("/sdcard", false, true)) {
|
||||||
printf("SD card initialization failed!\r\n");
|
printf("SD card initialization failed!\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("SD card OK (1-bit mode)\r\n");
|
printf("SD card OK (4-bit mode)\r\n");
|
||||||
uint8_t cardType = SD_MMC.cardType();
|
uint8_t cardType = SD_MMC.cardType();
|
||||||
if (cardType == CARD_NONE) { printf("No SD card attached\r\n"); return; }
|
if (cardType == CARD_NONE) { printf("No SD card attached\r\n"); return; }
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,13 @@
|
|||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
#include "SD_MMC.h"
|
#include "SD_MMC.h"
|
||||||
|
|
||||||
// SD card MMC pins (1-bit mode to avoid GPIO 21 conflict with LCD_CS)
|
// SD card MMC pins (4-bit mode, fully compatible now LCD_CS is on GPIO 42)
|
||||||
#define SD_CLK_PIN 14
|
#define SD_CLK_PIN 14
|
||||||
#define SD_CMD_PIN 15
|
#define SD_CMD_PIN 15
|
||||||
#define SD_D0_PIN 16
|
#define SD_D0_PIN 16
|
||||||
|
#define SD_D1_PIN 18
|
||||||
|
#define SD_D2_PIN 17
|
||||||
|
#define SD_D3_PIN 21
|
||||||
|
|
||||||
#define MAX_MEMORIES 50
|
#define MAX_MEMORIES 50
|
||||||
#define MAX_NAME_LEN 64
|
#define MAX_NAME_LEN 64
|
||||||
|
|||||||
Reference in New Issue
Block a user