mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Implementation of #622. Change operating frequency.
This commit is contained in:
parent
b119764160
commit
68ea8c2f00
@ -437,6 +437,32 @@ JsVar *jswrap_ESP8266WiFi_getRstInfo() {
|
||||
return restartInfo;
|
||||
}
|
||||
|
||||
/*JSON{
|
||||
"type" : "staticmethod",
|
||||
"class" : "ESP8266WiFi",
|
||||
"name" : "updateCPUFreq",
|
||||
"generate" : "jswrap_ESP8266WiFi_updateCPUFreq",
|
||||
"params" : [
|
||||
["freq","JsVar","Desired frequency - either 80 or 160."]
|
||||
]
|
||||
}
|
||||
* Update the operating frequency of the ESP8266 processor.
|
||||
*/
|
||||
void jswrap_ESP8266WiFi_updateCPUFreq(
|
||||
JsVar *jsFreq //!< Operating frequency of the processor. Either 80 or 160.
|
||||
) {
|
||||
if (!jsvIsInt(jsFreq)) {
|
||||
jsExceptionHere(JSET_ERROR, "Invalid frequency.");
|
||||
return;
|
||||
}
|
||||
int newFreq = jsvGetInteger(jsFreq);
|
||||
if (newFreq != 80 && newFreq != 160) {
|
||||
jsExceptionHere(JSET_ERROR, "Invalid frequency value, must be 80 or 160.");
|
||||
return;
|
||||
}
|
||||
system_update_cpu_freq(newFreq);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an object that contains details about the state of the ESP8266.
|
||||
|
||||
@ -30,5 +30,6 @@ JsVar *jswrap_ESP8266WiFi_getConnectedStations();
|
||||
JsVar *jswrap_ESP8266WiFi_getRSSI();
|
||||
JsVar *jswrap_ESP8266WiFi_getState();
|
||||
void jswrap_ESP8266WiFi_dumpSocket(JsVar *socketId);
|
||||
void jswrap_ESP8266WiFi_updateCPUFreq(JsVar *jsFreq);
|
||||
|
||||
#endif /* LIBS_NETWORK_ESP8266_JSWRAP_ESP8266_H_ */
|
||||
|
||||
@ -343,4 +343,14 @@ The returned object contains the following fields:
|
||||
|
||||
* `sdkVersion` - The version of the ESP8266 SDK used to build this release.
|
||||
* `cpuFrequency` - The CPU operating frequency in MHz.
|
||||
* `freeHeap` - The amount of free heap in bytes.
|
||||
* `freeHeap` - The amount of free heap in bytes.
|
||||
|
||||
----
|
||||
|
||||
##ESP8266WiFi.updateCPUFreq
|
||||
|
||||
Set the operating frequency of the ESP8266 processor.
|
||||
|
||||
`ESP8266WiFi.updateCPUFreq(newFreq)`
|
||||
|
||||
* `newFreq` - The new operating frequency of the CPU. Either 80 (80MHz) or 160 (160MHz).
|
||||
Loading…
x
Reference in New Issue
Block a user