Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit d0fe1ad

Browse files
committed
Fix for newer boards ("21-2-20") on 320x240 mode
1 parent 0c6a2c1 commit d0fe1ad

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ZX-ESPectrum-Wiimote
22

3-
**IMPORTANT: as of december 2022, I have learned that some boards sold recently don't handle well the 4:3 (320x240) mode. I have set the 16:9 mode as the default. If you have one of these boards and try the 4:3 mode, you will get no picture, and you will need to Upload Filesystem Image (for internal storage) or to manually edit the boot.cfg (for external storage, in the SD card) and set asp169 to true.**
3+
**IMPORTANT: as of december 2022, I have learned that some boards sold recently (with text "21-2-20" on the board serigraphy) don't handle the 320x240 (4:3) mode correctly. I have set the 16:9 mode as the default. If you have one of these boards and try the 4:3 mode, you will get no picture. There is a flag FIX_320_240_TTGO_21 in hardconfig.h which you can uncomment, which activates some hardcoded values on Bitluni's VGA library and seem to do the trick.**
44

55
**IMPORTANT: this branch is for running on a Lilygo TTGo vga32 board.**
66

Diff for: include/hardconfig.h

+9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@
6161

6262
//#define BORDER_EFFECTS
6363

64+
///////////////////////////////////////////////////////////////////////////////
65+
// Fix for 320x240 (4:3) mode on TTGO boards with "21-2-20" serigraphy.
66+
//
67+
// #define FIX_320_240_TTGO_21 for skipping Bitluni's APLL values calculation
68+
// and use a hardcoded set of values
69+
///////////////////////////////////////////////////////////////////////////////
70+
71+
// #define FIX_320_240_TTGO_21
72+
6473
///////////////////////////////////////////////////////////////////////////////
6574
// Video output switch
6675
//

Diff for: src/ESP32Lib/I2S/I2S.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
i2s_dev_t *i2sDevices[] = {&I2S0, &I2S1};
1818

19+
#include "../../../include/hardconfig.h"
20+
#include "../../../include/Config.h"
21+
1922
I2S::I2S(const int i2sIndex)
2023
{
2124
const periph_module_t deviceModule[] = {PERIPH_I2S0_MODULE, PERIPH_I2S1_MODULE};
@@ -325,7 +328,15 @@ bool I2S::initParallelOutputMode(const int *pinMap, long sampleRate, const int b
325328
//sdm = 0xA1fff;
326329
//odir = 0;
327330
if(sdm > 0xA1fff) sdm = 0xA1fff;
331+
332+
#ifndef FIX_320_240_TTGO_21
328333
rtc_clk_apll_enable(true, sdm & 255, (sdm >> 8) & 255, sdm >> 16, odir);
334+
#else
335+
if (Config::aspect_16_9)
336+
rtc_clk_apll_enable(true, sdm & 255, (sdm >> 8) & 255, sdm >> 16, odir);
337+
else
338+
rtc_clk_apll_enable(true, 0xA, 0x57, 0x7, 0x7); // thanks, @ackerman!
339+
#endif
329340
}
330341

331342
i2s.clkm_conf.val = 0;
@@ -395,7 +406,14 @@ void I2S::setAPLLClock(long sampleRate, int bitCount)
395406
//sdm = 0xA1fff;
396407
//odir = 0;
397408
if(sdm > 0xA1fff) sdm = 0xA1fff;
398-
rtc_clk_apll_enable(true, sdm & 255, (sdm >> 8) & 255, sdm >> 16, odir);
409+
#ifndef FIX_320_240_TTGO_21
410+
rtc_clk_apll_enable(true, sdm & 255, (sdm >> 8) & 255, sdm >> 16, odir);
411+
#else
412+
if (Config::aspect_16_9)
413+
rtc_clk_apll_enable(true, sdm & 255, (sdm >> 8) & 255, sdm >> 16, odir);
414+
else
415+
rtc_clk_apll_enable(true, 0xA, 0x57, 0x7, 0x7); // thanks, @ackerman!
416+
#endif
399417
}
400418

401419
void I2S::setClock(long sampleRate, int bitCount, bool useAPLL)

0 commit comments

Comments
 (0)