1
0
forked from me/IronOS

Animated icons (#866)

* Add animation Icons

* 2D dimensional array

* Added animation to GUI

* Added Adnimation Speed setting

* Added loop

* Added Loop switch

* Use Checkbox instead of +/-

* Animations can now be turned off

* Optimize animation code

* Move animation options to UI settings
This commit is contained in:
PlayDay
2021-03-15 08:01:12 +01:00
committed by GitHub
parent c7d69b37c5
commit 2796f095af
34 changed files with 1174 additions and 239 deletions

View File

@@ -147,224 +147,694 @@ const uint8_t disconnectedTipIcon[] = {
/*
* 16x16 icons
* 32 * 3 = Frame size * Frame count
* */
const uint8_t SettingsMenuIcons[] = {
const uint8_t SettingsMenuIcons[][32 * 3] = {
// Power
// 3 frames
// width = 16
// height = 16
0xC0,
0xB0,
0x8C,
0x83,
0x01,
0x01,
0x21,
0x31,
0xA9,
0x65,
0x03,
0x42,
0x62,
0x52,
0xCA,
0x06,
0x60,
0x58,
0x26,
0x11,
0x08,
0xC4,
0xB2,
0x4D,
0x23,
0x10,
0x08,
0x04,
0x02,
0x01,
0x00,
0x00,
{
// Power 1 frame
// width = 16
// height = 16
0xC0,
0xB0,
0x8C,
0x83,
0x01,
0x01,
0x21,
0x31,
0xB9,
0xFD,
0xFF,
0xFE,
0xFE,
0xDE,
0xCE,
0x06,
0x60,
0x58,
0x26,
0x11,
0x08,
0xC4,
0xF2,
0x7D,
0x3F,
0x1F,
0x0F,
0x07,
0x03,
0x01,
0x00,
0x00,
// Power 2 frame
// width = 16
// height = 16
0xC0,
0xF0,
0xFC,
0xFF,
0xFF,
0xFF,
0xFF,
0xFF,
0xEF,
0x67,
0x03,
0x42,
0x62,
0x52,
0xCA,
0x06,
0x60,
0x78,
0x3E,
0x1F,
0x0F,
0xC7,
0xB3,
0x4D,
0x23,
0x10,
0x08,
0x04,
0x02,
0x01,
0x00,
0x00,
// Power final frame
// width = 16
// height = 16
0xC0,
0xB0,
0x8C,
0x83,
0x01,
0x01,
0x21,
0x31,
0xA9,
0x65,
0x03,
0x42,
0x62,
0x52,
0xCA,
0x06,
0x60,
0x58,
0x26,
0x11,
0x08,
0xC4,
0xB2,
0x4D,
0x23,
0x10,
0x08,
0x04,
0x02,
0x01,
0x00,
0x00,
},
// Soldering
// 3 frames
// width = 16
// height = 16
0x00,
0x02,
0x04,
0x08,
0x12,
0x24,
0xC4,
0x42,
0x82,
0x04,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x01,
0x02,
0x07,
0x0A,
0x14,
0x28,
0x50,
0x60,
0x00,
{
// Soldering 1 frame
// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x80,
0x40,
0xE0,
0x50,
0x28,
0x14,
0x0A,
0x06,
0x00,
0x00,
0x40,
0x20,
0x10,
0x08,
0x04,
0x03,
0x02,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
// Soldering 2 frame
// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x80,
0x40,
0xE0,
0x50,
0x28,
0x14,
0x0A,
0x06,
0x00,
0x00,
0x48,
0x26,
0x10,
0x08,
0x04,
0x03,
0x02,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
// Soldering final frame
// width = 16
// height = 16
0x00,
0x80,
0x40,
0x00,
0x00,
0x00,
0x00,
0x80,
0x40,
0xE0,
0x50,
0x28,
0x14,
0x0A,
0x06,
0x00,
0x00,
0x49,
0x26,
0x10,
0x08,
0x04,
0x03,
0x02,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
},
// Sleep
// 3 frames
// width = 16
// height = 16
0x00,
0xC6,
0xE6,
0xF6,
0xBE,
0x9E,
0x8E,
0x86,
0x00,
0x00,
0x40,
0x40,
0xC0,
0xC0,
0xC0,
0x00,
0x00,
0x01,
0x01,
0x01,
0x45,
0x65,
0x75,
0x5D,
0x4C,
0x00,
0x06,
0x07,
0x07,
0x05,
0x04,
0x00,
{
// Sleep 1 frame
// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x44,
0x64,
0x74,
0x5C,
0x4C,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
// Sleep 2 frame
// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x40,
0x40,
0xC0,
0xC0,
0xC0,
0x00,
0x00,
0x00,
0x00,
0x00,
0x44,
0x64,
0x74,
0x5C,
0x4C,
0x00,
0x06,
0x07,
0x07,
0x05,
0x04,
0x00,
// Sleep final frame
// width = 16
// height = 16
0x00,
0xC6,
0xE6,
0xF6,
0xBE,
0x9E,
0x8E,
0x86,
0x00,
0x00,
0x40,
0x40,
0xC0,
0xC0,
0xC0,
0x00,
0x00,
0x01,
0x01,
0x01,
0x45,
0x65,
0x75,
0x5D,
0x4C,
0x00,
0x06,
0x07,
0x07,
0x05,
0x04,
0x00,
},
// Menu
// 3 frames
// width = 16
// height = 16
0x00,
0x80,
0x06,
0x86,
0x46,
0x06,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x00,
0x00,
0x00,
0x61,
0x60,
0x00,
0x00,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x00,
{
// Menu 1 frame
// width = 16
// height = 16
0x00,
0x80,
0x06,
0x06,
0x06,
0x06,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x00,
0x00,
0x00,
0x60,
0x60,
0x00,
0x00,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x00,
// Menu 2 frame
// width = 16
// height = 16
0x00,
0x80,
0x06,
0x06,
0x06,
0x06,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x00,
0x00,
0x00,
0x61,
0x60,
0x00,
0x00,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x00,
// Menu final frame
// width = 16
// height = 16
0x00,
0x80,
0x06,
0x86,
0x46,
0x06,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x86,
0x00,
0x00,
0x00,
0x61,
0x60,
0x00,
0x00,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x61,
0x00,
},
// Wrench
// 3 frames
/// width = 16
// height = 16
0x00,
0x18,
0x30,
0x32,
0x7E,
0x7C,
0xF0,
0xC0,
0x80,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x01,
0x03,
0x0F,
0x3E,
0x7E,
0x4C,
0x0C,
0x18,
0x00,
{
// Wrench 1 frame
/// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x18,
0x30,
0x32,
0x7E,
0x7C,
0xF0,
0xC0,
// Wrench 2 frame
/// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0xC0,
0x80,
0x90,
0xF0,
0xE0,
0x80,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x01,
0x01,
0x03,
0x03,
0x07,
0x0E,
0x1C,
0x78,
0xF0,
0xF0,
0x60,
// Wrench final frame
/// width = 16
// height = 16
0x00,
0x18,
0x30,
0x32,
0x7E,
0x7C,
0xF0,
0xC0,
0x80,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x01,
0x03,
0x0F,
0x3E,
0x7E,
0x4C,
0x0C,
0x18,
0x00,
},
#ifdef NOTUSED
// Calibration (Not used, kept for future menu layouts)
// 3 frames
// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x80,
0xC0,
0xE8,
0x70,
0x7A,
0x5E,
0x8E,
0x1C,
0x30,
0x00,
0x00,
0x10,
0x38,
0x1C,
0x0E,
0x07,
0x03,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
{
// Calibration 1 frame (Not used, kept for future menu layouts)
// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x80,
0xC0,
0xE0,
0x70,
0x3A,
0x1E,
0x0E,
0x1C,
0x30,
0x00,
0x00,
0x10,
0x3A,
0x1C,
0x1E,
0x17,
0x23,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
// Calibration 2 frame (Not used, kept for future menu layouts)
// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0x00,
0x40,
0x80,
0xC0,
0xE0,
0x70,
0x3A,
0x1E,
0x0E,
0x1C,
0x30,
0x00,
0x00,
0x10,
0x38,
0x1C,
0x0E,
0x07,
0x03,
0x03,
0x02,
0x04,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
// Calibration final frame (Not used, kept for future menu layouts)
// width = 16
// height = 16
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x80,
0xC0,
0xE8,
0x70,
0x7A,
0x5E,
0x8E,
0x1C,
0x30,
0x00,
0x00,
0x10,
0x38,
0x1C,
0x0E,
0x07,
0x03,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
}
#endif
};

View File

@@ -10,7 +10,7 @@
#ifndef SETTINGS_H_
#define SETTINGS_H_
#include <stdint.h>
#define SETTINGSVERSION (0x26)
#define SETTINGSVERSION (0x28)
/*Change this if you change the struct below to prevent people getting \
out of sync*/
@@ -29,6 +29,8 @@ typedef struct {
uint8_t QCIdealVoltage; // Desired QC3.0 voltage (9,12,20V)
uint8_t OrientationMode : 2; // Selects between Auto,Right and left handed layouts
uint8_t sensitivity : 4; // Sensitivity of accelerometer (5 bits)
uint8_t animationLoop : 1; // Animation loop switch
uint16_t animationSpeed; // Animation speed (in miliseconds)
uint8_t autoStartMode : 2; // Should the unit automatically jump straight
// into soldering mode when power is applied
uint8_t ShutdownTime; // Time until unit shuts down if left alone

View File

@@ -12,8 +12,8 @@ extern const uint8_t USER_FONT_12[];
extern const uint8_t USER_FONT_6x8[];
extern const bool HasFahrenheit;
extern const char *SettingsShortNames[29][2];
extern const char *SettingsDescriptions[29];
extern const char *SettingsShortNames[31][2];
extern const char *SettingsDescriptions[31];
extern const char *SettingsMenuEntries[5];
extern const char *SettingsCalibrationDone;

View File

@@ -70,6 +70,8 @@ void resetSettings() {
systemSettings.coolingTempBlink = COOLING_TEMP_BLINK; // Blink the temperature on the cooling screen when its > 50C
systemSettings.temperatureInF = TEMPERATURE_INF; // default to 0
systemSettings.descriptionScrollSpeed = DESCRIPTION_SCROLL_SPEED; // default to slow
systemSettings.animationLoop = ANIMATION_LOOP; // Default false
systemSettings.animationSpeed = ANIMATION_SPEED; // Default 400 ms (Medium)
systemSettings.CalibrationOffset = CALIBRATION_OFFSET; // the adc offset in uV
systemSettings.powerLimit = POWER_LIMIT; // 30 watts default limit
systemSettings.ReverseButtonTempChangeEnabled = REVERSE_BUTTON_TEMP_CHANGE; //

View File

@@ -70,6 +70,10 @@ static void settings_displayTempChangeLongStep(void);
static bool settings_setTempChangeLongStep(void);
static void settings_displayPowerPulse(void);
static bool settings_setPowerPulse(void);
static void settings_displayAnimationSpeed(void);
static bool settings_setAnimationSpeed(void);
static void settings_displayAnimationLoop(void);
static bool settings_setAnimationLoop(void);
#ifdef HALL_SENSOR
static void settings_displayHallEffect(void);
static bool settings_setHallEffect(void);
@@ -126,34 +130,34 @@ static bool settings_enterAdvancedMenu(void);
*
*/
const menuitem rootSettingsMenu[]{
/*
* Power Menu
* Soldering Menu
* Power Saving Menu
* UI Menu
* Advanced Menu
* Exit
*/
{(const char *)NULL, settings_enterPowerMenu, settings_displayPowerMenu}, /*Power*/
{(const char *)NULL, settings_enterSolderingMenu, settings_displaySolderingMenu}, /*Soldering*/
{(const char *)NULL, settings_enterPowerSavingMenu, settings_displayPowerSavingMenu}, /*Sleep Options Menu*/
{(const char *)NULL, settings_enterUIMenu, settings_displayUIMenu}, /*UI Menu*/
{(const char *)NULL, settings_enterAdvancedMenu, settings_displayAdvancedMenu}, /*Advanced Menu*/
{NULL, NULL, NULL} // end of menu marker. DO NOT REMOVE
/*
* Power Menu
* Soldering Menu
* Power Saving Menu
* UI Menu
* Advanced Menu
* Exit
*/
{(const char *)NULL, settings_enterPowerMenu, settings_displayPowerMenu}, /*Power*/
{(const char *)NULL, settings_enterSolderingMenu, settings_displaySolderingMenu}, /*Soldering*/
{(const char *)NULL, settings_enterPowerSavingMenu, settings_displayPowerSavingMenu}, /*Sleep Options Menu*/
{(const char *)NULL, settings_enterUIMenu, settings_displayUIMenu}, /*UI Menu*/
{(const char *)NULL, settings_enterAdvancedMenu, settings_displayAdvancedMenu}, /*Advanced Menu*/
{NULL, NULL, NULL} // end of menu marker. DO NOT REMOVE
};
const menuitem powerMenu[] = {
/*
* Power Source
*/
/*
* Power Source
*/
#ifdef POW_DC
{(const char *)SettingsDescriptions[0], settings_setInputVRange, settings_displayInputVRange}, /*Voltage input*/
{(const char *)SettingsDescriptions[28], settings_setInputMinVRange, settings_displayInputMinVRange}, /*Minimum voltage input*/
{(const char *)SettingsDescriptions[0], settings_setInputVRange, settings_displayInputVRange}, /*Voltage input*/
{(const char *)SettingsDescriptions[28], settings_setInputMinVRange, settings_displayInputMinVRange}, /*Minimum voltage input*/
#endif
#ifdef POW_QC
{(const char *)SettingsDescriptions[19], settings_setQCInputV, settings_displayQCInputV}, /*Voltage input*/
{(const char *)SettingsDescriptions[19], settings_setQCInputV, settings_displayQCInputV}, /*Voltage input*/
#endif
{NULL, NULL, NULL} // end of menu marker. DO NOT REMOVE
{NULL, NULL, NULL} // end of menu marker. DO NOT REMOVE
};
const menuitem solderingMenu[] = {
/*
@@ -185,6 +189,8 @@ const menuitem UIMenu[] = {
{(const char *)SettingsDescriptions[10], settings_setCoolingBlinkEnabled, settings_displayCoolingBlinkEnabled}, /*Cooling blink warning*/
{(const char *)SettingsDescriptions[15], settings_setScrollSpeed, settings_displayScrollSpeed}, /*Scroll Speed for descriptions*/
{(const char *)SettingsDescriptions[21], settings_setReverseButtonTempChangeEnabled, settings_displayReverseButtonTempChangeEnabled}, /* Reverse Temp change buttons + - */
{(const char *)SettingsDescriptions[30], settings_setAnimationSpeed, settings_displayAnimationSpeed}, /*Animation Speed adjustment */
{(const char *)SettingsDescriptions[29], settings_setAnimationLoop, settings_displayAnimationLoop}, /*Animation Loop switch */
{NULL, NULL, NULL} // end of menu marker. DO NOT REMOVE
};
const menuitem PowerSavingMenu[] = {
@@ -213,6 +219,8 @@ const menuitem advancedMenu[] = {
* Calibrate Input V
* Reset Settings
* Power Pulse
* Animation Loop
* Animation Speed
*/
{(const char *)SettingsDescriptions[20], settings_setPowerLimit, settings_displayPowerLimit}, /*Power limit*/
{(const char *)SettingsDescriptions[6], settings_setAdvancedIDLEScreens, settings_displayAdvancedIDLEScreens}, /* Advanced idle screen*/
@@ -328,7 +336,7 @@ static bool settings_setInputMinVRange(void) {
systemSettings.minVoltageCells = (systemSettings.minVoltageCells + 1) % 38;
if (systemSettings.minDCVoltageCells == 1 && systemSettings.minVoltageCells < 30)
systemSettings.minVoltageCells = 30;
else if(systemSettings.minVoltageCells < 24)
else if (systemSettings.minVoltageCells < 24)
systemSettings.minVoltageCells = 24;
return systemSettings.minVoltageCells == 37;
}
@@ -894,6 +902,52 @@ static void settings_displayPowerPulse(void) {
OLED::print(OffString);
}
}
static bool settings_setAnimationLoop(void) {
systemSettings.animationLoop = !systemSettings.animationLoop;
return false;
}
static void settings_displayAnimationLoop(void) {
printShortDescription(29, 7);
OLED::drawCheckbox(systemSettings.animationLoop);
}
static bool settings_setAnimationSpeed(void) {
switch (systemSettings.animationSpeed) {
case 0:
systemSettings.animationSpeed = TICKS_100MS * 5;
break;
case TICKS_100MS * 5:
systemSettings.animationSpeed = TICKS_100MS * 4;
break;
case TICKS_100MS * 4:
systemSettings.animationSpeed = TICKS_100MS * 3;
break;
default:
systemSettings.animationSpeed = 0;
break;
}
return systemSettings.animationSpeed == TICKS_100MS * 3;
}
static void settings_displayAnimationSpeed(void) {
printShortDescription(30, 7);
switch (systemSettings.animationSpeed) {
case TICKS_100MS * 5:
OLED::print(SettingSensitivityLow);
break;
case TICKS_100MS * 4:
OLED::print(SettingSensitivityMedium);
break;
case TICKS_100MS * 3:
OLED::print(SettingSensitivityHigh);
break;
default:
OLED::print(SettingSensitivityOff);
break;
}
}
#ifdef HALL_SENSOR
static void settings_displayHallEffect(void) {
printShortDescription(26, 7);
@@ -921,6 +975,9 @@ static bool settings_setHallEffect(void) {
return systemSettings.hallEffectSensitivity == 3;
}
#endif
static bool animOpenState = false;
static void displayMenu(size_t index) {
// Call into the menu
const char *textPtr = SettingsMenuEntries[index];
@@ -937,7 +994,19 @@ static void displayMenu(size_t index) {
// Draw symbol
// 16 pixel wide image
// 2 pixel wide scrolling indicator
OLED::drawArea(96 - 16 - 2, 0, 16, 16, (&SettingsMenuIcons[(16 * 2) * index]));
static TickType_t menuSwitchLoopTick = 0;
static size_t menuCurrentIndex = sizeof(rootSettingsMenu) + 1;
static size_t currentFrame = 0;
if (!animOpenState) {
if (menuCurrentIndex != index) {
menuCurrentIndex = index;
currentFrame = systemSettings.animationSpeed ? 0 : 2;
menuSwitchLoopTick = xTaskGetTickCount();
}
if (systemSettings.animationSpeed && (systemSettings.animationLoop || currentFrame != 2))
currentFrame = ((xTaskGetTickCount() - menuSwitchLoopTick) / systemSettings.animationSpeed) % 3;
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, (&SettingsMenuIcons[index][(16 * 2) * currentFrame]));
}
}
static void settings_displayCalibrateVIN(void) { printShortDescription(13, 5); }
@@ -993,6 +1062,7 @@ void gui_Menu(const menuitem *menu) {
// Then we play a transition from the current primary
// framebuffer to the new buffer.
// The extra buffer is discarded at the end of the transition.
animOpenState = true;
OLED::useSecondaryFramebuffer(true);
OLED::setFont(0);
OLED::setCursor(0, 0);
@@ -1000,6 +1070,7 @@ void gui_Menu(const menuitem *menu) {
menu[currentScreen].draw();
OLED::useSecondaryFramebuffer(false);
OLED::transitionSecondaryFramebuffer(true);
animOpenState = false;
}
while ((menu[currentScreen].draw != NULL) && earlyExit == false) {

View File

@@ -88,10 +88,12 @@
#define DETAILED_SOLDERING 0 // 0: Disable 1: Enable - Default 0
#define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0
#define CUT_OUT_SETTING 0 // default to no cut-off voltage
#define RECOM_VOL_CELL 33 // Minimum voltage per cell (Recommended 3.3V (33))
#define TEMPERATURE_INF 0 // default to 0
#define DESCRIPTION_SCROLL_SPEED 0 // 0: Slow 1: Fast - default to slow
#define CUT_OUT_SETTING 0 // default to no cut-off voltage
#define RECOM_VOL_CELL 33 // Minimum voltage per cell (Recommended 3.3V (33))
#define TEMPERATURE_INF 0 // default to 0
#define DESCRIPTION_SCROLL_SPEED 0 // 0: Slow 1: Fast - default to slow
#define ANIMATION_LOOP 0 // 0: off 1: on
#define ANIMATION_SPEED 400 // 0: off, 300: High, 400: Medium, 500: Low
#define OP_AMP_Rf_TS100 750 * 1000 // 750 Kilo-ohms -> From schematic, R1
#define OP_AMP_Rin_TS100 2370 // 2.37 Kilo-ohms -> From schematic, R2