This is an old revision of the document!
# USense
## Overview
Well, this project is a little, quick, and fun one. Basically, the idea was to see what could be done with some RGB leds and capacitive touch inputs.
## Pictures
## PCB ### Version 0 Before designing a board, I wanted to try the “capacitive input” stuff, so I designed this quick PCB
### Version 1
First version, used mostly for the firmware development and debug. The actual board is quite messy now, but still works. In this version, I thought I would put four leds on the board, but one was already enough…
### Version 2
## Firmware
### Test firmware
Since I don't have too much spare time, I only wrote a quick firmware to test the board and be able to give the v2 to a friend. - The RGB led pulses/fades from one color to another automatically - One capacitive input increases the fading speed - The other decreases the speed - The two combined change the color changing cycle
### Protocol
Messages are 8 bytes long (since it is the limit for wMaxPacketSize for low-speed USB devices) [ Mode ] [ Val0 ] [ Val1 ] [ Val2 ] [ Val3 ] [ Val4 ] [ Val5 ] [ Val6 ] * PC > USense ********************************************************* [ 0x01 ] Fade On [ 0xRR ] Maximum brightness Red [ 0xGG ] Maximum brightness Green [ 0xBB ] Maximum brightness Blue [ 0x02 ] Fade Off [ 0x03 ] Get Fade [ 0x04 ] Set Fade Steps [ 0xVV ] 0x00-020 [ 0x05 ] Get Fade Steps [ 0x06 ] Set Fade Delay [ 0x07 ] Get Fade Delay [ 0x10 ] Set Fixed color [ 0xRR ] [ OxGG ] [ 0xBB ] [ 0x11 ] Get LEDs color [ 0x12 ] LEDs Off [ 0x20 ] Get Touch [ 0x21 ] Enable Touch INT [ 0x22 ] Disable Touch INT [ 0x23 ] Get Touch INT [ 0x24 ] Enable Touch ACT [ 0x25 ] Disable Touch ACT [ 0x26 ] Get Touch ACT [ 0x30 ] Get Fade Mode [ 0x31 ] Set Fade Mode [ 0x80 ] Reset * Usense > PC ********************************************************* Usually, it's just an Ack so: [ 0xRR ] [ 0xAA ] [ 0xRR ] The request code (see PC > USense) [ 0xAA ] Ack (0x42) or NAck (0xFF) Value for the previous request For the "Get" requests, it's an Ack, then the value: [ 0xRR ] [ 0xAA ] [ 0xV1 ] [ 0xV2 ] ... [ 0xRR ] The request code (see PC > USense) [ 0xAA ] Ack (0x42) or NAck (0xFF) Value for the previous request [ 0xV1 ] ... The returned Value ex: Get LEDs color [ 0x11 ] [ 0x42 ] [ 0xRR ] [ 0xGG ] [ 0xBB ] [ 0xrr ] [ 0xgg ] [ 0xbb ] in capital letters: Value in small letters: maximum fvalue for fading stuff Get Touch [ 0x23 ] [ 0x42 ] [ 0xVV ] Returns Inputs mask [ 0xVV ] Touch inputs mask (0b1 means pressed, 0b0 means released) Special case: for the "INT" messages, the auto-ack is 0x24 instead of 0x42 ex: Touch INT [ 0x23 ] [ 0x24 ] [ 0xVV ] Touch INT message [ 0xVV ] See above