External devices
Instructions in this category are used to determine which peripheral or functions are enabled or disabled.
E.g. Using corresponding instructions to set duty cycles of PWM output pins, enable/disable specific functions such as temperature sensor and real time clock modules.
0xC0
Activation Switches: Peripheral and Modules
Enable/Disable peripherals in bitwise. Peripheral and functional modules are listed below:
bit | Funciton |
---|---|
0 | ADC Conversion |
1 | Environment Sensor |
2 | Real Time Clock |
3 | Colour Sensor |
4 | External PWM Generator |
5 | IMU |
6 | Full Colour LED |
7~11 | N/A reserved |
INST_ACTIVATE_MODULES | Hex | OP-1 | |
---|---|---|---|
Activate AD Conversion, PWM Generator and RTC | C0 | 0000 | 0015 |
The example above configures the 12 bits with a hexadecimal number 0015
, the correspoding binary value is:
Indicating bit-4, bit-2 and bit-0 are enabled as described in the description of the instruction above.
info
OP/sOP | Range | Remark |
---|---|---|
OP-0 | 0000 | Ignored |
OP-1 | 0000 ~0FFF | bitwise switches |
tip
R28
is status register of peripheral enables.
0xC1
Activation Switch: Analog-Digital Conversion
Enable or disable analog-to-digital conversion (ADC).
tip
Check the corresponding bit in R28
for AD conversion status. Once enabled, the result of AD conversion will be updated in R24
, R25
, R26
and R27
.
INST_ACTIVATE_ADS | Hex | sOP01 | ||
---|---|---|---|---|
Enable AD Conversion | C1 | 00 | 01 | 0000 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 | Disable module |
01 | Enable module | |
OP-1 | 0000 | Ignored |
0xC2
Activation Switch: Inertial Measurement Unit
Enable or disable inertial measurement unit module.
tip
Check the corresponding bit in R28
for IMU data. Once enabled, the measurement result of accelerometer will be updated in R29
, R2A
, R2B
; the measurement result of gyroscope will be stored in R2C
, R2D
, R2E
.
INST_ACTIVATE_IMU | Hex | sOP01 | ||
---|---|---|---|---|
Enable IMU sensor | C2 | 00 | 01 | 0000 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 | Disable module |
01 | Enable module | |
OP-1 | 0000 | Ignored |
0xC3
Activation Switch: Humidity/Temperature Sensor
Enable or disable humidity sensor BME280.
tip
Check the corresponding bit in R28
for BEM280 sensor. Current temperature and humidity are stored in R2F
and R30
respectively.
INST_ACTIVATE_BME | Hex | sOP01 | ||
---|---|---|---|---|
Enable BMP280/BME280 | C3 | 00 | 01 | 0000 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 | Disable module |
01 | Enable module | |
OP-1 | 0000 | Ignored |
0xC4
Activation Switch: Colour Detection Sensor
Enable or disable colour detection sensor.
tip
Check the corresponding bit in R28
for colour detection sensor. When enabled, the detected colour components R, G and B will be updated in R31
, R32
and R33
.
INST_ACTIVATE_TCS | Hex | sOP01 | ||
---|---|---|---|---|
Enable colour sensor | C4 | 00 | 01 | 0000 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 | Disable module |
01 | Enable module | |
OP-1 | 0000 | Ignored |
0xC5
Activation Switch: External PWM Generator
Enable or disable external PWM generator module.
tip
Check the corresponding bit in R28
for external PWM generator module. Once enabled, instructions for configuring PWM channel and duty cycles are activated.
INST_ACTIVATE_PCA | Hex | sOP01 | ||
---|---|---|---|---|
Enable external PWM generator | C5 | 00 | 01 | 0000 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 | Disable module |
01 | Enable module | |
OP-1 | 0000 | Ignored |
0xCB
Activation Switch: Real Time Clock (RTC) Module
Enable or disable real time clock module.
tip
Check the corresponding bit in R28
for RTC module,
INST_ACTIVATE_DS1307 | Hex | sOP01 | ||
---|---|---|---|---|
Enable RTC | C8 | 00 | 01 | 0000 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 | Disable module |
01 | Enable module | |
OP-1 | 0000 | Ignored |
0xCC
Activation Switch: Full Colour LED
Enable or disable the control of full colour LEDs.
tip
Check the corresponding bit in R28
for full colour LEDs control.
INST_ACTIVATE_WS2812B | Hex | sOP01 | ||
---|---|---|---|---|
Enable full colour LED control | CC | 00 | 01 | 0000 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 | Disable module |
01 | Enable module | |
OP-1 | 0000 | Ignored |
0xDD
~0xDF
Marks: Opcodes As Data (experimental)
Mark the current instruction line as data storage (experimental).
INST_DATA_LINE | Hex | ||
---|---|---|---|
Instruction is ignored | DD ~DF | ABCD | BEEF |
info
OP/sOP | Value/Range | Remark |
---|---|---|
OP-0 | 0000 | Ignored |
OP-1 | 0000 | Ignored |
0xE0
Declare Input Keys in Run-Time
At run time, when a program is running, declare the 6 user input keys as extra inputs. The declaration terminates when the program is stopped.
caution
When the input keys are declared, program debugging needs additional ←
+ ↓
combo keys to start.
INST_USE_BUTTONS_IN_PROG | Hex | ||
---|---|---|---|
Declare user keys in run time | E0 | 0000 | 0000 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
OP-0 | 0000 | Ignored |
OP-1 | 0000 | Ignored |
0xE3
Configuration:Set Date/Time
Set date and time of the DS1307 real time clock module using values in 6 continuous registers, with year, month, date, hour, minute and second.
tip
Current date and time are shown on page 3 on the secondary display, activation switch of RTC must be enabled to update.
INST_SET_DATE_TIME | Hex | sOP01 | ||
---|---|---|---|---|
Use 6 registers to set date and time, starting from R0A | E3 | 00 | 0A | 0000 |
For instance, values stored in R0A
~R0F
are:
Register | Value/Range |
---|---|
R0A | 07E4 |
R0B | 0004 |
R0C | 0004 |
R0D | 000A |
R0E | 0000 |
R0F | 0000 |
Date and time of the RTC clock will be set to 2020-04-04 10:00:00.
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register Index |
OP-1 | 0000 | Ignored |
0xE4
Configuration:Set Colour of a LED
Set colour of one WS2812B LED with an index.
INST_WS2812B_SET_COLOR | Hex | sOP00 | sOP01 | sOP10 | sOP11 |
---|---|---|---|---|---|
Set LED 00 to orange colour | E4 | 00 | FF | 80 | 00 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 ~0F | Index of target LED |
sOP01 | 00 ~FF | Red 0-255 |
sOP10 | 00 ~FF | Green 0-255 |
sOP11 | 00 ~FF | Blue 0-255 |
0xE5
Configuration: Set Colour for Multiple LEDs
Set colour of multiple WS2812B LED in batch mode.
INST_WS2812B_REGx_SET_COLOR | Hex | sOP00 | sOP01 | sOP10 | sOP11 |
---|---|---|---|---|---|
set multiple LEDs' colour using high-byte of 3 registers in series for R,G and B respectively | E5 | 31 | 01 | 00 | 02 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 -3F | Start of register index |
sOP01 | 00 | Use low-byte of each register |
01 | Use high-byte of each register | |
sOP10 | 00 - 0F | LED Index |
sOP11 | 01 - 0F | number of LEDs to set |
In the example above, OP01 is 01
, meaning that the high-byte of registers are used. Suppose values in R31
~R33
are 0x1521
, 0x8377
and 0xFF00
, then the LEDs are set to colour 0x1583FF
, start from LED 00
(included), two LEDs are rendered with the chosen colour.
0xE6
Configuration: Dimming Mode of Full Colour LEDs
Set all LEDs to one of the following modes: turned off, turned on with set colour, breathing with set colour, turned on with all white.
caution
Before using E6
to set , ``
INST_WS2812B_OP_SET_MODE | Hex | sOP01 | ||
---|---|---|---|---|
Set LEDs to breathing mode | E6 | 00 | 02 | 0000 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 | 全灭 |
01 | 当前颜色全亮 | |
02 | 当前颜色呼吸灯 | |
03 | 白色全亮 | |
OP-1 | 0000 | Ignored |
0xE8
Play a Tone
Play a tone from the preset three (high, mid, low) octaves.
INST_MELODY | Hex | OP-0 | OP-1 | |
---|---|---|---|---|
Play a mid-tone Si | E8 | 000E | 0007 |
info
OP/sOP | Value/Range | Remark |
---|---|---|
OP-0 | 01 ~07 | Low tone Do~Si |
08 ~0E | Mid tone Do~Si | |
0F ~15 | High tone Do~Si | |
00 | Rest | |
OP-1 | 0000 | Sixty-fourth note |
0001 | Thirty-second note | |
0002 | Dotted thirty-second note | |
0003 | Sixteenth note | |
0004 | Dotted sixteenth note | |
0005 | Eighth note | |
0006 | Dotted eighth note | |
0007 | Quarter note | |
0008 | Half note | |
0009 | Whole note |
0xEB
Configuration: external PWM generator
Choose PWM channels (0-15) in a bitwise way, set the chosen channels high-time with a value.
INST_PCA9685_CHANNEL_REGB_REGV | Hex | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Use the value in R00 as channel selections,set the chosen channels with the value stored in R02 | EB | 00 | 00 | 00 | 02 |
sOP01 points to R00
for channel selection. Suppose the stored value is 0087
, in binary it is:
Bit 0, 1, 2 and 7 are '1'
, so channel 0, 1, 2 and 7 are selected.
sOP11 points to R02
for high-time, suppose the stored value is 0800
, in decimal it is:
The range of high-time is [0, 4095], corresponding to [0%, 100%] in duty cycle. Therefore 0800
or 2048 is about 50% duty cycle.
tip
For details of PCA9685
chip and the definition of duty cycle please refer to the official datasheet.
The JoyKit configures its PCA9685 chip to 50Hz (20ms period), each full cycle contains 4096 levels.
info
OP/sOP | Value/Range | Remark |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register index for channel selection |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Register index for high-time |