Minimal C template for NW2S sketches

Discussion, support, and resources for our noise making modules and kits.

Moderators: Kent, scottwilson

Post Reply
Jcsveth
Common Wiggler
Posts: 180
Joined: Mon Aug 12, 2013 7:44 pm

Minimal C template for NW2S sketches

Post by Jcsveth » Sun Jan 25, 2015 8:27 pm

The following is my attempt at a minimal template for the NW2S arduino program. It is pretty much straight 'C' but uses a couple of library includes. I did not tackle the DACs or the SD card routines:

http://www.hungryzombies.info/temp/nw2s_minimal.zip

The following routines are available in the bAllIO.cpp and bAllIO.h files:
setupPins() - initiates the I/O
bLED(int) - turns on a Beat LED (the red ones on the left)
aIn(int) - returns a value of one of the analog inputs
dOut(int, int) - turns a digital out On or Off
dOut_On(int) - turns On a digital output
dOut_Off(int) - turns Off a digital output
dIn(int) - returns the state of a digital input
aLED(int, int) - applies a brightness to an analog LED
aLED_On(int) - turns On an analog LED
aLED_Off(int) - turns Off an analog LED
aOut(int, int) - applies a voltage to an analog output
monitorSerial() - monitors the serial port for the word 'reset' and then resets when found (used for Bluetooth programming)

There is a .pdf explanation of these routines in the zip file. To start a new sketch, copy the init folder to new folder and name the folder and the .ino file the same. This takes a very small amount of memory leaving a huge amount for programming.

I am just starting to get back into programming this unit and look forward to sharing a bunch of current and future sketches with all.

User avatar
scottwilson
Wiggling with Experience
Posts: 432
Joined: Mon Sep 16, 2013 12:54 pm

Post by scottwilson » Sun Jan 25, 2015 8:45 pm

Thanks for this. I'm sure a lot of folk find this very useful.

The SD library would be a bit tough, but not impossible to abstract into a few basic methods.

The DACs could also be done just like you have here. It seems hard, but with a little thought wouldn't take much work at all. (I've considered this in the past) If you were to statically allocate all 16 of the outputs in a header file and then write some plain-ol-c routines to write output values (and the LED values) just like you've set up here, it would hide a lot of the complexity.

s

Jcsveth
Common Wiggler
Posts: 180
Joined: Mon Aug 12, 2013 7:44 pm

Post by Jcsveth » Sun Jan 25, 2015 9:02 pm

I am really just trying to get more people up and running quickly on the unit. I figure that if you are tackling the DACs and SD, you are advanced enough not to need my attempts at programming. I hope that someone with 'C' programming skills can turn out a couple of cool, unique routines to share with us all while learning your all-encompassing framework. We'll see... It really is a fun and useful beast to program - thanks Scott.

User avatar
spacenoodle
Veteran Wiggler
Posts: 692
Joined: Tue Mar 20, 2012 9:00 pm
Location: Madison, WI

Post by spacenoodle » Mon Jan 26, 2015 12:47 pm

This is the way I'm used to working with Arduino. Good clear documentation too. Perfect!

I don't know if this subject has come up already but people sure would get on with a visual interface. I imagine something like Reaktor where you just drag and drop your device (library, logic functions, I/O) and then hook things up with virtual cables. Export in .ino format and then open in Arduino to upload. That would be a big undertaking, of course.
Last edited by spacenoodle on Wed Mar 22, 2017 12:35 am, edited 1 time in total.

Jcsveth
Common Wiggler
Posts: 180
Joined: Mon Aug 12, 2013 7:44 pm

Post by Jcsveth » Mon Jan 26, 2015 9:24 pm

Funny you mention this. As Scott was putting together his encompassing system, I was thinking that it would not be too difficult to do a drag and drop Interface for that framework. It could produce a simple text file saved to the SD card for his system to read. I do not think it is something that I would undertake, but definitely do-able.

Post Reply

Return to “nw2s”