Skip to content

Commit

Permalink
Update ble_battery_a0.js
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f authored Sep 14, 2022
1 parent 5d9710f commit 8828717
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ble_battery_a0.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
var Averager = require("Averager").Averager;
var voltageAverager = new Averager({scale:500});

function onSecond() {
volts = analogRead(A0) * E.getAnalogVRef() * 2.213;
voltageAverager.add(analogRead(A0) * E.getAnalogVRef() * 2.213);
volts = voltageAverager.series.hours.getCurrent()[voltageAverager.series.hours.lastBucket];
NRF.setAdvertising([
{0x180F : [Math.round(Math.min(1, volts / 4.22) * 100)]},
{0x180F : [Math.round(Math.min(1, (volts - 3.2) / (4.22 - 3.2)) * 100)]},
]);
// If graphics is defined
if (global.g) {
Expand Down

0 comments on commit 8828717

Please sign in to comment.