4
4
#define USE_SDL
5
5
// #define USE_MANGA_SCREEN2
6
6
7
- #define USE_BOUBLE_BUFFER
7
+ // #define USE_BOUBLE_BUFFER
8
8
9
9
#include < fstream>
10
10
#include < future>
@@ -39,7 +39,7 @@ extern "C"
39
39
40
40
extern " C"
41
41
{
42
- // #include "pigpio.h"
42
+ #include " pigpio.h"
43
43
}
44
44
45
45
extern uint8_t s_font_droid_sans[];
@@ -102,7 +102,7 @@ struct PI_HAL::Impl
102
102
};
103
103
std::array<Touch, MAX_TOUCHES> touches;
104
104
105
- // bool pigpio_is_isitialized = false;
105
+ bool pigpio_is_isitialized = false ;
106
106
float target_backlight = 1 .0f ;
107
107
float backlight = 0 .0f ;
108
108
@@ -117,38 +117,38 @@ struct PI_HAL::Impl
117
117
// /////////////////////////////////////////////////////////////////////////////////////////////////
118
118
119
119
120
- // bool PI_HAL::init_pigpio()
121
- // {
122
- // if (m_impl->pigpio_is_isitialized)
123
- // return true;
120
+ bool PI_HAL::init_pigpio ()
121
+ {
122
+ if (m_impl->pigpio_is_isitialized )
123
+ return true ;
124
124
125
- // LOGI("Initializing pigpio");
126
- // if (gpioCfgClock(2, PI_CLOCK_PCM, 0) < 0 ||
127
- // gpioCfgPermissions(static_cast<uint64_t>(-1)))
128
- // {
129
- // LOGE("Cannot configure pigpio");
130
- // return false;
131
- // }
132
- // if (gpioInitialise() < 0)
133
- // {
134
- // LOGE("Cannot init pigpio");
135
- // return false;
136
- // }
125
+ LOGI (" Initializing pigpio" );
126
+ if (gpioCfgClock (2 , PI_CLOCK_PCM, 0 ) < 0 ||
127
+ gpioCfgPermissions (static_cast <uint64_t >(-1 )))
128
+ {
129
+ LOGE (" Cannot configure pigpio" );
130
+ return false ;
131
+ }
132
+ if (gpioInitialise () < 0 )
133
+ {
134
+ LOGE (" Cannot init pigpio" );
135
+ return false ;
136
+ }
137
137
138
- // m_impl->pigpio_is_isitialized = true;
138
+ m_impl->pigpio_is_isitialized = true ;
139
139
140
- // return true;
141
- // }
140
+ return true ;
141
+ }
142
142
143
143
// ///////////////////////////////////////////////////////////////////////////////////////////////////
144
144
145
- // void PI_HAL::shutdown_pigpio()
146
- // {
147
- // if (m_impl->pigpio_is_isitialized)
148
- // gpioTerminate();
145
+ void PI_HAL::shutdown_pigpio ()
146
+ {
147
+ if (m_impl->pigpio_is_isitialized )
148
+ gpioTerminate ();
149
149
150
- // m_impl->pigpio_is_isitialized = false;
151
- // }
150
+ m_impl->pigpio_is_isitialized = false ;
151
+ }
152
152
153
153
// /////////////////////////////////////////////////////////////////////////////////////////////////
154
154
@@ -253,6 +253,8 @@ bool PI_HAL::init_display_dispmanx()
253
253
254
254
bool PI_HAL::init_display_sdl ()
255
255
{
256
+ // SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
257
+
256
258
#ifdef USE_SDL
257
259
SDL_Init (SDL_INIT_VIDEO);
258
260
#ifdef USE_BOUBLE_BUFFER
@@ -265,14 +267,18 @@ bool PI_HAL::init_display_sdl()
265
267
SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8 );
266
268
SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8 );
267
269
SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8 );
268
- SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 0 );
270
+ SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 8 );
269
271
SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 0 );
270
272
271
273
SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
272
274
SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 0 );
273
275
SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
274
276
SDL_GL_SetAttribute (SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1 );
275
277
278
+ SDL_SetHintWithPriority (SDL_HINT_VIDEO_DOUBLE_BUFFER, " 1" , SDL_HINT_OVERRIDE);
279
+ // SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC, "0", SDL_HINT_OVERRIDE);
280
+
281
+
276
282
int driver_count = SDL_GetNumVideoDrivers ();
277
283
LOGI (" Drivers: {}" , driver_count);
278
284
for (int i = 0 ; i < driver_count; i++)
@@ -290,9 +296,9 @@ bool PI_HAL::init_display_sdl()
290
296
291
297
// Create an application window with the following settings:
292
298
m_impl->window = SDL_CreateWindow (
293
- " An SDL2 window " , // window title
294
- SDL_WINDOWPOS_UNDEFINED , // initial x position
295
- SDL_WINDOWPOS_UNDEFINED , // initial y position
299
+ " ESP32 FPV " , // window title
300
+ 0 , // initial x position
301
+ 0 , // initial y position
296
302
m_impl->width , // width, in pixels
297
303
m_impl->height , // height, in pixels
298
304
SDL_WINDOW_FULLSCREEN |
@@ -430,6 +436,8 @@ bool PI_HAL::update_display()
430
436
}
431
437
432
438
SDL_GL_SwapWindow (m_impl->window );
439
+ // SDL_GL_SwapWindow(m_impl->window);
440
+ // SDL_GL_SwapWindow(m_impl->window);
433
441
// glFlush();
434
442
435
443
ImGui_ImplSDL2_NewFrame (m_impl->window );
@@ -580,11 +588,11 @@ bool PI_HAL::init()
580
588
bcm_host_init ();
581
589
#endif
582
590
583
- // if (!init_pigpio())
584
- // {
585
- // LOGE("Cannot initialize pigpio");
586
- // return false;
587
- // }
591
+ if (!init_pigpio ())
592
+ {
593
+ LOGE (" Cannot initialize pigpio" );
594
+ return false ;
595
+ }
588
596
if (!init_display ())
589
597
{
590
598
LOGE (" Cannot initialize display" );
@@ -614,7 +622,7 @@ void PI_HAL::shutdown()
614
622
{
615
623
ImGui_ImplOpenGL3_Shutdown ();
616
624
617
- // shutdown_pigpio();
625
+ shutdown_pigpio ();
618
626
shutdown_ts ();
619
627
shutdown_display ();
620
628
}
0 commit comments