martinohanlon / scratch_ext_prototypes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This repository and project has now been archived and is no longer supported. The code will remain available for reference and information.

Scratch extension prototype

This is a prototype I created of how the Raspberry Pi Scratch extension could be implemented.

It was created as a way of supporting a conversation rather than a statement of intent.

prototype blocks block

Notes:

  • The code is a bit "hacky", its not meant to be production!
  • the set input [pin] to [pull_up / pull_down] doesn't work as it would have required significant re-development of the extension.

Installation

  1. Clone this repo.
cd /home/pi
git clone https://github.com/martinohanlon/scratch_ext_prototypes
  1. Backup your existing scratch 2 extension.
cp /usr/lib/scratch2/scratch_extensions/piGPIOExtension.js /home/pi/scratch_ext_prototypes
  1. Install the prototype
sudo cp /home/pi/scratch_ext_prototypes/piGPIOExtension.js.prototype.js /usr/lib/scratch2/scratch_extensions/piGPIOExtension.js
  1. Start Scratch

  2. Restore original extension

sudo cp /home/pi/scratch_ext_prototypes/piGPIOExtension.js /usr/lib/scratch2/scratch_extensions

Initial prototypes

These are some early prototypes I created to support debate.

The prototypes "work" although the code lacks finesse having been pulled together in a hurry!

Events

piGPIOExtension.js.events.js

This adds an Event (or hat) block of when gpio [number] goes [high/low] to the existing extension.

event block

Pin based

The pin based prototype uses a pin description rather than a gpio:

pin based blocks

Device based

This prototypes splits blocks down in "devices" (LED, Button, Buzzer, PIR) to show how a higher level of abstraction could be implemented.

device based blocks

About


Languages

Language:JavaScript 100.0%