This commit is contained in:
105
ui/helper.c
105
ui/helper.c
@@ -78,6 +78,13 @@ void *memcpy_inv(void *dst, const void *src, size_t n) {
|
||||
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;
|
||||
const uint32_t total_width = Length * char_spacing; // Total width of the text
|
||||
|
||||
if (inv) {
|
||||
// Draw background rectangle from 1 px before the first char to 1 px after the last char
|
||||
memset(buffer, 0xFF, total_width + 2);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < Length; i++) {
|
||||
const unsigned int index = pString[i] - ' ' - 1;
|
||||
if (pString[i] > ' ' && pString[i] < 127) {
|
||||
@@ -91,7 +98,6 @@ void UI_PrintStringBuffer(const char *pString, uint8_t *buffer, uint32_t char_wi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@@ -109,26 +115,25 @@ void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End,
|
||||
UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *) gFontSmall, false);
|
||||
}
|
||||
|
||||
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_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line /*, uint8_t 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
|
||||
@@ -149,7 +154,7 @@ void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t *buffer) {
|
||||
|
||||
void UI_PrintStringSmallBufferBold(const char *pString, uint8_t *buffer) {
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
const uint8_t *font = (uint8_t *)gFontSmallBold;
|
||||
const uint8_t *font = (uint8_t *) gFontSmallBold;
|
||||
const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]);
|
||||
#else
|
||||
const uint8_t *font = (uint8_t *) gFontSmall;
|
||||
@@ -283,6 +288,30 @@ 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;
|
||||
// }
|
||||
//}
|
||||
|
||||
void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y,
|
||||
bool statusbar, bool fill) {
|
||||
uint8_t c;
|
||||
@@ -291,22 +320,25 @@ void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y,
|
||||
|
||||
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);
|
||||
for (int i = 0; i < (int) ARRAY_SIZE(gFontSmall[0]); ++i) {
|
||||
if (c) {
|
||||
pixels = gFontSmall[c - 1][i];
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
if (pixels & 1) {
|
||||
if (statusbar)
|
||||
PutPixelStatus(x + i, y + j, fill);
|
||||
else
|
||||
PutPixel(x + i, y + j, fill);
|
||||
}
|
||||
pixels >>= 1;
|
||||
}
|
||||
pixels >>= 1;
|
||||
}
|
||||
}
|
||||
x += 4;
|
||||
x += ARRAY_SIZE(gFontSmall[0]) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) {
|
||||
@@ -352,10 +384,17 @@ void UI_DisplayPopup(const char *string) {
|
||||
// UI_DrawPixelBuffer(117, y, true);
|
||||
// }
|
||||
// DrawRectangle(9,9, 118,38, true);
|
||||
UI_PrintString(string, 9, 118, 2, 8);
|
||||
UI_PrintString(string, 9, 118, 2 /*, 8 */);
|
||||
UI_PrintStringSmallNormal("Press EXIT", 9, 118, 6);
|
||||
}
|
||||
|
||||
void UI_ClearLine(uint8_t Line) {
|
||||
if (Line < 8) { // ST7565 has 8 pages (rows of 8 pixels)
|
||||
memset(gFrameBuffer[Line], 0x00, 128); // Clear all pixels on the line
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UI_DisplayClear() {
|
||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
||||
}
|
||||
|
Reference in New Issue
Block a user