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/constants.h"
|
||||||
#include "src/language.h"
|
#include "src/language.h"
|
||||||
|
|
||||||
|
|
||||||
#define GFXFF 1
|
#define GFXFF 1
|
||||||
#define FONT24 &Aura2CondensedPro_Regular24pt7b
|
#define FONT24 &Aura2CondensedPro_Regular24pt7b
|
||||||
#define FONT14 &Aura2CondensedPro_Regular14pt8b
|
#define FONT14 &Aura2CondensedPro_Regular14pt8b
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
#include "TEF6686.h"
|
#include "TEF6686.h"
|
||||||
|
#include <map>
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
|
||||||
void TEF6686::init(byte TEF) {
|
void TEF6686::init(byte TEF) {
|
||||||
uint8_t bootstatus;
|
uint8_t bootstatus;
|
||||||
@@ -296,6 +299,10 @@ bool TEF6686::readRDS(bool showrdserrors)
|
|||||||
|
|
||||||
if (ps_process == 2) {
|
if (ps_process == 2) {
|
||||||
strcpy(rds.stationName, ps_buffer);
|
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';
|
for (int i = 0; i < 9; i++) ps_buffer[i] = '\0';
|
||||||
ps_process = 0;
|
ps_process = 0;
|
||||||
rds.hasPS = true;
|
rds.hasPS = true;
|
||||||
@@ -583,3 +590,38 @@ void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
|
|||||||
delay (time);
|
delay (time);
|
||||||
devTEF_Radio_Set_Wavegen(0, 0, 0);
|
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 stationTypeCode;
|
||||||
byte MS;
|
byte MS;
|
||||||
char stationName[9];
|
char stationName[9];
|
||||||
|
wchar_t PStext[9] = L"";
|
||||||
|
String RDSPS;
|
||||||
char stationText[65];
|
char stationText[65];
|
||||||
char stationType[17];
|
char stationType[17];
|
||||||
char musicTitle[48];
|
char musicTitle[48];
|
||||||
@@ -172,6 +174,8 @@ class TEF6686 {
|
|||||||
bool mute;
|
bool mute;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void RDScharConverter(const char* input, wchar_t* output, size_t size);
|
||||||
|
String convertToUTF8(const wchar_t* input);
|
||||||
uint16_t rdsTimeOut = 32768;
|
uint16_t rdsTimeOut = 32768;
|
||||||
uint8_t ps_process;
|
uint8_t ps_process;
|
||||||
uint8_t rt_process;
|
uint8_t rt_process;
|
||||||
@@ -184,4 +188,4 @@ class TEF6686 {
|
|||||||
byte rt_timer;
|
byte rt_timer;
|
||||||
byte offsetold;
|
byte offsetold;
|
||||||
char stationTextBuffer[65];
|
char stationTextBuffer[65];
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user