File tree 3 files changed +38
-1
lines changed
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -437,6 +437,32 @@ JsVar *jswrap_ESP8266WiFi_getRstInfo() {
437
437
return restartInfo ;
438
438
}
439
439
440
+ /*JSON{
441
+ "type" : "staticmethod",
442
+ "class" : "ESP8266WiFi",
443
+ "name" : "updateCPUFreq",
444
+ "generate" : "jswrap_ESP8266WiFi_updateCPUFreq",
445
+ "params" : [
446
+ ["freq","JsVar","Desired frequency - either 80 or 160."]
447
+ ]
448
+ }
449
+ * Update the operating frequency of the ESP8266 processor.
450
+ */
451
+ void jswrap_ESP8266WiFi_updateCPUFreq (
452
+ JsVar * jsFreq //!< Operating frequency of the processor. Either 80 or 160.
453
+ ) {
454
+ if (!jsvIsInt (jsFreq )) {
455
+ jsExceptionHere (JSET_ERROR , "Invalid frequency." );
456
+ return ;
457
+ }
458
+ int newFreq = jsvGetInteger (jsFreq );
459
+ if (newFreq != 80 && newFreq != 160 ) {
460
+ jsExceptionHere (JSET_ERROR , "Invalid frequency value, must be 80 or 160." );
461
+ return ;
462
+ }
463
+ system_update_cpu_freq (newFreq );
464
+ }
465
+
440
466
441
467
/**
442
468
* Return an object that contains details about the state of the ESP8266.
Original file line number Diff line number Diff line change @@ -30,5 +30,6 @@ JsVar *jswrap_ESP8266WiFi_getConnectedStations();
30
30
JsVar * jswrap_ESP8266WiFi_getRSSI ();
31
31
JsVar * jswrap_ESP8266WiFi_getState ();
32
32
void jswrap_ESP8266WiFi_dumpSocket (JsVar * socketId );
33
+ void jswrap_ESP8266WiFi_updateCPUFreq (JsVar * jsFreq );
33
34
34
35
#endif /* LIBS_NETWORK_ESP8266_JSWRAP_ESP8266_H_ */
Original file line number Diff line number Diff line change @@ -343,4 +343,14 @@ The returned object contains the following fields:
343
343
344
344
* ` sdkVersion ` - The version of the ESP8266 SDK used to build this release.
345
345
* ` cpuFrequency ` - The CPU operating frequency in MHz.
346
- * ` freeHeap ` - The amount of free heap in bytes.
346
+ * ` freeHeap ` - The amount of free heap in bytes.
347
+
348
+ ----
349
+
350
+ ##ESP8266WiFi.updateCPUFreq
351
+
352
+ Set the operating frequency of the ESP8266 processor.
353
+
354
+ ` ESP8266WiFi.updateCPUFreq(newFreq) `
355
+
356
+ * ` newFreq ` - The new operating frequency of the CPU. Either 80 (80MHz) or 160 (160MHz).
You can’t perform that action at this time.
0 commit comments