sandeepmistry / node-chip-io

Johnny-Five IO Plugin for the Next Thing Co. C.H.I.P.
MIT License
96 stars 28 forks source link

Add battery percent and current #42

Open norgeous opened 7 years ago

norgeous commented 7 years ago

So it currently supports the battery voltage via:

var BAT_VOLT_MSB_REGISTER = 0x78; (in /lib/axp209.js)

Looking at battery.sh I believe support for the battery's percent and amps can be done via commands like:

BAT_VOLT_MSB=$(i2cget -y -f 0 0x34 0x78)
BAT_VOLT_LSB=$(i2cget -y -f 0 0x34 0x79)

BAT_IDISCHG_MSB=$(i2cget -y -f 0 0x34 0x7C)
BAT_IDISCHG_LSB=$(i2cget -y -f 0 0x34 0x7D)

BAT_GAUGE_HEX=$(i2cget -y -f 0 0x34 0xb9)
BAT_GAUGE_DEC=$(($BAT_GAUGE_HEX))

Can you add these in?

sandeepmistry commented 7 years ago

@norgeous pull requests welcome ...

norgeous commented 7 years ago

I will attempt to get this done today (battery % only). I imagine that the code will be quite similar to chipio.BatteryVoltage(); and will be a five.sensor. Will let you know how I get on.

norgeous commented 7 years ago

Making a PR here https://github.com/sandeepmistry/node-chip-io/pull/43

norgeous commented 7 years ago

43 for battery percentage and now #45 for battery charge amps