Skip to content

Commit b4c3c05

Browse files
authored
Merge pull request #2635 from makermelissa/main
Add Qualia S3 Factory Reset Source
2 parents 23c79df + 358039b commit b4c3c05

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

Factory_Tests/Qualia_ESP32S3_RGB666_FactoryTest/.none.test.only

Whitespace-only changes.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// SPDX-FileCopyrightText: 2023 Limor Fried for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include "Adafruit_TestBed.h"
6+
#include <Arduino_GFX_Library.h>
7+
8+
extern Adafruit_TestBed TB;
9+
10+
Arduino_XCA9554SWSPI *expander = new Arduino_XCA9554SWSPI(
11+
PCA_TFT_RESET, PCA_TFT_CS, PCA_TFT_SCK, PCA_TFT_MOSI,
12+
&Wire, 0x3F);
13+
14+
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
15+
TFT_DE, TFT_VSYNC, TFT_HSYNC, TFT_PCLK,
16+
TFT_R1, TFT_R2, TFT_R3, TFT_R4, TFT_R5,
17+
TFT_G0, TFT_G1, TFT_G2, TFT_G3, TFT_G4, TFT_G5,
18+
TFT_B1, TFT_B2, TFT_B3, TFT_B4, TFT_B5,
19+
1 /* hsync_polarity */, 50 /* hsync_front_porch */, 2 /* hsync_pulse_width */, 44 /* hsync_back_porch */,
20+
1 /* vsync_polarity */, 16 /* vsync_front_porch */, 2 /* vsync_pulse_width */, 18 /* vsync_back_porch */
21+
//,1, 30000000
22+
);
23+
24+
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
25+
480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
26+
expander, GFX_NOT_DEFINED /* RST */, TL021WVC02_init_operations, sizeof(TL021WVC02_init_operations));
27+
28+
uint16_t *colorWheel;
29+
30+
void setup(void)
31+
{
32+
Serial.begin(115200);
33+
//while (!Serial) delay(100);
34+
35+
#ifdef GFX_EXTRA_PRE_INIT
36+
GFX_EXTRA_PRE_INIT();
37+
#endif
38+
39+
Serial.println("Beginning");
40+
// Init Display
41+
42+
Wire.setClock(1000000); // speed up I2C
43+
if (!gfx->begin()) {
44+
Serial.println("gfx->begin() failed!");
45+
}
46+
47+
Serial.println("Initialized!");
48+
49+
gfx->fillScreen(BLACK);
50+
51+
expander->pinMode(PCA_TFT_BACKLIGHT, OUTPUT);
52+
expander->digitalWrite(PCA_TFT_BACKLIGHT, HIGH);
53+
54+
TB.begin();
55+
colorWheel = (uint16_t *) ps_malloc(480 * 480 * sizeof(uint16_t));
56+
if (colorWheel) generateColorWheel(colorWheel);
57+
}
58+
59+
60+
uint8_t allpins[] = {SS, SCK, MOSI, MISO, A1, A0};
61+
62+
bool test = false;
63+
void loop()
64+
{
65+
if (!test) {
66+
gfx->draw16bitRGBBitmap(0, 0, colorWheel, 480, 480);
67+
delay(100);
68+
return;
69+
}
70+
Serial.println("** Test Display!");
71+
gfx->fillScreen(BLACK);
72+
gfx->setTextSize(5);
73+
gfx->setTextColor(WHITE);
74+
gfx->setTextWrap(false);
75+
gfx->setCursor(100, gfx->height() / 2 - 175);
76+
gfx->println("Display OK!");
77+
78+
if (! TB.testpins(MOSI, A1, allpins, sizeof(allpins))) return;
79+
if (! TB.testpins(MISO, SS, allpins, sizeof(allpins))) return;
80+
if (! TB.testpins(SCK, A0, allpins, sizeof(allpins))) return;
81+
gfx->setCursor(100, gfx->height() / 2 - 125);
82+
gfx->println("GPIO OK!");
83+
84+
gfx->setCursor(100, gfx->height() / 2 - 75);
85+
if (! TB.scanI2CBus(0x15)) return;
86+
gfx->println("I2C OK!");
87+
88+
gfx->setCursor(100, gfx->height() / 2 - 25);
89+
gfx->setTextColor(RED);
90+
gfx->println("RED");
91+
92+
gfx->setCursor(100, gfx->height() / 2 + 25);
93+
gfx->setTextColor(GREEN);
94+
gfx->println("GREEN");
95+
96+
gfx->setCursor(100, gfx->height() / 2 + 75);
97+
gfx->setTextColor(BLUE);
98+
gfx->println("BLUE");
99+
100+
Serial.println("** TEST OK!");
101+
test = false;
102+
}
103+
104+
// https://chat.openai.com/share/8edee522-7875-444f-9fea-ae93a8dfa4ec
105+
void generateColorWheel(uint16_t *colorWheel) {
106+
float angle;
107+
uint8_t r, g, b;
108+
int index, scaled_index;
109+
110+
for(int y = 0; y < 240; y++) {
111+
for(int x = 0; x < 240; x++) {
112+
index = y * 240 + x;
113+
angle = atan2(y - 120, x - 120);
114+
r = uint8_t(127.5 * (cos(angle) + 1));
115+
g = uint8_t(127.5 * (sin(angle) + 1));
116+
b = uint8_t(255 - (r + g) / 2);
117+
uint16_t color = RGB565(r, g, b);
118+
119+
// Scale this pixel into 4 pixels in the 480x480 buffer
120+
for(int dy = 0; dy < 2; dy++) {
121+
for(int dx = 0; dx < 2; dx++) {
122+
scaled_index = (y * 2 + dy) * 480 + (x * 2 + dx);
123+
colorWheel[scaled_index] = color;
124+
}
125+
}
126+
}
127+
}
128+
}

0 commit comments

Comments
 (0)