Formatting, no functional changes

This commit is contained in:
Gordon Bolton 2024-06-25 21:34:47 +01:00
parent 5ab1db583a
commit 38375ea750
15 changed files with 248 additions and 227 deletions

View File

@ -11,7 +11,8 @@
void setup(); void setup();
void loop(); void loop();
void setup() { void setup()
{
Serial.begin(115200); Serial.begin(115200);
// Disable the watchdog timers // Disable the watchdog timers
@ -26,11 +27,11 @@ void setup() {
// Set pin modes // Set pin modes
pinMode(EN_PIN, OUTPUT); pinMode(EN_PIN, OUTPUT);
digitalWrite(EN_PIN, HIGH); // Disable motor initially digitalWrite(EN_PIN, HIGH); // Disable motor initially
pinMode(beeperPin, OUTPUT); pinMode(beeperPin, OUTPUT);
// Set stepper motor properties // Set stepper motor properties
stepper.setMaxSpeed(SPEED); stepper.setMaxSpeed(SPEED);
stepper.setAcceleration(9600); // Set acceleration stepper.setAcceleration(9600); // Set acceleration
// Display welcome message // Display welcome message
lcd.setCursor(6, 1); lcd.setCursor(6, 1);
@ -41,6 +42,7 @@ void setup() {
lcd.clear(); lcd.clear();
} }
void loop() { void loop()
{
startingMenu(); startingMenu();
} }

View File

@ -1,19 +1,18 @@
#include "config.h" #include "config.h"
// Global variables definition // Global variables definition
const char* version = "V0.1.0 20240625"; const char *version = "V0.1.0 20240625";
const byte ROWS = 5; const byte ROWS = 5;
const byte COLS = 4; const byte COLS = 4;
byte rowPins[ROWS] = { 19, 18, 5, 17, 16 }; byte rowPins[ROWS] = {19, 18, 5, 17, 16};
byte colPins[COLS] = { 15, 2, 0, 4 }; byte colPins[COLS] = {15, 2, 0, 4};
char keys[ROWS][COLS] = { char keys[ROWS][COLS] = {
{ 'F', 'E', '#', '*' }, {'F', 'E', '#', '*'},
{ '1', '2', '3', 'U' }, {'1', '2', '3', 'U'},
{ '4', '5', '6', 'D' }, {'4', '5', '6', 'D'},
{ '7', '8', '9', 'X' }, {'7', '8', '9', 'X'},
{ 'L', '0', 'R', 'E' } {'L', '0', 'R', 'E'}};
};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x27, LCD_COLUMNS, LCD_ROWS); LiquidCrystal_I2C lcd(0x27, LCD_COLUMNS, LCD_ROWS);
@ -32,12 +31,11 @@ unsigned long processStartTime;
unsigned long processTimeMillis; unsigned long processTimeMillis;
byte thermometer[8] = { byte thermometer[8] = {
B00100, B00100,
B01100, B01100,
B00100, B00100,
B01100, B01100,
B00100, B00100,
B01110, B01110,
B01110, B01110,
B01110 B01110};
};

View File

@ -21,7 +21,7 @@
#define TEMP_SENSOR_PIN 13 #define TEMP_SENSOR_PIN 13
#define NUM_DEV_SEQUENCES 6 #define NUM_DEV_SEQUENCES 6
extern const char* version; extern const char *version;
extern Keypad keypad; extern Keypad keypad;
extern LiquidCrystal_I2C lcd; extern LiquidCrystal_I2C lcd;
extern AccelStepper stepper; extern AccelStepper stepper;

View File

@ -1,103 +1,72 @@
#include "devSequence.h" #include "devSequence.h"
struct devSequence devSequences[NUM_DEV_SEQUENCES] = { struct devSequence devSequences[NUM_DEV_SEQUENCES] = {
{ {"C41",
"C41", 7,
7, {180, 195, 45, 180, 60, 60, 30}, // processTime
{ 180, 195, 45, 180, 60, 60, 30 }, //processTime {"Prewarm", "Developer", "Bleach", "Fix", "Rinse 1", "Rinse 2", "Fin Rinse"}, // processName
{ "Prewarm", "Developer", "Bleach", "Fix", "Rinse 1", "Rinse 2", "Fin Rinse" }, //processName {
{ {1, 5.5, 5.5, 5.5, 3.5, 3.5, 1}, // CW rotations processCycle
{ 1, 5.5, 5.5, 5.5, 3.5, 3.5, 1 }, //CW rotations processCycle {1, 5, 5, 5, 3, 3, 1}}, // CCW rotations processCycle
{ 1, 5, 5, 5, 3, 3, 1 } {
}, //CCW rotations processCycle {37.8, 37.8, 32, 32, 32, 32, 32}, // min processTemp
{ {38, 38, 38, 38, 38, 38, 38}, // preferred processTemp
{ 37.8, 37.8, 32, 32, 32, 32, 32 }, //min processTemp {38.2, 38.2, 38.2, 38.2, 38.2, 38.2, 38.2} // max processTemp
{ 38, 38, 38, 38, 38, 38, 38 }, //preferred processTemp }},
{ 38.2, 38.2, 38.2, 38.2, 38.2, 38.2, 38.2 } //max processTemp {"E6",
} 12,
}, {180, 360, 120, 120, 360, 120, 360, 240, 120, 120, 120, 30},
{ {"Preheat", "FirstDev", "Wash 1", "Reversal", "ColorDev", "PreBleach", "Bleach", "Fixer", "Wash 2", "Wash 3", "Wash 4", "Fin Rinse"},
"E6", {{1, 5.5, 3.5, 5, 5.5, 5.5, 5.5, 5.5, 3.5, 3.5, 3.5, 3.5},
12, {1, 5, 3, 5.5, 5, 5.5, 5.5, 5.5, 3, 3, 3, 3}},
{180, 360, 120, 120, 360, 120, 360, 240, 120, 120, 120, 30}, {{37.5, 37.7, 33.0, 37.7, 37.0, 37, 37.5, 37.5, 33.0, 33.0, 33.0, 19.0},
{"Preheat", "FirstDev", "Wash 1", "Reversal", "ColorDev", "PreBleach", "Bleach", "Fixer", "Wash 2", "Wash 3", "Wash 4", "Fin Rinse"}, {38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 20.0},
{ {38.5, 38.3, 38.0, 38.3, 39.0, 38, 38.5, 38.5, 38.5, 38.5, 38.5, 21.0}}},
{1, 5.5, 3.5, 5, 5.5, 5.5, 5.5, 5.5, 3.5, 3.5, 3.5, 3.5}, {"ECN-2",
{1, 5, 3, 5.5, 5, 5.5, 5.5, 5.5, 3, 3, 3, 3} 9,
}, {180, 0, 210, 60, 180, 150, 120, 300, 120},
{ {"Prebath", "RemJet", "Developer", "Stop Bath", "Wash", "Bleach", "Fixer", "Wash 2", "Fin Rinse"},
{37.5, 37.7, 33.0, 37.7, 37.0, 37, 37.5, 37.5, 33.0, 33.0, 33.0, 19.0}, {{1, 0, 5.5, 3.5, 3.5, 5.5, 5.5, 3.5, 1},
{38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0, 20.0}, {1, 0, 5, 3, 3, 5, 5, 3, 1}},
{38.5, 38.3, 38.0, 38.3, 39.0, 38, 38.5, 38.5, 38.5, 38.5, 38.5, 21.0} {{27.0, 0, 40.8, 27.0, 27.0, 27.0, 27.0, 27.0, 27.0},
} {38.0, 0, 41.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0},
}, {38.0, 0, 41.2, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0}}},
{ {"B&W",
"ECN-2", 7,
9, {510, 30, 300, 60, 90, 120, 30},
{180, 0, 210, 60, 180, 150, 120, 300, 120}, {"Developer", "Stop", "Fix", "Rinse 1", "Rinse 2", "Rinse 3", "Fin Rinse"},
{"Prebath", "RemJet", "Developer", "Stop Bath", "Wash", "Bleach", "Fixer", "Wash 2", "Fin Rinse"}, {{5.5, 3.5, 3.5, 3.5, 3.5, 3.5, 1},
{ {5, 3, 3, 3, 3, 3, 1}},
{1, 0, 5.5, 3.5, 3.5, 5.5, 5.5, 3.5, 1}, {{19, 19, 19, 19, 19, 19, 19},
{1, 0, 5, 3, 3, 5, 5, 3, 1} {20, 20, 20, 20, 20, 20, 20},
}, {21, 21, 21, 21, 21, 21, 21}}},
{ {"Custom",
{27.0, 0, 40.8, 27.0, 27.0, 27.0, 27.0, 27.0, 27.0}, 4,
{38.0, 0, 41.0, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0}, {10, 10, 10, 10},
{38.0, 0, 41.2, 38.0, 38.0, 38.0, 38.0, 38.0, 38.0} {"Developer", "Stop", "Fix", "Rinse"},
} {{5.5, 3.5, 3.5, 3.5},
}, {5, 3, 3, 3}},
{ {{19, 19, 19, 19},
"B&W", {20, 20, 20, 20},
7, {21, 21, 21, 21}}},
{510, 30, 300, 60, 90, 120, 30}, {"B&WREV",
{"Developer", "Stop", "Fix", "Rinse 1", "Rinse 2", "Rinse 3", "Fin Rinse"}, 12,
{ {720, 300, 300, 60, 120, 60, 120, 360, 60, 300, 60, 60},
{ 5.5, 3.5, 3.5, 3.5, 3.5, 3.5, 1}, {"FirstDev", "Wash 1", "Bleach", "Wash 2", "Clearing", "Wash 3", "Reversal", "SecondDev", "Wash 4", "Fix", "Wash 5", "Fin Rinse"},
{ 5, 3, 3, 3, 3, 3, 1} {{5.5, 3.5, 5.5, 3.5, 5.5, 3.5, 5.5, 5.5, 3.5, 5.5, 3.5, 3.5},
}, {5, 3, 5, 3, 5, 3, 5, 5, 3, 5, 3, 3}},
{ {{19.5, 15.5, 19.5, 15.5, 19.5, 15.5, 19.5, 19.5, 15.5, 19.5, 15.5, 15.5},
{19, 19, 19, 19, 19, 19, 19}, {20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0},
{20, 20, 20, 20, 20, 20, 20}, {20.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5}}}};
{21, 21, 21, 21, 21, 21, 21}
}
},
{
"Custom",
4,
{10, 10, 10, 10},
{"Developer", "Stop", "Fix", "Rinse"},
{
{ 5.5, 3.5, 3.5, 3.5},
{ 5, 3, 3, 3}
},
{
{19, 19, 19, 19},
{20, 20, 20, 20},
{21, 21, 21, 21}
}
},
{
"B&WREV",
12,
{720, 300, 300, 60, 120, 60, 120, 360, 60, 300, 60, 60},
{"FirstDev", "Wash 1", "Bleach", "Wash 2", "Clearing", "Wash 3", "Reversal", "SecondDev", "Wash 4", "Fix", "Wash 5", "Fin Rinse"},
{
{5.5, 3.5, 5.5, 3.5, 5.5, 3.5, 5.5, 5.5, 3.5, 5.5, 3.5, 3.5},
{5, 3, 5, 3, 5, 3, 5, 5, 3, 5, 3, 3}
},
{
{19.5, 15.5, 19.5, 15.5, 19.5, 15.5, 19.5, 19.5, 15.5, 19.5, 15.5, 15.5},
{20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0},
{20.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5}
}
}
};
struct devSequence* findSequenceByName(const char* processName) { struct devSequence *findSequenceByName(const char *processName)
for (int i = 0; i < NUM_DEV_SEQUENCES; i++) { {
if (strcmp(devSequences[i].processName, processName) == 0) { for (int i = 0; i < NUM_DEV_SEQUENCES; i++)
return &devSequences[i]; {
} if (strcmp(devSequences[i].processName, processName) == 0)
} {
return NULL; // Return NULL if not found return &devSequences[i];
}
}
return NULL; // Return NULL if not found
} }

View File

@ -3,7 +3,8 @@
#define NUM_DEV_SEQUENCES 6 #define NUM_DEV_SEQUENCES 6
#include <Arduino.h> #include <Arduino.h>
struct devSequence { struct devSequence
{
char processName[7]; char processName[7];
int cycles; int cycles;
unsigned long int processTime[20]; unsigned long int processTime[20];
@ -14,6 +15,6 @@ struct devSequence {
extern struct devSequence devSequences[NUM_DEV_SEQUENCES]; extern struct devSequence devSequences[NUM_DEV_SEQUENCES];
struct devSequence* findSequenceByName(const char* processName); struct devSequence *findSequenceByName(const char *processName);
#endif #endif

View File

@ -1,8 +1,8 @@
#include "display.h" #include "display.h"
#include "menu.h" #include "menu.h"
void startingMenu()
void startingMenu() { {
lcd.clear(); lcd.clear();
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print("Select Programme:"); lcd.print("Select Programme:");
@ -19,17 +19,20 @@ void startingMenu() {
lcd.setCursor(10, 3); lcd.setCursor(10, 3);
lcd.print("6. B&W Rev"); lcd.print("6. B&W Rev");
while (devPgm == "") { while (devPgm == "")
{
getMenuInput(); getMenuInput();
} }
lcd.print(devPgm); lcd.print(devPgm);
if (devPgm == "C41" || devPgm == "E6" || devPgm == "B&W" || devPgm == "ECN-2" || devPgm == "Custom" || devPgm == "B&WREV") { if (devPgm == "C41" || devPgm == "E6" || devPgm == "B&W" || devPgm == "ECN-2" || devPgm == "Custom" || devPgm == "B&WREV")
{
startDev(); startDev();
} }
} }
void processHeadings() { void processHeadings()
{
lcd.clear(); lcd.clear();
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print("Step"); lcd.print("Step");
@ -39,11 +42,11 @@ void processHeadings() {
lcd.print("Temp"); lcd.print("Temp");
} }
char *secondsToMinutesSeconds(int seconds)
{
char* secondsToMinutesSeconds(int seconds) { char *result = (char *)malloc(6 * sizeof(char));
char* result = (char*)malloc(6 * sizeof(char)); if (result == NULL)
if (result == NULL) { {
return NULL; return NULL;
} }

View File

@ -4,10 +4,10 @@
#include <LiquidCrystal_I2C.h> #include <LiquidCrystal_I2C.h>
#include "config.h" #include "config.h"
void updateTempDisplay(void* parameter); void updateTempDisplay(void *parameter);
void startingMenu(); void startingMenu();
void processHeadings(); void processHeadings();
void readTemperature(); void readTemperature();
char* secondsToMinutesSeconds(int seconds); char *secondsToMinutesSeconds(int seconds);
#endif #endif

View File

@ -1,66 +1,80 @@
#include "menu.h" #include "menu.h"
void getMenuInput() { void getMenuInput()
char key = keypad.getKey(); {
if (key != NO_KEY) { char key = keypad.getKey();
switch (key) { if (key != NO_KEY)
case '1': {
devPgm = "C41"; switch (key)
break; {
case '2': case '1':
devPgm = "E6"; devPgm = "C41";
break; break;
case '3': case '2':
devPgm = "B&W"; devPgm = "E6";
break; break;
case '4': case '3':
devPgm = "ECN-2"; devPgm = "B&W";
break; break;
case '5': case '4':
devPgm = "Custom"; devPgm = "ECN-2";
break; break;
case '6': case '5':
devPgm = "B&WREV"; devPgm = "Custom";
break; break;
} case '6':
} devPgm = "B&WREV";
break;
}
}
} }
char getScrollEntEscInput()
char getScrollEntEscInput() { {
while (true) { while (true)
{
char key = keypad.getKey(); char key = keypad.getKey();
if (key != NO_KEY) { if (key != NO_KEY)
if (key == 'U' || key == 'D' || key == 'X' || key == 'E' || key == 'L' || key == 'R') { {
if (key == 'U' || key == 'D' || key == 'X' || key == 'E' || key == 'L' || key == 'R')
{
return key; return key;
} }
} }
if (millis() % 1000 == 0) { if (millis() % 1000 == 0)
{
readTemperature(); readTemperature();
} }
} }
} }
char getEntEscInput() { char getEntEscInput()
while (true) { {
while (true)
{
char key = keypad.getKey(); char key = keypad.getKey();
if (key != NO_KEY) { if (key != NO_KEY)
if (key == 'X' || key == 'E') { {
if (key == 'X' || key == 'E')
{
return key; return key;
} }
} }
if (millis() % 1000 == 0) { if (millis() % 1000 == 0)
{
readTemperature(); readTemperature();
} }
} }
} }
int startProcessing(struct devSequence* sequence, int sequenceStep) { int startProcessing(struct devSequence *sequence, int sequenceStep)
{
run = 1; run = 1;
lcd.clear(); lcd.clear();
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(sequence->processCycleName[sequenceStep]); lcd.print(sequence->processCycleName[sequenceStep]);
for (int x = strlen(sequence->processCycleName[sequenceStep]); x < 10; x++) { for (int x = strlen(sequence->processCycleName[sequenceStep]); x < 10; x++)
{
lcd.print(" "); lcd.print(" ");
} }
@ -73,7 +87,8 @@ int startProcessing(struct devSequence* sequence, int sequenceStep) {
lcd.print("Ent:start Esc:quit"); lcd.print("Ent:start Esc:quit");
char key = getEntEscInput(); char key = getEntEscInput();
if (key == 'X') { if (key == 'X')
{
devPgm = ""; devPgm = "";
run = 0; run = 0;
return 0; return 0;
@ -81,7 +96,7 @@ int startProcessing(struct devSequence* sequence, int sequenceStep) {
processTimeMillis = (unsigned long)sequence->processTime[sequenceStep] * 1000; processTimeMillis = (unsigned long)sequence->processTime[sequenceStep] * 1000;
processStartTime = millis(); processStartTime = millis();
MotorTaskParams* params = new MotorTaskParams(); MotorTaskParams *params = new MotorTaskParams();
params->cwRotations = sequence->processCycle[0][sequenceStep]; params->cwRotations = sequence->processCycle[0][sequenceStep];
params->ccwRotations = sequence->processCycle[1][sequenceStep]; params->ccwRotations = sequence->processCycle[1][sequenceStep];
params->processEndTime = processStartTime + processTimeMillis; params->processEndTime = processStartTime + processTimeMillis;
@ -94,24 +109,26 @@ int startProcessing(struct devSequence* sequence, int sequenceStep) {
Serial.println(params->processEndTime); Serial.println(params->processEndTime);
xTaskCreatePinnedToCore( xTaskCreatePinnedToCore(
runMotorTask, runMotorTask,
"MotorTask", "MotorTask",
8192, 8192,
(void*)params, (void *)params,
1, 1,
&motorTaskHandle, &motorTaskHandle,
0); 0);
while (millis() < processStartTime + processTimeMillis) { while (millis() < processStartTime + processTimeMillis)
{
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd.print("Remaining: " + (String)secondsToMinutesSeconds((processStartTime + processTimeMillis - millis()) / 1000) + " "); lcd.print("Remaining: " + (String)secondsToMinutesSeconds((processStartTime + processTimeMillis - millis()) / 1000) + " ");
delay(410); delay(410);
Serial.println("before temp read" + (String) millis() + "\n"); Serial.println("before temp read" + (String)millis() + "\n");
readTemperature(); readTemperature();
Serial.println("after temp read" + (String) millis() + "\n"); Serial.println("after temp read" + (String)millis() + "\n");
} }
if (motorTaskHandle != NULL) { if (motorTaskHandle != NULL)
{
vTaskDelete(motorTaskHandle); vTaskDelete(motorTaskHandle);
motorTaskHandle = NULL; motorTaskHandle = NULL;
} }
@ -121,12 +138,15 @@ int startProcessing(struct devSequence* sequence, int sequenceStep) {
return 1; return 1;
} }
void startDev() { void startDev()
const char* searchName = devPgm.c_str(); {
struct devSequence* currentSequence = findSequenceByName(searchName); const char *searchName = devPgm.c_str();
struct devSequence *currentSequence = findSequenceByName(searchName);
for (int i = 0; i < currentSequence->cycles; i++) { for (int i = 0; i < currentSequence->cycles; i++)
if (run == 1) { {
if (run == 1)
{
run = startProcessing(currentSequence, i); run = startProcessing(currentSequence, i);
continue; continue;
} }
@ -134,7 +154,8 @@ void startDev() {
processHeadings(); processHeadings();
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd.print(currentSequence->processCycleName[i]); lcd.print(currentSequence->processCycleName[i]);
for (int x = strlen(currentSequence->processCycleName[i]); x < 10; x++) { for (int x = strlen(currentSequence->processCycleName[i]); x < 10; x++)
{
lcd.print(" "); lcd.print(" ");
} }
@ -147,29 +168,43 @@ void startDev() {
lcd.print("Scroll / Esc / Ent"); lcd.print("Scroll / Esc / Ent");
char key = getScrollEntEscInput(); char key = getScrollEntEscInput();
if (key == 'U') { if (key == 'U')
if (i > 0) { {
if (i > 0)
{
i--; i--;
} }
i--; i--;
} else if (key == 'D' && i < currentSequence->cycles - 1) { }
else if (key == 'D' && i < currentSequence->cycles - 1)
{
continue; continue;
} else if (key == 'D' && i == currentSequence->cycles - 1) { }
else if (key == 'D' && i == currentSequence->cycles - 1)
{
i--; i--;
continue; continue;
} else if (key == 'X') { }
else if (key == 'X')
{
devPgm = ""; devPgm = "";
run = 0; run = 0;
return; return;
} else if (key == 'E') { }
else if (key == 'E')
{
int run = 1; int run = 1;
startProcessing(currentSequence, i); startProcessing(currentSequence, i);
} else if (key == 'L') { }
else if (key == 'L')
{
currentSequence->processTime[i] -= 5; currentSequence->processTime[i] -= 5;
lcd.setCursor(10, 1); lcd.setCursor(10, 1);
lcd.print(secondsToMinutesSeconds(currentSequence->processTime[i])); lcd.print(secondsToMinutesSeconds(currentSequence->processTime[i]));
i--; i--;
} else if (key == 'R') { }
else if (key == 'R')
{
currentSequence->processTime[i] += 5; currentSequence->processTime[i] += 5;
lcd.setCursor(10, 1); lcd.setCursor(10, 1);
lcd.print(secondsToMinutesSeconds(currentSequence->processTime[i])); lcd.print(secondsToMinutesSeconds(currentSequence->processTime[i]));

View File

@ -10,7 +10,7 @@
void getMenuInput(); void getMenuInput();
char getScrollEntEscInput(); char getScrollEntEscInput();
char getEntEscInput(); char getEntEscInput();
int startProcessing(struct devSequence* sequence, int sequenceStep); int startProcessing(struct devSequence *sequence, int sequenceStep);
void startDev(); void startDev();
#endif #endif

View File

@ -1,16 +1,19 @@
#include "motor.h" #include "motor.h"
void runMotorTask(void* parameter) { void runMotorTask(void *parameter)
MotorTaskParams* params = (MotorTaskParams*)parameter; {
MotorTaskParams *params = (MotorTaskParams *)parameter;
// Enable the motor // Enable the motor
digitalWrite(EN_PIN, LOW); digitalWrite(EN_PIN, LOW);
while (true) { while (true)
{
// Rotate clockwise // Rotate clockwise
Serial.println("Rotating CW" + (String)params->cwRotations); Serial.println("Rotating CW" + (String)params->cwRotations);
stepper.setCurrentPosition(0); stepper.setCurrentPosition(0);
stepper.moveTo(STEPS_PER_REV * params->cwRotations); stepper.moveTo(STEPS_PER_REV * params->cwRotations);
while (stepper.distanceToGo() != 0) { while (stepper.distanceToGo() != 0)
{
stepper.run(); stepper.run();
} }
@ -18,12 +21,13 @@ void runMotorTask(void* parameter) {
Serial.println("Rotating CCW" + (String)params->ccwRotations); Serial.println("Rotating CCW" + (String)params->ccwRotations);
stepper.setCurrentPosition(0); stepper.setCurrentPosition(0);
stepper.moveTo(-STEPS_PER_REV * params->ccwRotations); stepper.moveTo(-STEPS_PER_REV * params->ccwRotations);
while (stepper.distanceToGo() != 0) { while (stepper.distanceToGo() != 0)
{
stepper.run(); stepper.run();
} }
} }
// Disable the motor // Disable the motor
digitalWrite(EN_PIN, HIGH); digitalWrite(EN_PIN, HIGH);
vTaskDelete(NULL); // Delete the task when done vTaskDelete(NULL); // Delete the task when done
} }

View File

@ -4,12 +4,13 @@
#include <AccelStepper.h> #include <AccelStepper.h>
#include "config.h" #include "config.h"
struct MotorTaskParams { struct MotorTaskParams
{
float cwRotations; float cwRotations;
float ccwRotations; float ccwRotations;
unsigned long int processEndTime; unsigned long int processEndTime;
}; };
void runMotorTask(void* parameter); void runMotorTask(void *parameter);
#endif #endif

View File

@ -1,15 +1,14 @@
#include "sound.h" #include "sound.h"
int melody[] = { int melody[] = {
262, 294, 330, 349, 392, 440, 494, 523, 587, 659, 698, 784, 880, 988, 1047 262, 294, 330, 349, 392, 440, 494, 523, 587, 659, 698, 784, 880, 988, 1047};
};
int noteDurations[] = { int noteDurations[] = {
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250};
};
void playTune() { void playTune()
for (int thisNote = 0; thisNote < 15; thisNote++) { {
for (int thisNote = 0; thisNote < 15; thisNote++)
{
int noteDuration = noteDurations[thisNote]; int noteDuration = noteDurations[thisNote];
tone(beeperPin, melody[thisNote], noteDuration); tone(beeperPin, melody[thisNote], noteDuration);
@ -20,8 +19,10 @@ void playTune() {
} }
} }
void playAlarmTone() { void playAlarmTone()
for (int i = 1; i <= 10; i++) { {
for (int i = 1; i <= 10; i++)
{
tone(beeperPin, 2000); tone(beeperPin, 2000);
delay(500); delay(500);
noTone(beeperPin); noTone(beeperPin);

View File

@ -1,2 +0,0 @@
spec.o: \
C:/Users/gordon/Documents/sloeber-workspace/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.cpp

View File

@ -1,29 +1,37 @@
#include "temperature.h" #include "temperature.h"
void readTemperature() { void readTemperature()
{
sensors.requestTemperatures(); sensors.requestTemperatures();
float temperatureC = sensors.getTempCByIndex(0); float temperatureC = sensors.getTempCByIndex(0);
lcd.setCursor(13, 3); lcd.setCursor(13, 3);
lcd.write(byte(0)); lcd.write(byte(0));
if (temperatureC == DEVICE_DISCONNECTED_C) { if (temperatureC == DEVICE_DISCONNECTED_C)
{
lcd.print("--"); lcd.print("--");
} else { }
else
{
lcd.print(temperatureC, 1); lcd.print(temperatureC, 1);
lcd.print("C"); lcd.print("C");
} }
} }
void updateTempDisplay(void* parameter) { void updateTempDisplay(void *parameter)
{
sensors.requestTemperatures(); sensors.requestTemperatures();
float temperatureC = sensors.getTempCByIndex(0); float temperatureC = sensors.getTempCByIndex(0);
lcd.setCursor(13, 3); lcd.setCursor(13, 3);
lcd.write(byte(0)); lcd.write(byte(0));
if (temperatureC == DEVICE_DISCONNECTED_C) { if (temperatureC == DEVICE_DISCONNECTED_C)
{
lcd.print("--"); lcd.print("--");
} else { }
else
{
lcd.print(temperatureC, 1); lcd.print(temperatureC, 1);
lcd.print("C"); lcd.print("C");
} }
vTaskDelete(NULL); // Delete the task when done vTaskDelete(NULL); // Delete the task when done
} }

View File

@ -6,7 +6,8 @@
#include "esp_task_wdt.h" #include "esp_task_wdt.h"
// Disable the watchdog timers // Disable the watchdog timers
void disableWatchdogTimers() { void disableWatchdogTimers()
{
esp_task_wdt_deinit(); esp_task_wdt_deinit();
TaskHandle_t idle_0 = xTaskGetIdleTaskHandleForCPU(0); TaskHandle_t idle_0 = xTaskGetIdleTaskHandleForCPU(0);
TaskHandle_t idle_1 = xTaskGetIdleTaskHandleForCPU(1); TaskHandle_t idle_1 = xTaskGetIdleTaskHandleForCPU(1);