Skip to content

Commit 5390d16

Browse files
committed
Hackier way to double buffer; but works
1 parent ebae124 commit 5390d16

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

jni/hw/dji_display.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
#define GOGGLES_V1_VOFFSET 575
66
#define GOGGLES_V2_VOFFSET 215
77

8-
static uint8_t which_fb = 0;
9-
108
static duss_result_t pop_func(duss_disp_instance_handle_t *disp_handle,duss_disp_plane_id_t plane_id, duss_frame_buffer_t *frame_buffer,void *user_ctx) {
119
dji_display_state_t *display_state = (dji_display_state_t *)user_ctx;
12-
display_state->frame_waiting = 0;
10+
display_state->frame_drawn = 0;
1311
printf("fbdebug pop_func\n");
1412
return 0;
1513
}
@@ -21,7 +19,7 @@ dji_display_state_t *dji_display_state_alloc(uint8_t is_v2_goggles) {
2119
display_state->fb_1 = (duss_frame_buffer_t *)calloc(1,sizeof(duss_frame_buffer_t));
2220
display_state->pb_0 = (duss_disp_plane_blending_t *)calloc(1, sizeof(duss_disp_plane_blending_t));
2321
display_state->is_v2_goggles = is_v2_goggles;
24-
display_state->frame_waiting = 0;
22+
display_state->frame_drawn = 0;
2523
return display_state;
2624
}
2725

@@ -280,22 +278,19 @@ void dji_display_open_framebuffer_injected(dji_display_state_t *display_state, d
280278
}
281279

282280
void dji_display_push_frame(dji_display_state_t *display_state) {
283-
// print which_fb
284-
printf("fbdebug which_fb: %d\n", which_fb);
285-
if (display_state->frame_waiting == 0) {
286-
which_fb = !which_fb;
287-
duss_frame_buffer_t *fb = which_fb ? display_state->fb_1 : display_state->fb_0;
281+
if (display_state->frame_drawn == 0) {
282+
duss_frame_buffer_t *fb = display_state->fb_0;
288283
duss_hal_mem_sync(fb->buffer, 1);
289-
display_state->frame_waiting = 1;
284+
display_state->frame_drawn = 1;
290285
printf("fbdebug pushing frame\n");
291286
duss_hal_display_push_frame(display_state->disp_instance_handle, display_state->plane_id, fb);
292287
} else {
293288
DEBUG_PRINT("!!! Dropped frame due to pending frame push!\n");
294-
printf("fbdebug dropping frame\n");
295289
}
290+
memcpy(display_state->fb0_virtual_addr, display_state->fb1_virtual_addr, sizeof(uint32_t) * 1440 * 810);
296291
}
297292

298293
void *dji_display_get_fb_address(dji_display_state_t *display_state) {
299-
return which_fb ? display_state->fb1_virtual_addr : display_state->fb0_virtual_addr;
294+
return display_state->fb1_virtual_addr;
300295
}
301296

jni/hw/dji_display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef struct dji_display_state_s {
1717
duss_frame_buffer_t *fb_1;
1818
duss_disp_plane_blending_t *pb_0;
1919
uint8_t is_v2_goggles;
20-
uint8_t frame_waiting;
20+
uint8_t frame_drawn;
2121
} dji_display_state_t;
2222

2323
void dji_display_push_frame(dji_display_state_t *display_state);

jni/osd_dji_overlay_udp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static void draw_character_map(display_info_t *display_info, void* restrict fb_a
188188
for(int y = 0; y < display_info->char_height; y++) {
189189
for(int x = 0; x < display_info->char_width; x++) {
190190
uint16_t c = character_map[x][y];
191-
// if (c != 0) {
191+
if (c != 0) {
192192
font = display_info->font_page_1;
193193
if (c > 255) {
194194
c = c & 0xFF;
@@ -210,7 +210,7 @@ static void draw_character_map(display_info_t *display_info, void* restrict fb_a
210210
target_offset += WIDTH * BYTES_PER_PIXEL - (display_info->font_width * BYTES_PER_PIXEL);
211211
}
212212
// DEBUG_PRINT("%c", c > 31 ? c : 20);
213-
// }
213+
}
214214
// DEBUG_PRINT(" ");
215215
}
216216
// DEBUG_PRINT("\n");
@@ -226,7 +226,7 @@ static void clear_framebuffer() {
226226
static void draw_screen() {
227227
void *fb_addr = dji_display_get_fb_address(dji_display);
228228
// DJI has a backwards alpha channel - FF is transparent, 00 is opaque.
229-
// memset(fb_addr, 0x000000FF, WIDTH * HEIGHT * BYTES_PER_PIXEL);
229+
memset(fb_addr, 0x000000FF, WIDTH * HEIGHT * BYTES_PER_PIXEL);
230230

231231
if (fakehd_is_enabled()) {
232232
fakehd_map_sd_character_map_to_hd(msp_character_map, msp_render_character_map);

0 commit comments

Comments
 (0)