I have a project that interfaces a uVGA-II in SGC mode to an Arduino. The Arduino currently reads a stream of values from a micrometer, performs a series of calculations, also reads inputs from a couple of momentary switches for "menu" and "sample" input, and constructs the screen output to be sent to the uVGA-II serially.
Now, I want to move all the display functions onto the uVGA-II in GFX mode. I'm trying to decide what functionality to leave on the Arduino. Where do I break the functionality into Arduino side, and GFX side?
If I let the Arduino do all the I/O and decision making, and just send the variable data that needs to be displayed, what's the fastest way to get that data into the GFX?
Current Arduino sketch:
int req = 5; //mic REQ line goes to pin 5 through q1 (arduino high pulls request line low)
int dat = 2; //mic Data line goes to pin 2
int clk = 3; //mic Clock line goes to pin 3
int i = 0; int j = 0; int k = 0;
int wave;
char* error = 0;
byte a;
float mm;
char* family;
char* menu;
int minnum;
int maxnum;
float maxmm;
int maxl;
int staticl;
int staticl5;
int staticl4;
int staticl3;
float jump;
float range;
byte mydata[14];
long num;
int gearFamily = 7;
int c0 = 0;
int c1 = 0;
// Mode button
const int buttonPin = 4; // the pin that the pushbutton is attached to
int buttonPushCounter = 7; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
// Average button
const int avgPin = 6; // switch is connected to pin 6
int avgVal; // variable for reading the pin status
int avgVal2; // variable for reading the delayed status
int avgButtonState = 0; // variable to hold the button state
int sampleState = 0; // Which sample am I taking (1 of 3)?
long m1=0;
long m2=0;
long m3=0;
int samplel1=0;
int samplel2=0;
int samplel3=0;
int sampleAvgl=0;
void setup()
{
Serial3.begin(9600);
pinMode(req, OUTPUT);
pinMode(clk, INPUT);
pinMode(dat, INPUT);
digitalWrite(clk, HIGH); // enable internal pull ups
digitalWrite(dat, HIGH); // enable internal pull ups
digitalWrite(req,LOW); // set request at LOW
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
pinMode(avgPin, INPUT); // Set the switch pin as input
avgButtonState = digitalRead(avgPin); // read the initial state
delay(500);
// initialize uVGA card with autobaud
autoBaud();
// resolution 640x480
control(12, 1); // 12 = screen resolution, 1 = 640x480
// set baud rate
setBaud(11); // 13 - 115200 Baud (won't work at higher rates)
Serial3.begin(56600);
// clear screen
clearScreen();
// Blue background
replaceBackground(0, 31); // color msb:lsb
//opaque text
textOpacity(1); // 0 = transparent, 1 = opaque
//pen size
penSize(0); // 0 = solid, 1 = wireframe
}
void loop()
{
// read menu button
// read the pushbutton input pin:r />buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// clearScreen();
// if the state has changed, increment the counter
if (buttonState == LOW) {
// if the current state is HIGH then the button
// went from off to on:
buttonPushCounter++;
clearScreen();
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
if (buttonPushCounter == 8) {
buttonPushCounter = 1;
}
gearFamily = buttonPushCounter;
// gearFamily = 1;
// get data from mic
// {
digitalWrite(req, HIGH); // generate set request
for( i = 0; i < 13; i++ ) {
k = 0;
for (j = 0; j < 4; j++) {
while( digitalRead(clk) == LOW) { } // hold until clock is high
while( digitalRead(clk) == HIGH) { } // hold until clock is low
bitWrite(k, j, (digitalRead(dat) & 0x1)); // read data bits, and reverse order )
}
// extract data
mydata[i] = k;
// sign = mydata[4];
// decimal = mydata[11];
// units = mydata[12];
}
// assemble measurement from bytes
char buf[7];
for(int lp=0;lp= 6371)
{
family = "Over W M17";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 2)
{
// do j/h pump
family="J/H Pump";
menu = "J/H Sort";
wave = 4;
if (num = 4477 && num = 4573 && num = 7038 && num = 7134 && num = 8325 && num = 8642 && num = 10908 && num = 11100 && num = 12045 && num = 12301 && num = 14089 && num = 14313 && num = 18869 && num = 19061)
{
family = "Over J/H 750";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 3)
{
// do minipump
family="Mini Pump";
menu = "MP Sort";
wave = 3;
if (num = 5042 && num = 5110 && num = 5810 && num = 5862 && num = 7062 && num = 7130 && num = 8576 && num = 8700 && num = 9890 && num = 9998)
{
family = "Over MP390";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 4)
{
// do webster pump match
family = "Webster";
menu = "Webster Match";
wave = 3;
if (num = 2290 && num = 2331 && num = 2920 && num = 2971 && num = 6330 && num = 6371)
{
family = "Over W M17";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 5)
{
// do j/h pump
family="J/H Pump";
menu = "J/H Match";
wave = 4;
if (num = 4477 && num = 4573 && num = 7038 && num = 7134 && num = 8325 && num = 8642 && num = 10908 && num = 11100 && num = 12045 && num = 12301 && num = 14089 && num = 14313 && num = 18869 && num = 19061)
{
family = "Over J/H 750";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 6)
{
// do minipump
family="Mini Pump";
menu = "MP Match";
wave = 3;
if (num = 5042 && num = 5110 && num = 5810 && num = 5862 && num = 7062 && num = 7130 && num = 8576 && num = 8700 && num = 9890 && num = 9998)
{
family = "Over MP390";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 7){
// do instructions
family = " ";
menu = "Instructions";
}
digitalWrite(req,LOW);
error=0;
// delay(25);
sendText(22, 05, 3, 255, 255, family);
sendText(22, 03, 3, 255, 255, menu);
// }
if (gearFamily >= 1 && gearFamily = 4 && gearFamily
Now, I want to move all the display functions onto the uVGA-II in GFX mode. I'm trying to decide what functionality to leave on the Arduino. Where do I break the functionality into Arduino side, and GFX side?
If I let the Arduino do all the I/O and decision making, and just send the variable data that needs to be displayed, what's the fastest way to get that data into the GFX?
Current Arduino sketch:
int req = 5; //mic REQ line goes to pin 5 through q1 (arduino high pulls request line low)
int dat = 2; //mic Data line goes to pin 2
int clk = 3; //mic Clock line goes to pin 3
int i = 0; int j = 0; int k = 0;
int wave;
char* error = 0;
byte a;
float mm;
char* family;
char* menu;
int minnum;
int maxnum;
float maxmm;
int maxl;
int staticl;
int staticl5;
int staticl4;
int staticl3;
float jump;
float range;
byte mydata[14];
long num;
int gearFamily = 7;
int c0 = 0;
int c1 = 0;
// Mode button
const int buttonPin = 4; // the pin that the pushbutton is attached to
int buttonPushCounter = 7; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
// Average button
const int avgPin = 6; // switch is connected to pin 6
int avgVal; // variable for reading the pin status
int avgVal2; // variable for reading the delayed status
int avgButtonState = 0; // variable to hold the button state
int sampleState = 0; // Which sample am I taking (1 of 3)?
long m1=0;
long m2=0;
long m3=0;
int samplel1=0;
int samplel2=0;
int samplel3=0;
int sampleAvgl=0;
void setup()
{
Serial3.begin(9600);
pinMode(req, OUTPUT);
pinMode(clk, INPUT);
pinMode(dat, INPUT);
digitalWrite(clk, HIGH); // enable internal pull ups
digitalWrite(dat, HIGH); // enable internal pull ups
digitalWrite(req,LOW); // set request at LOW
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
pinMode(avgPin, INPUT); // Set the switch pin as input
avgButtonState = digitalRead(avgPin); // read the initial state
delay(500);
// initialize uVGA card with autobaud
autoBaud();
// resolution 640x480
control(12, 1); // 12 = screen resolution, 1 = 640x480
// set baud rate
setBaud(11); // 13 - 115200 Baud (won't work at higher rates)
Serial3.begin(56600);
// clear screen
clearScreen();
// Blue background
replaceBackground(0, 31); // color msb:lsb
//opaque text
textOpacity(1); // 0 = transparent, 1 = opaque
//pen size
penSize(0); // 0 = solid, 1 = wireframe
}
void loop()
{
// read menu button
// read the pushbutton input pin:r />buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// clearScreen();
// if the state has changed, increment the counter
if (buttonState == LOW) {
// if the current state is HIGH then the button
// went from off to on:
buttonPushCounter++;
clearScreen();
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
if (buttonPushCounter == 8) {
buttonPushCounter = 1;
}
gearFamily = buttonPushCounter;
// gearFamily = 1;
// get data from mic
// {
digitalWrite(req, HIGH); // generate set request
for( i = 0; i < 13; i++ ) {
k = 0;
for (j = 0; j < 4; j++) {
while( digitalRead(clk) == LOW) { } // hold until clock is high
while( digitalRead(clk) == HIGH) { } // hold until clock is low
bitWrite(k, j, (digitalRead(dat) & 0x1)); // read data bits, and reverse order )
}
// extract data
mydata[i] = k;
// sign = mydata[4];
// decimal = mydata[11];
// units = mydata[12];
}
// assemble measurement from bytes
char buf[7];
for(int lp=0;lp= 6371)
{
family = "Over W M17";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 2)
{
// do j/h pump
family="J/H Pump";
menu = "J/H Sort";
wave = 4;
if (num = 4477 && num = 4573 && num = 7038 && num = 7134 && num = 8325 && num = 8642 && num = 10908 && num = 11100 && num = 12045 && num = 12301 && num = 14089 && num = 14313 && num = 18869 && num = 19061)
{
family = "Over J/H 750";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 3)
{
// do minipump
family="Mini Pump";
menu = "MP Sort";
wave = 3;
if (num = 5042 && num = 5110 && num = 5810 && num = 5862 && num = 7062 && num = 7130 && num = 8576 && num = 8700 && num = 9890 && num = 9998)
{
family = "Over MP390";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 4)
{
// do webster pump match
family = "Webster";
menu = "Webster Match";
wave = 3;
if (num = 2290 && num = 2331 && num = 2920 && num = 2971 && num = 6330 && num = 6371)
{
family = "Over W M17";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 5)
{
// do j/h pump
family="J/H Pump";
menu = "J/H Match";
wave = 4;
if (num = 4477 && num = 4573 && num = 7038 && num = 7134 && num = 8325 && num = 8642 && num = 10908 && num = 11100 && num = 12045 && num = 12301 && num = 14089 && num = 14313 && num = 18869 && num = 19061)
{
family = "Over J/H 750";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 6)
{
// do minipump
family="Mini Pump";
menu = "MP Match";
wave = 3;
if (num = 5042 && num = 5110 && num = 5810 && num = 5862 && num = 7062 && num = 7130 && num = 8576 && num = 8700 && num = 9890 && num = 9998)
{
family = "Over MP390";
staticl = 0;
staticl5 = 0;
staticl4 = 0;
staticl3 = 0;
}
}
else if (gearFamily == 7){
// do instructions
family = " ";
menu = "Instructions";
}
digitalWrite(req,LOW);
error=0;
// delay(25);
sendText(22, 05, 3, 255, 255, family);
sendText(22, 03, 3, 255, 255, menu);
// }
if (gearFamily >= 1 && gearFamily = 4 && gearFamily
Comment