@@ -22,9 +22,33 @@ Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
22
22
);
23
23
24
24
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
25
+ // 2.1" 480x480 round display
25
26
480 /* width */ , 480 /* height */ , rgbpanel, 0 /* rotation */ , true /* auto_flush */ ,
26
27
expander, GFX_NOT_DEFINED /* RST */ , TL021WVC02_init_operations, sizeof (TL021WVC02_init_operations));
27
28
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
+
28
52
uint16_t *colorWheel;
29
53
30
54
void setup (void )
@@ -52,72 +76,43 @@ void setup(void)
52
76
expander->digitalWrite (PCA_TFT_BACKLIGHT, HIGH);
53
77
54
78
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 ));
56
80
if (colorWheel) generateColorWheel (colorWheel);
57
81
}
58
82
59
83
60
84
uint8_t allpins[] = {SS, SCK, MOSI, MISO, A1, A0};
61
85
62
- bool test = false ;
63
86
void loop ()
64
87
{
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 ;
101
91
}
102
92
103
93
// https://chat.openai.com/share/8edee522-7875-444f-9fea-ae93a8dfa4ec
104
94
void 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 ;
105
99
float angle;
106
100
uint8_t r, g, b;
107
- int scaled_index;
101
+ int index, scaled_index;
108
102
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 );
112
107
r = uint8_t (127.5 * (cos (angle) + 1 ));
113
108
g = uint8_t (127.5 * (sin (angle) + 1 ));
114
109
b = uint8_t (255 - (r + g) / 2 );
115
110
uint16_t color = RGB565 (r, g, b);
116
111
117
- // Scale this pixel into 4 pixels in the 480x480 buffer
112
+ // Scale this pixel into 4 pixels in the full buffer
118
113
for (int dy = 0 ; dy < 2 ; dy++) {
119
114
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);
121
116
colorWheel[scaled_index] = color;
122
117
}
123
118
}
0 commit comments