This code looks like it could be of use to you. It at least helps to sort out the various sequences of bytes that are needed to converse with the fuel gauge chip. Translating from C to JavaScript would need to be done. A starting point is to replace the #define variable 0xvalue with var variable= 0xvalue. For example
#define BQ27441_CONTROL_STATUS 0x0000
becomes
var BQ27441_CONTROL_STATUS= 0x0000;
then functions need to be redefined
void init_i2c(char *DeviceName)
{
}
rewrite as
function init_i2c(DeviceName){
}
Lots of work from there to get it all working.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
This code looks like it could be of use to you. It at least helps to sort out the various sequences of bytes that are needed to converse with the fuel gauge chip. Translating from C to JavaScript would need to be done. A starting point is to replace the #define variable 0xvalue with var variable= 0xvalue. For example
#define BQ27441_CONTROL_STATUS 0x0000
becomes
var BQ27441_CONTROL_STATUS= 0x0000;
then functions need to be redefined
void init_i2c(char *DeviceName)
{
}
rewrite as
function init_i2c(DeviceName){
}
Lots of work from there to get it all working.
https://github.com/chintanp/i2c-charger/blob/master/BQ-27441-Gauge/c/gauge.c