
; counting_to_twelve.EZ
; Foxonix / Metre Ideas and Design
; www.foxonix.com

; Program: Will Sakran
; Created: 02.26.14
; Public - Modify and share this program as you wish.

; Program description
;	This program uses twelve inputs, with each input triggering a
;	different WAV file. The wave files are spoken numbers one through
;	twelve. This program can be used on its own or with an Arduino
;	through the Arduino shield. There are four outputs on port P3 that
;	demonstrate the output function.

; Hardware INPUTS
	; Triggers attached to pins P1.0 - P1.3, P2.0 - P2.3, P6.0 - P6.3
	; Speaker attached to PWM output

; Hardware OUTPUTS
	; Four LEDs connected to pins P3.0 - P3.3

; Set the device name
[device]
SNC21120


; Specify the number of pins declared in [input_states]
[key]
direct=16


; List WAV files to be included in the program
[files]
one.wav
two.wav
three.wav
four.wav
five.wav
six.wav
seven.wav
eight.wav
nine.wav
ten.wav
eleven.wav
twelve.wav


; Define the various input states for the program.
; This describes which pins will have buttons, switches, or
; other inputs attached to them, and defines when those
; inputs will be active and inactive. At least one input
; state must be defined even if it is not used.
[input_states]
; PIN		P1.0  P1.1  P1.2  P1.3  P2.0  P2.1  P2.2  P2.3  P3.0  P3.1  P3.2  P3.3  P6.0  P6.1  P6.2  P6.3
locked_out:	x     x     x     x     x     x     x     x     x     x     x     x     x     x     x     x
enabled:	but1  but2  but3  but4  but5  but6  but7  but8  x     x     x     x     but9  but10 but11 but12


; Define the various output states for the program.
; Outputs are used to drive LEDs, motor circuits, or any
; other output device.
[output_states]
p30_on:		P3=[x x x 1]		; sets pin P3.0 to 1
p30_off:	P3=[x x x 0]		; sets pin P3.0 to 0
p31_on:		P3=[x x 1 x]		; sets pin P3.1 to 1
p31_off:	P3=[x x 0 x]		; sets pin P3.1 to 0
p32_on:		P3=[x 1 x x]		; sets pin P3.2 to 1
p32_off:	P3=[x 0 x x]		; sets pin P3.2 to 0
p33_on:		P3=[1 x x x]		; sets pin P3.3 to 1
p33_off:	P3=[0 x x x]		; sets pin P3.3 to 0	


; Define the routines (paths) that the program will use.
; The init path is always called first on power up and reset.
[paths]
init:
	& locked_out		; ignore inputs during init
	& ppdac
	& freq=12k		; set sample playback rate to 12 kHz
	& enabled		; enable the inputs
	& end			; stop the program and enter low power mode

but1:
	& one.wav		; play wav file
	& end			; stop the program and enter low power mode

but2:
	& two.wav		
	& end			

but3:
	& three.wav		
	& end			

but4:
	& four.wav		
	& end			

but5:
	& five.wav		
	& end			

but6:
	& six.wav		
	& end			

but7:
	& seven.wav		
	& end			

but8:
	& eight.wav		
	& end			

but9:
	& p30_on
	& nine.wav
	& p30_off		
	& end			

but10:
	& p31_on
	& ten.wav
	& p31_off		
	& end			

but11:
	& p32_on
	& eleven.wav
	& p32_off		
	& end			

but12:
	& p33_on
	& twelve.wav
	& p33_off		
	& end			