From b63ca927af7814348ba0a23d07d30d62eddbd186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Tue, 8 May 2018 14:04:33 +0200 Subject: [PATCH] add the missing docs --- README.md | 6 ++-- UNIT_NEOPIXEL.md | 27 +++++++++++++----- UNIT_PWMDIM.md | 35 ++++++++++++++++++++++++ UNIT_TOUCH.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ UNIT_USART.md | 36 ++++++++++++++++++++++++ 5 files changed, 165 insertions(+), 10 deletions(-) create mode 100644 UNIT_PWMDIM.md create mode 100644 UNIT_TOUCH.md create mode 100644 UNIT_USART.md diff --git a/README.md b/README.md index 563b250..f033ed8 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,6 @@ This repository specifies the control protocol implemented by [gex-core](https:/ - [UNIT_1WIRE.md](UNIT_1WIRE.md) - 1-Wire master (thermometers, iButton...) - [UNIT_ADC.md](UNIT_ADC.md) - ADC with raw access, triggering, periodic capture - [UNIT_DAC.md](UNIT_DAC.md) - DAC with DDS -- UNIT_PWMDIM.md - Simple PWM output -- UNIT_TOUCH.md - Touch sense -- UNIT_USART.md - UART/USART/RS485 +- [UNIT_PWMDIM.md](UNIT_PWMDIM.md) - Simple PWM output +- [UNIT_TOUCH.md](UNIT_TOUCH.md) - Touch sense +- [UNIT_USART.md](UNIT_USART.md) - UART/USART/RS485 diff --git a/UNIT_NEOPIXEL.md b/UNIT_NEOPIXEL.md index c0dcf16..cbc481a 100644 --- a/UNIT_NEOPIXEL.md +++ b/UNIT_NEOPIXEL.md @@ -3,10 +3,12 @@ Implements the NeoPixel protocol for driving addressable LED strips. The strip length is configured in the unit settings. +Five color data encodings are available for user convenience. + ## Commands ### CLEAR (0x00) -Set all pixels to black. This is automatically executed on start-up to clear the strip. +Set all pixels to black. This is also automatically executed on start-up to clear the strip. ### LOAD (0x01) Load packed RGB data to the strip. @@ -15,22 +17,33 @@ Load packed RGB data to the strip. - a byte array `(R,G,B)` x length -### LOAD_U32_LE (0x02) -Load 32-bit `0x00BBGGRR` words encoded in little-endian as `(R,G,B,0)`. -This is more convenient for the PC script, but wastes 1/4 of the payload by padding -null bytes. +### LOAD_U32_ZRGB (0x08) +Load 32-bit `0x00RRGGBB` words encoded in big-endian as `(0,R,G,B)`. *Payload:* -- a byte array `(R,G,B,0)` x length +- a byte array `(0,R,G,B)` x length -### LOAD_U32_BE (0x03) +### LOAD_U32_ZBGR (0x09) Load 32-bit `0x00BBGGRR` words encoded in big-endian as `(0,B,G,R)`. *Payload:* - a byte array `(0,B,G,R)` x length +### LOAD_U32_RGBZ (0x0A) +Load 32-bit `0x00BBGGRR` words encoded in little-endian as `(R,G,B,0)`. + +*Payload:* + +- a byte array `(R,G,B,0)` x length + +### LOAD_U32_BGRZ (0x09) +Load 32-bit `0x00RRGGBB` words encoded in little-endian as `(B,G,R,0)`. + +*Payload:* + +- a byte array `(B,G,R,0)` x length ### GET_LEN (0x04) Read the neopixel strip length as configured in the settings. diff --git a/UNIT_PWMDIM.md b/UNIT_PWMDIM.md new file mode 100644 index 0000000..4a96ffe --- /dev/null +++ b/UNIT_PWMDIM.md @@ -0,0 +1,35 @@ +# PWMDIM + +This unit provides an up to 4-channel PWM output with shared frequency and independent duty cycles. Only one instance can be created due to using a +hardware timer. + + +## Commands + +### SET_FREQUENCY (0x00) + +Set the PWM frequency + +*Request:* +- u32 - frequency in Hz + +### SET_DUTY (0x01) + +Set the duty cycle of one or more channels + +*Request:* +- repeat 1-4 times: + - u8 - channel number 0-3 + - u16 - duty cycle 0-1000 + +### STOP (0x02) + +Stop the hardware timer. Outputs enter low level. Has no effect if stopped. + +### START (0x03) + +Start the timer. Has no effect if running. + +## Events + +*This unit generates no events.* diff --git a/UNIT_TOUCH.md b/UNIT_TOUCH.md new file mode 100644 index 0000000..123ced6 --- /dev/null +++ b/UNIT_TOUCH.md @@ -0,0 +1,71 @@ +# TOUCH + +Access to the hardware touch sensing controller. +Can be used to create capacitive touch interfaces or for rough capacitance measurement (e.g. water level in a bottle, or proximity sensing). + +Button mode is implemented for simple threshold checking with hystheresis. + + +## Commands + +### READ (0x00) + +Read the raw touch pad values (lower indicates higher capacitance). +Values are ordered by group and channel. + +*Response:* +- u16[] - values + +### SET_BIN_THR (0x01) + +Set button mode thresholds. Value 0 = button mode disabled fro the pad. + +*Request:* +- u16[] - thresholds + +### DISABLE_ALL_REPORTS (0x02) + +Set thresholds to 0, disabling the button mode for all pads. + + +### SET_DEBOUNCE_TIME (0x03) + +Set debounce time for the button mode (replaces the value from unit settings) + +*Request:* +- u16 - debounce time milliseconds + + +### SET_HYSTERESIS (0x04) + +Set hysteresis (replaces the default value from settings) + +Hysteresis is added to the threshold value for the switch-off level +(switch-off happens when the measured value is exceeded - capacitance of the pad +drops) + +*Request:* +- u16 - hystheresis + + +### GET_CH_COUNT (0x0A) + +Get the number of enabled channels + +*Response:* +- u8 - channel count + + + +## Events + +### BUTTON_CHANGE (0x00) + +The binary state of some of the capacitive pads +with button mode enabled changed. + +*Payload:* +- u32 - binary state of all channels (packed) +- u32 - changed / trigger-generating channels (packed) + + diff --git a/UNIT_USART.md b/UNIT_USART.md new file mode 100644 index 0000000..5266d7e --- /dev/null +++ b/UNIT_USART.md @@ -0,0 +1,36 @@ +# USART + +This unit provides access to the hardware USART peripheral. It is capable of +driving RS485 transceivers. + +The unit uses asynchronous reception and transmission using DMA to support +low baud rates without lagging the whole platform. Reception is double-buffered +and sent in buffer-sized chunks. The remainder is sent when a timeout from +the last received byte is reached. + + +## Commands + +### WRITE (0x00) + +Add data to the Tx buffer. Sending is asynchronous, but the command may wait +for free space in the DMA buffer. + +*Request:* +- u8[] - bytes to write + +### WRITE_SYNC (0x01) + +Add data to the Tx buffer and wait for the transmission to complete. + +*Request:* +- u8[] - bytes to write + +## Events + +### DATA_RECEIVED (0x00) + +Data was received on the serial port. + +*Payload:* +- u8[] - received bytes