Fix oled draw c2 section (#147)
* format * compensate for chars excluded from font fixes #146 * added comment to explain magic 32 consolidate whitespaces in this method (really spaces should be used everywhere instead of tabs (exception for makefile) )
This commit is contained in:
committed by
Ben V. Brown
parent
d03443e783
commit
1447b1cad8
@@ -93,43 +93,48 @@ void OLED::refresh() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prints a char to the screen.
|
||||||
|
* UTF font handling is done using the two input chars.
|
||||||
|
* Precursor is the command char that is used to select the table.
|
||||||
|
*/
|
||||||
void OLED::drawChar(char c, char PrecursorCommand) {
|
void OLED::drawChar(char c, char PrecursorCommand) {
|
||||||
//prints a char to the screen
|
if (c < ' ') {
|
||||||
if (c < ' ')
|
return;
|
||||||
return;
|
}
|
||||||
//We are left with
|
|
||||||
uint8_t* charPointer;
|
|
||||||
//Fonts are offset to start at the space char.
|
|
||||||
/*
|
|
||||||
* UTF font handling is done using the two input chars
|
|
||||||
* Precursor is the command char that is used to select the table
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
uint16_t index = 0;
|
|
||||||
if (PrecursorCommand == 0)
|
|
||||||
index = (c - ' ');
|
|
||||||
else {
|
|
||||||
|
|
||||||
//This is for extended range
|
//We are left with
|
||||||
//We decode the precursor command to find the offset
|
uint8_t* charPointer;
|
||||||
//Latin stats at 96
|
|
||||||
c -= 0x80;
|
|
||||||
if (PrecursorCommand == 0xC3)
|
|
||||||
index = (128) + (c);
|
|
||||||
else if (PrecursorCommand == 0xC2)
|
|
||||||
index = (96) + (c);
|
|
||||||
else if (PrecursorCommand == 0xD0)
|
|
||||||
index = (192) + (c);
|
|
||||||
else if (PrecursorCommand == 0xD1)
|
|
||||||
index = (256) + (c);
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
charPointer = ((uint8_t*) currentFont) + ((fontWidth * (fontHeight / 8)) * index);
|
|
||||||
|
|
||||||
if (cursor_x >= 0 && cursor_x < 96)
|
uint16_t index = 0;
|
||||||
drawArea(cursor_x, cursor_y, fontWidth, fontHeight, charPointer);
|
if (PrecursorCommand == 0) {
|
||||||
cursor_x += fontWidth;
|
//Fonts are offset to start at the space char
|
||||||
|
index = (c - ' ');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//This is for extended range
|
||||||
|
//We decode the precursor command to find the offset
|
||||||
|
//Latin starts at 96
|
||||||
|
c -= 0x80;
|
||||||
|
|
||||||
|
switch (PrecursorCommand) {
|
||||||
|
|
||||||
|
case 0xC2: index = (96 - 32) + (c); break; //-32 compensate for chars excluded from font C2 section
|
||||||
|
case 0xC3: index = (128) + (c); break;
|
||||||
|
case 0xD0: index = (192) + (c); break;
|
||||||
|
case 0xD1: index = (256) + (c); break;
|
||||||
|
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
charPointer = ((uint8_t*) currentFont) + ((fontWidth * (fontHeight / 8)) * index);
|
||||||
|
|
||||||
|
if (cursor_x >= 0 && cursor_x < 96) {
|
||||||
|
drawArea(cursor_x, cursor_y, fontWidth, fontHeight, charPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor_x += fontWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OLED::displayOnOff(bool on) {
|
void OLED::displayOnOff(bool on) {
|
||||||
|
|||||||
Reference in New Issue
Block a user