This started in a discussion in the NEWS section, but now that we're getting into nitty gritty details I'm trying to move it here under software/development...
In the end, I don't care about WRITE (the values won't change at run time). Most of my programs these days have to do with prop control, a LOT for Halloween, and as I'm an actor in LA and know a bunch of FX guys I help them, too. A lot of props use a simple sequencer template for the BSI that stores records like this:
EEPROM (%00000000, 0)
The first byte is what to put on the output pins, the second is how long (in timing units, usually 100 ms) to hold that state. In effect, it's a digital player piano. I'd like to duplicate this in the Ardunio -- it it's possible within the constraints of the language. What I'm really after is a named constant array that I can index through as the program runs.
A named constant array is pretty easy; the question is how much it should look like the equivalent PBASIC statements. I mean, here's ugly raw C that does it:
struct {int index; unsigned char data[];} playdata =
{0, {
0x81, 1,
0x42, 1,
0x24, 1,
0x18, 2
}
};
#define PLAYER_READ(pd) (pd.data[pd.index++])
#define PLAYER_RESET(pd) pd.index = 0;
void loop()
{
unsigned char bits, time;
PLAYER_RESET(playdata);
bits = PLAYER_READ(playdata);
time = PLAYER_READ(playdata);
setport(bits);
delay(time);
}
getting it to more exactly match the semantics of PBASIC READ (what to do after all the data is read, for instance) is harder, and hiding C ugliness (" What's "struct" do? It's not in the arduino manual!"), using EEPROM or flash to save ram space, and so on, are all ... additional effort.
(I always wanted to write an "LED blinking" language a lot like your "digital player piano." Alas, it tends to quickly suffer from feature bloat...)
[Question for the arduino experts: if I use the gcc primitives for putting data in EEPROM, does the arduino utility load the EEPROM when downloading a sketch?]