Work done on ASCII converter. (not ready yet!)
List needs to be filled.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "src/constants.h"
|
||||
#include "src/language.h"
|
||||
|
||||
|
||||
#define GFXFF 1
|
||||
#define FONT24 &Aura2CondensedPro_Regular24pt7b
|
||||
#define FONT14 &Aura2CondensedPro_Regular14pt8b
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include "TEF6686.h"
|
||||
#include <map>
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
void TEF6686::init(byte TEF) {
|
||||
uint8_t bootstatus;
|
||||
@@ -296,6 +299,10 @@ bool TEF6686::readRDS(bool showrdserrors)
|
||||
|
||||
if (ps_process == 2) {
|
||||
strcpy(rds.stationName, ps_buffer);
|
||||
|
||||
RDScharConverter(ps_buffer, rds.PStext, sizeof(rds.PStext) / sizeof(wchar_t));
|
||||
rds.RDSPS = convertToUTF8(rds.PStext);
|
||||
|
||||
for (int i = 0; i < 9; i++) ps_buffer[i] = '\0';
|
||||
ps_process = 0;
|
||||
rds.hasPS = true;
|
||||
@@ -583,3 +590,38 @@ void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
|
||||
delay (time);
|
||||
devTEF_Radio_Set_Wavegen(0, 0, 0);
|
||||
}
|
||||
|
||||
String TEF6686::convertToUTF8(const wchar_t* input) {
|
||||
String output;
|
||||
while (*input) {
|
||||
uint16_t unicode = *input;
|
||||
if (unicode < 0x80) {
|
||||
output += (char)unicode;
|
||||
} else if (unicode < 0x800) {
|
||||
output += (char)(0xC0 | (unicode >> 6));
|
||||
output += (char)(0x80 | (unicode & 0x3F));
|
||||
} else if (unicode < 0x10000) {
|
||||
output += (char)(0xE0 | (unicode >> 12));
|
||||
output += (char)(0x80 | ((unicode >> 6) & 0x3F));
|
||||
output += (char)(0x80 | (unicode & 0x3F));
|
||||
} else {
|
||||
output += (char)(0xF0 | (unicode >> 18));
|
||||
output += (char)(0x80 | ((unicode >> 12) & 0x3F));
|
||||
output += (char)(0x80 | ((unicode >> 6) & 0x3F));
|
||||
output += (char)(0x80 | (unicode & 0x3F));
|
||||
}
|
||||
input++;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
void TEF6686::RDScharConverter(const char* input, wchar_t* output, size_t size) {
|
||||
for (size_t i = 0; i < size - 1; i++) {
|
||||
char currentChar = input[i];
|
||||
switch (currentChar) {
|
||||
case 0x45: output[i] = L'ë'; break; // Test convert E to ë
|
||||
default: output[i] = static_cast<wchar_t>(currentChar); break;
|
||||
}
|
||||
}
|
||||
output[size - 1] = L'\0';
|
||||
}
|
||||
+5
-1
@@ -88,6 +88,8 @@ typedef struct _rds_ {
|
||||
byte stationTypeCode;
|
||||
byte MS;
|
||||
char stationName[9];
|
||||
wchar_t PStext[9] = L"";
|
||||
String RDSPS;
|
||||
char stationText[65];
|
||||
char stationType[17];
|
||||
char musicTitle[48];
|
||||
@@ -172,6 +174,8 @@ class TEF6686 {
|
||||
bool mute;
|
||||
|
||||
private:
|
||||
void RDScharConverter(const char* input, wchar_t* output, size_t size);
|
||||
String convertToUTF8(const wchar_t* input);
|
||||
uint16_t rdsTimeOut = 32768;
|
||||
uint8_t ps_process;
|
||||
uint8_t rt_process;
|
||||
@@ -184,4 +188,4 @@ class TEF6686 {
|
||||
byte rt_timer;
|
||||
byte offsetold;
|
||||
char stationTextBuffer[65];
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user