FAQ & Terms of UseFAQ & Terms Of Use   Wiggler RadioMW Radio   Muff Wiggler TwitterTwitter   Support the site @ PatreonPatreon 
 SearchSearch   RegisterSign up   Log inLog in 

Minimal C template for NW2S sketches
MUFF WIGGLER Forum Index -> nw2s  
Author Minimal C template for NW2S sketches
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:

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

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.
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.
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.
MUFF WIGGLER Forum Index -> nw2s  
Page 1 of 1
Powered by phpBB © phpBB Group