Skip to content

Commit 4c4ea29

Browse files
committed
Puck.js: E.getTemperature(true) will now use the uC's internal temp sensor (previously only external was possible)
1 parent 67932a1 commit 4c4ea29

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
nRF52840: Fix crash if receiving >32b of advertisement data
2323
Jolt.js: Fix memory leak in Q0/1/2/3.setPower
2424
I2C: Fix readReg to ensure it sends I2C STOP after the read
25+
Puck.js: E.getTemperature(true) will now use the uC's internal temp sensor (previously only external was possible)
2526

2627
2v27 : nRF5x: Ensure Bluetooth notifications work correctly when two separate connections use the same handle for their characteristics
2728
nRF5x: Remove handlers from our handlers array when a device is disconnected

src/jswrap_espruino.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ On earlier firmwares this was accessible via `global["\xff"]`
154154
"class" : "E",
155155
"name" : "getTemperature",
156156
"generate" : "jswrap_espruino_getTemperature",
157+
"params" : [
158+
["internal","bool","On Puck.js (where there is an external temperature sensor), set to true to use the internal microcontroller temperature sensor, false to use the external sensor. On other devices this parameter is ignored."]
159+
],
157160
"return" : ["float","The temperature in degrees C"]
158161
}
159162
Use the microcontroller's internal thermistor to work out the temperature.
@@ -169,12 +172,12 @@ devices. If so it'll return NaN.
169172
be reading 10 over degrees C above ambient temperature. When running from
170173
battery with `setDeepSleep(true)` it is much more accurate though.
171174
*/
172-
JsVarFloat jswrap_espruino_getTemperature() {
175+
JsVarFloat jswrap_espruino_getTemperature(bool internal) {
173176
#ifdef PUCKJS
174-
return jswrap_puck_getTemperature();
175-
#else
176-
return jshReadTemperature();
177+
if (!internal)
178+
return jswrap_puck_getTemperature();
177179
#endif
180+
return jshReadTemperature();
178181
}
179182

180183
/*JSON{

src/jswrap_espruino.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "jshardware.h"
2020
#include "jsflags.h" // for E.get/setFlags
2121

22-
JsVarFloat jswrap_espruino_getTemperature();
22+
JsVarFloat jswrap_espruino_getTemperature(bool internal);
2323
JsVar *jswrap_espruino_nativeCall(JsVarInt addr, JsVar *signature, JsVar *data);
2424

2525
JsVarFloat jswrap_espruino_clip(JsVarFloat x, JsVarFloat min, JsVarFloat max);

0 commit comments

Comments
 (0)