@@ -22,9 +22,33 @@ Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
2222 );
2323
2424Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
25+ // 2.1" 480x480 round display
2526 480 /* width */ , 480 /* height */ , rgbpanel, 0 /* rotation */ , true /* auto_flush */ ,
2627 expander, GFX_NOT_DEFINED /* RST */ , TL021WVC02_init_operations, sizeof (TL021WVC02_init_operations));
2728
29+ // 2.8" 480x480 round display
30+ // 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
31+ // expander, GFX_NOT_DEFINED /* RST */, TL028WVC01_init_operations, sizeof(TL028WVC01_init_operations));
32+
33+ // 3.4" 480x480 square display
34+ // 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
35+ // expander, GFX_NOT_DEFINED /* RST */, tl034wvs05_b1477a_init_operations, sizeof(tl034wvs05_b1477a_init_operations));
36+
37+ // 3.2" 320x820 rectangle bar display
38+ // 320 /* width */, 820 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
39+ // expander, GFX_NOT_DEFINED /* RST */, tl032fwv01_init_operations, sizeof(tl032fwv01_init_operations));
40+
41+ // 4.0" 720x720 square display
42+ // 720 /* width */, 720 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
43+ // expander, GFX_NOT_DEFINED /* RST */, NULL, 0);
44+
45+ // 4.0" 720x720 round display
46+ // 720 /* width */, 720 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
47+ // expander, GFX_NOT_DEFINED /* RST */, hd40015c40_init_operations, sizeof(hd40015c40_init_operations));
48+ // needs also the rgbpanel to have these pulse/sync values:
49+ // 1 /* hync_polarity */, 46 /* hsync_front_porch */, 2 /* hsync_pulse_width */, 44 /* hsync_back_porch */,
50+ // 1 /* vsync_polarity */, 50 /* vsync_front_porch */, 16 /* vsync_pulse_width */, 16 /* vsync_back_porch */
51+
2852uint16_t *colorWheel;
2953
3054void setup (void )
@@ -52,72 +76,43 @@ void setup(void)
5276 expander->digitalWrite (PCA_TFT_BACKLIGHT, HIGH);
5377
5478 TB.begin ();
55- colorWheel = (uint16_t *) ps_malloc (480 * 480 * sizeof (uint16_t ));
79+ colorWheel = (uint16_t *) ps_malloc (gfx-> width () * gfx-> height () * sizeof (uint16_t ));
5680 if (colorWheel) generateColorWheel (colorWheel);
5781}
5882
5983
6084uint8_t allpins[] = {SS, SCK, MOSI, MISO, A1, A0};
6185
62- bool test = false ;
6386void loop ()
6487{
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- gfx->println (" I2C OK!" );
86-
87- gfx->setCursor (100 , gfx->height () / 2 - 25 );
88- gfx->setTextColor (RED);
89- gfx->println (" RED" );
90-
91- gfx->setCursor (100 , gfx->height () / 2 + 25 );
92- gfx->setTextColor (GREEN);
93- gfx->println (" GREEN" );
94-
95- gfx->setCursor (100 , gfx->height () / 2 + 75 );
96- gfx->setTextColor (BLUE);
97- gfx->println (" BLUE" );
98-
99- Serial.println (" ** TEST OK!" );
100- test = false ;
88+ gfx->draw16bitRGBBitmap (0 , 0 , colorWheel, gfx->width (), gfx->height ());
89+ delay (1000 );
90+ return ;
10191}
10292
10393// https://chat.openai.com/share/8edee522-7875-444f-9fea-ae93a8dfa4ec
10494void generateColorWheel (uint16_t *colorWheel) {
95+ int width = gfx->width ();
96+ int height = gfx->height ();
97+ int half_width = width / 2 ;
98+ int half_height = height / 2 ;
10599 float angle;
106100 uint8_t r, g, b;
107- int scaled_index;
101+ int index, scaled_index;
108102
109- for (int y = 0 ; y < 240 ; y++) {
110- for (int x = 0 ; x < 240 ; x++) {
111- angle = atan2 (y - 120 , x - 120 );
103+ for (int y = 0 ; y < half_height; y++) {
104+ for (int x = 0 ; x < half_width; x++) {
105+ index = y * half_width + x;
106+ angle = atan2 (y - half_height / 2 , x - half_width / 2 );
112107 r = uint8_t (127.5 * (cos (angle) + 1 ));
113108 g = uint8_t (127.5 * (sin (angle) + 1 ));
114109 b = uint8_t (255 - (r + g) / 2 );
115110 uint16_t color = RGB565 (r, g, b);
116111
117- // Scale this pixel into 4 pixels in the 480x480 buffer
112+ // Scale this pixel into 4 pixels in the full buffer
118113 for (int dy = 0 ; dy < 2 ; dy++) {
119114 for (int dx = 0 ; dx < 2 ; dx++) {
120- scaled_index = (y * 2 + dy) * 480 + (x * 2 + dx);
115+ scaled_index = (y * 2 + dy) * width + (x * 2 + dx);
121116 colorWheel[scaled_index] = color;
122117 }
123118 }
0 commit comments