1- #define LGFX_USE_V1
21#include < M5Unified.h>
2+ #include < M5UnitRCA.h>
33
44#include " wav_unsigned_8bit_click.cpp"
55
6- class LGFX : public lgfx ::LGFX_Device {
7- public:
8- lgfx::Panel_CVBS _panel_instance;
9-
10- LGFX (void ) {
11- {
12- auto cfg = _panel_instance.config ();
13-
14- cfg.memory_width = 240 ;
15- cfg.memory_height = 180 ;
16- cfg.panel_width = 240 ;
17- cfg.panel_height = 180 ;
18- cfg.offset_x = 0 ;
19- cfg.offset_y = 0 ;
20- _panel_instance.config (cfg);
21- }
22- {
23- auto cfg = _panel_instance.config_detail ();
24-
25- // cfg.signal_type = cfg.signal_type_t::NTSC_J;
26- // cfg.signal_type = cfg.signal_type_t::PAL;
27- // cfg.signal_type = cfg.signal_type_t::PAL_M;
28- cfg.signal_type = cfg.signal_type_t ::PAL_N;
29-
30- cfg.pin_dac = 25 ;
31- cfg.use_psram = 0 ;
32- cfg.output_level = 128 ;
33- cfg.chroma_level = 128 ;
34- _panel_instance.config_detail (cfg);
35- }
36-
37- setPanel (&_panel_instance);
38- }
39- };
6+ M5UnitRCA gfx_rca;
407
41- LGFX gfx_rca;
8+ // M5UnitRCA gfx_rca ( 216 // logical_width
9+ // , 144 // logical_height
10+ // , 256 // output_width
11+ // , 160 // output_height
12+ // , M5UnitRCA::signal_type_t::PAL // signal_type
13+ // , 26 // GPIO pin
14+ // );
15+ // signal_type: can be selected from NTSC / NTSC_J / PAL / PAL_M / PAL_N.
16+ // GPIO pin: can be selected from 25 / 26
4217
4318static constexpr int color_list[3 ] = {TFT_RED, TFT_GREEN, TFT_BLUE};
4419static int color_index = 0 ;
@@ -73,7 +48,7 @@ void setup(void) {
7348 M5.Display .setTextColor (TFT_WHITE, TFT_BLACK);
7449 M5.Display .drawCenterString (" M5 RCA Module :)" , 160 , 20 );
7550
76- M5.Display .drawCenterString (" Using Pin 25 " , 160 , 120 );
51+ M5.Display .drawCenterString (" Using Pin 26 " , 160 , 120 );
7752 M5.Display .drawString (" Pin 25" , 25 , 210 );
7853 M5.Display .drawString (" Pin 26" , 220 , 210 );
7954
@@ -160,24 +135,7 @@ void loop(void) {
160135 is_pin_25 = true ;
161136 M5.Display .drawCenterString (" Using Pin 25" , 160 , 120 );
162137
163- lgfx::Panel_CVBS* p = (lgfx::Panel_CVBS*)gfx_rca.panel ();
164- p->deinit ();
165- auto cfg = p->config ();
166- cfg.memory_width = 240 ;
167- cfg.memory_height = 180 ;
168- cfg.panel_width = 240 ;
169- cfg.panel_height = 180 ;
170- cfg.offset_x = 0 ;
171- cfg.offset_y = 0 ;
172- p->config (cfg);
173- auto cfg_d = p->config_detail ();
174- cfg_d.pin_dac = 25 ;
175- cfg_d.use_psram = 0 ;
176- cfg_d.output_level = 128 ;
177- cfg_d.chroma_level = 128 ;
178- p->config_detail (cfg_d);
179-
180- gfx_rca.init ();
138+ gfx_rca.setOutputPin (25 );
181139 gfx_rca.setTextColor (TFT_WHITE, color_list[color_index]);
182140 gfx_rca.drawCenterString (" Using Pin 25" , 120 , 110 );
183141 }
@@ -189,24 +147,7 @@ void loop(void) {
189147 is_pin_25 = false ;
190148 M5.Display .drawCenterString (" Using Pin 26" , 160 , 120 );
191149
192- lgfx::Panel_CVBS* p = (lgfx::Panel_CVBS*)gfx_rca.panel ();
193- p->deinit ();
194- auto cfg = p->config ();
195- cfg.memory_width = 240 ;
196- cfg.memory_height = 180 ;
197- cfg.panel_width = 240 ;
198- cfg.panel_height = 180 ;
199- cfg.offset_x = 0 ;
200- cfg.offset_y = 0 ;
201- p->config (cfg);
202- auto cfg_d = p->config_detail ();
203- cfg_d.pin_dac = 26 ;
204- cfg_d.use_psram = 0 ;
205- cfg_d.output_level = 128 ;
206- cfg_d.chroma_level = 128 ;
207- p->config_detail (cfg_d);
208-
209- gfx_rca.init ();
150+ gfx_rca.setOutputPin (26 );
210151 gfx_rca.setTextColor (TFT_WHITE, color_list[color_index]);
211152 gfx_rca.drawCenterString (" Using Pin 26" , 120 , 110 );
212153 }
0 commit comments