For the temperature value, 0xFF is usually sent when the accelerometer doesn't understand the command you've given it. The other possibility is that the temperature reading has to be enabled using one of the other registers, but I couldn't find any mention of that when I looked.
Do you have any links to the other C code you mentioned? It might shed some light on why it's not working.
The NaN is probably because parseInt(tmp, 2) actually parses the integer (255 I guess) as a binary number (the 2 means base 2). Because none of the digits are binary, you get NaN (not a number) returned.
JavaScript does actually have a number type, but it automatically converts. Generally you wouldn't have to worry about converting between types though - especially in this case.
"STALL Sound"
For the DAC, it'll be a real struggle using the CS43L22 DAC from Espruino. I'd ignore it I'm afraid and would just use a PWM pin to give you a square wave of the relevant pitch, or use the Waveform class to play back an actual waveform.
fit all 3 queries into one command.
I'm afraid I2C doesn't work that easily, because generally you have to write and then read. I2C devices do tend to let you download blocks of data anyway though - you'd have to read the Datasheets.
Pico boards
I'm afraid the KickStarter has ended, so unless you already went for one you'll have to wait until after April when the boards should start to appear in distributors. You can sign up here and I'll let you know when they're available though.
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.
For the temperature value, 0xFF is usually sent when the accelerometer doesn't understand the command you've given it. The other possibility is that the temperature reading has to be enabled using one of the other registers, but I couldn't find any mention of that when I looked.
Do you have any links to the other C code you mentioned? It might shed some light on why it's not working.
The
NaN
is probably becauseparseInt(tmp, 2)
actually parses the integer (255 I guess) as a binary number (the 2 means base 2). Because none of the digits are binary, you getNaN
(not a number) returned.JavaScript does actually have a number type, but it automatically converts. Generally you wouldn't have to worry about converting between types though - especially in this case.
For the DAC, it'll be a real struggle using the CS43L22 DAC from Espruino. I'd ignore it I'm afraid and would just use a PWM pin to give you a square wave of the relevant pitch, or use the
Waveform
class to play back an actual waveform.I'm afraid I2C doesn't work that easily, because generally you have to write and then read. I2C devices do tend to let you download blocks of data anyway though - you'd have to read the Datasheets.
I'm afraid the KickStarter has ended, so unless you already went for one you'll have to wait until after April when the boards should start to appear in distributors. You can sign up here and I'll let you know when they're available though.