Skip to content

Commit 6af2001

Browse files
committed
Look for font.bin in entware environment before falling back to default.
1 parent 6b7c168 commit 6af2001

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

osd_dji_udp.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#define SHUTDOWN_STRING "MSP OSD SHUTTING DOWN..."
4343

4444
#define FALLBACK_FONT_PATH "/blackbox/font.bin"
45+
#define ENTWARE_FONT_PATH "/opt/fonts/font.bin"
4546
#define SDCARD_FONT_PATH "/storage/sdcard0/font.bin"
4647
#define FONT_FILE_SIZE 1990656
4748

@@ -53,7 +54,7 @@
5354

5455
#define SWAP32(data) \
5556
( (((data) >> 24) & 0x000000FF) | (((data) >> 8) & 0x0000FF00) | \
56-
(((data) << 8) & 0x00FF0000) | (((data) << 24) & 0xFF000000) )
57+
(((data) << 8) & 0x00FF0000) | (((data) << 24) & 0xFF000000) )
5758

5859
static volatile sig_atomic_t quit = 0;
5960
dji_display_state_t *dji_display;
@@ -90,18 +91,18 @@ static void draw_screen() {
9091
for(uint8_t gy = 0; gy < FONT_HEIGHT; gy++) {
9192
uint32_t font_offset = character_offset + (gy * FONT_WIDTH * BYTES_PER_PIXEL) + (gx * BYTES_PER_PIXEL);
9293
uint32_t target_offset = ((((pixel_x + gx) * BYTES_PER_PIXEL) + ((pixel_y + gy) * WIDTH * BYTES_PER_PIXEL)));
93-
*((uint8_t *)fb_addr + target_offset) = *(uint8_t *)((uint8_t *)font + font_offset + 2);
94-
*((uint8_t *)fb_addr + target_offset + 1) = *(uint8_t *)((uint8_t *)font + font_offset + 1);
95-
*((uint8_t *)fb_addr + target_offset + 2) = *(uint8_t *)((uint8_t *)font + font_offset);
96-
*((uint8_t *)fb_addr + target_offset + 3) = ~*(uint8_t *)((uint8_t *)font + font_offset + 3);
94+
*((uint8_t *)fb_addr + target_offset) = *(uint8_t *)((uint8_t *)font + font_offset + 2);
95+
*((uint8_t *)fb_addr + target_offset + 1) = *(uint8_t *)((uint8_t *)font + font_offset + 1);
96+
*((uint8_t *)fb_addr + target_offset + 2) = *(uint8_t *)((uint8_t *)font + font_offset);
97+
*((uint8_t *)fb_addr + target_offset + 3) = ~*(uint8_t *)((uint8_t *)font + font_offset + 3);
9798
}
9899
}
99100
DEBUG_PRINT("%c", c > 31 ? c : 20);
100101
}
101102
DEBUG_PRINT(" ");
102103
}
103104
DEBUG_PRINT("\n");
104-
}
105+
}
105106
}
106107

107108
static void clear_screen()
@@ -113,7 +114,7 @@ static void draw_complete() {
113114
draw_screen();
114115
dji_display_push_frame(dji_display, which_fb);
115116
which_fb = !which_fb;
116-
DEBUG_PRINT("drew a frame\n");
117+
DEBUG_PRINT("drew a frame\n");
117118
}
118119

119120
static void msp_callback(msp_msg_t *msp_message)
@@ -167,7 +168,9 @@ static void stop_display() {
167168

168169
static void load_font() {
169170
if (open_font(SDCARD_FONT_PATH, &font) < 0) {
170-
open_font(FALLBACK_FONT_PATH, &font);
171+
if (open_font(ENTWARE_FONT_PATH, &font) < 0) {
172+
open_font(FALLBACK_FONT_PATH, &font);
173+
}
171174
}
172175
}
173176

@@ -185,7 +188,7 @@ int main(int argc, char *argv[])
185188

186189
msp_state_t *msp_state = calloc(1, sizeof(msp_state_t));
187190
msp_state->cb = &msp_callback;
188-
191+
189192
int event_fd = open(INPUT_FILENAME, O_RDONLY);
190193
assert(event_fd > 0);
191194

@@ -252,7 +255,7 @@ int main(int argc, char *argv[])
252255
}
253256
DEBUG_PRINT("input type: %i, code: %i, value: %i\n", ev.type, ev.code, ev.value);
254257
}
255-
if(poll_fds[0].revents) {
258+
if(poll_fds[0].revents) {
256259
// Got UDP packet
257260
if (0 < (recv_len = recvfrom(socket_fd,&buffer,sizeof(buffer),0,(struct sockaddr*)&src_addr,&src_addr_len)))
258261
{
@@ -273,4 +276,4 @@ int main(int argc, char *argv[])
273276
close(event_fd);
274277

275278
return 0;
276-
}
279+
}

0 commit comments

Comments
 (0)