int P1[][12] = { //0-10
{0}, //MODE
{0, 0, 0, 0,}, //TOD variables
// OnHR, OnMin, OffHr, OffMin
{0}, //DOW
{0, 0, 0, 0,}, //Sunday
{0, 0, 0, 0,}, // OnHR, OnMin, OffHr, OffMin
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,}, //Saturday
{0, 0, 0, 0, 0,} // Temperature variables
//Sensor, GreaterThan/LessThan, Temp, Buffer, State
};
void HrMinBounce() {
int i = 0;
int q = 0;
for (int i; i < 10; i++) { //iterating down Plug arrays
for (int q; q < 4; q++) {
if (i != 0 || i != 2) { //non time arrays
if (q == 0 || q == 2) { //hours
if (P1[i][q] > 23) {
P1[i][q] = 0;
}
if (P1[i][q] < 0) {
P1[i][q] = 23;
}
}//End of hours
if (q == 1 || q == 3) { //minutes
if (P1[i][q] > 59) {
P1[i][q] = 0;
}
if (P1[i][q] < 0) {
P1[i][q] = 59;
}
}//End of minutes
}
}
}
}
}
I have 5 of these arrays, so I was hoping to make one loop that could take care of all 5 at once. Here is my previous loop that works but I would have to copy and paste a whole lot to get the result without the extra for loop.
void MinHrLimit() {
int i = 0;
for (int i; i < 3; i++) {
if (i == 0 || i == 2) {
if (P1[1][i] > 23) {
P1[1][i] = 0;
}
if (P1[1][i] < 0) {
P1[1][i] = 23;
}
}
}
}