mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-18 16:23:07 +01:00
Change function for setting CPU speed
This commit is contained in:
@@ -64,19 +64,9 @@ void OBP60Init(GwApi *api){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set CPU speed
|
// Get CPU speed
|
||||||
String cpuspeed = api->getConfig()->getConfigItem(api->getConfig()->cpuSpeed,true)->asString();
|
|
||||||
if(String(cpuspeed) == "80"){
|
|
||||||
setCpuFrequencyMhz(80);
|
|
||||||
}
|
|
||||||
if(String(cpuspeed) == "160"){
|
|
||||||
setCpuFrequencyMhz(160);
|
|
||||||
}
|
|
||||||
if(String(cpuspeed) == "240"){
|
|
||||||
setCpuFrequencyMhz(240);
|
|
||||||
}
|
|
||||||
int freq = getCpuFrequencyMhz();
|
int freq = getCpuFrequencyMhz();
|
||||||
api->getLogger()->logDebug(GwLog::LOG,"CPU speed: %i MHz", freq);
|
api->getLogger()->logDebug(GwLog::LOG,"CPU speed at boot: %i MHz", freq);
|
||||||
|
|
||||||
// Settings for backlight
|
// Settings for backlight
|
||||||
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
||||||
@@ -437,6 +427,7 @@ void OBP60Task(GwApi *api){
|
|||||||
Color color = colorMapping(backlightColor);
|
Color color = colorMapping(backlightColor);
|
||||||
uint brightness = 2.55 * uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
|
uint brightness = 2.55 * uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
|
||||||
bool uvoltage = api->getConfig()->getConfigItem(api->getConfig()->underVoltage,true)->asBoolean();
|
bool uvoltage = api->getConfig()->getConfigItem(api->getConfig()->underVoltage,true)->asBoolean();
|
||||||
|
String cpuspeed = api->getConfig()->getConfigItem(api->getConfig()->cpuSpeed,true)->asString();
|
||||||
|
|
||||||
// refreshmode defined in init section
|
// refreshmode defined in init section
|
||||||
// displaycolor defined in init section
|
// displaycolor defined in init section
|
||||||
@@ -459,6 +450,7 @@ void OBP60Task(GwApi *api){
|
|||||||
commonData.time = boatValues.findValueOrCreate("GPST"); // Load GpsTime
|
commonData.time = boatValues.findValueOrCreate("GPST"); // Load GpsTime
|
||||||
commonData.date = boatValues.findValueOrCreate("GPSD"); // Load GpsTime
|
commonData.date = boatValues.findValueOrCreate("GPSD"); // Load GpsTime
|
||||||
bool delayedDisplayUpdate = false; // If select a new pages then make a delayed full display update
|
bool delayedDisplayUpdate = false; // If select a new pages then make a delayed full display update
|
||||||
|
bool cpuspeedsetted = false; // Marker for change CPU speed
|
||||||
long firststart = millis(); // First start
|
long firststart = millis(); // First start
|
||||||
long starttime0 = millis(); // Mainloop
|
long starttime0 = millis(); // Mainloop
|
||||||
long starttime1 = millis(); // Full display refresh for the first 5 min (more often as normal)
|
long starttime1 = millis(); // Full display refresh for the first 5 min (more often as normal)
|
||||||
@@ -479,6 +471,22 @@ void OBP60Task(GwApi *api){
|
|||||||
underVoltageDetection(api);
|
underVoltageDetection(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set CPU speed after boot after 1min
|
||||||
|
if(millis() > firststart + (1 * 60 * 1000) && cpuspeedsetted == false){
|
||||||
|
if(String(cpuspeed) == "80"){
|
||||||
|
setCpuFrequencyMhz(80);
|
||||||
|
}
|
||||||
|
if(String(cpuspeed) == "160"){
|
||||||
|
setCpuFrequencyMhz(160);
|
||||||
|
}
|
||||||
|
if(String(cpuspeed) == "240"){
|
||||||
|
setCpuFrequencyMhz(240);
|
||||||
|
}
|
||||||
|
int freq = getCpuFrequencyMhz();
|
||||||
|
api->getLogger()->logDebug(GwLog::LOG,"CPU speed: %i MHz", freq);
|
||||||
|
cpuspeedsetted = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(millis() > starttime0 + 100){
|
if(millis() > starttime0 + 100){
|
||||||
starttime0 = millis();
|
starttime0 = millis();
|
||||||
commonData.data=shared->getSensorData();
|
commonData.data=shared->getSensorData();
|
||||||
|
|||||||
Reference in New Issue
Block a user