Patch to handle UTF slightly better.

Not perfect but working for now
This commit is contained in:
Ben V. Brown
2017-09-17 12:21:25 +10:00
parent 0aae546dc9
commit 0e7e304f4e
4 changed files with 61 additions and 55 deletions

View File

@@ -24,7 +24,7 @@ const u8* Data_Command(u8 len, const u8* ptr);
void Clear_Screen(void); //Clear the screen void Clear_Screen(void); //Clear the screen
/*Functions for writing to the screen*/ /*Functions for writing to the screen*/
void OLED_DrawString(const char* string, const uint8_t length); void OLED_DrawString(const char* string, const uint8_t length);
void OLED_DrawChar(char c, uint8_t x); void OLED_DrawChar(char c, uint8_t x,char preCursor);
void OLED_DrawExtraFontChars(uint8_t id, uint8_t x); void OLED_DrawExtraFontChars(uint8_t id, uint8_t x);
void OLED_DrawSymbolChar(uint8_t id, uint8_t x); void OLED_DrawSymbolChar(uint8_t id, uint8_t x);
void OLED_DrawWideChar(uint8_t id, uint8_t x); void OLED_DrawWideChar(uint8_t id, uint8_t x);

View File

@@ -466,7 +466,7 @@ void DrawUI() {
if (StatusFlags == 8) if (StatusFlags == 8)
OLED_DrawExtraFontChars(2, 4); OLED_DrawExtraFontChars(2, 4);
else { else {
OLED_DrawChar(' ', 4); OLED_DrawChar(' ', 4, 0);
} }
//Draw in battery symbol if desired //Draw in battery symbol if desired
if (systemSettings.cutoutSetting) { if (systemSettings.cutoutSetting) {
@@ -521,12 +521,12 @@ void DrawUI() {
case TEMP_ADJ: case TEMP_ADJ:
//We are prompting the user to change the temp so we draw the current setpoint temp //We are prompting the user to change the temp so we draw the current setpoint temp
//With the nifty arrows //With the nifty arrows
OLED_DrawChar(' ', 0); OLED_DrawChar(' ', 0,0);
OLED_DrawChar('<', 1); OLED_DrawChar('<', 1,0);
drawTemp(systemSettings.SolderingTemp, 2, 0); drawTemp(systemSettings.SolderingTemp, 2, 0);
OLED_DrawChar(' ', 5); OLED_DrawChar(' ', 5,0);
OLED_DrawChar(' ', 7); OLED_DrawChar(' ', 7,0);
OLED_DrawChar('>', 6); OLED_DrawChar('>', 6,0);
break; break;
case SETTINGS: case SETTINGS:
//We are prompting the user the setting name //We are prompting the user the setting name
@@ -546,7 +546,7 @@ void DrawUI() {
+ settingsLongTestScrollPos, lengthLeft); + settingsLongTestScrollPos, lengthLeft);
if (lengthLeft < 8) if (lengthLeft < 8)
for (uint8_t i = lengthLeft; i < 8; i++) for (uint8_t i = lengthLeft; i < 8; i++)
OLED_DrawChar(' ', i); OLED_DrawChar(' ', i, 0);
if (millis() - lastOLEDDrawTime > 120) { if (millis() - lastOLEDDrawTime > 120) {
settingsLongTestScrollPos++; settingsLongTestScrollPos++;
lastOLEDDrawTime = millis(); lastOLEDDrawTime = millis();
@@ -558,12 +558,12 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[UVCO], 6); OLED_DrawString(SettingsShortNames[UVCO], 6);
if (systemSettings.cutoutSetting == 0) { if (systemSettings.cutoutSetting == 0) {
//DC //DC
OLED_DrawChar('D', 6); OLED_DrawChar('D', 6, 0);
OLED_DrawChar('C', 7); OLED_DrawChar('C', 7, 0);
} else { } else {
//S count //S count
OLED_DrawChar('2' + systemSettings.cutoutSetting, 6); OLED_DrawChar('2' + systemSettings.cutoutSetting, 6, 0);
OLED_DrawChar('S', 7); OLED_DrawChar('S', 7, 0);
} }
break; break;
case SLEEP_TEMP: case SLEEP_TEMP:
@@ -575,11 +575,11 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[SLEEP_TIME], 5); OLED_DrawString(SettingsShortNames[SLEEP_TIME], 5);
//Draw in the timescale //Draw in the timescale
if (systemSettings.SleepTime < 6) { if (systemSettings.SleepTime < 6) {
OLED_DrawChar('S', 7); OLED_DrawChar('S', 7, 0);
OLED_DrawTwoNumber(systemSettings.SleepTime * 10, 5); OLED_DrawTwoNumber(systemSettings.SleepTime * 10, 5);
} else { } else {
OLED_DrawChar('M', 7); OLED_DrawChar('M', 7, 0);
OLED_DrawTwoNumber(systemSettings.SleepTime - 5, 5); OLED_DrawTwoNumber(systemSettings.SleepTime - 5, 5);
} }
break; break;
@@ -590,29 +590,29 @@ void DrawUI() {
case TEMPDISPLAY:/*Are we showing in C or F ?*/ case TEMPDISPLAY:/*Are we showing in C or F ?*/
OLED_DrawString(SettingsShortNames[TEMPDISPLAY], 7); OLED_DrawString(SettingsShortNames[TEMPDISPLAY], 7);
if (systemSettings.displayTempInF) if (systemSettings.displayTempInF)
OLED_DrawChar(SettingTempFChar, 7); OLED_DrawChar(SettingTempFChar, 7, 0);
else else
OLED_DrawChar(SettingTempCChar, 7); OLED_DrawChar(SettingTempCChar, 7, 0);
break; break;
case SCREENROTATION: case SCREENROTATION:
OLED_DrawString(SettingsShortNames[SCREENROTATION], 7); OLED_DrawString(SettingsShortNames[SCREENROTATION], 7);
switch (systemSettings.OrientationMode) { switch (systemSettings.OrientationMode) {
case 0: case 0:
OLED_DrawChar(SettingRightChar, 7); OLED_DrawChar(SettingRightChar, 7, 0);
break; break;
case 1: case 1:
OLED_DrawChar(SettingLeftChar, 7); OLED_DrawChar(SettingLeftChar, 7, 0);
break; break;
case 2: case 2:
OLED_DrawChar(SettingAutoChar, 7); OLED_DrawChar(SettingAutoChar, 7, 0);
break; break;
} }
break; break;
case MOTIONSENSITIVITY: case MOTIONSENSITIVITY:
OLED_DrawString(SettingsShortNames[MOTIONSENSITIVITY], 7); OLED_DrawString(SettingsShortNames[MOTIONSENSITIVITY], 7);
OLED_DrawChar('0' + systemSettings.sensitivity, 7); OLED_DrawChar('0' + systemSettings.sensitivity, 7,0);
break; break;
case TEMPROUNDING: case TEMPROUNDING:
//We are prompting the user about their display mode preferences //We are prompting the user about their display mode preferences
@@ -621,13 +621,13 @@ void DrawUI() {
switch (systemSettings.temperatureRounding) { switch (systemSettings.temperatureRounding) {
case ROUNDING_NONE: case ROUNDING_NONE:
OLED_DrawChar('1', 7); OLED_DrawChar('1', 7,0);
break; break;
case ROUNDING_FIVE: case ROUNDING_FIVE:
OLED_DrawChar('5', 7); OLED_DrawChar('5', 7,0);
break; break;
case ROUNDING_TEN: case ROUNDING_TEN:
OLED_DrawChar('X', 7); OLED_DrawChar('X', 7,0);
break; break;
} }
} }
@@ -638,13 +638,13 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[DISPUPDATERATE], 7); OLED_DrawString(SettingsShortNames[DISPUPDATERATE], 7);
switch (systemSettings.displayUpdateSpeed) { switch (systemSettings.displayUpdateSpeed) {
case DISPLAYMODE_FAST: case DISPLAYMODE_FAST:
OLED_DrawChar(SettingFastChar, 7); OLED_DrawChar(SettingFastChar, 7,0);
break; break;
case DISPLAYMODE_SLOW: case DISPLAYMODE_SLOW:
OLED_DrawChar(SettingSlowChar, 7); OLED_DrawChar(SettingSlowChar, 7,0);
break; break;
case DISPLAYMODE_MEDIUM: case DISPLAYMODE_MEDIUM:
OLED_DrawChar(SettingMediumChar, 7); OLED_DrawChar(SettingMediumChar, 7,0);
break; break;
} }
@@ -655,10 +655,10 @@ void DrawUI() {
switch (systemSettings.boostModeEnabled) { switch (systemSettings.boostModeEnabled) {
case 1: case 1:
OLED_DrawChar(SettingTrueChar, 7); OLED_DrawChar(SettingTrueChar, 7,0);
break; break;
case 0: case 0:
OLED_DrawChar(SettingFalseChar, 7); OLED_DrawChar(SettingFalseChar, 7,0);
break; break;
} }
break; break;
@@ -670,10 +670,10 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[POWERDISPLAY], 7); OLED_DrawString(SettingsShortNames[POWERDISPLAY], 7);
switch (systemSettings.powerDisplay) { switch (systemSettings.powerDisplay) {
case 1: case 1:
OLED_DrawChar(SettingTrueChar, 7); OLED_DrawChar(SettingTrueChar, 7,0);
break; break;
case 0: case 0:
OLED_DrawChar(SettingFalseChar, 7); OLED_DrawChar(SettingFalseChar, 7,0);
break; break;
} }
@@ -682,13 +682,13 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[AUTOSTART], 7); OLED_DrawString(SettingsShortNames[AUTOSTART], 7);
switch (systemSettings.autoStart) { switch (systemSettings.autoStart) {
case 1: case 1:
OLED_DrawChar(SettingTrueChar, 7); OLED_DrawChar(SettingTrueChar, 7,0);
break; break;
case 0: case 0:
OLED_DrawChar(SettingFalseChar, 7); OLED_DrawChar(SettingFalseChar, 7,0);
break; break;
case 2: case 2:
OLED_DrawChar(SettingSleepChar, 7); OLED_DrawChar(SettingSleepChar, 7,0);
break; break;
} }
break; break;
@@ -696,10 +696,10 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[COOLINGBLINK], 7); OLED_DrawString(SettingsShortNames[COOLINGBLINK], 7);
switch (systemSettings.coolingTempBlink) { switch (systemSettings.coolingTempBlink) {
case 1: case 1:
OLED_DrawChar(SettingTrueChar, 7); OLED_DrawChar(SettingTrueChar, 7,0);
break; break;
case 0: case 0:
OLED_DrawChar(SettingFalseChar, 7); OLED_DrawChar(SettingFalseChar, 7,0);
break; break;
} }
break; break;
@@ -759,14 +759,14 @@ void DrawUI() {
if (StatusFlags == 0 || ((millis() % 1000) > 500)) { if (StatusFlags == 0 || ((millis() % 1000) > 500)) {
OLED_DrawString("IN", 2); OLED_DrawString("IN", 2);
OLED_DrawChar(48 + ((voltage / 100) % 10), 2); OLED_DrawChar(48 + ((voltage / 100) % 10), 2,0);
voltage -= (voltage / 100) * 100; voltage -= (voltage / 100) * 100;
OLED_DrawChar(48 + ((voltage / 10) % 10), 3); OLED_DrawChar(48 + ((voltage / 10) % 10), 3,0);
voltage -= (voltage / 10) * 10; voltage -= (voltage / 10) * 10;
OLED_DrawChar('.', 4); OLED_DrawChar('.', 4,0);
OLED_DrawChar(48 + (voltage % 10), 5); OLED_DrawChar(48 + (voltage % 10), 5,0);
OLED_DrawChar('V', 6); OLED_DrawChar('V', 6,0);
OLED_DrawChar(' ', 7); OLED_DrawChar(' ', 7,0);
} else { } else {
OLED_DrawString("IN ", 8); OLED_DrawString("IN ", 8);
} }

View File

@@ -192,13 +192,19 @@ void Clear_Screen(void) {
*/ */
void OLED_DrawString(const char* string, const uint8_t length) { void OLED_DrawString(const char* string, const uint8_t length) {
for (uint8_t i = 0; i < length; i++) { for (uint8_t i = 0; i < length; i++) {
OLED_DrawChar(string[i], i); if (string[i] >= 0x80) {
OLED_DrawChar(string[i + 1], i, string[i]);
i++;
OLED_DrawChar(' ', i,0);
} else
OLED_DrawChar(string[i], i, '\0');
} }
} }
/* /*
* Draw a char onscreen at letter index x * Draw a char onscreen at letter index x
*/ */
void OLED_DrawChar(char c, uint8_t x) { void OLED_DrawChar(char c, uint8_t x, char preCursor) {
if (x > 7) if (x > 7)
return; //clipping return; //clipping
@@ -208,9 +214,9 @@ void OLED_DrawChar(char c, uint8_t x) {
if (c < 0x80) { if (c < 0x80) {
ptr = (u8*) FONT; ptr = (u8*) FONT;
offset = c - ' '; offset = c - ' ';
} else if (c >= 0xA0) { } else if (preCursor>0) {
ptr = (u8*) FontLatin2; ptr = (u8*) FontLatin2;
offset = c - 0xA0; //this table starts at 0xA0 offset = c - 0xA0+0x40; //this table starts at 0xA0
} else } else
return; //not in font return; //not in font
@@ -252,27 +258,27 @@ void OLED_BlankSlot(uint8_t xStart, uint8_t width) {
*/ */
void OLED_DrawTwoNumber(uint8_t in, uint8_t x) { void OLED_DrawTwoNumber(uint8_t in, uint8_t x) {
OLED_DrawChar(48 + (in / 10) % 10, x); OLED_DrawChar(48 + (in / 10) % 10, x,0);
OLED_DrawChar(48 + in % 10, x + 1); OLED_DrawChar(48 + in % 10, x + 1,0);
} }
/* /*
* Draw a 3 digit number to the display at letter slot x * Draw a 3 digit number to the display at letter slot x
*/ */
void OLED_DrawThreeNumber(uint16_t in, uint8_t x) { void OLED_DrawThreeNumber(uint16_t in, uint8_t x) {
OLED_DrawChar(48 + (in / 100) % 10, x); OLED_DrawChar(48 + (in / 100) % 10, x,0);
OLED_DrawChar(48 + (in / 10) % 10, x + 1); OLED_DrawChar(48 + (in / 10) % 10, x + 1,0);
OLED_DrawChar(48 + in % 10, x + 2); OLED_DrawChar(48 + in % 10, x + 2,0);
} }
/* /*
* Draw a 4 digit number to the display at letter slot x * Draw a 4 digit number to the display at letter slot x
*/ */
void OLED_DrawFourNumber(uint16_t in, uint8_t x) { void OLED_DrawFourNumber(uint16_t in, uint8_t x) {
OLED_DrawChar(48 + (in / 1000) % 10, x); OLED_DrawChar(48 + (in / 1000) % 10, x,0);
OLED_DrawChar(48 + (in / 100) % 10, x + 1); OLED_DrawChar(48 + (in / 100) % 10, x + 1,0);
OLED_DrawChar(48 + (in / 10) % 10, x + 2); OLED_DrawChar(48 + (in / 10) % 10, x + 2,0);
OLED_DrawChar(48 + (in % 10), x + 3); OLED_DrawChar(48 + (in % 10), x + 3,0);
} }
void OLED_DrawIDLELogo() { void OLED_DrawIDLELogo() {

View File

@@ -5,7 +5,7 @@
* Author: Ben V. Brown * Author: Ben V. Brown
*/ */
#include "Strings.h" #include "Strings.h"
#define LANG_EN #define LANG_IT
#ifdef LANG_EN #ifdef LANG_EN
const char* SettingsLongNames[14] = { const char* SettingsLongNames[14] = {
/*These are all the help text for all the settings.*/ /*These are all the help text for all the settings.*/