Discuss Scratch

SimpleScratch
Scratcher
500+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Aah - got you - but the set in/out function doesn't use those mappings

Also, Gordon's wiringPi numbering scheme is 3rd in the pecking order of numbering schemes

There have been big debates over whether its best to use Broadcom pin numbering over Physical Pin numbering
(I'm in the physical pin numbering camp BTW)

But Gordon's is mainly just used by Gordon and his library users (which is a significant minority as his library is very good and useful especially for C programmers)

Anyway, my suggestion would be that if using the webiopi backend then stick with GPIO numbering as it maintains consistency

Simon
SimpleScratch
Scratcher
500+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

And if you could make it so that we can use 1 or 0 instead of the boolean then that would make the blocks easier to use

Simon
procd
Scratcher
100+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

It'a all something of a dog's dinner! That wasn't the reference I used originally but couldn't find it. Was a nice spreadsheet with the data and made most sense. The reason I didn't go with the BCM numbering was that I thought it may be a bit odd having blocks and menus that weren't contiguous. GPIO0..7 seems much nicer.
Realised that this would be a nuisance and was why I asked for block suggestions in the beginning. I'm happy to change the naming to whatever you think is best whether as is or BCM or physical pin numbering?
I'll have a look at the set in/out issue.
SimpleScratch
Scratcher
500+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

I ALWAYS want physical pin numbering

but 49% of others want GPIO numbering

Since you've used the Webiopi on the Pi, then for consitencies sake (and over my deep personal beliefs!) I'd have to say to go with broadcom numbering

(and when debuuged OK - offer 2 extensions - one for each type)

Simon

PS Great stuff - Thanks very much

PPS As an OpenSource person I'd like to see it go that way BTW :-)

PPS - I recommend Github as a great way of sharing but still retaining control
https://github.com/cymplecy
procd
Scratcher
100+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Not tested to really check the set issue but looking at the code the set uses the same conversion so should be ok.

Put down what blocks you want. e.g.

<Pin 11> or (Pin 11) (Think Boolean block is the most sensible way but can do a reporter to return 0 or 1 as well?)

I'll add in a menu so you can set value to “high ” or “low” or would you rather it be 0 and 1?

I set up a github account recently ready for this. When it's good to go I'll pop the code on there unless you need it now?
SimpleScratch
Scratcher
500+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Well the set commands sends GPIO numbers not WiringPi numbers according to debug posted a few posts back

On/Off is my pref but high/low 1/0 are OK

Simon
drmcw
Scratcher
1000+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

SimpleScratch wrote:

Well the set commands sends GPIO numbers not WiringPi numbers according to debug posted a few posts back

On/Off is my pref but high/low 1/0 are OK

Simon

You mean this?
Listening on port 8080
Press return to exit.
Scratch Request : /setGPIOFn/4/OUT
POSTing WebIOPi : /GPIO/23/function/OUT
WebIOPi response : OUT
Scratch Request : /setGPIO/4/true
POSTing WebIOPi : /GPIO/23/value/1
WebIOPi response : 1
That's converting GPIO4 to BCM GPIO23 for both function and value. So looks ok to me.

SimpleScratch
Scratcher
500+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Ignore me Brain must have got mixed up sorry

Simon
SimpleScratch
Scratcher
500+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

I've got about 10 balls in the air today
youobjc
New Scratcher
4 posts

Connect Scratch 2 to Raspberry Pi GPIO port

well, great ! I am gonna to give it a try on my device.
procd
Scratcher
100+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

I've uploaded a new version. Download from same location. This contains more blocks that use PIn labels. Try them out and see what you think.
SimpleScratch
Scratcher
500+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Much better

everthign worked fine except for Pin 13 and then I realised that we ‘d run into the rev 1 pins numbering vs revision 2 pin nuimbering where they changed the GPIO pin numbers on physical pin numbers 3, 5 and 13.

The majority of boards out ther eare revision 2 so I’d target those ones until you can add a parameter switch to WiPi.exe to handle the differences or add in a board revision block to do it from Scratch which would be better overall

Great progress though

Simon
SimpleScratch
Scratcher
500+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Are you on twitter BTW?

Simon
procd
Scratcher
100+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Great. I shall add a switch to the config file to select the revision and make revision 2 the default. I assume the Pin blocks are better than the GPIO ones so shall remove those, however what are your thought on the Boolean blocks. To me they make more sense than reporting “0” or “1” or selecting “ON” or “OFF”. Do you think they should be kept but converted to Pin?

I have an unused twitter account for another username!
procd
Scratcher
100+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Have uploaded a new version which allow debug to be switched on or off from the config file and also to set the revision. Haven't had time to test unfortunately. The camjam arrived today too but also has to remain in the tin untested,
SimpleScratch
Scratcher
500+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Sorry - been so busy !

Schools hols starts next wednesday so I'll get time then!

Simon
procd
Scratcher
100+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Same here but because the holidays have already begun! Camjam arrived but was buzzerless, so is being resent. I'll need the buzzer as the pi is in the other room
procd
Scratcher
100+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Looks good. Camjam works nicely too. Really just need to finalise what blocks the extension should provide?

I've only got a rev1 board so cannot check the rev 2 side.

Last edited by procd (July 19, 2014 07:34:09)

procd
Scratcher
100+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

Pushed the code to github here https://github.com/scratch2procd/WiPi
mytie
Scratcher
100+ posts

Connect Scratch 2 to Raspberry Pi GPIO port

A first you can't install scratch 2 on pi. It's processor architecture doesn't support flash. So no offline or online scratch. Why don't you try scratch 1.4 which comes with the pi?

Powered by DjangoBB