All library constants are integers e.g. you can print the library constants value by entering its name into the REPL. Note that all library constants are immutable – any attempt to modify them will have no effect. The library constants are detailed as follows:
Core
|
Constant |
Description |
|---|---|
|
CORE<x> |
Represents CORE number ‘x’, For example, in the REPL (or an uploaded program): $ print("Value of CORE3 is: "..CORE3)
Value of CORE3 is: 3
|
Pin
|
Constant |
Description |
|
PIN<x> |
Represents I/O PIN number ‘x’, For example, in the REPL (or an uploaded program): $ print("Value of PIN7 is: "..PIN7)
Value of PIN7 is: 7
|
|
PIN<x>_ BITMASK |
Represents I/O PIN number ‘x’ bitmask. For example, handling interrupts: $ function interrupt(interrupt_vector)
if (interrupt_vector & PIN3_BITMASK) ~= 0 then
print("Interrupt occurred on PIN3!")
end
end
|
I/O Level
|
Constant |
Description |
|
LOW |
Represents a voltage low (0 volts) signal level. |
|
HIGH |
Represents a voltage high (3.3 volts) signal level. |
|
TOGGLE |
Represents an inverse voltage signal level, i.e. high the opposite of low. For example: $ set_gpio(PIN7, TOGGLE) |
I/O Type
|
Constant |
Description |
|
NONE |
Represents an I/O type of none. |
|
GPIO_OUT |
Represents an General Purpose, ‘Digital I/O’ type with direction output. |
|
GPIO_IN |
Represents an General Purpose, ‘Digital I/O’ type with direction input. |
|
PWM |
Represents a Pulse-Width-Modulation, ‘Digital I/O’ type. |
|
UART_OUT |
Represents a UART communications protocol, ‘Digital I/O’ pin type, with direction output. |
|
UART_IN |
Represents a UART communications protocol, ‘Digital I/O’ pin type, with direction input. |
|
SPI_OUT |
Represents a SPI communications protocol, ‘Digital I/O’ pin type, with direction output. |
|
SPI_IN |
Represents a SPI communications protocol, ‘Digital I/O’ pin type, with direction input. |
|
I2C |
Represents a I2C communications protocol, ‘Digital I/O’ pin type, with direction input and output. For example: $ set_io_config(PIN14, I2C) |
GPIO Interrupt
|
Constant |
Description |
|
GPIO_ INTRPT_ LOW |
Represents a low (0 volts) interrupt type on an I/O configured as GPIO_IN. |
|
GPIO_ INTRPT_ HIGH |
Represents a high (3.3 volts) interrupt type on an I/O configured as GPIO_IN. |
|
GPIO_ INTRPT_ RISING_ EDGE |
Represents a low to high transition interrupt type on an I/O configured as GPIO_IN. |
|
GPIO_ INTRPT_ FALLING_ EDGE |
Represents a high to low interrupt type on an I/O configured as GPIO_IN. For example, parsing interrupt types: $ gpio_interrupt_vector = get_interrupts_on_pin(PIN6)
if (tgpio_interrupt_vector & GPIO_INTRPT_RISING_EDGE) ~= 0
then
print("Detected rising edge on PIN6!")
end
|
UART Interrupt
|
Constant |
Description |
|
UART_RX_ INTRPT_ DATA_ AVAILABLE |
Represents data available interrupt type on an I/O configured as UART_IN. |