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

Reallygeek is asking a question about spectral-workbench: Subscribe to answer questions on this topic

Reallygeek asked on December 10, 2017 20:08
170 | 1 answers | shortlink

I used the $ 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?

arduino spectralworkbench spectral-workbench-api



Log in to comment

1 Answers

Hi, I believe you should be able to override the $W.getCrossSection() function here:

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! :-)

Reallygeek 5 months ago

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.

warren 5 months ago

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.

Reallygeek 5 months ago

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

warren 5 months ago

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!

Reallygeek 4 months ago

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

Reallygeek 4 months ago

I also tried to "override" by making this:

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

Log in to comment

Sign up or Login to post an answer to this question.