This commit is contained in:
e2002
2022-10-14 11:00:49 +03:00
parent dbe0f32e14
commit 1c4b1dec6e
94 changed files with 5320 additions and 6613 deletions

View File

@@ -0,0 +1,82 @@
#ifndef common_gfx_h
#define common_gfx_h
public:
DspCore();
char plMenu[PLMITEMS][PLMITEMLENGHT];
void initDisplay();
void drawLogo(uint16_t top);
void clearDsp(bool black=false);
void printClock(){}
void printClock(uint16_t top, uint16_t rightspace, uint16_t timeheight, bool redraw);
void clearClock();
char* utf8Rus(const char* str, bool uppercase);
void drawPlaylist(uint16_t currentItem, char* currentItemText);
void loop(bool force=false);
void charSize(uint8_t textsize, uint8_t& width, uint16_t& height);
#ifndef DSP_LCD
#if DSP_MODEL==DSP_NOKIA5110
virtual void command(uint8_t c);
virtual void data(uint8_t c);
#else
virtual void startWrite(void);
virtual void endWrite(void);
#endif
void setTextSize(uint8_t s);
#else
uint16_t width();
uint16_t height();
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){}
void setTextSize(uint8_t s){}
void setTextSize(uint8_t sx, uint8_t sy){}
void setTextColor(uint16_t c, uint16_t bg){}
void setFont(){}
void apScreen();
#endif
void flip();
void invert();
void sleep();
void wake();
void writePixel(int16_t x, int16_t y, uint16_t color);
void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void setClipping(clipArea ca);
void clearClipping();
void setScrollId(void * scrollid) { _scrollid = scrollid; }
void * getScrollId() { return _scrollid; }
void setNumFont();
uint16_t textWidth(const char *txt);
#if DSP_MODEL==DSP_ILI9225
uint16_t width(void) { return (int16_t)maxX(); }
uint16_t height(void) { return (int16_t)maxY(); }
void drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap, int16_t w, int16_t h);
uint16_t print(const char* s);
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void setFont(const GFXfont *f = NULL);
void setFont(uint8_t* font, bool monoSp=false );
void setTextColor(uint16_t fg, uint16_t bg);
void setCursor(int16_t x, int16_t y);
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
uint16_t drawChar(uint16_t x, uint16_t y, uint16_t ch, uint16_t color = COLOR_WHITE);
#endif
private:
char _timeBuf[20], _dateBuf[20], _oldTimeBuf[20], _oldDateBuf[20], _bufforseconds[4], _buffordate[40];
uint16_t _timewidth, _timeleft, _datewidth, _dateleft, _oldtimeleft, _oldtimewidth, _olddateleft, _olddatewidth, clockTop, clockRightSpace, clockTimeHeight, _dotsLeft;
bool _clipping, _printdots;
clipArea _cliparea;
void * _scrollid;
void _getTimeBounds();
void _clockSeconds();
void _clockDate();
void _clockTime();
uint8_t _charWidth(unsigned char c);
#if DSP_MODEL==DSP_ILI9225
uint16_t _bgcolor, _fgcolor;
int16_t _cursorx, _cursory;
bool _gFont/*, _started*/;
#endif
#endif

View File

@@ -0,0 +1,18 @@
#ifndef _display_l10n_h
#define _display_l10n_h
//==================================================
#if L10N_LANGUAGE==RU
#define L10N_PATH "../../../locale/displayL10n_ru.h"
#else
#define L10N_PATH "../../../locale/displayL10n_en.h"
#endif
#if __has_include("../../../locale/displayL10n_custom.h")
#include "../../../locale/displayL10n_custom.h"
#else
#include L10N_PATH
#endif
//==================================================
#endif

View File

@@ -0,0 +1,78 @@
#ifndef utf8RusGFX_h
#define utf8RusGFX_h
char* DspCore::utf8Rus(const char* str, bool uppercase) {
int index = 0;
static char strn[BUFLEN];
bool E = false;
strlcpy(strn, str, BUFLEN);
if (uppercase) {
bool next = false;
for (char *iter = strn; *iter != '\0'; ++iter)
{
if (E) {
E = false;
continue;
}
byte rus = (byte) * iter;
if (rus == 208 && (byte) * (iter + 1) == 129) { // ёКостыли
*iter = (char)209;
*(iter + 1) = (char)145;
E = true;
continue;
}
if (rus == 209 && (byte) * (iter + 1) == 145) {
*iter = (char)209;
*(iter + 1) = (char)145;
E = true;
continue;
}
if (next) {
if (rus >= 128 && rus <= 143) *iter = (char)(rus + 32);
if (rus >= 176 && rus <= 191) *iter = (char)(rus - 32);
next = false;
}
if (rus == 208) next = true;
if (rus == 209) {
*iter = (char)208;
next = true;
}
*iter = toupper(*iter);
}
}
while (strn[index])
{
if (strn[index] >= 0xBF)
{
switch (strn[index]) {
case 0xD0: {
if (strn[index + 1] == 0x81) {
strn[index] = 0xA8;
break;
}
if (strn[index + 1] >= 0x90 && strn[index + 1] <= 0xBF) strn[index] = strn[index + 1] + 0x30;
break;
}
case 0xD1: {
if (strn[index + 1] == 0x91) {
//strn[index] = 0xB7;
strn[index] = 0xB8;
break;
}
if (strn[index + 1] >= 0x80 && strn[index + 1] <= 0x8F) strn[index] = strn[index + 1] + 0x70;
break;
}
}
int sind = index + 2;
while (strn[sind]) {
strn[sind - 1] = strn[sind];
sind++;
}
strn[sind - 1] = 0;
}
index++;
}
return strn;
}
#endif

View File

@@ -0,0 +1,111 @@
#ifndef utf8RusLCD_h
#define utf8RusLCD_h
char* DspCore::utf8Rus(const char* str, bool uppercase) {
int index = 0;
static char strn[BUFLEN];
static char newStr[BUFLEN];
bool E = false;
strlcpy(strn, str, BUFLEN);
newStr[0] = '\0';
bool next = false;
for (char *iter = strn; *iter != '\0'; ++iter)
{
if (E) {
E = false;
continue;
}
byte rus = (byte) * iter;
if (rus == 208 && (byte) * (iter + 1) == 129) { // ёКостыли
*iter = (char)209;
*(iter + 1) = (char)145;
E = true;
continue;
}
if (rus == 209 && (byte) * (iter + 1) == 145) {
*iter = (char)209;
*(iter + 1) = (char)145;
E = true;
continue;
}
if (next) {
if (rus >= 128 && rus <= 143) *iter = (char)(rus + 32);
if (rus >= 176 && rus <= 191) *iter = (char)(rus - 32);
next = false;
}
if (rus == 208) next = true;
if (rus == 209) {
*iter = (char)208;
next = true;
}
*iter = toupper(*iter);
}
while (strn[index])
{
if (strlen(newStr) > BUFLEN - 2) break;
if (strn[index] >= 0xBF)
{
switch (strn[index]) {
case 0xD0: {
switch (strn[index + 1])
{
case 0x90: strcat(newStr, "A"); break;
case 0x91: strcat(newStr, "B"); break;
case 0x92: strcat(newStr, "V"); break;
case 0x93: strcat(newStr, "G"); break;
case 0x94: strcat(newStr, "D"); break;
case 0x95: strcat(newStr, "E"); break;
case 0x96: strcat(newStr, "ZH"); break;
case 0x97: strcat(newStr, "Z"); break;
case 0x98: strcat(newStr, "I"); break;
case 0x99: strcat(newStr, "Y"); break;
case 0x9A: strcat(newStr, "K"); break;
case 0x9B: strcat(newStr, "L"); break;
case 0x9C: strcat(newStr, "M"); break;
case 0x9D: strcat(newStr, "N"); break;
case 0x9E: strcat(newStr, "O"); break;
case 0x9F: strcat(newStr, "P"); break;
case 0xA0: strcat(newStr, "R"); break;
case 0xA1: strcat(newStr, "S"); break;
case 0xA2: strcat(newStr, "T"); break;
case 0xA3: strcat(newStr, "U"); break;
case 0xA4: strcat(newStr, "F"); break;
case 0xA5: strcat(newStr, "H"); break;
case 0xA6: strcat(newStr, "TS"); break;
case 0xA7: strcat(newStr, "CH"); break;
case 0xA8: strcat(newStr, "SH"); break;
case 0xA9: strcat(newStr, "SHCH"); break;
case 0xAA: strcat(newStr, "'"); break;
case 0xAB: strcat(newStr, "YU"); break;
case 0xAC: strcat(newStr, "'"); break;
case 0xAD: strcat(newStr, "E"); break;
case 0xAE: strcat(newStr, "YU"); break;
case 0xAF: strcat(newStr, "YA"); break;
}
break;
}
case 0xD1: {
if (strn[index + 1] == 0x91) {
strcat(newStr, "YO"); break;
break;
}
break;
}
}
int sind = index + 2;
while (strn[sind]) {
strn[sind - 1] = strn[sind];
sind++;
}
strn[sind - 1] = 0;
} else {
char Temp[2] = {(char) strn[index] , 0 } ;
strcat(newStr, Temp);
}
index++;
}
return newStr;
}
#endif