ghlawrence2000:
Maybe something like this? :-
void printAll(int adc)
{
const char adcstring1[] PROGMEM = "ADC = ";
const char adcstring2[] PROGMEM = " mV";
Serial.print(adcstring1); Serial.print(adc); Serial.println(adcstring2);
tft.print(adcstring1); tft.print(adc); tft.println(adcstring2);
}
Or even this? :-
void printAll(int adc)
{
const char adcstring1[] PROGMEM = "ADC = ";
const char adcstring2[] PROGMEM = " mV";
char numbuf[6]; // upto 99999 mv
itoa(adc, numbuf, 10);
char line[15];
strcpy(line, adcstring1);
strcat(line, numbuf);
strcat(line, adcstring2);
Serial.println(line);
tft.println(line);
}
Don't know if that's the kind of thing you were looking for.
Regards,
Graham
yes i can understand how that would work on that situation but its not really a solve all thing. i sorta understand how functions work and i just need one that will take for example the GSM FONA board there are plenty of menu items and each return different values
so for example and this is just a few lines i would want each print to serial to also print to tft
case 'b': {
// read the battery voltage and percentage
uint16_t vbat;
if (! fona.getBattVoltage(&vbat)) {
Serial.println(F("Failed to read Batt"));
} else {
Serial.print(F("VBat = ")); Serial.print(vbat); Serial.println(F(" mV"));
}
if (! fona.getBattPercent(&vbat)) {
Serial.println(F("Failed to read Batt"));
} else {
Serial.print(F("VPct = ")); Serial.print(vbat); Serial.println(F("%"));
}
break;
}
case 'C': {
// read the CCID
fona.getSIMCCID(replybuffer); // make sure replybuffer is at least 21 bytes!
Serial.print(F("SIM CCID = ")); Serial.println(replybuffer);
break;
}
case 'i': {
// read the RSSI
uint8_t n = fona.getRSSI();
int8_t r;
Serial.print(F("RSSI = ")); Serial.print(n); Serial.print(": ");
if (n == 0) r = -115;
if (n == 1) r = -111;
if (n == 31) r = -52;
if ((n >= 2) && (n <= 30)) {
r = map(n, 2, 30, -110, -54);
}
Serial.print(r); Serial.println(F(" dBm"));
break;
}
at the moment i am doing this
case 'i': {
// read the RSSI
uint8_t n = fona.getRSSI();
int8_t r;
Serial.print(F("RSSI = ")); Serial.print(n); Serial.print(": ");
tft.print(F("RSSI = ")); tft.print(n); tft.print(": ");
if (n == 0) r = -115;
if (n == 1) r = -111;
if (n == 31) r = -52;
if ((n >= 2) && (n <= 30)) {
r = map(n, 2, 30, -110, -54);
}
Serial.print(r); Serial.println(F(" dBm"));
tft.print(r); tft.println(F(" dBm"));
break;
}
and so on etc now at the moment i have over 2000 lines of code and it is building up at first i was happy with just a serial print but then decided to go with a tft screen half way through the job.
so thats where i am at the moment just every time i see a serial.print line i copy it paste it underneath and replace serial with tft
hence looking for an easy way out .