User Interface

This week I made a web based UI for my PWM audio micro-synth from "output devices" week. The browser connects to node.js server running on the local machine. AJAX requests are interpreted by the node server, which sends serial messages over the FTDI usb cable. Swiping the mouse across the screen changes the pitch of the psuedo-saw sound, and the brightness of the LED.

User Interface Demonstration from Charles Holbrow on Vimeo.

Disable Interrupts When Speaking Serially

An interrupt-on-compare for the 16 bit AVR counter clocked my audio. I ran the processor at 20Mhz. I borrowed Neil's put_char and get_char methods for the hello.ftdi.44.echo.c example. I had to add cli(); and sei(); inside both methods so that the audio sample firing approximately every 1000 clock cycles wouldn't interrupt the serial communication

Study RS232

I used node-serialport to send and receive serial messages. When using npm serialport, you cannot write numbers -- only strings. This (sort-of) makes sense, given the complexities of the number type in JavaScript.

serialPort.write(10); // wrong!!
serialPort.write(String.fromCharCode(10)); // correct
        
Another issue I ran into: I assumed that data in rs-232 contains 8 bits of. I think that it actually only support 7 bits of meaningful data -- perhaps for the same reasons as 7-bit MIDI data.