Apply my changes v1
Some checks failed
Build Firmware / build (push) Failing after 3m21s

This commit is contained in:
2025-02-27 16:49:04 +01:00
parent ba5257f2f6
commit f4ff2e6048
37 changed files with 3890 additions and 4607 deletions

View File

@@ -24,15 +24,13 @@
#include "misc.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
#endif
void UI_GenerateChannelString(char *pString, const uint8_t Channel)
{
void UI_GenerateChannelString(char *pString, const uint8_t Channel) {
unsigned int i;
if (gInputBoxIndex == 0)
{
if (gInputBoxIndex == 0) {
sprintf(pString, "CH-%02u", Channel + 1);
return;
}
@@ -44,8 +42,7 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel)
pString[i + 3] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
}
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber)
{
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber) {
if (gInputBoxIndex > 0) {
for (unsigned int i = 0; i < 3; i++) {
pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
@@ -65,41 +62,38 @@ void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uin
}
}
void UI_PrintStringBuffer(const char *pString, uint8_t * buffer, uint32_t char_width, const uint8_t *font)
{
void *memcpy_inv(void *dst, const void *src, size_t n) {
if (!dst || !src) return dst;
uint8_t *d = (uint8_t *) dst;
const uint8_t *s = (const uint8_t *) src;
while (n--) {
*d++ = ~(*s++);
}
return dst;
}
void UI_PrintStringBuffer(const char *pString, uint8_t *buffer, uint32_t char_width, const uint8_t *font, bool inv) {
const size_t Length = strlen(pString);
const unsigned int char_spacing = char_width + 1;
for (size_t i = 0; i < Length; i++) {
const unsigned int index = pString[i] - ' ' - 1;
if (pString[i] > ' ' && pString[i] < 127) {
const uint32_t offset = i * char_spacing + 1;
memcpy(buffer + offset, font + index * char_width, char_width);
if (inv) {
memcpy_inv(buffer + offset, font + index * char_width, char_width);
} else {
memcpy(buffer + offset, font + index * char_width, char_width);
}
}
}
}
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width)
{
size_t i;
size_t Length = strlen(pString);
if (End > Start)
Start += (((End - Start) - (Length * Width)) + 1) / 2;
for (i = 0; i < Length; i++)
{
const unsigned int ofs = (unsigned int)Start + (i * Width);
if (pString[i] > ' ' && pString[i] < 127)
{
const unsigned int index = pString[i] - ' ' - 1;
memcpy(gFrameBuffer[Line + 0] + ofs, &gFontBig[index][0], 7);
memcpy(gFrameBuffer[Line + 1] + ofs, &gFontBig[index][7], 7);
}
}
}
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t char_width, const uint8_t *font)
{
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t char_width,
const uint8_t *font, bool inv) {
const size_t Length = strlen(pString);
const unsigned int char_spacing = char_width + 1;
@@ -107,79 +101,99 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
Start += (((End - Start) - Length * char_spacing) + 1) / 2;
}
UI_PrintStringBuffer(pString, gFrameBuffer[Line] + Start, char_width, font);
UI_PrintStringBuffer(pString, gFrameBuffer[Line] + Start, char_width, font, inv);
}
void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
{
UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *)gFontSmall);
void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) {
UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *) gFontSmall, false);
}
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
{
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width) {
Width = Width;
UI_PrintStringSmallNormal(pString, Start, End, Line);
// size_t i;
// size_t Length = strlen(pString);
//
// if (End > Start)
// Start += (((End - Start) - (Length * Width)) + 1) / 2;
//
// for (i = 0; i < Length; i++)
// {
// const unsigned int ofs = (unsigned int)Start + (i * Width);
// if (pString[i] > ' ' && pString[i] < 127)
// {
// const unsigned int index = pString[i] - ' ' - 1;
// memcpy(gFrameBuffer[Line + 0] + ofs, &gFontSmall[index + '0'][0], 7);
// memcpy(gFrameBuffer[Line + 1] + ofs, &gFontSmall[index + '0'][7], 7);
// }
// }
}
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) {
//#ifdef ENABLE_SMALL_BOLD
// const uint8_t *font = (uint8_t *)gFontSmallBold;
// const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]);
//#else
// const uint8_t *font = (uint8_t *) gFontSmall;
// const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]);
//#endif
//
// UI_PrintStringSmall(pString, Start, End, Line, char_width, font);
UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *) gFontSmall, true);
}
void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t *buffer) {
UI_PrintStringBuffer(pString, buffer, ARRAY_SIZE(gFontSmall[0]), (uint8_t *) gFontSmall, false);
}
void UI_PrintStringSmallBufferBold(const char *pString, uint8_t *buffer) {
#ifdef ENABLE_SMALL_BOLD
const uint8_t *font = (uint8_t *)gFontSmallBold;
const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]);
#else
const uint8_t *font = (uint8_t *)gFontSmall;
const uint8_t *font = (uint8_t *) gFontSmall;
const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]);
#endif
UI_PrintStringSmall(pString, Start, End, Line, char_width, font);
UI_PrintStringBuffer(pString, buffer, char_width, font, false);
}
void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t * buffer)
{
UI_PrintStringBuffer(pString, buffer, ARRAY_SIZE(gFontSmall[0]), (uint8_t *)gFontSmall);
}
void UI_PrintStringSmallBufferBold(const char *pString, uint8_t * buffer)
{
#ifdef ENABLE_SMALL_BOLD
const uint8_t *font = (uint8_t *)gFontSmallBold;
const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]);
#else
const uint8_t *font = (uint8_t *)gFontSmall;
const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]);
#endif
UI_PrintStringBuffer(pString, buffer, char_width, font);
}
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
{
const unsigned int char_width = 13;
uint8_t *pFb0 = gFrameBuffer[Y] + X;
uint8_t *pFb1 = pFb0 + 128;
bool bCanDisplay = false;
uint8_t len = strlen(string);
for(int i = 0; i < len; i++) {
char c = string[i];
if(c=='-') c = '9' + 1;
if (bCanDisplay || c != ' ')
{
bCanDisplay = true;
if(c>='0' && c<='9' + 1) {
memcpy(pFb0 + 2, gFontBigDigits[c-'0'], char_width - 3);
memcpy(pFb1 + 2, gFontBigDigits[c-'0'] + char_width - 3, char_width - 3);
}
else if(c=='.') {
*pFb1 = 0x60; pFb0++; pFb1++;
*pFb1 = 0x60; pFb0++; pFb1++;
*pFb1 = 0x60; pFb0++; pFb1++;
continue;
}
}
else if (center) {
pFb0 -= 6;
pFb1 -= 6;
}
pFb0 += char_width;
pFb1 += char_width;
}
}
//void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center) {
// const unsigned int char_width = 13;
// uint8_t *pFb0 = gFrameBuffer[Y] + X;
// uint8_t *pFb1 = pFb0 + 128;
// bool bCanDisplay = false;
//
// uint8_t len = strlen(string);
// for (int i = 0; i < len; i++) {
// char c = string[i];
// if (c == '-') c = '9' + 1;
// if (bCanDisplay || c != ' ') {
// bCanDisplay = true;
// if (c >= '0' && c <= '9' + 1) {
// memcpy(pFb0 + 2, gFontSmall[(unsigned char) c], char_width - 3);
// memcpy(pFb1 + 2, gFontSmall[(unsigned char) c] + char_width - 3, char_width - 3);
// } else if (c == '.') {
// *pFb1 = 0x60;
// pFb0++;
// pFb1++;
// *pFb1 = 0x60;
// pFb0++;
// pFb1++;
// *pFb1 = 0x60;
// pFb0++;
// pFb1++;
// continue;
// }
//
// } else if (center) {
// pFb0 -= 6;
// pFb1 -= 6;
// }
// pFb0 += char_width;
// pFb1 += char_width;
// }
//}
/*
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
@@ -221,18 +235,16 @@ void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
}
*/
void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black)
{
void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black) {
const uint8_t pattern = 1 << (y % 8);
if(black)
buffer[y/8][x] |= pattern;
if (black)
buffer[y / 8][x] |= pattern;
else
buffer[y/8][x] &= ~pattern;
buffer[y / 8][x] &= ~pattern;
}
static void sort(int16_t *a, int16_t *b)
{
if(*a > *b) {
static void sort(int16_t *a, int16_t *b) {
if (*a > *b) {
int16_t t = *a;
*a = *b;
*b = t;
@@ -240,66 +252,13 @@ static void sort(int16_t *a, int16_t *b)
}
#ifdef ENABLE_FEAT_F4HWN
/*
void UI_DrawLineDottedBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
{
if(x2==x1) {
sort(&y1, &y2);
for(int16_t i = y1; i <= y2; i+=2) {
UI_DrawPixelBuffer(buffer, x1, i, black);
}
} else {
const int multipl = 1000;
int a = (y2-y1)*multipl / (x2-x1);
int b = y1 - a * x1 / multipl;
sort(&x1, &x2);
for(int i = x1; i<= x2; i+=2)
{
UI_DrawPixelBuffer(buffer, i, i*a/multipl +b, black);
}
}
}
*/
void PutPixel(uint8_t x, uint8_t y, bool fill) {
UI_DrawPixelBuffer(gFrameBuffer, x, y, fill);
}
void PutPixelStatus(uint8_t x, uint8_t y, bool fill) {
UI_DrawPixelBuffer(&gStatusLine, x, y, fill);
}
void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y,
bool statusbar, bool fill) {
uint8_t c;
uint8_t pixels;
const uint8_t *p = (const uint8_t *)pString;
while ((c = *p++) && c != '\0') {
c -= 0x20;
for (int i = 0; i < 3; ++i) {
pixels = gFont3x5[c][i];
for (int j = 0; j < 6; ++j) {
if (pixels & 1) {
if (statusbar)
PutPixelStatus(x + i, y + j, fill);
else
PutPixel(x + i, y + j, fill);
}
pixels >>= 1;
}
}
x += 4;
}
}
#endif
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
/*
void UI_DrawLineDottedBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
{
if(x2==x1) {
sort(&y1, &y2);
for(int16_t i = y1; i <= y2; i++) {
for(int16_t i = y1; i <= y2; i+=2) {
UI_DrawPixelBuffer(buffer, x1, i, black);
}
} else {
@@ -308,24 +267,75 @@ void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x
int b = y1 - a * x1 / multipl;
sort(&x1, &x2);
for(int i = x1; i<= x2; i++)
for(int i = x1; i<= x2; i+=2)
{
UI_DrawPixelBuffer(buffer, i, i*a/multipl +b, black);
}
}
}
*/
void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
{
UI_DrawLineBuffer(buffer, x1,y1, x1,y2, black);
UI_DrawLineBuffer(buffer, x1,y1, x2,y1, black);
UI_DrawLineBuffer(buffer, x2,y1, x2,y2, black);
UI_DrawLineBuffer(buffer, x1,y2, x2,y2, black);
void PutPixel(uint8_t x, uint8_t y, bool fill) {
UI_DrawPixelBuffer(gFrameBuffer, x, y, fill);
}
void PutPixelStatus(uint8_t x, uint8_t y, bool fill) {
UI_DrawPixelBuffer(&gStatusLine, x, y, fill);
}
void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y,
bool statusbar, bool fill) {
uint8_t c;
uint8_t pixels;
const uint8_t *p = (const uint8_t *) pString;
while ((c = *p++) && c != '\0') {
c -= 0x20;
for (int i = 0; i < 3; ++i) {
pixels = gFont3x5[c][i];
for (int j = 0; j < 6; ++j) {
if (pixels & 1) {
if (statusbar)
PutPixelStatus(x + i, y + j, fill);
else
PutPixel(x + i, y + j, fill);
}
pixels >>= 1;
}
}
x += 4;
}
}
#endif
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) {
if (x2 == x1) {
sort(&y1, &y2);
for (int16_t i = y1; i <= y2; i++) {
UI_DrawPixelBuffer(buffer, x1, i, black);
}
} else {
const int multipl = 1000;
int a = (y2 - y1) * multipl / (x2 - x1);
int b = y1 - a * x1 / multipl;
sort(&x1, &x2);
for (int i = x1; i <= x2; i++) {
UI_DrawPixelBuffer(buffer, i, i * a / multipl + b, black);
}
}
}
void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) {
UI_DrawLineBuffer(buffer, x1, y1, x1, y2, black);
UI_DrawLineBuffer(buffer, x1, y1, x2, y1, black);
UI_DrawLineBuffer(buffer, x2, y1, x2, y2, black);
UI_DrawLineBuffer(buffer, x1, y2, x2, y2, black);
}
void UI_DisplayPopup(const char *string)
{
void UI_DisplayPopup(const char *string) {
UI_DisplayClear();
// for(uint8_t i = 1; i < 5; i++) {
@@ -346,7 +356,6 @@ void UI_DisplayPopup(const char *string)
UI_PrintStringSmallNormal("Press EXIT", 9, 118, 6);
}
void UI_DisplayClear()
{
void UI_DisplayClear() {
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
}