Transition Control
- autotransition can be turn on and of in onscreen menu - autotransition is turned off when only one app is loaded closes #1 closes #2
This commit is contained in:
@@ -56,20 +56,20 @@ void MatrixDisplayUi::setTargetFPS(uint8_t fps)
|
||||
|
||||
// -/------ Automatic controll ------\-
|
||||
|
||||
void MatrixDisplayUi::enableAutoTransition()
|
||||
void MatrixDisplayUi::enablesetAutoTransition()
|
||||
{
|
||||
this->autoTransition = true;
|
||||
this->setAutoTransition = true;
|
||||
}
|
||||
void MatrixDisplayUi::disableAutoTransition()
|
||||
void MatrixDisplayUi::disablesetAutoTransition()
|
||||
{
|
||||
this->autoTransition = false;
|
||||
this->setAutoTransition = false;
|
||||
}
|
||||
void MatrixDisplayUi::setAutoTransitionForwards()
|
||||
void MatrixDisplayUi::setsetAutoTransitionForwards()
|
||||
{
|
||||
this->state.frameTransitionDirection = 1;
|
||||
this->lastTransitionDirection = 1;
|
||||
}
|
||||
void MatrixDisplayUi::setAutoTransitionBackwards()
|
||||
void MatrixDisplayUi::setsetAutoTransitionBackwards()
|
||||
{
|
||||
this->state.frameTransitionDirection = -1;
|
||||
this->lastTransitionDirection = -1;
|
||||
@@ -173,7 +173,7 @@ int8_t MatrixDisplayUi::update()
|
||||
if (timeBudget <= 0)
|
||||
{
|
||||
// Implement frame skipping to ensure time budget is keept
|
||||
if (this->autoTransition && this->state.lastUpdate != 0)
|
||||
if (this->setAutoTransition && this->state.lastUpdate != 0)
|
||||
this->state.ticksSinceLastStateSwitch += ceil(-timeBudget / this->updateInterval);
|
||||
|
||||
this->state.lastUpdate = frameStart;
|
||||
@@ -205,7 +205,7 @@ void MatrixDisplayUi::tick()
|
||||
}
|
||||
if (this->state.ticksSinceLastStateSwitch >= this->ticksPerFrame)
|
||||
{
|
||||
if (this->autoTransition)
|
||||
if (this->setAutoTransition)
|
||||
{
|
||||
|
||||
this->state.frameState = IN_TRANSITION;
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
uint16_t ticksPerFrame = 151; // ~ 5000ms at 30 FPS
|
||||
uint16_t ticksPerTransition = 15; // ~ 500ms at 30 FPS
|
||||
|
||||
bool autoTransition = true;
|
||||
bool setAutoTransition = true;
|
||||
|
||||
AppCallback *AppFunctions;
|
||||
|
||||
@@ -129,18 +129,18 @@ public:
|
||||
/**
|
||||
* Enable automatic transition to next frame after the some time can be configured with `setTimePerApp` and `setTimePerTransition`.
|
||||
*/
|
||||
void enableAutoTransition();
|
||||
void enablesetAutoTransition();
|
||||
|
||||
/**
|
||||
* Disable automatic transition to next frame.
|
||||
*/
|
||||
void disableAutoTransition();
|
||||
void disablesetAutoTransition();
|
||||
|
||||
/**
|
||||
* Set the direction if the automatic transitioning
|
||||
*/
|
||||
void setAutoTransitionForwards();
|
||||
void setAutoTransitionBackwards();
|
||||
void setsetAutoTransitionForwards();
|
||||
void setsetAutoTransitionBackwards();
|
||||
|
||||
/**
|
||||
* Set the approx. time a frame is displayed
|
||||
|
||||
@@ -67,14 +67,18 @@ void DisplayManager_::MatrixState(bool on)
|
||||
setBrightness(BRIGHTNESS);
|
||||
}
|
||||
|
||||
void DisplayManager_::disableAutoTransition()
|
||||
bool DisplayManager_::setAutoTransition(bool active)
|
||||
{
|
||||
ui.disableAutoTransition();
|
||||
}
|
||||
|
||||
void DisplayManager_::enableAutoTransition()
|
||||
{
|
||||
ui.enableAutoTransition();
|
||||
if (active && AUTO_TRANSITION)
|
||||
{
|
||||
ui.enablesetAutoTransition();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.disablesetAutoTransition();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayManager_::drawGIF(uint16_t x, uint16_t y, fs::File gifFile)
|
||||
@@ -396,6 +400,8 @@ void DisplayManager_::loadApps()
|
||||
// Apps.push_back(std::make_pair(5, WeatherFrame));
|
||||
nativeAppsCount = Apps.size();
|
||||
ui.setApps(Apps); // Add frames
|
||||
if (AUTO_TRANSITION && nativeAppsCount == 1)
|
||||
setAutoTransition(false);
|
||||
StartAppUpdater();
|
||||
}
|
||||
|
||||
@@ -406,6 +412,7 @@ void DisplayManager_::setup()
|
||||
gif.setMatrix(&matrix);
|
||||
ui.setAppAnimation(SLIDE_DOWN);
|
||||
ui.setOverlays(overlays, 4);
|
||||
setAutoTransition(AUTO_TRANSITION);
|
||||
ui.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,7 @@ public:
|
||||
void generateNotification(String);
|
||||
void generateCustomPage(uint16_t, String);
|
||||
void printText(int16_t x, int16_t y, const char *text, bool centered);
|
||||
void disableAutoTransition();
|
||||
void enableAutoTransition();
|
||||
bool setAutoTransition(bool active);
|
||||
void drawGIF(uint16_t x, uint16_t y, fs::File gifFile);
|
||||
void drawJPG(uint16_t x, uint16_t y, fs::File jpgFile);
|
||||
};
|
||||
|
||||
@@ -262,11 +262,11 @@ void ShowCustomFrame(uint8_t id, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
|
||||
// Disable auto transition if text is repeating and too wide
|
||||
if ((cf->repeat > 0) && (getTextWidth(cf->text.c_str()) > availableWidth) && (state->frameState == FIXED))
|
||||
{
|
||||
DisplayManager.disableAutoTransition();
|
||||
DisplayManager.setAutoTransition(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayManager.enableAutoTransition();
|
||||
DisplayManager.setAutoTransition(true);
|
||||
}
|
||||
|
||||
// Check if text is wider than available display width and frame is not in transition
|
||||
@@ -286,7 +286,7 @@ void ShowCustomFrame(uint8_t id, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
|
||||
// Transition to next app if frame is repeating and repeat limit has been reached
|
||||
if ((cf->currentRepeat + 1 >= cf->repeat) && (cf->repeat > 0))
|
||||
{
|
||||
DisplayManager.enableAutoTransition();
|
||||
DisplayManager.setAutoTransition(true);
|
||||
cf->currentRepeat = 0;
|
||||
DisplayManager.nextApp();
|
||||
return;
|
||||
|
||||
@@ -10,6 +10,7 @@ void loadSettings()
|
||||
BRIGHTNESS = Settings.getUChar("BRI", 120);
|
||||
AUTO_BRIGHTNESS = Settings.getBool("ABRI", true);
|
||||
TEXTCOLOR_565 = Settings.getUInt("COL", 0xFFFF);
|
||||
AUTO_TRANSITION = Settings.getBool("TRANS", true);
|
||||
Settings.end();
|
||||
}
|
||||
|
||||
@@ -19,6 +20,7 @@ void saveSettings()
|
||||
Settings.putUChar("FPS", MATRIX_FPS);
|
||||
Settings.putUChar("BRI", BRIGHTNESS);
|
||||
Settings.putBool("ABRI", AUTO_BRIGHTNESS);
|
||||
Settings.putBool("TRANS", AUTO_TRANSITION);
|
||||
Settings.putUInt("COL", TEXTCOLOR_565);
|
||||
Settings.end();
|
||||
}
|
||||
@@ -28,7 +30,7 @@ IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
IPAddress primaryDNS;
|
||||
IPAddress secondaryDNS;
|
||||
const char *VERSION = "0.30";
|
||||
const char *VERSION = "0.31";
|
||||
String MQTT_HOST = "";
|
||||
uint16_t MQTT_PORT = 1883;
|
||||
String MQTT_USER;
|
||||
@@ -71,11 +73,11 @@ uint8_t SNOOZE_TIME;
|
||||
String TIMER_SOUND;
|
||||
|
||||
// Matrix States
|
||||
bool AUTO_TRANSITION = false;
|
||||
bool AUTO_BRIGHTNESS = true;
|
||||
bool UPPERCASE_LETTERS = true;
|
||||
bool AP_MODE;
|
||||
bool MATRIX_OFF;
|
||||
bool TIMER_ACTIVE;
|
||||
bool ALARM_ACTIVE;
|
||||
uint16_t TEXTCOLOR_565 = 0xFFFF;
|
||||
|
||||
uint16_t TEXTCOLOR_565 = 0xFFFF;
|
||||
@@ -52,7 +52,7 @@ extern String ALARM_SOUND;
|
||||
extern String TIMER_SOUND;
|
||||
extern uint16_t TEXTCOLOR_565;
|
||||
extern uint8_t SNOOZE_TIME;
|
||||
|
||||
extern bool AUTO_TRANSITION;
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
@@ -19,36 +19,38 @@ enum MenuState
|
||||
StationSelection,
|
||||
PlayingStation,
|
||||
Reset,
|
||||
Volume,
|
||||
Brightness,
|
||||
FPS,
|
||||
Color
|
||||
VolumeMenu,
|
||||
BrightnessMenu,
|
||||
FPSMenu,
|
||||
ColorMenu,
|
||||
SwitchMenu
|
||||
};
|
||||
|
||||
const char *menuItems[] = {
|
||||
"BRIGHT",
|
||||
"FPS",
|
||||
"COLOR",
|
||||
"SWITCH",
|
||||
"RESET"};
|
||||
|
||||
byte menuItemCount = 4;
|
||||
byte menuItemCount = 5;
|
||||
|
||||
MenuState currentState = MainMenu;
|
||||
|
||||
uint16_t textColors[] = {
|
||||
0xFFFF, // White
|
||||
0xF800, // Red
|
||||
0xF812, // Dark orange
|
||||
0xF81F, // Yellow
|
||||
0x881F, // Dark green
|
||||
0x001F, // Blue
|
||||
0x04FF, // Light blue
|
||||
0x07FC, // Cyan
|
||||
0x07E2, // Seafoam green
|
||||
0xAFE0, // Light green
|
||||
0xFFE0, // Light yellow
|
||||
0xFD60, // Dark yellow
|
||||
0xFBC0}; // Pink
|
||||
0xFFFF, // White
|
||||
0xF800, // Red
|
||||
0xF812, // Dark orange
|
||||
0xF81F, // Yellow
|
||||
0x881F, // Dark green
|
||||
0x001F, // Blue
|
||||
0x04FF, // Light blue
|
||||
0x07FC, // Cyan
|
||||
0x07E2, // Seafoam green
|
||||
0xAFE0, // Light green
|
||||
0xFFE0, // Light yellow
|
||||
0xFD60, // Dark yellow
|
||||
0xFBC0}; // Pink
|
||||
|
||||
uint8_t currentColor;
|
||||
|
||||
@@ -67,7 +69,7 @@ String MenuManager_::menutext()
|
||||
{
|
||||
return (menuItems[menuIndex]);
|
||||
}
|
||||
else if (currentState == Brightness)
|
||||
else if (currentState == BrightnessMenu)
|
||||
{
|
||||
if (AUTO_BRIGHTNESS)
|
||||
{
|
||||
@@ -78,11 +80,11 @@ String MenuManager_::menutext()
|
||||
return (String(BRIGHTNESS_PERCENT) + "%");
|
||||
}
|
||||
}
|
||||
else if (currentState == FPS)
|
||||
else if (currentState == FPSMenu)
|
||||
{
|
||||
return String(MATRIX_FPS) + " FPS";
|
||||
}
|
||||
else if (currentState == Color)
|
||||
else if (currentState == ColorMenu)
|
||||
{
|
||||
DisplayManager.setTextColor(textColors[currentColor]);
|
||||
String colorStr = String(textColors[currentColor], HEX);
|
||||
@@ -92,6 +94,10 @@ String MenuManager_::menutext()
|
||||
}
|
||||
return colorStr;
|
||||
}
|
||||
else if (currentState == SwitchMenu)
|
||||
{
|
||||
return AUTO_TRANSITION ? "ON" : "OFF";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -111,7 +117,7 @@ void MenuManager_::rightButton()
|
||||
{
|
||||
AudioManager.nextStation();
|
||||
}
|
||||
else if (currentState == Brightness)
|
||||
else if (currentState == BrightnessMenu)
|
||||
{
|
||||
if (!AUTO_BRIGHTNESS)
|
||||
{
|
||||
@@ -122,16 +128,20 @@ void MenuManager_::rightButton()
|
||||
DisplayManager.setBrightness(BRIGHTNESS);
|
||||
}
|
||||
}
|
||||
else if (currentState == FPS)
|
||||
else if (currentState == FPSMenu)
|
||||
{
|
||||
if (MATRIX_FPS < 30)
|
||||
++MATRIX_FPS;
|
||||
}
|
||||
else if (currentState == Color)
|
||||
else if (currentState == ColorMenu)
|
||||
{
|
||||
int arraySize = sizeof(textColors) / sizeof(textColors[0]);
|
||||
currentColor = (currentColor + 1) % arraySize;
|
||||
}
|
||||
else if (currentState == SwitchMenu)
|
||||
{
|
||||
AUTO_TRANSITION = !AUTO_TRANSITION;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuManager_::leftButton()
|
||||
@@ -150,7 +160,7 @@ void MenuManager_::leftButton()
|
||||
{
|
||||
AudioManager.prevStation();
|
||||
}
|
||||
else if (currentState == Brightness)
|
||||
else if (currentState == BrightnessMenu)
|
||||
{
|
||||
if (!AUTO_BRIGHTNESS)
|
||||
{
|
||||
@@ -161,16 +171,20 @@ void MenuManager_::leftButton()
|
||||
DisplayManager.setBrightness(BRIGHTNESS);
|
||||
}
|
||||
}
|
||||
else if (currentState == FPS)
|
||||
else if (currentState == FPSMenu)
|
||||
{
|
||||
if (MATRIX_FPS > 15)
|
||||
--MATRIX_FPS;
|
||||
}
|
||||
else if (currentState == Color)
|
||||
else if (currentState == ColorMenu)
|
||||
{
|
||||
int arraySize = sizeof(textColors) / sizeof(textColors[0]);
|
||||
currentColor = (currentColor - 1 + arraySize) % arraySize;
|
||||
}
|
||||
else if (currentState == SwitchMenu)
|
||||
{
|
||||
AUTO_TRANSITION = !AUTO_TRANSITION;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuManager_::selectButton()
|
||||
@@ -182,17 +196,21 @@ void MenuManager_::selectButton()
|
||||
if (menuIndex == 0) // BRIGHT
|
||||
{
|
||||
BRIGHTNESS_PERCENT = map(BRIGHTNESS, 0, 255, 0, 100);
|
||||
currentState = Brightness;
|
||||
currentState = BrightnessMenu;
|
||||
}
|
||||
else if (menuIndex == 1) // RESET
|
||||
{
|
||||
currentState = FPS;
|
||||
currentState = FPSMenu;
|
||||
}
|
||||
else if (menuIndex == 2) // COLOR
|
||||
{
|
||||
currentState = Color;
|
||||
currentState = ColorMenu;
|
||||
}
|
||||
else if (menuIndex == 3) // FPS
|
||||
else if (menuIndex == 3) // COLOR
|
||||
{
|
||||
currentState = SwitchMenu;
|
||||
}
|
||||
else if (menuIndex == 4) // FPS
|
||||
{
|
||||
ESP.restart();
|
||||
}
|
||||
@@ -201,7 +219,7 @@ void MenuManager_::selectButton()
|
||||
{
|
||||
AudioManager.startRadioStation(AudioManager.getCurrentRadioStation());
|
||||
}
|
||||
else if (currentState == Brightness)
|
||||
else if (currentState == BrightnessMenu)
|
||||
{
|
||||
AUTO_BRIGHTNESS = !AUTO_BRIGHTNESS;
|
||||
}
|
||||
@@ -211,17 +229,17 @@ void MenuManager_::selectButtonLong()
|
||||
{
|
||||
if (inMenu)
|
||||
{
|
||||
if (currentState == Brightness)
|
||||
if (currentState == BrightnessMenu)
|
||||
{
|
||||
BRIGHTNESS = map(BRIGHTNESS_PERCENT, 0, 100, 0, 255);
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == FPS)
|
||||
else if (currentState == FPSMenu)
|
||||
{
|
||||
DisplayManager.setFPS(MATRIX_FPS);
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == Color)
|
||||
else if (currentState == ColorMenu)
|
||||
{
|
||||
TEXTCOLOR_565 = textColors[currentColor];
|
||||
saveSettings();
|
||||
@@ -230,7 +248,11 @@ void MenuManager_::selectButtonLong()
|
||||
{
|
||||
inMenu = false;
|
||||
}
|
||||
|
||||
else if (currentState == SwitchMenu)
|
||||
{
|
||||
DisplayManager.setAutoTransition(AUTO_TRANSITION);
|
||||
saveSettings();
|
||||
}
|
||||
currentState = MainMenu;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user