basic reading of battery level (#182)

This commit is contained in:
Peli de Halleux
2018-01-04 21:50:13 -08:00
committed by GitHub
parent 0db6987ee5
commit 1e460eef9e
6 changed files with 26 additions and 1 deletions

12
libs/core/battery.ts Normal file
View 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;
}
}