@@ -678,7 +678,7 @@ int msg_layout = 0;
678
678
/// white font
679
679
int msg_colour = 0 ;
680
680
681
- int msg_colour_background = -1 ;
681
+ int msg_colour_background = -1 ;
682
682
683
683
static unsigned long long LastCleared = 0 ;
684
684
static bool osd_msg_enabled = false;
@@ -1110,10 +1110,9 @@ static void draw_Ladder() {
1110
1110
static int droppedTTL = 0 ;
1111
1111
static bool first_wfb_read = true;
1112
1112
1113
-
1114
1113
void fill (char * str ) {
1115
1114
unsigned int rxb_l , txb_l , cpu_l [7 ];
1116
- char out [MAX_STATUS_MSG_LEN + 100 ] = "" ;
1115
+ char out [MAX_STATUS_MSG_LEN + 100 ] = "" ;
1117
1116
char param = 0 ;
1118
1117
int ipos = 0 , opos = 0 ;
1119
1118
@@ -1311,30 +1310,29 @@ void fill(char *str) {
1311
1310
msg_colour -- ;
1312
1311
1313
1312
ipos += 3 ;
1314
- }
1315
- } else if (str [ipos + 1 ] == 'G' && isdigit (str [ipos + 2 ]) ) {
1316
- if (!DrawOSD ) {// we need to keep &Cx
1313
+ }
1314
+ } else if (str [ipos + 1 ] == 'G' && isdigit (str [ipos + 2 ])) {
1315
+ if (!DrawOSD ) { // we need to keep &Cx
1317
1316
strncat (out , str + ipos , 1 );
1318
1317
opos ++ ;
1319
1318
} else {
1320
1319
// Extract the one digit after $C as an integer
1321
-
1322
- msg_colour_background = str [ipos + 2 ]- '0' ;
1320
+
1321
+ msg_colour_background = str [ipos + 2 ] - '0' ;
1323
1322
if (msg_colour_background == 0 )
1324
1323
msg_colour_background = COLOR_WHITE ;
1325
1324
else if (msg_colour_background == 1 )
1326
1325
msg_colour_background = COLOR_BLACK ;
1327
1326
else if (msg_colour_background == 8 )
1328
- msg_colour_background = 9 ;// semi-transparent
1329
- else if (msg_colour_background == 9 )// remove it, i.e. make it transparent
1327
+ msg_colour_background = 9 ; // semi-transparent
1328
+ else if (msg_colour_background == 9 ) // remove it, i.e. make it transparent
1330
1329
msg_colour_background = -1 ;
1331
1330
else
1332
1331
msg_colour_background -- ;
1333
-
1332
+
1334
1333
ipos += 2 ;
1335
1334
}
1336
- }
1337
- else if (str [ipos + 1 ] == '&' ) {
1335
+ } else if (str [ipos + 1 ] == '&' ) {
1338
1336
ipos ++ ;
1339
1337
strcat (out , "&" );
1340
1338
opos ++ ;
@@ -1398,27 +1396,26 @@ void remove_carriage_returns(char *out) {
1398
1396
out [j ] = '\0' ; // Null-terminate the modified string
1399
1397
}
1400
1398
1401
-
1402
- #define MAX_LINES 100 // Maximum number of lines we expect to handle
1399
+ #define MAX_LINES 100 // Maximum number of lines we expect to handle
1403
1400
void split_lines (char * str , char * lines [MAX_LINES ], int * line_count ) {
1404
- * line_count = 0 ; // Initialize the line count
1405
- lines [(* line_count )++ ] = str ; // Store the pointer to the first line
1406
-
1407
- while (* str ) {
1408
- if (* str == '\n' ) {//'@'
1409
- * str = '\0' ; // Replace the carriage return with a null terminator
1410
- if (* (str + 1 ) != '\0' ) { // Check if it's not the end of the string
1411
- lines [(* line_count )++ ] = str + 1 ; // Store the pointer to the next line
1412
- }
1413
- }
1414
- str ++ ;
1415
- }
1401
+ * line_count = 0 ; // Initialize the line count
1402
+ lines [(* line_count )++ ] = str ; // Store the pointer to the first line
1403
+
1404
+ while (* str ) {
1405
+ if (* str == '\n' ) { //'@'
1406
+ * str = '\0' ; // Replace the carriage return with a null terminator
1407
+ if (* (str + 1 ) != '\0' ) { // Check if it's not the end of the string
1408
+ lines [(* line_count )++ ] = str + 1 ; // Store the pointer to the next line
1409
+ }
1410
+ }
1411
+ str ++ ;
1412
+ }
1416
1413
}
1417
1414
1418
1415
char osdmsg [MAX_STATUS_MSG_LEN ];
1419
1416
1420
1417
bool DrawTextOnOSDBitmap (char * msg ) {
1421
- char * font ;
1418
+ char * font ;
1422
1419
#ifdef _x86
1423
1420
asprintf (& font , "fonts/%s.ttf" , osds [FULL_OVERLAY_ID ].font );
1424
1421
#else
@@ -1475,7 +1472,7 @@ bool DrawTextOnOSDBitmap(char *msg) {
1475
1472
if (!DrawOSD && out_sock > 0 ) { // send the line to the ground
1476
1473
static uint8_t msg_buffer [256 ];
1477
1474
static uint8_t payload_buffer [256 ];
1478
- //out[79] = 0; // just in case
1475
+ // out[79] = 0; // just in case
1479
1476
int msglen = strlen (& out [0 ]);
1480
1477
1481
1478
payload_buffer [0 ] = MSP_DISPLAYPORT_INFO_MSG ;
@@ -1495,38 +1492,40 @@ bool DrawTextOnOSDBitmap(char *msg) {
1495
1492
if ((osds [FULL_OVERLAY_ID ].size < 5.0 ) || (osds [FULL_OVERLAY_ID ].size > 99.0 ))
1496
1493
osds [FULL_OVERLAY_ID ].size = 20.0 ;
1497
1494
1495
+ RECT rect ; // = measure_text(font, osds[FULL_OVERLAY_ID].size, out);
1498
1496
1499
- RECT rect ;// = measure_text(font, osds[FULL_OVERLAY_ID].size, out);
1497
+ if (bitmapText .pData != NULL ) {
1498
+ free (bitmapText .pData );
1499
+ bitmapText .pData = NULL ;
1500
+ }
1501
+ char * lines [MAX_LINES ]; // Array to hold pointers to each line
1502
+ int line_count = 0 ;
1503
+
1504
+ split_lines (out , lines , & line_count ); // Here we will modify the message
1505
+ int maxwidth = 0 ;
1500
1506
1501
- if (bitmapText .pData != NULL ) {
1502
- free (bitmapText .pData );
1503
- bitmapText .pData = NULL ;
1507
+ for (int i = 0 ; i < line_count ; i ++ ) {
1508
+ // printf("OSD Statistics Line %d: %s\n", i + 1, lines[i]);
1509
+ rect = measure_text (font , osds [FULL_OVERLAY_ID ].size , lines [i ]);
1510
+ maxwidth = (rect .width > maxwidth ) ? rect .width : maxwidth ;
1504
1511
}
1505
- char * lines [MAX_LINES ]; // Array to hold pointers to each line
1506
- int line_count = 0 ;
1507
-
1508
- split_lines (out , lines , & line_count );//Here we will modify the message
1509
- int maxwidth = 0 ;
1510
-
1511
- for (int i = 0 ; i < line_count ; i ++ ) {
1512
- //printf("OSD Statistics Line %d: %s\n", i + 1, lines[i]);
1513
- rect = measure_text (font , osds [FULL_OVERLAY_ID ].size , lines [i ]);
1514
- maxwidth = (rect .width > maxwidth )?rect .width :maxwidth ;
1515
- }
1516
-
1517
- bitmapText .u32Height = line_count * rect .height ;// preview_height;//rows *
1518
- bitmapText .u32Width = MIN ( (maxwidth + 15 ) & ~15 , bmpBuff .u32Width - 16 ) ;// should be multiple of 16 OVERLAY_WIDTH-16
1519
- bitmapText .pData = (unsigned char * ) malloc (bitmapText .u32Height * getRowStride (bitmapText .u32Width , 16 ));
1512
+
1513
+ bitmapText .u32Height = line_count * rect .height ; // preview_height;//rows *
1514
+ bitmapText .u32Width = MIN ((maxwidth + 15 ) & ~15 ,
1515
+ bmpBuff .u32Width - 16 ); // should be multiple of 16 OVERLAY_WIDTH-16
1516
+ bitmapText .pData =
1517
+ (unsigned char * )malloc (bitmapText .u32Height * getRowStride (bitmapText .u32Width , 16 ));
1520
1518
memset (bitmapText .pData , 0 , bitmapText .u32Height * getRowStride (bitmapText .u32Width , 16 ));
1521
1519
1522
- for (int i = 0 ;i < line_count ;i ++ ){
1523
- BITMAP bitmapTextLine = raster_text (font , osds [FULL_OVERLAY_ID ].size , lines [i ]); // allocates new bitmap, Bus error on goke ?!
1524
- //raster_text always return argb1555
1525
- copyRectARGB1555 (bitmapTextLine .pData , bitmapTextLine .u32Width , bitmapTextLine .u32Height ,
1526
- bitmapText .pData , bitmapText .u32Width , bitmapText .u32Height ,
1527
- 0 , 0 , MIN (bitmapTextLine .u32Width ,bitmapText .u32Width ) , MIN (bitmapTextLine .u32Height , bitmapText .u32Height ),
1528
- 0 , i * rect .height );
1529
- free (bitmapTextLine .pData ); // Free the memory allocated by raster_text !!!
1520
+ for (int i = 0 ; i < line_count ; i ++ ) {
1521
+ BITMAP bitmapTextLine = raster_text (font , osds [FULL_OVERLAY_ID ].size ,
1522
+ lines [i ]); // allocates new bitmap, Bus error on goke ?!
1523
+ // raster_text always return argb1555
1524
+ copyRectARGB1555 (bitmapTextLine .pData , bitmapTextLine .u32Width ,
1525
+ bitmapTextLine .u32Height , bitmapText .pData , bitmapText .u32Width ,
1526
+ bitmapText .u32Height , 0 , 0 , MIN (bitmapTextLine .u32Width , bitmapText .u32Width ),
1527
+ MIN (bitmapTextLine .u32Height , bitmapText .u32Height ), 0 , i * rect .height );
1528
+ free (bitmapTextLine .pData ); // Free the memory allocated by raster_text !!!
1530
1529
}
1531
1530
1532
1531
if (PIXEL_FORMAT_DEFAULT ==
@@ -1537,7 +1536,7 @@ bool DrawTextOnOSDBitmap(char *msg) {
1537
1536
getRowStride (bitmapText .u32Width , PIXEL_FORMAT_BitsPerPixel ));
1538
1537
1539
1538
convertBitmap1555ToI4 (bitmapText .pData , bitmapText .u32Width , bitmapText .u32Height ,
1540
- destBitmap , msg_colour ,msg_colour_background );
1539
+ destBitmap , msg_colour , msg_colour_background );
1541
1540
1542
1541
free (bitmapText .pData ); // free ARGB1555 bitmap
1543
1542
// This is inefficient, we use 4 times more memory, but the buffer
0 commit comments