Skip to content

Commit

Permalink
Functionality to run some portion of code with high CPU speed(e.g. re…
Browse files Browse the repository at this point in the history
…nder watch faces) #feature
  • Loading branch information
spaceAngel committed Jun 19, 2022
1 parent d15c7b0 commit a6c0825
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/System/BatteryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool BatteryManager::handleCabelPlugRemoveIRQ() {
void BatteryManager::energyConsumptionSavingsSettings() {
WiFi.disconnect(true); // Disconnect from the network
WiFi.mode(WIFI_OFF); // Switch WiFi off //not need to wifi on -> power saving
setCpuFrequencyMhz(CPU_FREQUENCY);
setCpuFrequencyMhz(CPU_FREQUENCY_LOW);
}


Expand Down
6 changes: 6 additions & 0 deletions src/System/Esp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ void Esp32::cleanIRQ() {
void Esp32::setIsIRQ() {
this->IRQ = true;
}

void Esp32::runWithCpuSpeedHigh(std::function<void(void)> f) {
setCpuFrequencyMhz(CPU_FREQUENCY_HIGH);
f();
setCpuFrequencyMhz(CPU_FREQUENCY_LOW);
}
2 changes: 2 additions & 0 deletions src/System/Esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Esp32 {
void cleanIRQ();
void setIsIRQ();

void runWithCpuSpeedHigh(std::function<void(void)> f);

protected:

static Esp32 *inst;
Expand Down
3 changes: 2 additions & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#define BATTERY_FULL_CAPACITY 4200
#define BATTERY_LOW_CAPACITY 3200

#define CPU_FREQUENCY 40
#define CPU_FREQUENCY_LOW 20
#define CPU_FREQUENCY_HIGH 240
#define CROSS_SWIPE_TOLERANCE 12

#define COLOR_BACKGROUND 0x0000
Expand Down

0 comments on commit a6c0825

Please sign in to comment.