Full code here:
Edit: Due to members of this forum admonishing me for providing a link to my code on an external site I have removed it. I have asked my question elsewhere and will not be monitoring this page or using this forum in general.
Demo of early version, graphs not updating asynchronously:
Link removed.
Background: My goal is to write a library to allow a master Arduino to drive a slave Arduino via serial and print to a master-defined graph or graphs on an SSD1306 I2C display(no SPI version to test with). The graphing code is finished. Currently I can have 4 graphs that can update synchronously or asynchronously, there is no blanking and only writes the portions that need updating.
Both arduinos currently run the same sketch and determine their role via a pullup_input tied to ground, however in later versions the sketch will compile using if statements with a #defined boolean to greatly save on program space for the master arduino.
So far:
The actual graphing is working and the graph updates whenever a graphAdd(graphNumber, newVal); is called.
The graphs are to be defined in the master code as such:
struct graphStruct {
uint8_t gx;
uint8_t gy;
uint8_t gw;
uint8_t gh;
int gVal;
int graphBuffer[graphBufferSize];
bool isReady;
};
#define graphNum 4 //Set this to the number of Graphs you want.
graphStruct graph[graphNum] = { //Each set of brackets is an instance of a graph, one for each specified in graphNum
//Graph 1 //Usage: {LeftX, TopY, width, height}
{0, 0, 31, 32},
//Graph 2
{32, 0, 31, 32},
//Graph 3
{64, 0, 31, 32},
//Graph 4
{96, 0, 31, 32},
};
This currently works to define the graphs when the program is running essentially "demo mode" (just doing a graphAdd(graphNumber, random(1024)); on the slave side).
Currently Working:
- Slave awaits connection indefinitely
- Master sends ready byte
- Slave acks
- Master sends number of graphs wanted
- My problem is now instantiating a globally accessible array of structs from within a function as I don't want to have to pre-code the number of graphs.
Next Steps:
Writing structs over serial for graph position and dimension setup (I've done this before in the past, not too hard)
Setting up packets to send the graph data over. Again not to hard, essentially sending two ints like (graph#, graphData)
Add graph "titling" (like "ACC" or "Light intensity")
Implemented:
Graphing system
A serial "call - response" system and acknowledgement system.
Error Handling
Loops/Second counter