basic reading of battery level (#182)
This commit is contained in:
12
libs/core/battery.ts
Normal file
12
libs/core/battery.ts
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
namespace brick {
|
||||
/**
|
||||
* Returns the current battery level
|
||||
*/
|
||||
//% blockId=brickBatteryLevel block="battery level"
|
||||
//% group="More"
|
||||
export function batteryLevel(): number {
|
||||
const info = sensors.internal.getBatteryInfo();
|
||||
return info.current;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user