failing to read data pin based on clock pin with setWatch and digitalRead #986
Replies: 4 comments
-
Posted at 2018-06-25 by Wilberforce what hardware are interfacing too? there might already be a module you can use - or something similiar that you could modify. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-06-25 by @gfwilliams The issue you're hitting is that One way around this is to actually watch the data pin for changes as well:
However reading clocked data is a really common thing to want to do, so in version 1v96 I added the ability to also record a separate data source using setWatch:
So that should do exactly what you want. More info at: http://www.espruino.com/Reference#l__global_setWatch As @wilberforce says, depending on what you're trying to connect to there might also be a way to set up the underlying hardware to help you out. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-06-25 by mkol5222 @gordon and @wilberforce Many thanks for quick response. Suggestion to use new setWatch functionality for reading data pin exactly resolved timing issues with data readings. I am amazed how Puck.JS and Espruino JavaScript approach makes prototyping so easy including making easy publishing of data via BLE GATT service. We have submitted order for additional Espruino gatgets to learn even more. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-06-26 by @gfwilliams Great, thanks! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-06-24 by mkol5222
Hello,
I am trying to port Arduino C code to Puck.JS JavaScript
and I think I have potential timing issue with use of setWatch on clock PIN
to read data from data PIN similar to code below.
Is it possible to find optimal solution to interpret my input PINs
even with setWatch callback?
I do not get consistent results reading the data and I am worried that
only solution would be to have native code handling it?
What I try to do - storing each data bit on clock edge to array (to be interpreted later)
Arduino code was similar to
Arduino is using loop driven by CLK pin vs. Espruino based on JavaScript callback with set Watch for CLK edge...
My HW is Puck.JS.
Beta Was this translation helpful? Give feedback.
All reactions