//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
// Struct used to allow jagged arrays
// See - https://forum.arduino.cc/t/multi-dimensional-arrays-with-different-number-of-elements/557252/2?msclkid=e1f2d9e2b44011ecb63f1d572262f5c5
// (Checked April 2022)
#define NUMELEMENTS(x) (sizeof(x) / sizeof(x[0]))
// {wait, run, walk,... ,end (0xFF)}
// FORGOT 3 WORKOUTS WEEK 5 & 6
int week1[]{1000,2000,5000,2000,5000,2000,5000,0xFF};
int week2[]{1000,2000,5000,2000,5000,2000,5000,0xFF};
int week3[]{1000,2000,5000,2000,5000,2000,5000,0xFF};
int week4[]{1000,2000,5000,2000,5000,2000,5000,0xFF};
int week5[]{1000,2000,5000,2000,5000,2000,5000,0xFF};
int week6[]{1000,2000,5000,2000,5000,2000,5000,0xFF};
int week7[]{1000,2000,5000,2000,5000,2000,5000,0xFF};
int week8[]{1000,2000,5000,2000,5000,2000,5000,0xFF};
int week9[]{1000,2000,5000,2000,5000,2000,5000,0xFF};
struct WORKOUTS
{
int *workouts;
uint16_t numElements;
};
WORKOUTS workoutsMatrix[] =
{
{week1, NUMELEMENTS(week1)},
{week2, NUMELEMENTS(week2)},
{week3, NUMELEMENTS(week3)},
{week4, NUMELEMENTS(week4)},
{week5, NUMELEMENTS(week5)},
{week6, NUMELEMENTS(week6)},
{week7, NUMELEMENTS(week7)},
{week8, NUMELEMENTS(week8)},
{week9, NUMELEMENTS(week9)},
};
void setup()
{
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.clear();
lcd.setCursor(6,0);
lcd.print("C25K");
}
void loop()
{
int repeats=0;
int stop=5;
int i=0;
//beep long
lcd.setCursor(5,1);
lcd.print("Warmup");
delay(week1[0]);
//beep beep
lcd.setCursor(5,1);
lcd.print(" ");
for(i=1;week1[i]!=0xFF;i++){
if(i&1){
lcd.setCursor(6,1);
lcd.print("Run ");
delay(week1[i]);
//beep
}
else{
lcd.setCursor(6,1);
lcd.print("Rest");
delay(week1[i]);
//beep beep
}
}
//beep beep beep
lcd.setCursor(6,1);
lcd.print("Stop");
while(1);
}
/*
#define NUMELEMENTS(x) (sizeof(x) / sizeof(x[0]))
int pin1[] = {1, 2};
int pin2[] = {9, 8, 7, 6, 5};
int pin3[] = {3, 4};
struct PINS
{
int *pins;
uint16_t numElements;
};
PINS pinMatrix[] =
{
{pin1, NUMELEMENTS(pin1)},
{pin2, NUMELEMENTS(pin2)},
{pin3, NUMELEMENTS(pin3)},
};
void setup()
{
Serial.begin(57600);
Serial.print("number of rows in pinMatrix = "); Serial.println(NUMELEMENTS(pinMatrix));
Serial.println();
for (uint16_t rowCnt = 0; rowCnt < NUMELEMENTS(pinMatrix); rowCnt++)
{
Serial.print("number of columns in pinMatrix["); Serial.print(rowCnt);
Serial.print("] = "); Serial.println(pinMatrix[rowCnt].numElements);
Serial.print("content = ");
for (uint16_t colCnt = 0; colCnt < pinMatrix[rowCnt].numElements; colCnt++)
{
Serial.print(pinMatrix[rowCnt].pins[colCnt]); Serial.print(", ");
}
Serial.println();
Serial.println();
}
}
void loop()
{
// put your main code here, to run repeatedly:
}
*/