Skip to content

Commit 9a0c63d

Browse files
committed
prepare for ESP32S3
1 parent 628de34 commit 9a0c63d

File tree

5 files changed

+59
-21
lines changed

5 files changed

+59
-21
lines changed

lib/tftLib/src/tft.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// first release on 09/2019
2-
// updated on May 09 2022
2+
// updated on May 31 2022
33

44
#include "Arduino.h"
55
#include "tft.h"
@@ -4185,16 +4185,17 @@ TP::TP(uint8_t CS, uint8_t IRQ){
41854185
pinMode(TP_IRQ, INPUT);
41864186
TP_SPI=SPISettings(400000, MSBFIRST, SPI_MODE0); //slower speed
41874187
_rotation=0;
4188+
SPIClass *x = TFT::spi_TFT;
41884189
}
41894190

41904191
uint16_t TP::TP_Send(uint8_t set_val){
41914192
uint16_t get_val;
4192-
SPI.beginTransaction(TP_SPI); // Prevent other SPI users
4193+
TFT::spi_TFT->beginTransaction(TP_SPI); // Prevent other SPI users
41934194
digitalWrite(TP_CS, 0);
4194-
SPI.write(set_val);
4195-
get_val=SPI.transfer16(0);
4195+
TFT::spi_TFT->write(set_val);
4196+
get_val = TFT::spi_TFT->transfer16(0);
41964197
digitalWrite(TP_CS, 1);
4197-
SPI.endTransaction(); // Allow other SPI users
4198+
TFT::spi_TFT->endTransaction(); // Allow other SPI users
41984199
return get_val>>4;
41994200
}
42004201

lib/tftLib/src/tft.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// first release on 09/2019
2-
// updated on May 09 2022
2+
// updated on May 31 2022
33

44

55
#pragma once
@@ -201,7 +201,9 @@ virtual size_t write(const uint8_t *buffer, size_t size);
201201
uint8_t _TFTcontroller = ILI9341;
202202

203203
SPISettings TFT_SPI; // SPI settings for this slave
204-
SPIClass* spi_TFT = NULL;
204+
public:
205+
SPIClass* spi_TFT = NULL; // use in class TP
206+
private:
205207
uint32_t _freq;
206208
uint16_t _height;
207209
uint16_t _width;
@@ -682,7 +684,7 @@ class JPEGDecoder {
682684

683685

684686

685-
class TP {
687+
class TP : public TFT {
686688
public:
687689

688690
TP(uint8_t TP_CS, uint8_t TP_IRQ);

platformio.ini

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
; https://docs.platformio.org/en/latest/platforms/espressif32.html
1010

1111
[env:esp32dev]
12-
;platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
13-
platform = https://github.com/platformio/platform-espressif32.git#v4.2.0
12+
;platform = https://github.com/platformio/platform-espressif32.git#v4.2.0
13+
platform = https://github.com/platformio/platform-espressif32.git#v4.3.0
14+
1415
board = esp32dev
16+
;board = esp32-s3-devkitc-1
17+
1518
board_build.f_cpu = 240000000L
1619
board_build.flash_size=4MB
1720
board_build.flash_freq=80m
@@ -29,7 +32,6 @@ lib_deps =
2932

3033

3134
platform_packages =
32-
platformio/tool-esptoolpy @ ~1.30100
3335
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1-RC1
3436
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3-RC1
3537
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#master

src/common.h

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// created: 10.02.2022
2-
// updated: 13.05.2022
2+
// updated: 31.05.2022
33

44
#pragma once
55

66
#define _SSID "mySSID" // Your WiFi credentials here
77
#define _PW "myWiFiPassword"
88
#define TZName "CET-1CEST,M3.5.0,M10.5.0/3" // Timezone (more TZNames in "rtime.cpp")
99
#define DECODER 1 // (0)VS1053 , (1)MAX98357A PCM5102A... (2)AC101 (3)ES8388 (4)WM8978
10-
#define TFT_CONTROLLER 3 // (0)ILI9341, (1)HX8347D, (2)ILI9486a, (3)ILI9486b, (4)ILI9488
10+
#define TFT_CONTROLLER 2 // (0)ILI9341, (1)HX8347D, (2)ILI9486a, (3)ILI9486b, (4)ILI9488
1111
#define DISPLAY_INVERSION 0 // (0) off (1) on
1212
#define TFT_FREQUENCY 40000000 // 27000000, 40000000, 80000000
1313
#define TFT_ROTATION 3 // 1 or 3 (landscape)
@@ -49,9 +49,9 @@
4949
#define SD_MMC_CLK 14 // cannot be changed
5050
#define SD_MMC_CMD 15 // cannot be changed
5151
#define IR_PIN 35
52-
#define SPI_MOSI 23 // TFT and TP (VSPI)
53-
#define SPI_MISO 19 // TFT and TP (VSPI)
54-
#define SPI_SCK 18 // TFT and TP (VSPI)
52+
#define TFT_MOSI 23 // TFT and TP (VSPI)
53+
#define TFT_MISO 19 // TFT and TP (VSPI)
54+
#define TFT_SCK 18 // TFT and TP (VSPI)
5555
#if DECODER == 0
5656
#define VS1053_CS 33
5757
#define VS1053_DCS 4
@@ -153,7 +153,7 @@ void connecttoFS(const char* filename, uint32_t resumeFilePos = 0);
153153
void stopSong();
154154
void IRAM_ATTR headphoneDetect();
155155

156-
// //prototypes (audiotask.cpp)
156+
//prototypes (audiotask.cpp)
157157
void audioInit();
158158
void audioSetVolume(uint8_t vol);
159159
uint8_t audioGetVolume();
@@ -163,4 +163,34 @@ uint32_t audioStopSong();
163163
void audioSetTone(int8_t param0, int8_t param1, int8_t param2, int8_t param3 = 0);
164164
uint32_t audioInbuffFilled();
165165
uint32_t audioInbuffFree();
166-
boolean audioIsRunning();
166+
boolean audioIsRunning();
167+
168+
169+
170+
171+
172+
173+
174+
175+
// PINS for ESP32S3 (suggestion)
176+
177+
// // Digital I/O used
178+
// #define TFT_CS 7
179+
// #define TFT_DC 12
180+
// #define TFT_BL 6 // at -1 the brightness menu is not displayed
181+
// #define TP_IRQ 39
182+
// #define TP_CS 15
183+
// #define SD_MMC_D0 11
184+
// #define SD_MMC_CLK 13
185+
// #define SD_MMC_CMD 14
186+
// #define IR_PIN 35
187+
// #define SPI_MOSI 18 // TFT and TP (FSPI)
188+
// #define SPI_MISO 2 // TFT and TP (FSPI)
189+
// #define SPI_SCK 17 // TFT and TP (FSPI)
190+
191+
192+
// #define I2S_DOUT 9
193+
// #define I2S_DIN -1 // pin not used
194+
// #define I2S_BCLK 3
195+
// #define I2S_LRC 1
196+
// #define I2S_MCLK 0 // mostly not used

src/main.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MiniWebRadio -- Webradio receiver for ESP32
33
44
first release on 03/2017
5-
Version 2.3b, May 19/2022
5+
Version 2.3b, May 31/2022
66
77
2.8" color display (320x240px) with controller ILI9341 or HX8347D (SPI) or
88
3.5" color display (480x320px) wiht controller ILI9486 or ILI9488 (SPI)
@@ -980,7 +980,6 @@ void setup(){
980980
Serial.printf("Arduino Version: %d.%d.%d\n", avMajor, avMinor, avPatch);
981981

982982
Serial.print("\n\n");
983-
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI); // VSPI
984983
mutex_rtc = xSemaphoreCreateMutex();
985984
mutex_display = xSemaphoreCreateMutex();
986985
SerialPrintfln("");
@@ -1006,8 +1005,12 @@ void setup(){
10061005
pref.begin("MiniWebRadio", false); // instance of preferences for defaults (tone, volume ...)
10071006
stations.begin("Stations", false); // instance of preferences for stations (name, url ...)
10081007

1008+
#if CONFIG_IDF_TARGET_ESP32
1009+
tft.begin(TFT_CS, TFT_DC, VSPI, TFT_MOSI, TFT_MISO, TFT_SCK); // Init TFT interface ESP32
1010+
#else
1011+
tft.begin(TFT_CS, TFT_DC, FSPI, TFT_MOSI, TFT_MISO, TFT_SCK); // Init TFT interface ESP32S3
1012+
#endif
10091013

1010-
tft.begin(TFT_CS, TFT_DC, VSPI); // Init TFT interface
10111014
tft.setFrequency(TFT_FREQUENCY);
10121015
tft.setRotation(TFT_ROTATION);
10131016
tp.setVersion(TP_VERSION);

0 commit comments

Comments
 (0)