timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

New Scratch things for Raspbian September 2016

Wed Sep 28, 2016 6:04 pm

I've already had several message asking about the 'improvements made to Scratch' so herewith a list of the changes I've made recently.

It's now built on the recently released Squeak 5.1 release (see http://www.squeak.org as always) with the latest in virtual machines etc. This has made the system around 10% faster in the big benchmarks we like to use but probably won't make any earth shattering changes to the Scratch user experience. It does mean that I can run AsteroidBlaster at over 350 frames per second on my Pi3 when the 'make it polite to other applications' setting is turned off. And really, you can't shoot asteroids like that.

A change that is big news for a sizeable but rarely heard from (in this forum at least) group of users is that the system now works with the X 'composition window' subsystem that allows for entering characters from languages such as Japanese, Chinese and Korean. There's a bunch of packages you have to install to provide the handler and fonts and I hope to get a tutorial added to the 'Usage' section of this site to explain it all.

Perhaps the most important bug fix is an attempt to make sure that all data written to projects files is really, truly, completely flushed, committed, synced and definitely dealt with. Linux loves to cache data and only write it when it gets bored; unfortunately it is quite common for youngsters to get bored rather sooner than linux does and they can power-off before the bits make their way to the actual sd card. Hopefully this will be a thing of the past, but do report any continuing problems.

The source code packages for NuScratch are now on SqueakMap and stored in SqueakSource. The source stuff for this release will be there soon. If you don't know about SqM & SqS then you won't really care about this.

Most of the visible changes are in the GPIOServer arena. I've relaxed the parsing so that the broadcast command syntax can be a little less constricted; for example spaces can be put between commands and arguments without causing problems. This was required in order to support access to the openweathermaps services - many city names include spaces! As with any major re-write there may be 'interesting' bugs still lurking.

Temperature sensing -
a) the popular DS18B20 sensors are now supported. You obviously have to enable 1-wire support first. The broadcast 'gettemp' will try to find an active DS18B20 and, if found, will connect a variable named 'temp+sensor id'. If you already know the 12 hex digit sensor id you can broadcast 'gettemp 1234567890ABCD', which should allow for connecting several. Be warned that reading the sensor can take up to 600mS, so strange apparent pauses in Scratch occur. I advise against having the variable watcher open! There is a new example project to illustrate this by plotting a simple graph.
b) the cpu temp can be read with 'gettemp cpu'. There is a new example project to illustrate this by plotting a simple graph.

Camera
You can now ask for a bigger picture from the camera. As before a simple 'photo' will take a 320x240 picture and add it as the current sprite's current costume. 'photo big' or 'photo large' will take a picture 640x480 to fill the stage area - useful for a new stage background. 'phone 720 @ 500' would take a picture 720 by 500 pixels *if* the camera will allow that. Some small sizes seem to produce very odd images - or nothing, and obviously very large sizes can use a lot of time and memory.

Weather
As mentioned above, we can now talk to the openweathermaps.org weather server to find the weather conditions almost anywhere. Currently only the latest conditions are available; forecasts may come later. You will need to sign up for a key on their site; it's free for basic service. You need to know the name of the location and the two character ISO name for the country as well. Broadcast 'getweather Rio de Janeiro, BR, {your key}' and a variable for 'Rain in Rio de Janeiro' etc will be created. An example for the weather in London UK is included. Note that we don't check the website more than once every 15 minutes in order to be polite to the free service.

SenseHAT
You can now set individual pixels on the SenseHAT LEDs by broadcasting e.g. 'ledpixel x {0-7} y {0-7} colour {colour name or code}' - for example 'ledpixelx 3 y 4 colour red' or 'led pixel at [email protected] colour 42,231,97'. You can also use the HTML colour hex description if you want - #4A67A0 for example.

The GPIOServer documentation in the usage section of this site should be updated soon with more detailed explanations.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

iw1
Posts: 47
Joined: Mon Oct 13, 2014 8:10 am

Re: New Scratch things for Raspbian September 2016

Wed Sep 28, 2016 9:51 pm

I haven't been able to take advantage of the improvements yet but have encountered a problem when running programs, which did work with the previous version, with the new version of Scratch, namely the usual commands to the outputs of the Pibrella board, both the on-board leds and the connector outputs, no longer produce a response. Pressing the big red button is detected. I don't know whether the problem is unique to the Pibrella board and have no clues to offer unfortunately. The programs do turn on the GPIO server.
Edit: I notice that there is a new folder (empty) called ScratchGPIODrivers in home/pi/Documents. Is this relevant?

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Thu Sep 29, 2016 9:54 pm

iw1 wrote: the usual commands to the outputs of the Pibrella board, both the on-board leds and the connector outputs, no longer produce a response. Pressing the big red button is detected.
Hmm. Odd, since I did test my Pibrella with the latest code just a couple of weeks ago. Ah, the joys of software - how is it that bits manage to rot?
iw1 wrote: Edit: I notice that there is a new folder (empty) called ScratchGPIODrivers in home/pi/Documents. Is this relevant?
Well yes and no. It's where a new class of files will live once I've really sorted out how they work. Think of it as a place Scratch will use to store files that can add new AddOn options without having to update the entire system.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

iw1
Posts: 47
Joined: Mon Oct 13, 2014 8:10 am

Re: New Scratch things for Raspbian September 2016

Fri Sep 30, 2016 7:28 am

I should have mentioned the context. I was using the newly released PIXEL version of Raspbian (freshly downloaded) so it was not just the version of Scratch that was new. In the past changes outside of Scratch have been a cause of problems. That may or may not be the case here.

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Fri Sep 30, 2016 11:26 pm

I've just been trying the Pibrella out on the very latest Raspbian/Scratch. It certainly isn't working quite like I expect.

Testing each individual output works ok. What seems to have happened is that I left in a smidge of code that ought to have been altered when I changed the broadcast command parsing and so a broadcast like `redoff yellowoff` - which I actually put in the example! - doesn't work properly anymore. Further, it seems like something might be causing a problem in the buzzer operation.

There are two things to try using the example pibrella script
a) in the line for the 'when green flag clicked' script that reads `broadcast gpioserveron redoff yellow off`, split up the broadcast to three separate ones
broadcast gpioserver on
broadcast redoff
broadcast yellowoff
b) a little lower down, pull the `broadcast buzzer 400` and `broadcast outputeon` blocks out and move them above the `repeat until` block

With those changes things work a lot better, though there is definitely still a bug in my handling of the buzzer to sort out.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

iw1
Posts: 47
Joined: Mon Oct 13, 2014 8:10 am

Re: New Scratch things for Raspbian September 2016

Sun Oct 02, 2016 12:06 pm

I have discovered why my Pibrella programs stopped working with the latest version of Scratch. Previously, broadcast commands controlling the leds etc. were not case-sensitive so a command such as RedOn would work. This is the way I typed such commands. Now the command has to be redon, all lowercase. (The clue that this might be the reason was in your last post, Tim.) I suspect that somewhere along the line the code (toupper() / tolower()?) that converted all broadcast commands to be the same case (I don't know whether it was lower or upper) has been lost. It would more convenient (for me) if broadcast commands were case-insensitive.

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Tue Oct 04, 2016 5:23 pm

iw1 wrote:I have discovered why my Pibrella programs stopped working with the latest version of Scratch. Previously, broadcast commands controlling the leds etc. were not case-sensitive so a command such as RedOn would work. This is the way I typed such commands. Now the command has to be redon, all lowercase. (The clue that this might be the reason was in your last post, Tim.) I suspect that somewhere along the line the code (toupper() / tolower()?) that converted all broadcast commands to be the same case (I don't know whether it was lower or upper) has been lost. It would more convenient (for me) if broadcast commands were case-insensitive.
Wow, well they *were* case-insensitive. Or at least I intended it that way... anyway, I've found solutions to that, as well as the command stream getting out of sorts and even the buzzer code. It'll be out sometime soon I hope.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

teddysetgo
Posts: 39
Joined: Thu Dec 03, 2015 10:51 pm

Re: New Scratch things for Raspbian September 2016

Tue Oct 04, 2016 11:37 pm

Has anyone else experienced a change in the way Scratch deals with simultaneous key presses?

For example, when using if blocks inside of a forever block to check for left arrow and right arrow (for moving a character perhaps), the user may accidentally press the left arrow before releasing the right arrow or vice versa.

In the past, this worked as expected, Scratch only recognized the most recent key press and the character would move in the new direction. But lately, I am noticing that strange things happen, often resulting in one of the keys being 'stuck'.

I have recreated this issue in several different programs on several different Pi's. I am just wondering if anyone else is noticing anything similar. I never had this issue before.

teddysetgo
Posts: 39
Joined: Thu Dec 03, 2015 10:51 pm

Re: New Scratch things for Raspbian September 2016

Wed Oct 05, 2016 11:57 am

I experimented with this some more and it is definitely a new bug.

It isn't just for the arrow keys, but for any key. The sensing block that returns a boolean for key whether or not a key is pressed gets stuck on true if you press a different key before releasing the original key.

Example:
-The key 'a' pressed? boolean starts as false.
-If you press and hold the 'a' key, the key 'a' pressed? boolean switches to true.
-If you release the 'a' key, the key 'a' pressed? boolean switches back to false.
-Press and hold 'a' again and the key 'a' pressed? boolean switches back to true. (all of this is typical behavior to this point).
-While holding 'a', begin holding 'b' simultaneously. The key 'a' pressed? boolean remains true, as it should.
-Release the 'a' key while still holding 'b' and the key 'a' pressed? boolean STAYS true. It will be stuck at true unless you press and release the 'a' key again.

Do we know what could be causing this? It makes game programming in Scratch very difficult for students. :-)

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Wed Oct 05, 2016 6:22 pm

Yes, something broke in keypress handling done in the 'is this key down' style as opposed to the 'oh a keypress event, what do I do' style. The annoying thing is that I haven't been able to replicate it running on the prior Raspbian but same Scratch. Which makes for a very puzzling debug session because I didn't deliberately change anything to do with key presses, nor did the new Raspbian.

I'm looking into it; more news when I can offer some.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

teddysetgo
Posts: 39
Joined: Thu Dec 03, 2015 10:51 pm

Re: New Scratch things for Raspbian September 2016

Wed Oct 05, 2016 11:15 pm

How can I 'downgrade' to a previous version of Scratch to test this out myself?

Similarly, how can I downgrade to a previous Raspbian?

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Fri Oct 07, 2016 12:11 am

OK, it looks like something really stupid happened and the version of the vm included in the latest release has a key event bug. Worse, I can't see any way this could have been missed, which is especially annoying since clearly it was ...

It's actually fixed in the latest development systems, which is nice but not too helpful to those of you out there.

If you're feeling brave, here is what to do until we can get an update published -

Download https://github.com/raspberrypi/scratch/ ... 160824.tgz
Move it into some new and empty directory
Unzip it with

Code: Select all

tar xzvf NuScratch20160824.tgz
You should find a new subdirectory called usr and subdirectories lib, then squeak, then 5.0-201608180858. That last is a VM that works better. So copy it with

Code: Select all

sudo cp -r usr/lib/squeak.5.0201608180858 /usr/lib/squeak
After that you should be able to run scratch normally and notice the difference
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

teddysetgo
Posts: 39
Joined: Thu Dec 03, 2015 10:51 pm

Re: New Scratch things for Raspbian September 2016

Fri Oct 07, 2016 12:46 am

I need to do this to about 30 Pi's, which I'm willing to do. However, how long until we might see a published update? I might be willing to wait.

Thanks for looking into this and responding so quickly and clearly. Your contributions to Scratch for Pi are literally changing lives in my classroom.

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Fri Oct 07, 2016 1:46 am

Ouch, that's a lot of Pi to clean up. Still, once you've done the download and unzip you could simply copy the usr/lib/squeak.5.0201608180858 directory to each machine's /usr quickly enough. Assuming they're all networked.. eh, even stick it on a usb stick would help.

Of course, this is exactly where having the PXE netbook really reliably working and configured would help.

As for an online package update - no idea. I do't get to control any of that so I can't offer any info at all. I'll poke a stick at the relevant people in Cambridge and we'll see what happens.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

ghp
Posts: 1170
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: New Scratch things for Raspbian September 2016

Fri Oct 07, 2016 6:18 am

For the distribution of updates in a not network connected classroom, I use a 'snowball' method:
I prepare an envelope with a 'secret letter' where some actions are described. In this letter are three envelopes.

Then I grab one team, give them the 'secret letter' and supervise them doing the actions.

The actions are:
- get three other teams (not yet having executed the procedure) to join your workplace
- tell them to carefully observe what is done on the computer

- copy one file from a stick to /home/pi
- open terminal (we exercise basic terminal usage during introduction lesson )
- untar
- execute an install.sh script

- copy the file to the sticks of the other teams
- give them the envelopes and tell them to execute the procedure.

Not to forget that the envelopes contain again a letter and envelopes. This procedure terminates quite quickly.
One precondition is that each team has an usb stick; we are lucky to have enough of them.
If you embed a 'desktop item' into the tar file, then its easy to monitor which teams have completed the procedure.

Regards,
Gerhard

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Fri Oct 07, 2016 6:51 pm

ghp wrote:For the distribution of updates in a not network connected classroom, I use a 'snowball' method:
Cute! I like that - it makes fixing the problem part of the game.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Sat Oct 08, 2016 12:50 am

If you were to check the 'old' blog page for the latest release of Raspbian you'd see a comment near the top about updating scratch. We though we had fixed the key event problem - and indeed when run to test things all seems well. It's just that somewhere, something weird is happening and when installed via the apt-get process the result (despite being binary identical according to `cmd -b`) behaves differently. As in wrongly.

So don't update yet and expect an improvement. This is just weird.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

teddysetgo
Posts: 39
Joined: Thu Dec 03, 2015 10:51 pm

Re: New Scratch things for Raspbian September 2016

Wed Oct 12, 2016 11:54 am

Any updates on this?

Changing Squeak didn't seem to help. I'll take just about any solution at this point. I just need working key presses again for my students.

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Wed Oct 12, 2016 7:22 pm

After a really "fun" couple of days debugging I've been able to pin the blame on some code recently added to the Squeak vm intended to support 'composition input' - for Japanese etc. Because that involve multiple keypresses per ideograph there is some nasty interaction with repeat keys. I was hoping that we could have a nice simple way to support this in Raspbian but it looks like that can't be done just yet.

The good news is that after updating NuScratch with the usual

Code: Select all

sudo apt-get install NuScratch
you can very quickly 'solve' the problem for now by editing the /usr/bin/squeak {edit: incorrectly referred to scratch script} shell script to comment out a single line. Find the line near the end that says

Code: Select all

export LC_ALL= $LANG
- ie stick a # at the beginning of the line. You'll need to sudo the editor since the file is owned by root.
Doing this will stop the system from even considering multi-key input and things will work as before. The really annoying thing for me is that the problem was masked on my development systems since I had the other Japanese language support libraries loaded and so far as I can tell that hides the bug. I'm still trying to work out how that happens.

A new release will be published soon and I'll include all the latest other fixes. All I can do is apologise for the pain and promise to beat the guilty party until morale improves.
Last edited by timrowledge on Tue Oct 25, 2016 5:47 pm, edited 1 time in total.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

teddysetgo
Posts: 39
Joined: Thu Dec 03, 2015 10:51 pm

Re: New Scratch things for Raspbian September 2016

Thu Oct 13, 2016 11:57 am

I don't see that line in the shell script. Perhaps I'm looking in the wrong place? The scratch shell script in my /usr/bin/ directory doesn't include that code.

teddysetgo
Posts: 39
Joined: Thu Dec 03, 2015 10:51 pm

Re: New Scratch things for Raspbian September 2016

Thu Oct 13, 2016 2:37 pm

I found it. It's in the Squeak shell script, not Scratch.

It's working great. Thanks for your help!

Side question: Will NuScratch continued to be developed now that Flash has been made available for the Pi?

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Sat Oct 22, 2016 3:45 am

For those of you waiting for a new release that solves this key event problem, an official update package will be out sometime soon.

Until then you may like to try out the blob at https://github.com/raspberrypi/scratch/ ... 161021.tgz

Download it to some place on your Pi.

Code: Select all

cd /
sudo tar xvzf {where you downloaded it to}/NuScratch20161021.tgz
This will (warning - you're sudoing in root directory, getting this wrong may delete the planet) load up the entire new release. If you

Code: Select all

ls /usr/lib/squeak
you should now see an entry for 5.0-201610101924
If you run scratch the window title should be
Scratch 1.4 (Linux) of 2016-10-21
AsteroidBlaster should now work properly, sounds stop when you evaluate the 'stop all sounds' block, the assorted dialogues should have proper inset borders for text entry fields and European users accustomed to using a comma as the decimal separator should find it works in the rounded numeric entry fields. Also the Pibrella buzzer works so much better, broadcast commands are returned to being non-case-dependant, and the /dev/tty/AMA serial ports are now available from the ScratchBoard menu.

Oh, and if you run scratch from the command line or even your own scripts, you can now do

Code: Select all

scratch presentation
or

Code: Select all

scratch fullscreen
to cause it to start up in either of these modes, or

Code: Select all

scratch my-project.sb
to start with my-project.sb loaded
or even mix them to start my-project.sb in fullscreen mode with

Code: Select all

scratch presentation my-project.sb
The sharp-eyed among you will have realised that this is not a configured package to be loaded with apt-get or pdkg or pip or any other package manager. This is a tar'd zip file - or is that a zipped tar file? - of the resultant directory tree.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

timrowledge
Posts: 1141
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: New Scratch things for Raspbian September 2016

Tue Nov 15, 2016 9:48 pm

There is now an update online that includes fixes for the keypress issue and improvements in sound, pibrella, text field borders, decimal point handling, export errors and serial port problems that were reported. Do the usual sudo apt-get update/upgrade dance to get up to date. You should end up with a version labeled "Scratch 1.4(Linux) of 2016-10-21"
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

User avatar
rpdom
Posts: 12741
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: New Scratch things for Raspbian September 2016

Tue Nov 15, 2016 10:00 pm

timrowledge wrote:This is a tar'd zip file - or is that a zipped tar file?
Neither. It's a gzipped tar file. ;-)

jjraspberry
Posts: 1
Joined: Tue Oct 10, 2017 1:11 am

Re: New Scratch things for Raspbian September 2016

Tue Oct 10, 2017 5:18 am

Hello,

I have been trying out Scratch on Raspberry Pi and I am thinking to use it to teach some kids coding. Love it so far.

One question - the kit I bought has the DHT11 temperature sensor. Is there an easy way to use it with Scratch?

Thanks!

JJ

Return to “Scratch”

Who is online

Users browsing this forum: No registered users and 1 guest