S3DGPIO : ScratchGPIO for Scratch 3 Desktop on Raspberry Pi

ALPHA STATUS: ONLY FOR EXPERIMENTAL USERS 🙂

I’ve manage to add native ScratchGPIO blocks to Scratch 3 Desktop on the Pi. If you fancy trying it out (its liable to change so don’t start using it to make big projects or run courses)

Installing

You need to install Scratch 3 Desktop by adding it via the Pi menu Preferences > Recommended Software

Then move /usr/lib/scratch3/resources/app.asar to /usr/lib/scratch3/resources/app.orig (in case you want to return to standard setup)

 sudo mv /usr/lib/scratch3/resources/app.asar /usr/lib/scratch3/resources/app.orig 

Download
https://www.dropbox.com/s/ze8ayittmclg1qm/app.asar?dl=0
and move it to /usr/lib/scratch3/resources/app.asar with it (I’ll automate these steps eventually)

Re-install ScratchGPIO using standard instructions and hopefully you’ll have new S3DGPIO Desktop icon

Launch S3DGPIO Desktop – click on extension icon at bottom right and scrolldown to find S3DGPIO – click it

You should now have at least 3 blocks command (Pin 11 off etc) , set x to y (AddOn to UnicornHAT or Motor11 to 50 etc) and read (equivalent to ScratchGPIO sensor values)

NB. No pins are set to default to inputs so do a command Config 7 In to set pin 7 as an input with a pull-up resistor selected

Like I say very alpha at moment so not for in-experienced users!

DEbug mode

Reboot

Terminal 1

cd /opt/scratchgpio8

sudo python scratchgpio_handler8.py

Open terminal 2

cd /opt/scratchgpio8

sudo python S3GPIOServer.py

 

Launch Scratch 3 (not S3DGPIO – just plain one)

Try pin 11 on and see if message gets to each terminal

 

 

You may also like...

3 Responses

  1. Edson says:

    Hi, I would like to know if you have the step by step guide to create a new app.asar, as you have in the https://vipzinho.com.br/wp-content/uploads.
    I have tried several times, but my app.asar is always empty (with 1kb)

    Thanks!

    • cymplecy says:

      Sorry for delay – I don’t get notifed when someone comments

      The process is quite painful and I wouldn’t recommend doing it – I need a better method
      I’ don’t have enough time to detail the process but I cna tell you the steps I used

      The app.asar file is very compressed and original code can end up in VERY long lines so simply using a text editor didn’t work for me

      But I found if I split the file, line by line, then I ended up with 100s of files – one of which contains the code for extensions
      It easy to spot it as its about 50MBytes in size!

      to do the splitting I used the Linux spit command

      The next problem is that the 50MB file is one LONG line

      So you I replaced all /n with a true newline (had to work out how to use sed to acheive this but maybe it could be done in the editor)

      So then I now have a mostly readable file that can be editied

      However, it took me quite some time to find an editor than can handle a 50MB file and work faster than treacle 🙂

      I’m using JOE joe-editor.sourceforge.io so I had to learn how to use it – I wish I could fine a GUI editor that isn’t slow 🙂

      Then the actual fun starts in trying to find the places to add a new extension in

      If you search on an existing extension name – you find that there are 3 spots in the file where additions have to be made

      And then trying to work out syntax for new code is fun 🙂

      Then you have to reverse everything!

      I don’t actullaly work on orginal files (as I make mistakes all the time and need to revert to working code) so I have to replace all newlines in my modified file with /n

      Then join the modified file back with the other originals that I split in the first place

      You then have a new app.asar

      You then find you made a small syntax error somewhere and its back to the editor!

      My method is not an easy process!

      Simon

Leave a Reply

Your email address will not be published.