Discuss Scratch

SimpleScratch
Scratcher
500+ posts

Scratch 3 Raspberry Pi GPIO control

Had a good today and managed to use @sheep_maker's wonderful extension playground working, to interface it to my old and trusty ScratchGPIO

I've simply got the extension to make calls to a python webserver running on the Pi, that then forwards the requests onto my existing GPIO python handler prog.



Last edited by SimpleScratch (Jan. 27, 2019 21:38:09)

SimpleScratch
Scratcher
500+ posts

Scratch 3 Raspberry Pi GPIO control

I've halted development using above technique as @sheep_maker extension reporter blocks don't fully work (they return a value but the value isn't available if you put the reporter block inside another block)

In the meantime, I've come up with a method that basically intercepts calls that the translate extension blocks make. Needs some jiggery-pokery on the Raspberry Pi but I've got it interfacing with my existing python GPIO handler quite well with the help of some user-defined blocks

As an example, these are screenshots of it taking readings from a SenseHAT

https://scratch.mit.edu/projects/282520183





Last edited by SimpleScratch (Jan. 27, 2019 21:57:03)

SimpleScratch
Scratcher
500+ posts

Scratch 3 Raspberry Pi GPIO control

Thigs are progressing using this technique.
A friend has developed a Chrome extension that lets normal translations through untouched but any calls with text inside get diverted to local webserver instead (which then passes them onto my existing ScratchGPIO handler)

so
(translate (hello::#8BC34A) to (French::#8BC34A)::#8BC34A)

will return pomme

but
(translate (\[All Off \]::#8BC34A) to (French::#8BC34A)::#8BC34A)


will turn all the pins on a Raspberry Pi off (0V)



Last edited by SimpleScratch (Jan. 31, 2019 09:08:40)

SimpleScratch
Scratcher
500+ posts

Scratch 3 Raspberry Pi GPIO control

I've launched my S3GPIO method of getting Scratch 3 to talk to Raspberry PI gpio pins
http://simplesi.net/s3gpio/

Powered by DjangoBB