embed_with_elliot-circular_buffer
embed_with_elliot-circular_buffer copied to clipboard
Demo code to go along with Hackaday article on circular buffers
embed_with_elliot-circular_buffer
Demo code to go along with Hackaday article on Circular Buffers.
Try Me!
Straight out of the box, this will compile for AVR on any platform that's got AVR-GCC
and make
installed. The code will work with AVR Studio or even Arduino, because it's just C. However you're compiling code, just do that.
For Arduino
To compile / flash C code on Arduino:
- Create a new sketch, delete everything (the setup and loop functions) from the default
.ino
file, and quit Arduino - Copy the
.c
and.h
files over to the sketch's directory - Open the Arduino IDE again and you'll see the code opened up for you in tabs
- Compile as usual. Edit. Flash. Play around.
Versions
There are multiple demo versions hidden in the history of this project. Check them out!
-
Naive Demo (a793508): with lots of printing. Good to watch it run and figure out what's going on. Probably too long, sorry.
-
Loopback Demo (f33be28): shows how two buffers (one for receiving and one for transmitting) and some interrupt code can handle serial input and output. This is a lot like what the Arduino libraries do under the hood, but written less generally and much more transparently, IMO.
-
Words Demo (55ab726): Uses interrupt-driven RX and TX and the
bufferPeek()
function to print out what you type in only after a complete word has been sent.
Serial Terminals
Most of the examples depend on having an instantaneous-response serial terminal program. Unfortunately, you Arduino folks are out in the cold here -- Arduino's default serial monitor program only responds when you hit the "Enter" key.
I use a python module (PySerial) that just happens to have a nice built-in serial terminal emulator program. This will work anywhere you've got Python installed: python -m serial.tools.miniterm --cr $PORT $BAUD
On Windows, try Realterm or Tera Term if you're not running XP anymore. (R.I.P. Hyperterminal.)