# 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 It's all version 1, I unfortunately don't have any picture of the version 2 (but it was better!)

UsenseBoard USenseDevel UsenseFinal

## PCB

Always print the PCB at 600DPI. The text acts as a fool-proof system. It should be readable on your final board. B ### Version 0 Before designing a board, I wanted to try the “capacitive input” stuff, so I designed this quick PCB

Test PCB

### Version 1

USense 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

Usense version  2

I think this is the “Release” version.

## Firmware

### Bootloader

I worked hard to have a USB bootloader to be able to distribute the board, so Micronucleus fires up for 2-3 seconds at power-up. Here's the link: micronucleus-t84.tar.gz

### 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

The archive can be downloaded here: usense_20140907.tar.gz

### Test firmware - Protocol This can be found in include/usense_protocol.h

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

### Firmware ideas

When I made the board, I was convinced you could do something actually useful with it… Here are a few ideas:

* Input device with visual feedback (both RGB and Status led), like a morse Keyer or something * Music/Media control * Notification LED you can actually dismiss by hardware (for emails, Skype, IRC, …) * Mood lamp, zen/ambiant visualization for a small room * Write an HTTP API and make it available from the Internet, so other people can visually _communicate_ with you * Sound-reactive visualization * … Up to you =)