Skip to content

Instantly share code, notes, and snippets.

@binocularity
Created October 18, 2022 20:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binocularity/a3c6e95af3905fca9a0c23eaa7988b7e to your computer and use it in GitHub Desktop.
Save binocularity/a3c6e95af3905fca9a0c23eaa7988b7e to your computer and use it in GitHub Desktop.
@cheerlights dynamic updating with dropped network mangement in @WolframResearch Mathematica from @binocularity
req = HTTPRequest[
"http://api.thingspeak.com/channels/1417/field/2/last.json"];
f[] := (
colour = HatchFilling[];
reqStat = Quiet[ URLRead[ req, TimeConstraint -> 2]];
If[ Not[FailureQ[reqStat]],
( rawData = Import[req];
colour = RGBColor[Lookup[ rawData, "field2"]]; )
];
colour
)
CreateDocument[ Dynamic[ Graphics[{f[], Rectangle[{0.0, 0.0}]}], UpdateInterval -> 8] ];
@binocularity
Copy link
Author

binocularity commented Oct 18, 2022

NB you need to copy and paste this into Mathematica it is not a .nb notebook.
NB 2 it should work with Wolfram Engine/Mathematica free on the Raspberry PI but I have not tested it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment