Question: How to use the API to export a constant stream of data?

by Reallygeek | December 10, 2017 20:08 | #15349


I used the $W.data command in the chrome console, and I was able to get data at that time of the intensity of the wavelengths, I would like to be able to get constantly updating information, and export it to an arduino sketch, is there a command for that?



7 Comments

Hi, I believe you should be able to override the $W.getCrossSection() function here: https://github.com/publiclab/spectral-workbench/blob/master/app/assets/javascripts/capture.js#L180

and it'll run each time a sample is collected -- many times per second. Exciting to see what you're doing! Please share some build photos if you can! :-)

So when I typed "$W.getCrossSection()" into the console I got: TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)' at Object.getCrossSection (capture-2378d6dbb368cce52b64ccc75b38a3a4.js:1) at :1:4

Did I do something wrong?

Also thank you! I see if I can make a little blog post with what I've done so far, or maybe once I finish.

Is this a question? Click here to post it to the Questions page.


Oh sorry, you have to redefine the function with a new one of your own, that can be a revision of the existing one, and it'll get called each frame. Make sense? I'm happy to review your code and offer tips.

Is this a question? Click here to post it to the Questions page.


Is there not a way to make chrome console repeat a command over a period of time?

Is this a question? Click here to post it to the Questions page.


Ah, there is! setInterval -- but the getCrossSection function is already run using this technique. Can you share a link to your code so I can help troubleshoot? Happy new year!

Is this a question? Click here to post it to the Questions page.


Ok so all I did was, $W.getCrossSection= $W.data; which gave me the data one time, then every half second I got "$W.getCrossSection is not a function" every half second.


I also tried to "override" by making this: https://docs.google.com/document/d/1cctjKW-4lCkrBZuILErFq1bBNidR6Igmm5zh9k_wvFo/edit?usp=sharing

but I'm not sure how to use it... or if it will work

Is this a question? Click here to post it to the Questions page.


Reply to this comment...


Log in to comment