Scripting


Note: This feature is only available for Process event type, using this in Coin and Boot does nothing.

XTimer

Description

Scripting in profile was introduced starting with v1.2.0. This powerful feature enables XTimer to create custom process flow where custom input state and condition profile are needed.

External Modules Supported

# Name Input Output Protocol Type Pins Mode
1 PCF8574 i2c IO 8 hi lo
2 PCA9685 i2c PWM/O 16 pwm
3 MCP23017 i2c IO 16 hi lo
4 MAX485 uart COM 1 - any all
5 MAX232 uart COM 1 - any all

These are list of modules, devices and protocols supported by the scripting engine specifically used for vending custom input state, operation, and condition.

Scripting keywords

# Name Definition
1 if logical if statement
2 else else statement
3 elseif elseif statement
4 while while loop
5 var declare variable
6 func function declaration
7 return return function
8 array variable array declaration

Scripting Operators

# Name Definition
1 * product/ multiplication
2 / division
3 % modulo
4 + sum
5 - difference
6 ! equals alternative
7 & bit and
8 | bit or
9 ^ bit xor
10 >> right bit shift
11 << left bit shift
12 = equal to
13 <> not equal
14 < less than
15 <= less than or equal
16 > greater than
17 => greater than or equal

Built in functions

# Name Description Args Return
1 digitalRead read pin status hi/lo 1 int
2 digitalWrite write pin hi/lo 2 int
3 pinMode set internal pin mode in/out 2 int
4 delay delay execution 1 int
5 millis get running millisecond 0 int
6 pcfAddress set pcf8754 address 1 int
7 pcfPinMode set pcf8754 mode in/out 1 int
8 pcfRead read pcf8754 pin status 1 int
9 pcfWrite set pin hi/low output 2 int
10 pcaAddress set pca9685 address 1 int
11 pcaFrequency set pca9685 pwm frequency 1 int
12 pcaPwm set pca9685 PWM 1 int
13 pcaBegin initialize pca9685 0 int
14 pcaAngle move to angle 0 to 180 2 int
15 pcaWrite run pwm on pca9685 pin 1 int
16 pcaAllOff stop all pca9685 pwm 1 int
17 mcpAddress set mcp23017 address 1 int
18 mcpPinMode set pcf8754 mode in our out 2 int
19 mcpRead read mcp23017 pin status hi/lo 1 int
20 mcpWrite set mcp23017 pin hi/low output 2 int
21 serWrite uart write array value 1 int
22 serRead uart read single byte 1 int
23 serAvailable uart has data buffer 1 int
24 setGlobal set global variables elapsed, remaining, and status 1 int
25 lcdWrite write status to display on row 2 int
26 plsSet pulse input set pin and mode 2 int
27 plsStop stop pulse input pin 1 int
28 plsRead read raw value/seconds with conversion factor 1 int
29 plsTotal read cumulative value with convertion factor 1 int
30 chgCoin compute coin change 2 int
31 chgOne get computed number of 1s 1 int
32 chgFive get computed number of 5s 1 int
33 chgTen get computed number of 10s 1 int
34 chgTwenty get computed number of 20s 1 int
35 chgReset reset remaining credit to zero 1 int
36 chgGet reset remaining credit to zero 0 int
37 chgSet reset remaining credit to zero 1 int

The above are custom built-in functions for advance vending profile and operation

Built in constants

# Name Return
1 HIGH int
2 LOW int
3 INPUT int
4 OUTPUT int
5 INPUT_PULLUP int
6 FALLING int
7 RISING int
8 CHANGE int

The above are mostly used for internal pins! use with care.

Variables

Operators

Functions

Arrays

Examples

var count = 0
while(count <> 10){
  delay(1000)
  count = count + 1
   lcdWrite(3, count)
}
print "finished"