Skip to content

Commit 56fe2f1

Browse files
committed
AirSide custom text colors fixes
1 parent f8b75d4 commit 56fe2f1

6 files changed

Lines changed: 59 additions & 29 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"--ahi",
118118
"3",
119119
"--matrix",
120-
"11",
120+
"99",
121121
"-v",
122122
"-f",
123123
"/home/home/",

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ Extra params withing the message to be shown:
122122
- &C - CPU Usage percent
123123
- &t - Time
124124
- &Fxx - Set text font size (10 to 99)
125-
- &Lxx - Set text colour (first digit 0- white, 1 - black, 2- blue, 3 - green, 4 - red, 5 - yellow, 6 - magenta, 7 - cyan) and postion on the screen(second digit) 0-TopLeft, 1-TopCenter, 2-TopRight, 3-TopMoving,4-BottomLeft, 5-BottomCenter, 6-BottomRight, 7-BottomMoving
125+
- &Lxx - Set text colour (first digit 0- white, 1 - black, 2- red, 3 - green, 4 - blue, 5 - yellow, 6 - magenta, 7 - cyan, 8 - orchid, 9 - dark red)
126+
and postion on the screen( second digit) 0-TopLeft, 1-TopCenter, 2-TopRight, 3-TopMoving,4-BottomLeft, 5-BottomCenter, 6-BottomRight, 7-BottomMoving
126127
- &Gx - Set text backGround color (0- white, 1 - black, 2- blue, 3 - green, 4 - red, 5 - yellow, 6 - magenta, 7 - cyan, 8 - semi-transparent, 9 - transparent)
127128
-&p - Dropped packet injections by wfb-ng (on 8812xx extracted from /sys/class/net/wlan0/statistics/tx_dropped)
128129

bmp/bitmap.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -709,10 +709,10 @@ MI_RGN_PaletteTable_t g_stPaletteTable = {{// index0 ~ index15
709709
{0xFF, 0x00, 0xF8, 0xF8}, // 0x03FF -> Cyan
710710
{0xFF, 0xFF, 0xFF, 0xFF}, // 0x7FFF -> White
711711
{0xFF, 0x00, 0x00, 0x00}, // 0x0000 -> Black index 8
712-
{0xAF, 0x00, 0x00, 0x00}, // Semi transparent
713-
{0xFF, 0x42, 0x08, 0x08}, //
712+
{0x6F, 0x00, 0x00, 0x00}, // Semi transparent
713+
{0xFF, 0xA2, 0x08, 0x08}, // Dark Red
714714
{0xFF, 0x63, 0x18, 0xC6}, //
715-
{0xFF, 0xAD, 0x52, 0xD6}, //
715+
{0xFF, 0xAD, 0x52, 0xD6}, // Orchid
716716
{0xFF, 0xCC, 0xCC, 0xCC}, // 0x739C -> Gray (Light) {0xFF, 0xCC, 0xCC, 0xCC}
717717
{0xFF, 0x77, 0x77, 0x77}, // 0x18C6 -> Gray (Dark)
718718
{0x00, 0, 0, 0}, // transparent index 15, 0x0A
@@ -1028,19 +1028,22 @@ void ConvertI4ToRGBA(uint8_t *bitmapI4, uint8_t *rgbaData, uint32_t width, uint3
10281028
// Extract the first (high) pixel
10291029
uint8_t index1 = (byte & 0xF0) >> 4;
10301030
MI_RGN_PaletteElement_t color1 = palette[index1];
1031-
rgbaData[pixelIndex * 4 + 0] = color1.u8Red;
1031+
1032+
//Cairo expects image surfaces to be in premultiplied ARGB32 format on little-endian systems,
1033+
//which in memory layout becomes: memory layout per pixel: [Blue, Green, Red, Alpha] (BGRA)
1034+
rgbaData[pixelIndex * 4 + 2] = color1.u8Red;
10321035
rgbaData[pixelIndex * 4 + 1] = color1.u8Green;
1033-
rgbaData[pixelIndex * 4 + 2] = color1.u8Blue;
1036+
rgbaData[pixelIndex * 4 + 0] = color1.u8Blue;
10341037
rgbaData[pixelIndex * 4 + 3] = color1.u8Alpha;
10351038
pixelIndex++;
10361039

10371040
if (x + 1 < width) {
10381041
// Extract the second (low) pixel
10391042
uint8_t index2 = byte & 0x0F;
10401043
MI_RGN_PaletteElement_t color2 = palette[index2];
1041-
rgbaData[pixelIndex * 4 + 0] = color2.u8Red;
1044+
rgbaData[pixelIndex * 4 + 2] = color2.u8Red;
10421045
rgbaData[pixelIndex * 4 + 1] = color2.u8Green;
1043-
rgbaData[pixelIndex * 4 + 2] = color2.u8Blue;
1046+
rgbaData[pixelIndex * 4 + 0] = color2.u8Blue;
10441047
rgbaData[pixelIndex * 4 + 3] = color2.u8Alpha;
10451048
pixelIndex++;
10461049
}

bmp/bitmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,13 @@ uint16_t GetARGB1555From_RGN_Palette(int index);
181181
#define COLOR_CYAN 6
182182
#define COLOR_WHITE 7
183183
#define COLOR_BLACK 8
184-
#define COLOR_GRAY_Darker 9
184+
#define COLOR_SEMI_TRANSPARENT 9
185185
#define COLOR_GRAY_Darkest 10
186186
#define COLOR_GRAY_Medium 11
187187
#define COLOR_GRAY_Lighter 12
188188
#define COLOR_GRAY_Light 13
189189
#define COLOR_GRAY_Dark 14
190+
#define COLOR_TRANSPARENT 15
190191

191192
/*
192193
{0xFF, 0x84, 0x10, 0x10}, // 0x4210 -> Gray (Darker)

develepment_notes.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ cp ./msposd_goke ./release/goke/msposd
6767
cp ./msposd_hisi ./release/hisi/msposd
6868

6969
-- Test different color and size per line
70-
echo -e "LINE1 Purple font 24 &L52 &F24\nLINE2 Red font size 20 &L32 &F20 \nLine3 bluish size 28 &L42 &F28 " > ./MSPOSD.msg
70+
echo -e "LINE1 Purple font 24 &L52 &F24\nLINE2 Red font size 20 &L32 &F20 \nLine3 bluish size 28 &L42 &F28 " > ./MSPOSD.msg
71+
echo -e "&G8 0 - White &L02&F28\n 1 - Black &L12\n 2 - Red &L22\n 3 - Green &L32\n 4 - Blue &L42\n 5 - Yellow &L52\n 6 - Magenta &L62\n 7 - Cyan &L72\n 8 - Orchid &L82\n 9 - DarkRed &L92" > /tmp/MSPOSD.msg

osd.c

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,20 +1139,50 @@ int parse_LF(const char *input, int *L, int *F, int max_lines) {
11391139
char *l_ptr = strstr(line, "&L");
11401140
char *f_ptr = strstr(line, "&F");
11411141

1142-
if (l_ptr && f_ptr) {
1143-
L[line_count] = atoi(l_ptr + 2);
1144-
F[line_count] = atoi(f_ptr + 2);
1142+
if (l_ptr) {
1143+
L[line_count] = atoi(l_ptr + 2);
11451144
} else {
1146-
L[line_count] = -1;
1145+
L[line_count] = -1;
1146+
}
1147+
if (f_ptr) {
1148+
F[line_count] = atoi(f_ptr + 2);
1149+
} else {
11471150
F[line_count] = -1;
11481151
}
11491152

1153+
11501154
line_count++;
11511155
}
11521156

11531157
return line_count;
11541158
}
11551159

1160+
/* We use some predefined color indexes and need to keep them for compatibility
1161+
0- white, 1 - black, 2- blue, 3 - green, 4 - red, 5 - yellow, 6 - magenta, 7 - cyan, 8 - semi-transparent, 9 - transparent
1162+
*/
1163+
int I4ColorIndex(int msg_colour) {
1164+
1165+
// if (msg_colour == 8)//9
1166+
// return COLOR_SEMI_TRANSPARENT;
1167+
// if (msg_colour == 9)//
1168+
// return COLOR_TRANSPARENT;
1169+
1170+
if (msg_colour == 8)//9
1171+
return 12; //Orchid
1172+
if (msg_colour == 9)//
1173+
return 10;
1174+
1175+
if (msg_colour == 0)
1176+
msg_colour = COLOR_WHITE;
1177+
else if (msg_colour == 1)
1178+
msg_colour = COLOR_BLACK;
1179+
else
1180+
//index in palette 1=Red, Green, Blue, Yellow ,Magenta, 6=Cyan,
1181+
msg_colour--;
1182+
1183+
return msg_colour;
1184+
}
1185+
11561186
static int droppedTTL = 0;
11571187
static int droppedTTL_start=0;
11581188
static bool first_wfb_read = true;
@@ -1366,14 +1396,7 @@ void fill(char *str) {
13661396
int value = atoi(numStr);
13671397
// Ugly
13681398
msg_layout = value % 10;
1369-
msg_colour = value / 10;
1370-
if (msg_colour == 0)
1371-
msg_colour = COLOR_WHITE;
1372-
else if (msg_colour == 1)
1373-
msg_colour = COLOR_BLACK;
1374-
else
1375-
// 1=Red, Green, Blue, Yellow ,Magenta, 6=Cyan
1376-
msg_colour--;
1399+
msg_colour=I4ColorIndex(value / 10);
13771400

13781401
ipos += 3;
13791402
}
@@ -1585,8 +1608,9 @@ bool DrawTextOnOSDBitmap(char *msg) {
15851608
osds[FULL_OVERLAY_ID].size = F[i];
15861609
rect = measure_text(font, osds[FULL_OVERLAY_ID].size, lines[i]);
15871610
maxwidth = (rect.width > maxwidth) ? rect.width : maxwidth;
1588-
heighttl += rect.height - 2 - ((i>0)?1:0);
1611+
heighttl += (int)(rect.height*0.9) /*- ((rect.height>40)?1:0)*/;
15891612
}
1613+
heighttl+=2;
15901614

15911615
bitmapText.u32Height = heighttl; // line_count * rect.height;
15921616
bitmapText.u32Width = MIN((maxwidth + 15) & ~15,
@@ -1603,7 +1627,7 @@ bool DrawTextOnOSDBitmap(char *msg) {
16031627

16041628
uint16_t color = 0xFFFF;
16051629
if (L[i] > 0) {
1606-
msg_colour = L[i] / 10;
1630+
msg_colour = I4ColorIndex(L[i] / 10);
16071631
color = GetARGB1555From_RGN_Palette(msg_colour);
16081632
}
16091633

@@ -1616,7 +1640,7 @@ bool DrawTextOnOSDBitmap(char *msg) {
16161640
bitmapText.u32Height, 0, 0, MIN(bitmapTextLine.u32Width, bitmapText.u32Width),
16171641
MIN(bitmapTextLine.u32Height, bitmapText.u32Height), 0, heighttl);
16181642

1619-
heighttl += bitmapTextLine.u32Height - 2;
1643+
heighttl += (int)(bitmapTextLine.u32Height * 0.9);
16201644
free(bitmapTextLine.pData); // Free the memory allocated by raster_text !!!
16211645
}
16221646

@@ -1628,7 +1652,7 @@ bool DrawTextOnOSDBitmap(char *msg) {
16281652
getRowStride(bitmapText.u32Width, PIXEL_FORMAT_BitsPerPixel));
16291653

16301654
convertBitmap1555ToI4(bitmapText.pData, bitmapText.u32Width, bitmapText.u32Height,
1631-
destBitmap, (L[1] > 0) ? -1 : msg_colour,
1655+
destBitmap, (L[0] > 0) ? -1 : msg_colour,
16321656
msg_colour_background); // If different color per line is used
16331657

16341658
free(bitmapText.pData); // free ARGB1555 bitmap
@@ -2378,8 +2402,8 @@ static void InitMSPHook() {
23782402
OVERLAY_WIDTH = current_display_info.font_width *
23792403
(current_display_info.char_width); // must be multiple of 8 !!!
23802404
OVERLAY_WIDTH = (OVERLAY_WIDTH + 7) & ~7;
2381-
if (matrix_size > 10 && OVERLAY_WIDTH < (1920 - (53 * 2))) {
2382-
printf("Matrix size not supported on resolutions smaller than 1920x1080p!\n");
2405+
if (matrix_size == 11 && OVERLAY_WIDTH < (1920 - (53 * 2))) {
2406+
printf("Matrix size 11 not supported on resolutions smaller than 1920x1080p!\n");
23832407
matrix_size = 0;
23842408
}
23852409
/*

0 commit comments

Comments
 (0)