Skip to content

Commit 5d49b08

Browse files
committed
v0.9.693
1 parent 5f408e8 commit 5d49b08

File tree

8 files changed

+88
-183
lines changed

8 files changed

+88
-183
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ Work is in progress...
235235

236236
---
237237
## Version history
238+
#### v0.9.693
239+
- fixed incorrect behavior of the `HIDE_VU` setting [#205](https://github.com/e2002/yoradio/issues/205)
240+
- fixed `CORRUPT HEAP` error when playing "invalid links" [#203](https://github.com/e2002/yoradio/issues/203)
241+
- optimized code of `utfToAscii` [utf8Rus](https://github.com/e2002/yoradio/blob/main/yoRadio/src/displays/tools/utf8Rus.cpp)
242+
238243
#### v0.9.689
239244
- fixed artifacts in scrolling text
240245

yoRadio/src/audioI2S/Audio.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) {
427427
char *extension = NULL; // "/mp3" in "skonto.ls.lv:8002/mp3"
428428

429429
if(pos_slash > 1) {
430-
hostwoext = (char*)malloc(pos_slash + 1);
430+
hostwoext = (char*)malloc(pos_slash + 2);
431431
memcpy(hostwoext, h_host, pos_slash);
432432
hostwoext[pos_slash] = '\0';
433433
uint16_t extLen = urlencode_expected_len(h_host + pos_slash);
@@ -579,7 +579,7 @@ bool Audio::httpPrint(const char* host) {
579579
char *extension = NULL; // "/mp3" in "skonto.ls.lv:8002/mp3"
580580

581581
if(pos_slash > 1) {
582-
hostwoext = (char*)malloc(pos_slash + 1);
582+
hostwoext = (char*)malloc(pos_slash + 2);
583583
memcpy(hostwoext, h_host, pos_slash);
584584
hostwoext[pos_slash] = '\0';
585585
uint16_t extLen = urlencode_expected_len(h_host + pos_slash);

yoRadio/src/audioVS1053/audioVS1053Ex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) {
17761776
char *extension = NULL; // "/mp3" in "skonto.ls.lv:8002/mp3"
17771777

17781778
if(pos_slash > 1) {
1779-
hostwoext = (char*)malloc(pos_slash + 1);
1779+
hostwoext = (char*)malloc(pos_slash + 2);
17801780
memcpy(hostwoext, h_host, pos_slash);
17811781
hostwoext[pos_slash] = '\0';
17821782
uint16_t extLen = urlencode_expected_len(h_host + pos_slash);

yoRadio/src/core/display.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ void Display::putRequest(displayRequestType_e type, int payload){
415415
}
416416

417417
void Display::_layoutChange(bool played){
418-
if(config.store.vumeter){
418+
if(config.store.vumeter && _vuwidget){
419419
if(played){
420420
if(_vuwidget) _vuwidget->unlock();
421421
//_clock->moveTo(clockMove);
@@ -428,8 +428,9 @@ void Display::_layoutChange(bool played){
428428
}
429429
}else{
430430
if(played){
431+
if(clockMove.width<0) _clock->moveBack(); else _clock->moveTo(clockMove);
431432
if(_weather) _weather->moveTo(weatherMove);
432-
_clock->moveBack();
433+
//_clock->moveBack();
433434
}else{
434435
if(_weather) _weather->moveBack();
435436
_clock->moveBack();

yoRadio/src/core/netserver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "controls.h"
1313
#include "commandhandler.h"
1414
#include "timekeeper.h"
15+
#include "../displays/dspcore.h"
1516
#include "../displays/widgets/widgetsconfig.h" //BitrateFormat
1617

1718
#if DSP_MODEL==DSP_DUMMY

yoRadio/src/core/options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define options_h
33
#pragma once
44

5-
#define YOVERSION "0.9.689"
5+
#define YOVERSION "0.9.693"
66

77
/*******************************************************
88
DO NOT EDIT THIS FILE.

yoRadio/src/displays/tools/utf8Rus.cpp

Lines changed: 74 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -3,190 +3,87 @@
33
#include "../dspcore.h"
44
#include "utf8Rus.h"
55

6-
#ifndef DSP_LCD
7-
char* utf8Rus(const char* str, bool uppercase) {
8-
int index = 0;
9-
static char strn[BUFLEN];
10-
bool E = false;
11-
strlcpy(strn, str, BUFLEN);
12-
if (uppercase) {
13-
bool next = false;
14-
for (char *iter = strn; *iter != '\0'; ++iter)
15-
{
16-
if (E) {
17-
E = false;
18-
continue;
19-
}
20-
uint8_t rus = (uint8_t) * iter;
21-
if (rus == 208 && (uint8_t) * (iter + 1) == 129) { // ёКостыли
22-
*iter = (char)209;
23-
*(iter + 1) = (char)145;
24-
E = true;
25-
continue;
26-
}
27-
if (rus == 209 && (uint8_t) * (iter + 1) == 145) {
28-
*iter = (char)209;
29-
*(iter + 1) = (char)145;
30-
E = true;
31-
continue;
32-
}
33-
if (next) {
34-
if (rus >= 128 && rus <= 143) *iter = (char)(rus + 32);
35-
if (rus >= 176 && rus <= 191) *iter = (char)(rus - 32);
36-
next = false;
37-
}
38-
if (rus == 208) next = true;
39-
if (rus == 209) {
40-
*iter = (char)208;
41-
next = true;
42-
}
43-
*iter = toupper(*iter);
44-
}
45-
}
46-
if(L10N_LANGUAGE==EN) return strn;
47-
while (strn[index])
48-
{
49-
if (strn[index] >= 0xBF)
50-
{
51-
switch (strn[index]) {
52-
case 0xD0: {
53-
if (strn[index + 1] == 0x81) {
54-
strn[index] = 0xA8;
55-
break;
56-
}
57-
if (strn[index + 1] >= 0x90 && strn[index + 1] <= 0xBF) strn[index] = strn[index + 1] + 0x30;
58-
break;
59-
}
60-
case 0xD1: {
61-
if (strn[index + 1] == 0x91) {
62-
//strn[index] = 0xB7;
63-
strn[index] = 0xB8;
64-
break;
65-
}
66-
if (strn[index + 1] >= 0x80 && strn[index + 1] <= 0x8F) strn[index] = strn[index + 1] + 0x70;
67-
break;
68-
}
69-
}
70-
int sind = index + 2;
71-
while (strn[sind]) {
72-
strn[sind - 1] = strn[sind];
73-
sind++;
74-
}
75-
strn[sind - 1] = 0;
6+
size_t strlen_utf8(const char* s) {
7+
size_t count = 0;
8+
while (*s) {
9+
count++;
10+
if ((*s & 0xF0) == 0xF0) { // 4-byte character
11+
s += 4;
12+
} else if ((*s & 0xE0) == 0xE0) { // 3-byte character
13+
s += 3;
14+
} else if ((*s & 0xC0) == 0xC0) { // 2-byte character
15+
s += 2;
16+
} else { // 1-byte character (ASCII)
17+
s += 1;
7618
}
77-
index++;
7819
}
79-
return strn;
20+
return count;
8021
}
81-
#else //#ifndef DSP_LCD
82-
char* utf8Rus(const char* str, bool uppercase) {
83-
int index = 0;
84-
static char strn[BUFLEN];
85-
static char newStr[BUFLEN];
86-
bool E = false;
87-
strlcpy(strn, str, BUFLEN);
88-
newStr[0] = '\0';
89-
bool next = false;
90-
for (char *iter = strn; *iter != '\0'; ++iter)
91-
{
92-
if (E) {
93-
E = false;
94-
continue;
95-
}
96-
uint8_t rus = (uint8_t) * iter;
97-
if (rus == 208 && (uint8_t) * (iter + 1) == 129) { // ёКостыли
98-
*iter = (char)209;
99-
*(iter + 1) = (char)145;
100-
E = true;
101-
continue;
102-
}
103-
if (rus == 209 && (uint8_t) * (iter + 1) == 145) {
104-
*iter = (char)209;
105-
*(iter + 1) = (char)145;
106-
E = true;
107-
continue;
108-
}
109-
if (next) {
110-
if (rus >= 128 && rus <= 143) *iter = (char)(rus + 32);
111-
if (rus >= 176 && rus <= 191) *iter = (char)(rus - 32);
112-
next = false;
113-
}
114-
if (rus == 208) next = true;
115-
if (rus == 209) {
116-
*iter = (char)208;
117-
next = true;
118-
}
119-
*iter = toupper(*iter);
120-
}
12122

122-
while (strn[index])
123-
{
124-
if (strlen(newStr) > BUFLEN - 2) break;
125-
if (strn[index] >= 0xBF)
126-
{
127-
switch (strn[index]) {
128-
case 0xD0: {
129-
switch (strn[index + 1])
130-
{
131-
case 0x90: strcat(newStr, "A"); break;
132-
case 0x91: strcat(newStr, "B"); break;
133-
case 0x92: strcat(newStr, "V"); break;
134-
case 0x93: strcat(newStr, "G"); break;
135-
case 0x94: strcat(newStr, "D"); break;
136-
case 0x95: strcat(newStr, "E"); break;
137-
case 0x96: strcat(newStr, "ZH"); break;
138-
case 0x97: strcat(newStr, "Z"); break;
139-
case 0x98: strcat(newStr, "I"); break;
140-
case 0x99: strcat(newStr, "Y"); break;
141-
case 0x9A: strcat(newStr, "K"); break;
142-
case 0x9B: strcat(newStr, "L"); break;
143-
case 0x9C: strcat(newStr, "M"); break;
144-
case 0x9D: strcat(newStr, "N"); break;
145-
case 0x9E: strcat(newStr, "O"); break;
146-
case 0x9F: strcat(newStr, "P"); break;
147-
case 0xA0: strcat(newStr, "R"); break;
148-
case 0xA1: strcat(newStr, "S"); break;
149-
case 0xA2: strcat(newStr, "T"); break;
150-
case 0xA3: strcat(newStr, "U"); break;
151-
case 0xA4: strcat(newStr, "F"); break;
152-
case 0xA5: strcat(newStr, "H"); break;
153-
case 0xA6: strcat(newStr, "TS"); break;
154-
case 0xA7: strcat(newStr, "CH"); break;
155-
case 0xA8: strcat(newStr, "SH"); break;
156-
case 0xA9: strcat(newStr, "SHCH"); break;
157-
case 0xAA: strcat(newStr, "'"); break;
158-
case 0xAB: strcat(newStr, "YU"); break;
159-
case 0xAC: strcat(newStr, "'"); break;
160-
case 0xAD: strcat(newStr, "E"); break;
161-
case 0xAE: strcat(newStr, "YU"); break;
162-
case 0xAF: strcat(newStr, "YA"); break;
163-
}
164-
break;
165-
}
166-
case 0xD1: {
167-
if (strn[index + 1] == 0x91) {
168-
strcat(newStr, "YO"); break;
169-
break;
170-
}
171-
break;
172-
}
23+
char* utf8Rus(const char* str, bool uppercase) {
24+
static char out[BUFLEN];
25+
int outPos = 0;
26+
#ifdef DSP_LCD
27+
static const char* mapD0[] = {
28+
"A","B","V","G","D","E","ZH","Z","I","Y",
29+
"K","L","M","N","O","P","R","S","T","U",
30+
"F","H","TS","CH","SH","SHCH","'","YU","'","E","YU","YA"
31+
};
32+
#endif
33+
for (int i = 0; str[i] && outPos < BUFLEN - 1; i++) {
34+
uint8_t c = (uint8_t)str[i];
35+
if (c == 0xD0 && str[i+1]) {
36+
uint8_t n = (uint8_t)str[++i];
37+
if (n == 0x81) { // Ё
38+
#ifdef DSP_LCD
39+
const char* t = "YO";
40+
for (; *t && outPos < BUFLEN-1; t++) out[outPos++] = *t;
41+
#else
42+
out[outPos++] = uppercase ? 0xA8 : 0xB8;
43+
#endif
44+
} else if (n >= 144 && n <= 191) {
45+
#ifdef DSP_LCD
46+
if(n>=176) n-=32;
47+
const char* t = mapD0[n - 0x90];
48+
for (; *t && outPos < BUFLEN-1; t++) out[outPos++] = *t;
49+
#else
50+
uint8_t ch = n + 48;
51+
if(n>=176 && uppercase) ch-=32;
52+
out[outPos++] = ch;
53+
#endif
17354
}
174-
int sind = index + 2;
175-
while (strn[sind]) {
176-
strn[sind - 1] = strn[sind];
177-
sind++;
55+
} else if (c == 0xD1 && str[i+1]) {
56+
uint8_t n = (uint8_t)str[++i];
57+
if (n == 0x91) { // ё
58+
#ifdef DSP_LCD
59+
const char* t = "YO";
60+
for (; *t && outPos < BUFLEN-1; t++) out[outPos++] = *t;
61+
#else
62+
out[outPos++] = uppercase ? 0xA8 : 0xB8;
63+
#endif
64+
} else if (n >= 128 && n <= 143) {
65+
#ifdef DSP_LCD
66+
n+=16;
67+
const char* t = mapD0[n - 128];
68+
for (; *t && outPos < BUFLEN-1; t++) out[outPos++] = *t;
69+
#else
70+
uint8_t ch = n + 112;
71+
if(uppercase) ch-=32;
72+
out[outPos++] = ch;
73+
#endif
17874
}
179-
strn[sind - 1] = 0;
180-
} else {
181-
if(strn[index]==7) strn[index]=165;
182-
if(strn[index]==9) strn[index]=223;
183-
char Temp[2] = {(char) strn[index] , 0 } ;
184-
strcat(newStr, Temp);
75+
} else { // ASCII
76+
#ifdef DSP_LCD
77+
char ch = (char)toupper(c);
78+
if (ch == 7) ch = (char)165;
79+
if (ch == 9) ch = (char)223;
80+
out[outPos++] = ch;
81+
#else
82+
out[outPos++] = uppercase ? toupper(c) : c;
83+
#endif
18584
}
186-
index++;
18785
}
188-
return newStr;
86+
out[outPos] = 0;
87+
return out;
18988
}
190-
#endif //#ifndef DSP_LCD
191-
19289

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef utf8Rus_h
22
#define utf8Rus_h
33

4+
size_t strlen_utf8(const char* s);
45
char* utf8Rus(const char* str, bool uppercase);
56

67
#endif

0 commit comments

Comments
 (0)