how to get integers from analogRead #1176
Replies: 5 comments
-
Posted at 2018-08-22 by @gfwilliams Just multiply the analogRead value by 65536 (assuming you're reading a 16 bit waveform?) - that's all you should need. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-22 by Steffen Well, of course. In the code there is a function jshPinAnalogFast - can I acces it from JS? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-22 by Steffen ... or can and want you enhance analogRead to take an optional 2nd parameter (boolean, true) to return the integer? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-22 by @gfwilliams You can't access it from JS - I don't understand why you'd want to? It produces a lower quality output most of the time - but when you're calling it from JS the speed really doesn't matter - it's a very small percentage of the overall JS execution time |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-23 by Steffen Having seen that in the C code for analogRead, as one of the last steps the data is divided by 65536, I thought why not shortcut it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2018-08-22 by Steffen
I'm reading chunks of data using Waveform, which returns UInt values.
There are accompanying single measurements via analogRead. Unfortunately analogRead values need to be converted from Float to Integer to be comparable with the Waveform data. Is there a way to make analogRead return integers (may be a flag)?
Any other reliable, though probably hacky way to get ADC data fast and as int?
Beta Was this translation helpful? Give feedback.
All reactions