-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Zoe is a programming language for LED animations. The language is very BASIC-like and designed to be simple and performant.
Zoe programs compile into byte codes that run on a custom VM on the Parallax Propeller board (the Oreo Board).
The language syntax will edit visually within a JavaScript editor.
Zoe programs are written as functions that call one another. All variables are global. There are no local variables, and you do not pass arguments to a function or return values from them.
Zoe commands are single lines. There is no semicolon or other marker on the end of the line. Spaces are ignored. Commands are not case sensitive.
The best way to write Zoe programs is to modify an existing example. Examples and command-references follow.
Every Zoe program must have an "init" function. This function is called at startup.
Other functions are called in response to events sent to the board through the serial link.
// The ROBORIO board sends these serial events:
// [ModeAutonomousRed] Entering autonomous mode on RED team
// [ModeAutonomousBlue] Entering autonomous mode on BLUE team
// [ModeTeleop] Entering teleop mode
// [GearBasketOpen] Open the gear basket
// [GearBasketClose] Close the gear basket
// [StopClimb] Climber stop
// [ClimbUp] Climb up
// [ClimbDown] Climb down
function init() {
var teamColor
var x
var y
// D3 is the bottom of the robot (center square)
configure (out=D3, length=142, hasWhite=true)
// Team Red
defineColor(color=0, W=0, R=0, G=0, B=0)
defineColor(color=1, W=0, R=10, G=0, B=0)
defineColor(color=2, W=0, R=20, G=0, B=0)
defineColor(color=3, W=0, R=30, G=0, B=0)
defineColor(color=4, W=0, R=40, G=0, B=0)
defineColor(color=5, W=0, R=50, G=0, B=0)
defineColor(color=6, W=0, R=60, G=0, B=0)
defineColor(color=7, W=0, R=70, G=0, B=0)
defineColor(color=8, W=0, R=80, G=0, B=0)
defineColor(color=9, W=0, R=90, G=0, B=0)
defineColor(color=10, W=0, R=100, G=0, B=0)
defineColor(color=11, W=0, R=110, G=0, B=0)
defineColor(color=12, W=0, R=120, G=0, B=0)
defineColor(color=13, W=0, R=130, G=0, B=0)
defineColor(color=14, W=0, R=140, G=0, B=0)
defineColor(color=15, W=0, R=150, G=0, B=0)
// Team Blue
defineColor(color=32, W=0, B=0, G=0, R=0)
defineColor(color=33, W=0, B=10, G=0, R=0)
defineColor(color=34, W=0, B=20, G=0, R=0)
defineColor(color=35, W=0, B=30, G=0, R=0)
defineColor(color=36, W=0, B=40, G=0, R=0)
defineColor(color=37, W=0, B=50, G=0, R=0)
defineColor(color=38, W=0, B=60, G=0, R=0)
defineColor(color=39, W=0, B=70, G=0, R=0)
defineColor(color=40, W=0, B=80, G=0, R=0)
defineColor(color=41, W=0, B=90, G=0, R=0)
defineColor(color=42, W=0, B=100, G=0, R=0)
defineColor(color=43, W=0, B=110, G=0, R=0)
defineColor(color=44, W=0, B=120, G=0, R=0)
defineColor(color=45, W=0, B=130, G=0, R=0)
defineColor(color=46, W=0, B=140, G=0, R=0)
defineColor(color=47, W=0, B=150, G=0, R=0)
defineColor(color=20, W=0, R=50, B=50, G=50)
[teamColor] = 0
solid(color=47)
here:
pause(time=1000)
goto(here)
}
function [ModeAutonomousRed]() { // Entering autonomous mode on RED team
[teamColor] = 0
[x] = [teamColor] + 15
solid(color=[x])
// Endless loop
here:
pause(time=5000)
goto(here)
}
function [ModeAutonomousBlue]() { // Entering autonomous mode on BLUE team
[teamColor] = 0
[x] = [teamColor] + 15
solid(color=[x])
// Endless loop
here:
pause(time=5000)
goto(here)
}
function [ModeTeleop]() { // Entering teleop mode
top:
[x] = 0
[y] = [teamColor]
loop1:
solid(color=[y])
pause(time=250)
[y] = [y] + 1
[x] = [x] + 1
if([x]<15)
goto(loop1)
loop2:
solid(color=[y])
pause(time=250)
[y] = [y] - 1
[x] = [x] - 1
if([x]>0)
goto(loop2)
goto(top)
}
function init() {
var teamColor
[teamColor] = 2 // Neutral
// The D1 area is the pixel grid
configure (out=D1, length=192, hasWhite=false)
defineColor(color=0, W=0, R=0, G=0, B=0) // Color 0 : Black
defineColor(color=1, W=0, R=100, G=0, B=0) // Color 1 : Red
defineColor(color=2, W=0, R=120, G=80, B=4) // Color 2 : Yellow(ish)
//
defineColor(color=8, W=0, R=0, G=0, B=100) // Color 8 : Blue
defineColor(color=9, W=0, R=50, G=50, B=50) // Color 9 : White
defineColor(color=10, W=0, R=50, G=50, B=50) // Color 10 : White
//
defineColor(color=11, W=0, R=100, G=0, B=0) // Color 16 : Red
defineColor(color=12, W=0, R=50, G=50, B=50) // Color 17 : White
defineColor(color=13, W=0, R=50, G=50, B=50) // Color 18 : White
//
defineColor(color=20, W=0, R=100, G=0, B=0) // Color 20 : Team Red
defineColor(color=21, W=0, R=0, G=0, B=100) // Color 21 : Team Blue
defineColor(color=22, W=0, R=5, G=5, B=5) // Color 22 : Team Neutral
// Large 5
pattern(number=0) {
11111
1....
1....
.111.
....1
....1
11111
}
// Large 8
pattern(number=1) {
22222
2...2
2...2
.222.
2...2
2...2
22222
}
pattern(number=2) {
1111
1...
111.
...1
...1
1111
}
pattern(number=3) {
2222
2..2
.22.
2..2
2..2
2222
}
pattern(number=4) {
111
1..
111
..1
111
}
pattern(number=5) {
222
2.2
222
2.2
222
}
// Blank the display
solid(color=0)
// Draw the large 5858
drawPattern(number=0, x=0, y=0)
drawPattern(number=1, x=6, y=0)
drawPattern(number=0, x=12, y=0)
drawPattern(number=1, x=18, y=0)
// Endless loop
here:
pause(time=5000)
goto(here)
}
function alternate() {
}
function jiggle() {
}
function shrinkGrow() {
}
function [ModeAutonomousRed]() { // Entering autonomous mode on RED team
[teamColor] = 20
set(pixel=56,color=[teamColor])
set(pixel=57,color=22)
set(pixel=58,color=22)
set(pixel=59,color=22)
// Endless loop
here:
pause(time=5000)
goto(here)
}
function [ModeAutonomousBlue]() { // Entering autonomous mode on BLUE team
[teamColor] = 20
// Endless loop
set(pixel=56,color=[teamColor])
set(pixel=57,color=22)
set(pixel=58,color=22)
set(pixel=59,color=[teamColor])
here:
pause(time=5000)
goto(here)
}
function [ModeTeleop]() { // Entering teleop mode
// Endless loop
set(pixel=56,color=[teamColor])
set(pixel=57,color=22)
set(pixel=58,color=[teamColor])
set(pixel=59,color=22)
here:
pause(time=5000)
goto(here)
}
function [GearBasketOpen]() { // Open the gear basket
// Endless loop
set(pixel=56,color=[teamColor])
set(pixel=57,color=22)
set(pixel=58,color=[teamColor])
set(pixel=59,color=[teamColor])
here:
pause(time=5000)
goto(here)
}
function [GearBasketClose]() { // Close the gear basket
// Endless loop
set(pixel=56,color=[teamColor])
set(pixel=57,color=[teamColor])
set(pixel=58,color=22)
set(pixel=59,color=22)
here:
pause(time=5000)
goto(here)
}
function [StopClimb]() { // Climber stop
// Endless loop
set(pixel=56,color=[teamColor])
set(pixel=57,color=[teamColor])
set(pixel=58,color=22)
set(pixel=59,color=[teamColor])
here:
pause(time=5000)
goto(here)
}
function [ClimbUp]() { // Climb up
// Endless loop
set(pixel=56,color=[teamColor])
set(pixel=57,color=[teamColor])
set(pixel=58,color=[teamColor])
set(pixel=59,color=22)
here:
pause(time=5000)
goto(here)
}
function [ClimbDown]() { // Climb down
// Endless loop
set(pixel=56,color=[teamColor])
set(pixel=57,color=[teamColor])
set(pixel=58,color=[teamColor])
set(pixel=59,color=[teamColor])
here:
pause(time=5000)
goto(here)
}