strcat expects two strings, so how the heck am I to append a char? I need it to be a single char because I make comparisons with literal chars later on in another function. It compiles but warns me of the incompatibility.
currentBlock is a char
strcat(html2, currentBlock);
#include <EEPROM.h>
char currentBlock;
void setup() {
Serial.begin(9600);
char html0[550] = { 0 }, html1[100] = { 0 }, html2[100] = { 0 }, html3[100] = { 0 }, html4[100] = { 0 };
char scheduleHHA[4] = { 0 };
char scheduleMMA[4] = { 0 };
char scheduleTempA[4] = { 0 };
int scheduleHHi, scheduleMMi, scheduleTempi;
char buff[10] = { 0 };
currentBlock = 'A';
strcpy(html0, "<!DOCTYPE html><html><head><title>Thermostat Schedule</title></head><body><hr>");
strcpy(html1, "<table><tr><th> Time </th > <th> Temp. </th> <tr><td><a href=AHHUp> + </a>");
strcat(html0, html1);
for (int i = 0; i < 8; i++) {
currentBlock++;
Serial.print("currentBlock:");
Serial.println(currentBlock);
scheduleHHi = scheduleArray(currentBlock, 'r', "scheduleHH", 0);
scheduleMMi = scheduleArray(currentBlock, 'r', "scheduleMM", 0);
scheduleTempi = scheduleArray(currentBlock, 'r', "scheduleTemp", 0);
itoa(scheduleHHi,buff,10);
strcpy(scheduleHHA,buff);
itoa(scheduleMMi,buff,10);
strcpy(scheduleMMA,buff);
itoa(scheduleTempi,buff,10);
strcpy(scheduleTempA,buff);
Serial.print("ScheduleTemp:"); Serial.println(scheduleTempA);
strcpy(html2, "<a href=");
strcat(html2, currentBlock);
strcat(html2, "HHDown> - </a>");
strcat(html2, scheduleHHA);
strcat(html2, "<a href=");
strcat(html2, currentBlock);
strcat(html2, "HHUp> + </a>");
strcat(html2, ": <a href=");
strcat(html2, currentBlock);
strcat(html2, "MMDown> - </a>");
strcat(html2, scheduleMMA);
strcat(html2, "MMUp> + </a>");
strcat(html2, " </td> <td>");
strcat(html3, ": <a href=");
strcat(html3, currentBlock);
strcat(html3, "TempDown> - </a>");
strcpy(html3, scheduleTempA);
strcat(html3, "TempUp> + </a>");
strcat(html3, " </td></tr><tr><td>");
strcat(html0, html2);
strcat(html0, html3);
}
strcpy(html4, " </table> </body> </html> ");
strcat(html0, html4);
//Serial.println(html0);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("Ping!");
delay(1000);
}
int scheduleArray(char Block, char rw, char* item, int data) {
int block;
int out;
int arrTimeHH[8], arrTimeMM[8], arrTemp[8];
out = 0;
if (Block == 'A') block = 0;
if (Block == 'B') block = 1;
if (Block == 'C') block = 2;
if (Block == 'D') block = 3;
if (Block == 'E') block = 4;
if (Block == 'F') block = 5;
if (Block == 'G') block = 6;
if (Block == 'G') block = 7;
//Serial.print('['); Serial.print(item); Serial.print(']');
if (rw == 'r') { //Read data
EEPROM.get(210, arrTimeHH);
EEPROM.get(230, arrTimeMM);
EEPROM.get(250, arrTemp);
if (strcmp(item, "timeHH") == 0) {
out = arrTimeHH[block];
}
if (strcmp(item, "timeMM") == 0) {
out = arrTimeMM[block];
}
if (strcmp(item, "temperature") == 0) { //Do NOT use "temp" - for some reason doesn't work.
out = arrTemp[block];
}
}
if (rw == 'w') { //Write data
if (strcmp(item, "timeHH") == 0) {
arrTimeHH[block] = data;
EEPROM.put(210, arrTimeHH);
}
if (strcmp(item, "timeMM") == 0) {
arrTimeMM[block] = data;
EEPROM.put(230, arrTimeMM);
}
if (strcmp(item, "temperature") == 0) {
arrTemp[block] = data;
EEPROM.put(250, arrTemp);
}
}
return out;
}