Compare commits

..

4 Commits

5 changed files with 85 additions and 59 deletions

View File

@ -73,11 +73,11 @@ boolean ConnectivityManager::startAP()
return false;
}
else if((*cfgDictionary)("SSID") != NULL && (*cfgDictionary)("PASSWORD") != NULL && (*cfgDictionary)("CHANNEL") != NULL && (*cfgDictionary)("SSID_HIDDEN") != NULL && (*cfgDictionary)("AP_MAX_CONNECTION") != NULL && (*cfgDictionary)("ENABLED") != NULL)
else if((*cfgDictionary)("SSID") != NULL && (*cfgDictionary)("PASSWORD") != NULL && (*cfgDictionary)("CHANNEL") != NULL && (*cfgDictionary)("HIDE_SSID") != NULL && (*cfgDictionary)("AP_MAX_CONNECTION") != NULL && (*cfgDictionary)("ENABLED") != NULL)
{
if((*cfgDictionary)("ENABLED")->booleanValue())
{
if(!softAP((*cfgDictionary)("SSID")->stringValue(), strcmp((*cfgDictionary)("PASSWORD")->stringValue(),"") == 0 ? NULL:(*cfgDictionary)("PASSWORD")->stringValue(), (*cfgDictionary)("CHANNEL")->intValue(), (*cfgDictionary)("SSID_HIDDEN")->booleanValue(), (*cfgDictionary)("AP_MAX_CONNECTION")->intValue()))
if(!softAP((*cfgDictionary)("SSID")->stringValue(), strcmp((*cfgDictionary)("PASSWORD")->stringValue(),"") == 0 ? NULL:(*cfgDictionary)("PASSWORD")->stringValue(), (*cfgDictionary)("CHANNEL")->intValue(), (*cfgDictionary)("HIDE_SSID")->booleanValue(), (*cfgDictionary)("AP_MAX_CONNECTION")->intValue()))
{
_error |= AP_SETUP_ERR;
toBeReturned = false;

View File

@ -1028,7 +1028,7 @@ class FTPServer : public TCPServer<T>
char *_login;
char *_password;
const char *_FTPDir = NULL; //Pointer to constant string and char * cont is a constant pointer to string
const char *_FTPDir = NULL; //Pointer to constant string and char * const is a constant pointer to string
uint16_t _dataPort;
WiFiServer _dataServer; //In passive mode, the FTP server opens two different ports (one for the commands and the other for the data stream)

View File

@ -32,31 +32,28 @@ boolean ScreenManager::applyCfgFromSD()
return false;
}
if(cfgDictionary->get("ENABLED") != NULL)
setEnabled(cfgDictionary->get("ENABLED")->booleanValue());
if( cfgDictionary->get("ENABLED") != NULL &&
cfgDictionary->get("DIMMED") != NULL &&
cfgDictionary->get("INVERTED") != NULL &&
cfgDictionary->get("ORIENTATION") != NULL &&
cfgDictionary->get("AUTO_OFF") != NULL)
{
setEnabled(cfgDictionary->get("ENABLED")->booleanValue());
_displayRef.setRotation(orientationTranslator(cfgDictionary->get("ORIENTATION")->intValue()));
_displayRef.invertDisplay(cfgDictionary->get("INVERTED")->booleanValue());
_displayRef.dim(cfgDictionary->get("DIMMED")->booleanValue());
_displayRef.setTextColor(WHITE);
setAutoOFFDelay(cfgDictionary->get("AUTO_OFF")->uintValue());
if(cfgDictionary->get("DIMMED") != NULL)
_displayRef.dim(cfgDictionary->get("DIMMED")->booleanValue());
delete cfgDictionary;
return true;
}
else //Default value applied
{
setDefault();
delete cfgDictionary;
return false;
}
if(cfgDictionary->get("INVERTED") != NULL)
_displayRef.invertDisplay(cfgDictionary->get("INVERTED")->booleanValue());
if(cfgDictionary->get("ORIENTATION") != NULL)
_displayRef.setRotation(orientationTranslator(cfgDictionary->get("ORIENTATION")->intValue()));
else
_displayRef.setRotation(OR_0);
if(cfgDictionary->get("AUTO_OFF") != NULL)
setAutoOFFDelay(cfgDictionary->get("AUTO_OFF")->uintValue());
_displayRef.setTextColor(WHITE);
delete cfgDictionary;
return true;
}
else //Default value applied
else //Default values applied
{
setDefault();
return true;
@ -211,14 +208,18 @@ ScreenManager::ViewLink* ScreenManager::getLinkByUID(ViewLinkedList viewLinkedLi
void ScreenManager::run()
{
if(!_enabled) return;
//We handle the auto off logic here
if(_autoOFFDelay && _enabled)
if(_autoOFFDelay)
{
if(millis() - _autoOFFDelayRef > _autoOFFDelay)
setEnabled(false);
if(millis() - _autoOFFDelayRef >= _autoOFFDelay)
{
sleep();
return;
}
}
if((millis() - _timeRef < _refreshInterval && !_forceRefresh) || !_enabled) return;
if(millis() - _timeRef < _refreshInterval && !_forceRefresh) return;
_timeRef = millis();
@ -268,8 +269,13 @@ void ScreenManager::forceRefresh()
boolean ScreenManager::displayView(const uint8_t UID)
{
_autoOFFDelayRef = millis();
if(!_enabled) return false;
if(isSleeping())
wakeUp();
_autoOFFDelayRef = millis(); //Resets the auto off delay so the screen do not sleep on us.
_forceRefresh = true;
ViewLink *viewLink = getLinkByUID(_viewLinkedList, UID);
@ -297,8 +303,16 @@ boolean ScreenManager::displayView(const uint8_t UID)
boolean ScreenManager::displayNextView()
{
_autoOFFDelayRef = millis();
if(!_enabled) return false;
if(isSleeping())
{
wakeUp();
return true;
}
_autoOFFDelayRef = millis(); //Resets the auto off delay so the screen do not sleep on us.
_forceRefresh = true;
_error = OK;
if(isListEmpty(_viewLinkedList))return false;
@ -333,8 +347,16 @@ boolean ScreenManager::displayNextView()
boolean ScreenManager::displayPreviousView()
{
_autoOFFDelayRef = millis();
if(!_enabled) return false;
if(isSleeping())
{
wakeUp();
return true;
}
_autoOFFDelayRef = millis(); //Resets the auto off delay so the screen do not sleep on us.
_forceRefresh = true;
_error = OK;
if(isListEmpty(_tail))return false;
@ -381,13 +403,17 @@ void ScreenManager::dimDisplay(const boolean dimmed)
void ScreenManager::sleep()
{
_enabled = false;
if(!_enabled || _sleeping)return;
_sleeping = true;
_displayRef.sleep();
}
void ScreenManager::wakeUp()
{
_enabled = true;
if(!_enabled || !_sleeping)return;
_sleeping = false;
_autoOFFDelayRef = millis();
_displayRef.wakeUp();
}
@ -414,6 +440,7 @@ boolean ScreenManager::isDisplayDimmed() const
void ScreenManager::clearDisplay(const boolean bufferOnly)
{
if(!_enabled) return;
if(bufferOnly)
_displayRef.clearDisplay();
else
@ -439,10 +466,11 @@ void ScreenManager::clearViews()
void ScreenManager::setEnabled(boolean value)
{
_enabled = value;
if(value)
wakeUp();
_displayRef.wakeUp();
else
sleep();
_displayRef.sleep();
}
void ScreenManager::setAutoOFFDelay(const uint64_t delay)
@ -450,11 +478,16 @@ void ScreenManager::setAutoOFFDelay(const uint64_t delay)
_autoOFFDelay = delay;
}
boolean ScreenManager::getEnabled()
boolean ScreenManager::isEnabled() const
{
return _enabled;
}
boolean ScreenManager::isSleeping() const
{
return _sleeping;
}
unsigned char ScreenManager::getViewCount()
{
unsigned char counter = 0;

View File

@ -38,8 +38,10 @@ class ScreenManager
void sleep();
void wakeUp();
void setEnabled(boolean value);
void setAutoOFFDelay(const uint64_t delay);
boolean getEnabled();
// Default value is 0 : this disables auto off
void setAutoOFFDelay(const uint64_t delay = 0);
boolean isEnabled() const;
boolean isSleeping() const;
boolean init();
void run();
@ -72,6 +74,7 @@ class ScreenManager
boolean _displayColorInverted = false;
boolean _displayDimmed = false;
boolean _enabled = true;
boolean _sleeping = false;
uint8_t _refreshRateHz = 1;
uint16_t _refreshInterval = 1000;
uint64_t _timeRef = 0, _autoOFFDelayRef = 0, _autoOFFDelay = 0;

View File

@ -132,26 +132,16 @@ void loop()
switch(evt)
{
case EventHandler::Event::FLASH_BUTTON_PRESS:
if(sab.getScreenManager().getEnabled())
{
sab.getScreenManager().displayNextView();
#ifdef DEBUG
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
#endif
}
else
sab.getScreenManager().wakeUp();
sab.getScreenManager().displayNextView();
#ifdef DEBUG
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
#endif
break;
case EventHandler::Event::FLASH_BUTTON_LONG_PRESS:
if(sab.getScreenManager().getEnabled())
{
sab.getScreenManager().displayPreviousView();
#ifdef DEBUG
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
#endif
}
else
sab.getScreenManager().wakeUp();
sab.getScreenManager().displayPreviousView();
#ifdef DEBUG
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
#endif
break;
default: //NO_EVENT
break;