Skip to content
Christopher Cantrell edited this page Sep 14, 2017 · 8 revisions

Zoe

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.

Basics

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.

Events and INIT

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.

Language Reference

VAR and Math

PAUSE(TIME=?)

CONFIGURE(OUT=?, LENGTH=?, HASWHITE=?)

DEFINECOLOR(COLOR=?, W=?, R=?, G=?, B=?)

STRIP.SOLID(COLOR=)

STRIP.SET(PIXEL=, COLOR=)

PATTERN(NUMBER=) { ... }

STRIP.PATTERN(X=?, Y=?, PATTERN=?, COLOROFFSET=?)

Example

// 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)
    
}
Clone this wiki locally