Foxonix uses a script style language called EZ Language which is built upon a set of simple, easy to use commands.
Refer to the sections below to learn how to use these commands, and take a look at the SAMPLE PROGRAMS.
Foxonix supports several "devices names." This refers to the amount of memory or I/O available for a particular project. Selecting a larger device gives you more space for your audio (and in some cases more I/O), but the code editor generates a larger binary file, which takes longer to upload to the board. Choose a device from the following table that best suits your project.
| Device Name | Storage at 12kHz sampling rate |
Number of I/O (Ports Used) | Audio Output |
| SNC21030 | 15 sec. | 12 (P1, P2, P3) | PWM only |
| SNC21031 | 15 sec. | 12 (P1, P2, P3) | DAC only |
| SNC21060 | 30 sec. | 12 (P1, P2, P3) | PWM only |
| SNC21085 | 42.5 sec. | 12 (P1, P2, P3) | PWM only |
| SNC21120 | 60 sec. | 16 (P1, P2, P3, P6) | PWM or DAC |
| SNC21168 | 84 sec. | 16 (P1, P2, P3, P6) | PWM or DAC |
| SNC21200 | 100 sec. | 16 (P1, P2, P3, P6) | PWM or DAC |
| SNC21268 | 134 sec. | 16 (P1, P2, P3, P6) | PWM or DAC |
| SNC21340 | 170 sec. | 16 (P1, P2, P3, P6) | PWM or DAC |
The native data format for Foxonix is the 4-bit integer. This means the registers used to store numbers are 4 bits wide, so those registers can hold numbers ranging from 0 to 15. There are sixteen 4-bit registers.
Foxonix also supports data that is 8-bits wide, and an 8-bit register can hold numbers ranging from 0 to 255. An 8-bit register is made from two 4-bit registers, so using an 8-bit register counts as two against the sixteen total 4-bit registers available.
In a Foxonix program, a 4-bit register is represented by Mi. For example, M0, M1, M2, up through M15. An 8-bit register is represented by Xi. For example, X0, X1, X2, up through X7. When using Xi, the code compiler assembles the 8-bit register for you. X0 will be assembled from M0 and M1, X1 will be assembled from M2 and M3, and so on.
|
Code Example |
Meaning |
|
M2=3 |
Load the integer number 3 into 4-bit register M2. |
|
X0=127 |
Load the integer number 127 into 8-bit register X2. |
Numbers can also be represented in binary and hex format.
|
Code Example |
Meaning |
|
M2=0011b |
Load the binary number 0011 into 4-bit register M2. |
|
X0=0FFh |
Load the hex number FF into 8-bit register X0. |
Note that when using hex format the first digit must begin with a number. If the hex number begins with A - F, then a zero must be added to the front of the number as shown in the example above.
The native register size for Foxonix is 4-bits, but 8-bit registers are also supported. Register names in the "Mi" format are 4-bit and register names in the "Xi" format are 8-bit. These links provide detailed command descriptions for both 4-bit and 8-bit uses.
|
Expression |
Description |
Example |
Meaning |
|
Set register Mi to integer |
M2=3 |
Store the number 3 in register M2. |
|
|
Set register Mi equal to register Mj |
M2=M0 |
Copy the value stored in register M0 into register M2. |
|
|
Set register Mi equal to random variable Randn |
M2=Rand0 |
Copy random number Rand0 into register M2. |
|
|
Set bit n in register Mi to 0 or 1. |
M2(0)=1 |
Set bit 0 in register M2 to 1. |
|
|
Set register Mi equal to input port Pn |
M2=P1 |
Read input port P1 and store the value in register M2. |
|
|
Set output port Pn to value stored in register Mi. |
P3=M2 |
Copy the data in register M2 to output port P3. |
|
|
Set output port Pn to [x x x x] |
P3=[1 1 1 1] |
Set all pins on output port P3 to 1. |
|
Command |
Description |
Example |
Meaning |
|
Jump to a label somewhere else in the program |
label1 |
Jump to label1: |
|
|
Jump to a label determined by the value of Mi. |
M1:[label0 label1] |
If M1 is equal to 0, then jump to label0. |
|
|
Read an input port, compare the value, and jump |
P2?[1 0 0 1]:label0 |
Read port P2. If equal to 1 0 0 1, then jump to label0: |
|
|
If Mi is equal to Mj jump to <label> |
M0?M5:label1 |
If M0 is equal to M5, then jump to label1. |
|
|
If there is audio currently playing, then jump to <label> |
Play?:motor_on |
If there is audio playing, jump to label "motor_on:" |
|
|
If Mi is equal to a specific value, jump to <label> |
M0?9:led_on |
If M0 is equal to 9, then jump to label led_on: |
|
|
If a random variable is equal to the value in Mi, |
rand0?M2:label1 |
If rand0 is equal to M2, then jump to label1: |
|
|
If a random variable is equal to a specific number, jump to <label> |
rand0?9:label1 |
If rand0 is equal to 9, then jump to label1: |
|
|
Jump to a random label determined by the value of rand0. |
rand0:[label0 label1] | If rand0 is equal to 0, then jump to label0. If rand0 is equal to 1, then jump to label1. |
|
Function |
Description |
Example |
Meaning |
|
Add integer to value stored in register Mi |
M2=M2+3 |
Add 3 to the value in register M2 and store in M2. |
|
|
Add integer to value in register Mj and store in Mi |
M2=M3+2 |
Add 2 to the value in register M3 and store in M2. |
|
|
Add value in Mj to value in Mk and store in Mi |
M2=M3+M4 |
Add the value in M4 to the value in M3 and store in M2. |
|
|
Subtract integer from value stored in Mi |
M2=M2-3 |
Subtract 3 from the value in register M3 and store in M2. |
|
|
Subtract integer from value in register Mj and store in Mi |
M2=M3-2 |
Subtract 2 from the value in register M3 and store in M2. |
|
|
Subtract value in Mk from value in Mj and store in Mi |
M2=M3-M4 |
Subtract the value in M4 from the value in M3 and store in M2. |
|
Command |
Description |
Example |
Meaning |
|
Set the audio output to use the Push-Pull DAC (PWM) |
|
||
|
Set the audio output to use the DAC |
|
||
|
Set the audio playback rate |
freq=12k |
Set the audio playback rate to 12 kHz. |
|
|
Play an audio file |
SFX1.wav |
Play the audio file SFX1.wav |
|
|
Set the audio playback volume |
vol=5 |
Set the audio playback volume to level 5. |
|
|
Stop the repeat function |
|||
|
Stop all audio playback |
|||
|
Gently step the audio driver output to zero |
|
Command |
Description |
Example |
Meaning |
|
Pause the program for a specified period of time |
delay(.320) |
Pause the program for .320 seconds (320 mS). |
|
|
Define a random number variable |
rand0=12 |
Define random variable rand0 with a maximum |
|
|
Stop the program and put the chip into low power mode |
|
|
Command |
Description |
Example |
Meaning |
|
Enable or disable the event marker function |
eflag=1 |
Enable the event marker function |
|
|
Define a label that is called when an event occurs |
e1: M0=5 |
When marker e1 occurs, set register M0 to 5. |