Hi,
i'm accessing a DIP204-4 via 4-bit-mode. i had to replace some chars (unicode-chars are most difficult)
here my current code (maybe someone needs it):
void ChangeUnicode(char *text,int pos,char c)
{
text[pos]=c;
for (int j=pos+1;j<strlen(text)-1;j++)
{
text[j]=text[j+1];
}
text[strlen(text)-1]='\0';
}
void ChangeChars(char *text)
{
for (int i=0;i<strlen(text);i++)
{
//char hexcode[4];
//sprintf(hexcode,"%x",text[i]);
//Serial.println(hexcode);
if ((text[i]==0xFFC2) || (text[i]==0xFFC3))
{//handling unicode
//Serial.println("handling Unicode...");
switch(text[i])
{
case 0xFFC3:
{
switch (text[i+1])
{
case 0xFF84: ChangeUnicode(text,i,0x5B); break;//Ä
case 0xFF96: ChangeUnicode(text,i,0x5C); break;//Ö
case 0xFF9C: ChangeUnicode(text,i,0x5E); break;//Ü
case 0xFFA4: ChangeUnicode(text,i,0x7B); break;//ä
case 0xFFB6: ChangeUnicode(text,i,0x7C); break;//ö
case 0xFFBC: ChangeUnicode(text,i,0x7E); break;//ü
case 0xFF9F: ChangeUnicode(text,i,0xBE); break;//ß
//C3 88 C3 89 C3 8A C3 8B (ÈÉÊË) => diagonal arrows (ul:16,ur:17,dl:18dr:19)
case 0xFF88: ChangeUnicode(text,i,0x16); break;//È => ul
case 0xFF89: ChangeUnicode(text,i,0x17); break;//É => ur
case 0xFF8A: ChangeUnicode(text,i,0x18); break;//Ê => dl
case 0xFF8B: ChangeUnicode(text,i,0x19); break;//Ë => dr
//C3 92 C3 93 C3 94 C3 95 (ÒÓÔÕ) => straight arrows (u:DE,r:DF,d:E0,l:E1)
case 0xFF92: ChangeUnicode(text,i,0xDE); break;//Ò => u
case 0xFF93: ChangeUnicode(text,i,0xDF); break;//Ó => r
case 0xFF94: ChangeUnicode(text,i,0xE0); break;//Ô => d
case 0xFF95: ChangeUnicode(text,i,0xE1); break;//Õ => l
}
}break;
case 0xFFC2:
{
switch (text[i+1])//todo: remove i+1
{
case 0xFFBD: ChangeUnicode(text,i,0x8A); break;//1/2
case 0xFFBC: ChangeUnicode(text,i,0x8B); break;//1/4
case 0xFFB5: ChangeUnicode(text,i,0x8F); break;//µ
}
}break;
}
} else
{
switch(text[i])
{
case '{': text[i]=0xFD; break;
case '}': text[i]=0xFF; break;
case '
this code works like a charm...but why is text 2 bytes (i tested using print out the hexcode of "char", see code above)?
regards Frank: text[i]=0xA2; break;
case '@': text[i]=0xA0; break;
case '[': text[i]=0xFA; break;
case ']': text[i]=0xFC; break;
}
}
}
}
void ShowTextOnDisplay(int row,int col, char *text)
{
lcd.setCursor(col,row);
//now replacing wrong chars
ChangeChars(text);
lcd.print(text);
}
this code works like a charm...but why is text *2 bytes (i tested using print out the hexcode of "char", see code above)?*
*regards Frank*