-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from Dev-Cwsc/sleep-dim-implemented
Sleep and screen dim added
- Loading branch information
Showing
11 changed files
with
186 additions
and
27 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "powerSave.h" | ||
#include "settings.h" | ||
|
||
/* Turn off the display */ | ||
void turnOffDisplay() { | ||
#if !defined(STICK_C_PLUS) | ||
analogWrite(BACKLIGHT, 0); | ||
#else | ||
axp192.ScreenBreath(0); | ||
#endif | ||
} | ||
|
||
/* If the device screen is off, turn on, else just refresh sleep timer */ | ||
bool wakeUpScreen(){ | ||
previousMillis = millis(); | ||
if(isScreenOff){ | ||
isScreenOff = false; | ||
dimmer = false; | ||
getBrightness(); | ||
delay(200); | ||
return true; | ||
}else if(dimmer){ | ||
dimmer = false; | ||
getBrightness(); | ||
delay(200); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/* Check if it's time to put the device to sleep */ | ||
void checkPowerSaveTime(){ | ||
if(dimmerSet!=0){ | ||
if((millis() - previousMillis) >= (dimmerSet * 1000) && dimmer == false && isSleeping == false){ | ||
dimmer = true; | ||
setBrightness(5, false); | ||
}else if((millis() - previousMillis) >= ((dimmerSet * 1000) + 5000) && isScreenOff == false && isSleeping == false){ | ||
isScreenOff = true; | ||
turnOffDisplay(); | ||
} | ||
} | ||
} | ||
|
||
/* Put device on sleep mode */ | ||
void sleepModeOn(){ | ||
isSleeping = true; | ||
setCpuFrequencyMhz(80); | ||
turnOffDisplay(); | ||
delay(200); | ||
} | ||
|
||
/* Wake up device */ | ||
void sleepModeOff(){ | ||
isSleeping = false; | ||
setCpuFrequencyMhz(240); | ||
getBrightness(); | ||
delay(200); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "globals.h" | ||
#include "display.h" | ||
|
||
//It is here to not create a new set of files just to use AXP192 library again | ||
void turnOffDisplay(); | ||
|
||
bool wakeUpScreen(); | ||
|
||
void checkPowerSaveTime(); | ||
|
||
void sleepModeOn(); | ||
|
||
void sleepModeOff(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters