Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Convert Elements of String to number

I receive an BCD encoded String from my I2C RTC (7 bytes long)

I try to use each element of the string as a number to perform a BCD to DEC conversion.

for (let j = 0; j < result.length; j++) {
        let xx = (result[j]); //Error
        //let xx = 12; //works
        print((xx / 0x10 * 0xA) + (xx % 0x10));
    }

Error:
MJS callback error: implicit type conversion is prohibited

How to explicit convert the char value to a number ? Number() is not working.

Thanks
Holger

Comments

Sign In or Register to comment.