mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Description scroll speed parametrized + smooth scroll in userConfirmation (#221)
* Enabled DOUBLE line for Croatian + translation fix Enabled DOUBLE line Menu for Croatian. A minor translation fix. * Added Double line menus for Croatian Added Double line menus for Croatian. For some reason they were not included in the previous pull request, even though I made them (most probably it was by my mistake). * Added "Power: " translation for Croatian * Menu desciption scroll sped up 3x * Slow scroll * Additional HR translation fix * EOL fixed * Fixed flickering - update only when required * Parametrized description scrolling speed * Synchronized Translation.c with original Ralim master * Removed unnecessary check * lcd.refresh() in description scroll called only when required * Smooth scrolling also implemented in userConfirmation() method * Variable messageSpeedFactor renamed to messageSpeedFactor * Variable renamed
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="1452291918433808979" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="3703734836139458" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
@@ -16,7 +16,7 @@
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="1452291918433808979" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="3703734836139458" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#ifndef FONT_H_
|
||||
#define FONT_H_
|
||||
#include "Translation.h"
|
||||
|
||||
#define FONT_12_WIDTH 12
|
||||
|
||||
/*
|
||||
* Remember screen is LSB at the top, MSB at the bottom of the strip!
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
#define DEVICEADDR_OLED (0x3c<<1)
|
||||
#define OLED_WIDTH 96
|
||||
|
||||
class OLED {
|
||||
public:
|
||||
|
||||
@@ -102,19 +102,30 @@ static void printShortDescription(uint32_t shortDescIndex,
|
||||
}
|
||||
|
||||
static int userConfirmation(const char* message) {
|
||||
uint8_t maxOffset = strlen(message) + 7;
|
||||
uint32_t messageStart = xTaskGetTickCount();
|
||||
uint16_t messageWidth = FONT_12_WIDTH * (strlen(message) + 7);
|
||||
uint32_t messageStart = HAL_GetTick();
|
||||
|
||||
lcd.setFont(0);
|
||||
lcd.setCursor(0, 0);
|
||||
int16_t lastOffset = -1;
|
||||
bool lcdRefresh = true;
|
||||
|
||||
// TODO Scrolling speed factor can be moved to User Interface settings
|
||||
uint16_t scrollingSpeedFactor = 4; // lower the value - higher the speed
|
||||
|
||||
for (;;) {
|
||||
int16_t messageOffset = (((xTaskGetTickCount() - messageStart) / 15)
|
||||
% maxOffset);
|
||||
int16_t messageOffset = (int) ((HAL_GetTick() - messageStart)
|
||||
/ (float) scrollingSpeedFactor + 0.5) % messageWidth;
|
||||
|
||||
lcd.clearScreen();
|
||||
lcd.setCursor(12 * (7 - messageOffset), 0);
|
||||
lcd.print(message);
|
||||
if (lastOffset != messageOffset) {
|
||||
lcd.clearScreen();
|
||||
|
||||
//^ Rolling offset based on time
|
||||
lcd.setCursor((OLED_WIDTH - messageOffset), 0);
|
||||
lcd.print(message);
|
||||
lastOffset = messageOffset;
|
||||
lcdRefresh = true;
|
||||
}
|
||||
|
||||
ButtonState buttons = getButtonState();
|
||||
switch (buttons) {
|
||||
@@ -132,8 +143,11 @@ static int userConfirmation(const char* message) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
lcd.refresh();
|
||||
osDelay(50);
|
||||
if (lcdRefresh) {
|
||||
lcd.refresh();
|
||||
osDelay(20);
|
||||
lcdRefresh = false;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ uint8_t PCBVersion = 0;
|
||||
uint16_t currentlyActiveTemperatureTarget = 0;
|
||||
uint32_t lastMovementTime = 0;
|
||||
uint32_t lastButtonTime = 0;
|
||||
int16_t lastOffset = 0;
|
||||
|
||||
// FreeRTOS variables
|
||||
osThreadId GUITaskHandle;
|
||||
@@ -332,6 +331,12 @@ static void gui_settingsMenu() {
|
||||
uint32_t autoRepeatTimer = 0;
|
||||
bool earlyExit = false;
|
||||
uint32_t descriptionStart = 0;
|
||||
int16_t lastOffset = -1;
|
||||
bool lcdRefresh = true;
|
||||
|
||||
// TODO Scrolling speed factor can be moved to User Interface settings
|
||||
uint16_t scrollingSpeedFactor = 4; // lower the value - higher the speed
|
||||
|
||||
while ((settingsMenu[currentScreen].incrementHandler.func != NULL)
|
||||
&& earlyExit == false) {
|
||||
lcd.setFont(0);
|
||||
@@ -341,25 +346,29 @@ static void gui_settingsMenu() {
|
||||
lcd.clearScreen();
|
||||
|
||||
settingsMenu[currentScreen].draw.func();
|
||||
lastOffset = 0;
|
||||
lastOffset = -1;
|
||||
lcdRefresh = true;
|
||||
} else {
|
||||
// Draw description
|
||||
// draw string starting from descriptionOffset
|
||||
int16_t maxOffset = strlen(settingsMenu[currentScreen].description)
|
||||
+ 7;
|
||||
int16_t descriptionWidth = FONT_12_WIDTH
|
||||
* (strlen(settingsMenu[currentScreen].description) + 7);
|
||||
if (descriptionStart == 0)
|
||||
descriptionStart = HAL_GetTick();
|
||||
|
||||
int16_t descriptionOffset = ((((HAL_GetTick() - descriptionStart)
|
||||
/ 20) % (maxOffset * 2))) * 6;
|
||||
int16_t descriptionOffset =
|
||||
(int) ((HAL_GetTick() - descriptionStart)
|
||||
/ (float) scrollingSpeedFactor + 0.5)
|
||||
% descriptionWidth;
|
||||
|
||||
if (lastOffset == 0 || lastOffset!=descriptionOffset) {
|
||||
if (lastOffset != descriptionOffset) {
|
||||
lcd.clearScreen();
|
||||
|
||||
//^ Rolling offset based on time
|
||||
lcd.setCursor(((7 * 12) - descriptionOffset), 0);
|
||||
lcd.setCursor((OLED_WIDTH - descriptionOffset), 0);
|
||||
lcd.print(settingsMenu[currentScreen].description);
|
||||
lastOffset = descriptionOffset;
|
||||
lcdRefresh = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -403,8 +412,11 @@ static void gui_settingsMenu() {
|
||||
break;
|
||||
}
|
||||
|
||||
lcd.refresh(); // update the LCD
|
||||
osDelay(20);
|
||||
if (lcdRefresh) {
|
||||
lcd.refresh(); // update the LCD
|
||||
osDelay(20);
|
||||
lcdRefresh = false;
|
||||
}
|
||||
}
|
||||
|
||||
saveSettings();
|
||||
|
||||
Reference in New Issue
Block a user