aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2017-12-12 11:53:43 +1100
committerBen V. Brown <[email protected]>2017-12-12 11:53:43 +1100
commitc5c89a516eb5f9106cdba18d575597ec2908f2db (patch)
tree0571a25bc4adeb7fe6cae9f51396e20b17d80577
parent9d536c4d2520c5682700ce2ec8d04431406527bd (diff)
downloadIronOS-c5c89a516eb5f9106cdba18d575597ec2908f2db.tar.gz
IronOS-c5c89a516eb5f9106cdba18d575597ec2908f2db.zip
Pixel by Pixel scrolling
Closes #140
-rw-r--r--workspace/TS100/inc/Translation.h2
-rw-r--r--workspace/TS100/src/OLED.cpp107
-rw-r--r--workspace/TS100/src/main.cpp9
-rw-r--r--workspace/ts100/.cproject10
4 files changed, 72 insertions, 56 deletions
diff --git a/workspace/TS100/inc/Translation.h b/workspace/TS100/inc/Translation.h
index 158bf2ec..950acff6 100644
--- a/workspace/TS100/inc/Translation.h
+++ b/workspace/TS100/inc/Translation.h
@@ -23,7 +23,7 @@ extern const char SettingRightChar;
extern const char SettingLeftChar;
extern const char SettingAutoChar;
-//#define LANG_EN
+#define LANG_EN
//#define LANG_RU
//#define LANG_ES
//#define LANG_SE
diff --git a/workspace/TS100/src/OLED.cpp b/workspace/TS100/src/OLED.cpp
index e81f5286..90614026 100644
--- a/workspace/TS100/src/OLED.cpp
+++ b/workspace/TS100/src/OLED.cpp
@@ -63,7 +63,8 @@ void OLED::initialize() {
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
HAL_Delay(5);
//Send the setup settings
- HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, configLength, 0xFFFF);
+ HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array,
+ configLength, 0xFFFF);
//displayOnOff(true);
}
@@ -73,9 +74,9 @@ void OLED::refresh() {
screenBuffer[0] = 0x80;
screenBuffer[1] = 0x21;
screenBuffer[2] = 0x80;
- screenBuffer[3] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide
+ screenBuffer[3] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide
screenBuffer[4] = 0x80;
- screenBuffer[5] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide)
+ screenBuffer[5] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide)
screenBuffer[6] = 0x80; //Set pages to rollover after 2
screenBuffer[7] = 0x22;
@@ -88,7 +89,8 @@ void OLED::refresh() {
taskENTER_CRITICAL();
//Because I2C is shared, we cant task switch in the middle of the xfer
- HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED, screenBuffer, 12 + 96 * 2 + 1, 0xFFFF);
+ HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED, screenBuffer, 12 + 96 * 2 + 1,
+ 0xFFFF);
taskEXIT_CRITICAL();
}
@@ -99,42 +101,49 @@ void OLED::refresh() {
* Precursor is the command char that is used to select the table.
*/
void OLED::drawChar(char c, char PrecursorCommand) {
- if (c < ' ') {
- return;
- }
-
- //We are left with
- uint8_t* charPointer;
-
- uint16_t index = 0;
- if (PrecursorCommand == 0) {
- //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;
+ if (c < ' ') {
+ return;
+ }
+
+ //We are left with
+ uint8_t* charPointer;
+
+ uint16_t index = 0;
+ if (PrecursorCommand == 0) {
+ //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);
+
+ drawArea(cursor_x, cursor_y, fontWidth, fontHeight, charPointer);
+
+ cursor_x += fontWidth;
}
void OLED::displayOnOff(bool on) {
@@ -165,7 +174,8 @@ void OLED::setRotation(bool leftHanded) {
}
taskENTER_CRITICAL();
- HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, 50, 0xFFFF);
+ HAL_I2C_Master_Transmit(i2c, DEVICEADDR_OLED,
+ (uint8_t*) OLED_Setup_Array, 50, 0xFFFF);
taskEXIT_CRITICAL();
inLeftHandedMode = leftHanded;
}
@@ -257,26 +267,31 @@ void OLED::drawBattery(uint8_t state) {
void OLED::drawSymbol(uint8_t symbolID) {
//draw a symbol to the current cursor location
setFont(2);
- drawChar(' ' + symbolID); // space offset is in all fonts, so we pad it here and remove it later
+ drawChar(' ' + symbolID); // space offset is in all fonts, so we pad it here and remove it later
setFont(0);
}
//Draw an area, but y must be aligned on 0/8 offset
-void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t* ptr) {
+void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
+ const uint8_t* ptr) {
// Splat this from x->x+wide in two strides
if (x < 0)
return; //cutoffleft
- if ((x + wide) > 96)
+ if ((x) > 96)
return; //cutoff right
+ uint8_t width = wide;
+ if ((x + wide) > 96)
+ width = 96 - x; // trimming to draw partials
+
if (y == 0) {
//Splat first line of data
- for (uint8_t xx = 0; xx < (wide); xx++) {
+ for (uint8_t xx = 0; xx < (width); xx++) {
firstStripPtr[xx + x] = ptr[xx];
}
}
if (y == 8 || height == 16) {
// Splat the second line
- for (uint8_t xx = 0; xx < wide; xx++) {
+ for (uint8_t xx = 0; xx < width; xx++) {
secondStripPtr[x + xx] = ptr[xx + (height == 16 ? wide : 0)];
}
diff --git a/workspace/TS100/src/main.cpp b/workspace/TS100/src/main.cpp
index 1392922c..672e8b34 100644
--- a/workspace/TS100/src/main.cpp
+++ b/workspace/TS100/src/main.cpp
@@ -314,7 +314,8 @@ static void gui_settingsMenu() {
settingsResetRequest = false;
bool earlyExit = false;
uint32_t descriptionStart = 0;
- while ((settingsMenu[currentScreen].incrementHandler.func != NULL) && earlyExit == false) {
+ while ((settingsMenu[currentScreen].incrementHandler.func != NULL)
+ && earlyExit == false) {
lcd.setFont(0);
lcd.clearScreen();
lcd.setCursor(0, 0);
@@ -331,9 +332,9 @@ static void gui_settingsMenu() {
descriptionStart = HAL_GetTick();
int16_t descriptionOffset = (((HAL_GetTick() - descriptionStart)
- / 150) % maxOffset);
+ / 10) % (maxOffset * 12));
//^ Rolling offset based on time
- lcd.setCursor(12 * (7 - descriptionOffset), 0);
+ lcd.setCursor(((7 * 12) - descriptionOffset), 0);
lcd.print(settingsMenu[currentScreen].description);
}
@@ -376,7 +377,7 @@ static void gui_settingsMenu() {
}
lcd.refresh(); //update the LCD
- GUIDelay();
+ osDelay(20);
HAL_IWDG_Refresh(&hiwdg);
}
diff --git a/workspace/ts100/.cproject b/workspace/ts100/.cproject
index 83c86dfa..5714c8cf 100644
--- a/workspace/ts100/.cproject
+++ b/workspace/ts100/.cproject
@@ -124,12 +124,12 @@
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573" name="Release" parent="fr.ac6.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.bin&quot;; arm-none-eabi-size -B &quot;${BuildArtifactFileName}&quot; ;arm-none-eabi-objcopy -O ihex &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.hex&quot;">
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573." name="/" resourcePath="">
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release.1456567544" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release">
- <option id="fr.ac6.managedbuild.option.gnu.cross.mcu.67332574" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" value="STM32F103T8Ux" valueType="string"/>
- <option id="fr.ac6.managedbuild.option.gnu.cross.board.1570943989" name="Board" superClass="fr.ac6.managedbuild.option.gnu.cross.board" value="ts100" valueType="string"/>
+ <option id="fr.ac6.managedbuild.option.gnu.cross.mcu.67332574" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" useByScannerDiscovery="false" value="STM32F103T8Ux" valueType="string"/>
+ <option id="fr.ac6.managedbuild.option.gnu.cross.board.1570943989" name="Board" superClass="fr.ac6.managedbuild.option.gnu.cross.board" useByScannerDiscovery="false" value="ts100" valueType="string"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="fr.ac6.managedbuild.targetPlatform.gnu.cross.793444160" isAbstract="false" osList="all" superClass="fr.ac6.managedbuild.targetPlatform.gnu.cross"/>
<builder buildPath="${workspace_loc:/TS100}/Release" id="fr.ac6.managedbuild.builder.gnu.cross.548236022" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="fr.ac6.managedbuild.builder.gnu.cross"/>
<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.1363306495" name="MCU GCC Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler">
- <option id="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level.1100266163" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.c.optimization.level.more" valueType="enumerated"/>
+ <option id="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level.1100266163" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.c.optimization.level.size" valueType="enumerated"/>
<option id="gnu.c.compiler.option.debugging.level.2139237845" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.1770182855" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/inc&quot;"/>
@@ -154,7 +154,7 @@
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s.1210653460" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s"/>
</tool>
<tool id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.1414722294" name="MCU G++ Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler">
- <option id="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level.1489744363" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.cpp.optimization.level.more" valueType="enumerated"/>
+ <option id="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level.1489744363" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.cpp.optimization.level.size" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.debugging.level.641509376" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.105977434" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/inc&quot;"/>
@@ -188,7 +188,7 @@
</tool>
<tool id="fr.ac6.managedbuild.tool.gnu.archiver.907512577" name="MCU GCC Archiver" superClass="fr.ac6.managedbuild.tool.gnu.archiver"/>
<tool id="fr.ac6.managedbuild.tool.gnu.cross.assembler.1906472572" name="MCU GCC Assembler" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler">
- <option id="gnu.both.asm.option.include.paths.1277819409" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <option id="gnu.both.asm.option.include.paths.1277819409" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/inc&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/CMSIS/core&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/CMSIS/device&quot;"/>