Skip to content

Commit

Permalink
Patch to handle UTF slightly better.
Browse files Browse the repository at this point in the history
Not perfect but working for now
  • Loading branch information
Ben V. Brown authored and Ben V. Brown committed Sep 17, 2017
1 parent 0aae546 commit 0e7e304
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 55 deletions.
2 changes: 1 addition & 1 deletion workspace/ts100/inc/Oled.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const u8* Data_Command(u8 len, const u8* ptr);
void Clear_Screen(void); //Clear the screen
/*Functions for writing to the screen*/
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_DrawSymbolChar(uint8_t id, uint8_t x);
void OLED_DrawWideChar(uint8_t id, uint8_t x);
Expand Down
80 changes: 40 additions & 40 deletions workspace/ts100/src/Modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ void DrawUI() {
if (StatusFlags == 8)
OLED_DrawExtraFontChars(2, 4);
else {
OLED_DrawChar(' ', 4);
OLED_DrawChar(' ', 4, 0);
}
//Draw in battery symbol if desired
if (systemSettings.cutoutSetting) {
Expand Down Expand Up @@ -521,12 +521,12 @@ void DrawUI() {
case TEMP_ADJ:
//We are prompting the user to change the temp so we draw the current setpoint temp
//With the nifty arrows
OLED_DrawChar(' ', 0);
OLED_DrawChar('<', 1);
OLED_DrawChar(' ', 0,0);
OLED_DrawChar('<', 1,0);
drawTemp(systemSettings.SolderingTemp, 2, 0);
OLED_DrawChar(' ', 5);
OLED_DrawChar(' ', 7);
OLED_DrawChar('>', 6);
OLED_DrawChar(' ', 5,0);
OLED_DrawChar(' ', 7,0);
OLED_DrawChar('>', 6,0);
break;
case SETTINGS:
//We are prompting the user the setting name
Expand All @@ -546,7 +546,7 @@ void DrawUI() {
+ settingsLongTestScrollPos, lengthLeft);
if (lengthLeft < 8)
for (uint8_t i = lengthLeft; i < 8; i++)
OLED_DrawChar(' ', i);
OLED_DrawChar(' ', i, 0);
if (millis() - lastOLEDDrawTime > 120) {
settingsLongTestScrollPos++;
lastOLEDDrawTime = millis();
Expand All @@ -558,12 +558,12 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[UVCO], 6);
if (systemSettings.cutoutSetting == 0) {
//DC
OLED_DrawChar('D', 6);
OLED_DrawChar('C', 7);
OLED_DrawChar('D', 6, 0);
OLED_DrawChar('C', 7, 0);
} else {
//S count
OLED_DrawChar('2' + systemSettings.cutoutSetting, 6);
OLED_DrawChar('S', 7);
OLED_DrawChar('2' + systemSettings.cutoutSetting, 6, 0);
OLED_DrawChar('S', 7, 0);
}
break;
case SLEEP_TEMP:
Expand All @@ -575,11 +575,11 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[SLEEP_TIME], 5);
//Draw in the timescale
if (systemSettings.SleepTime < 6) {
OLED_DrawChar('S', 7);
OLED_DrawChar('S', 7, 0);
OLED_DrawTwoNumber(systemSettings.SleepTime * 10, 5);

} else {
OLED_DrawChar('M', 7);
OLED_DrawChar('M', 7, 0);
OLED_DrawTwoNumber(systemSettings.SleepTime - 5, 5);
}
break;
Expand All @@ -590,29 +590,29 @@ void DrawUI() {
case TEMPDISPLAY:/*Are we showing in C or F ?*/
OLED_DrawString(SettingsShortNames[TEMPDISPLAY], 7);
if (systemSettings.displayTempInF)
OLED_DrawChar(SettingTempFChar, 7);
OLED_DrawChar(SettingTempFChar, 7, 0);
else
OLED_DrawChar(SettingTempCChar, 7);
OLED_DrawChar(SettingTempCChar, 7, 0);
break;
case SCREENROTATION:
OLED_DrawString(SettingsShortNames[SCREENROTATION], 7);

switch (systemSettings.OrientationMode) {
case 0:
OLED_DrawChar(SettingRightChar, 7);
OLED_DrawChar(SettingRightChar, 7, 0);
break;
case 1:
OLED_DrawChar(SettingLeftChar, 7);
OLED_DrawChar(SettingLeftChar, 7, 0);
break;
case 2:
OLED_DrawChar(SettingAutoChar, 7);
OLED_DrawChar(SettingAutoChar, 7, 0);
break;
}
break;
case MOTIONSENSITIVITY:
OLED_DrawString(SettingsShortNames[MOTIONSENSITIVITY], 7);

OLED_DrawChar('0' + systemSettings.sensitivity, 7);
OLED_DrawChar('0' + systemSettings.sensitivity, 7,0);
break;
case TEMPROUNDING:
//We are prompting the user about their display mode preferences
Expand All @@ -621,13 +621,13 @@ void DrawUI() {

switch (systemSettings.temperatureRounding) {
case ROUNDING_NONE:
OLED_DrawChar('1', 7);
OLED_DrawChar('1', 7,0);
break;
case ROUNDING_FIVE:
OLED_DrawChar('5', 7);
OLED_DrawChar('5', 7,0);
break;
case ROUNDING_TEN:
OLED_DrawChar('X', 7);
OLED_DrawChar('X', 7,0);
break;
}
}
Expand All @@ -638,13 +638,13 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[DISPUPDATERATE], 7);
switch (systemSettings.displayUpdateSpeed) {
case DISPLAYMODE_FAST:
OLED_DrawChar(SettingFastChar, 7);
OLED_DrawChar(SettingFastChar, 7,0);
break;
case DISPLAYMODE_SLOW:
OLED_DrawChar(SettingSlowChar, 7);
OLED_DrawChar(SettingSlowChar, 7,0);
break;
case DISPLAYMODE_MEDIUM:
OLED_DrawChar(SettingMediumChar, 7);
OLED_DrawChar(SettingMediumChar, 7,0);
break;

}
Expand All @@ -655,10 +655,10 @@ void DrawUI() {

switch (systemSettings.boostModeEnabled) {
case 1:
OLED_DrawChar(SettingTrueChar, 7);
OLED_DrawChar(SettingTrueChar, 7,0);
break;
case 0:
OLED_DrawChar(SettingFalseChar, 7);
OLED_DrawChar(SettingFalseChar, 7,0);
break;
}
break;
Expand All @@ -670,10 +670,10 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[POWERDISPLAY], 7);
switch (systemSettings.powerDisplay) {
case 1:
OLED_DrawChar(SettingTrueChar, 7);
OLED_DrawChar(SettingTrueChar, 7,0);
break;
case 0:
OLED_DrawChar(SettingFalseChar, 7);
OLED_DrawChar(SettingFalseChar, 7,0);
break;

}
Expand All @@ -682,24 +682,24 @@ void DrawUI() {
OLED_DrawString(SettingsShortNames[AUTOSTART], 7);
switch (systemSettings.autoStart) {
case 1:
OLED_DrawChar(SettingTrueChar, 7);
OLED_DrawChar(SettingTrueChar, 7,0);
break;
case 0:
OLED_DrawChar(SettingFalseChar, 7);
OLED_DrawChar(SettingFalseChar, 7,0);
break;
case 2:
OLED_DrawChar(SettingSleepChar, 7);
OLED_DrawChar(SettingSleepChar, 7,0);
break;
}
break;
case COOLINGBLINK:
OLED_DrawString(SettingsShortNames[COOLINGBLINK], 7);
switch (systemSettings.coolingTempBlink) {
case 1:
OLED_DrawChar(SettingTrueChar, 7);
OLED_DrawChar(SettingTrueChar, 7,0);
break;
case 0:
OLED_DrawChar(SettingFalseChar, 7);
OLED_DrawChar(SettingFalseChar, 7,0);
break;
}
break;
Expand Down Expand Up @@ -759,14 +759,14 @@ void DrawUI() {
if (StatusFlags == 0 || ((millis() % 1000) > 500)) {

OLED_DrawString("IN", 2);
OLED_DrawChar(48 + ((voltage / 100) % 10), 2);
OLED_DrawChar(48 + ((voltage / 100) % 10), 2,0);
voltage -= (voltage / 100) * 100;
OLED_DrawChar(48 + ((voltage / 10) % 10), 3);
OLED_DrawChar(48 + ((voltage / 10) % 10), 3,0);
voltage -= (voltage / 10) * 10;
OLED_DrawChar('.', 4);
OLED_DrawChar(48 + (voltage % 10), 5);
OLED_DrawChar('V', 6);
OLED_DrawChar(' ', 7);
OLED_DrawChar('.', 4,0);
OLED_DrawChar(48 + (voltage % 10), 5,0);
OLED_DrawChar('V', 6,0);
OLED_DrawChar(' ', 7,0);
} else {
OLED_DrawString("IN ", 8);
}
Expand Down
32 changes: 19 additions & 13 deletions workspace/ts100/src/Oled.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,19 @@ void Clear_Screen(void) {
*/
void OLED_DrawString(const char* string, const uint8_t length) {
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
*/
void OLED_DrawChar(char c, uint8_t x) {
void OLED_DrawChar(char c, uint8_t x, char preCursor) {
if (x > 7)
return; //clipping

Expand All @@ -208,9 +214,9 @@ void OLED_DrawChar(char c, uint8_t x) {
if (c < 0x80) {
ptr = (u8*) FONT;
offset = c - ' ';
} else if (c >= 0xA0) {
} else if (preCursor>0) {
ptr = (u8*) FontLatin2;
offset = c - 0xA0; //this table starts at 0xA0
offset = c - 0xA0+0x40; //this table starts at 0xA0
} else
return; //not in font

Expand Down Expand Up @@ -252,27 +258,27 @@ void OLED_BlankSlot(uint8_t xStart, uint8_t width) {
*/
void OLED_DrawTwoNumber(uint8_t in, uint8_t x) {

OLED_DrawChar(48 + (in / 10) % 10, x);
OLED_DrawChar(48 + in % 10, x + 1);
OLED_DrawChar(48 + (in / 10) % 10, x,0);
OLED_DrawChar(48 + in % 10, x + 1,0);
}
/*
* Draw a 3 digit number to the display at letter slot x
*/
void OLED_DrawThreeNumber(uint16_t in, uint8_t x) {

OLED_DrawChar(48 + (in / 100) % 10, x);
OLED_DrawChar(48 + (in / 10) % 10, x + 1);
OLED_DrawChar(48 + in % 10, x + 2);
OLED_DrawChar(48 + (in / 100) % 10, x,0);
OLED_DrawChar(48 + (in / 10) % 10, x + 1,0);
OLED_DrawChar(48 + in % 10, x + 2,0);
}
/*
* Draw a 4 digit number to the display at letter slot x
*/
void OLED_DrawFourNumber(uint16_t in, uint8_t x) {

OLED_DrawChar(48 + (in / 1000) % 10, x);
OLED_DrawChar(48 + (in / 100) % 10, x + 1);
OLED_DrawChar(48 + (in / 10) % 10, x + 2);
OLED_DrawChar(48 + (in % 10), x + 3);
OLED_DrawChar(48 + (in / 1000) % 10, x,0);
OLED_DrawChar(48 + (in / 100) % 10, x + 1,0);
OLED_DrawChar(48 + (in / 10) % 10, x + 2,0);
OLED_DrawChar(48 + (in % 10), x + 3,0);
}

void OLED_DrawIDLELogo() {
Expand Down
2 changes: 1 addition & 1 deletion workspace/ts100/src/Strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Author: Ben V. Brown
*/
#include "Strings.h"
#define LANG_EN
#define LANG_IT
#ifdef LANG_EN
const char* SettingsLongNames[14] = {
/*These are all the help text for all the settings.*/
Expand Down

0 comments on commit 0e7e304

Please sign in to comment.