Nella dichiarazione di struttura.
Sicuro?
Ok, non funziona neanche a me, ma si tratta di un risultato non atteso e deriva dal fatto che long timeArray[27] viene dichiarato e inizializzato a tempo di compilazione (compile-time), mentre la funzione void assignParameters() viene eseguita a tempo di esecuzione (run-time). Se ci fai caso tutti gli indici che usano cycleArray[progIndex] stampano zero.
SFOGO {
Poi perché scrivete cose per cacciarvi nei guai da soli.
}
Ok, io preferisco la seguente dichiarazione che mi permette
di aggiungere commenti:
// il compilatore conta meglio di me e non serve [27].
long timeArray[] = {
K
, 1.5 * K
, cycleArray[progIndex].prewashDuration1
, cycleArray[progIndex].heatedPrewash * timeToHeat(cycleArray[progIndex].prewashTemp)
, cycleArray[progIndex].prewashDuration2 * K
, K
, 1.5 * K
, cycleArray[progIndex].washTime1 * K
, timeToHeat(45)
, cycleArray[progIndex].washTime2 * K
, cycleArray[progIndex].secondHeating * timeToHeat(cycleArray[progIndex].secondHeatingTemp - 45 )
, cycleArray[progIndex].washTime3 * K
, cycleArray[progIndex].thirdHeating * timeToHeat(cycleArray[progIndex].thirdHeatingTemp - cycleArray[progIndex].secondHeatingTemp)
, cycleArray[progIndex].washTime4 * K, 2.5 * K
, 1.5 * K
, cycleArray[progIndex].rinse1Duration * K
, K
, 1.5 * K
, cycleArray[progIndex].rinse2Duration * K
, K
, 1.5 * K
, timeToHeat(cycleArray[progIndex].rinse3Temp)
, cycleArray[progIndex].rinse3Duration * K
, K
, cycleArray[progIndex].dryingDuration * K
, K //drying
};
Per stampare ho usato questo:
for (byte i=0; i<27; i++) {
Serial.print(i);
Serial.print("\t");
Serial.println(timeArray[i]);
}
L'output è questo:
0 60000
1 90000
2 0
3 0
4 0
5 60000
6 90000
7 0
8 840000
9 0
10 0
11 0
12 0
13 0
14 150000
15 90000
16 0
17 60000
18 90000
19 0
20 60000
21 90000
22 -216000
23 0
24 60000
25 0
26 60000
Ciao.
puoi postare il codice completo?
l'inizializzazione di timeArray dovrebbe essere eseguita con una funzione o non terrà conto dei valori che cambiano di progIndex
Come detto non funziona ed è normale che non funzioni.
Qui il link a progetto su wokwi.
PS: salvatevi il progetto, perché fra una settimana non lo trovate più.
PS1: cercando con google "lavastoviglie con Arduino"
ho trovato questo torbidimetro
Ciao.
Nel rispetto del tuo lavoro, del nostro tempo e nell'interesse di risolvere questo mistero, mi asterrò dal tentare di aiutare le persone che lo cercano su questo pezzo di Internet. Stammi bene.
@Standardoil ti ringrazio, ho corretto l'errore, doveva essere un byte
@Maurotec come posso risolvere questo problema della esecuzione in momenti diversi? Come dovrei riscrivere il codice?
@J-M-L l codice completo è il seguente:
file principale:
#include "SevenSegmentTM1637.h"
#include "controlPanel.h"
#include "StateMachine.h"
#include "cycleProperties.h"*/
#include <Wire.h>
void setup() {
Wire.begin(); // (SDA=A4,SCL=A5)
Serial.begin(115200);
display.begin(); // initializes the display
display.setBacklight(75);
display.clear();
delay(200);
}
void loop() {
Serial.println(calculateTime(progIndex));
delay(2000);
}
file stateMachine (in base ai pulsanti premuti decide in che stato entrare, ad esempio pausa o avvio ciclo)
#ifndef statemachine_h
#define statemachine_h
/*
STATE 0: program selection possible
STATE 1: cycle started and running
STATE 2: cycle paused
STATE 3: cycle ended
STATE 4: set salt
STATE 5: set rinse aid
STATE 6: service mode
STATE 7: programming mode
STATE 8: blocking error mode (eg. faulty drain pump)
*/
#define PROGSELECTION 0
#define CYCLERUNNING 1
#define CYCLEPAUSED 2
#define CYCLEENDED 3
#define SETSALT 4
#define SETRINSEAID 5
#define SERVICEMODE 6
#define PROGRAMMINGMODE 7
#define BLOCKINGERRORMODE 8
byte currentMacroState = 0;
void setState() {
switch (currentMacroState) {//program selection stage, selection possible as long as start is not pressed
case 0:
controlPanel();
if (controlPCF() == B11101111) { //start button pressed -> start the wash cycle
currentMacroState = CYCLERUNNING;
}
break;
case 1:
Serial.println("Washing");
if (controlPCF() == B11101111) { //pause button pressed -> pause the wash program
currentMacroState = CYCLEPAUSED;
}
delay(1000);
break;
case 2:
Serial.println("Paused");
if (controlPCF() == B11101111) { //start button pressed -> resume the wash cycle
currentMacroState = CYCLERUNNING;
}
delay(1000);
break;
case 3:
display.clear();
display.setCursor(1, 1);
display.print("End");
delay(100);
break;
}
}
#endif
file controlPanel (usa un PCF8574 per leggere dei pulsanti e scrivere dei LED (ad es. opzioni o mancanza sale e brillantante)
#ifndef controlPanel_h
#define controlPanel_h
#include "SevenSegmentTM1637.h"
#include <Wire.h>
#include <Arduino.h>
#define clockPin 8
#define dIOPin 9
#define PROG_SEL_BTN B11111110
#define ECO_DRY_BTN B11111101
#define HALF_LOAD_BTN B11111011
#define SUPER_WASH_BTN B11110111
#define DELAY_TIMER_BTN B11101111
#define START_BTN B11011111
byte PCF_address = 0x20;
byte progIndex = 0;
byte delayTime = 0;
byte reading;
byte controlPanelState = 0;
bool isCompatible[2][8] = {{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 0, 1, 0, 0},
};
SevenSegmentTM1637 display(clockPin, dIOPin);
byte prevControlPanelState = 0;
bool ecoDry = false;
bool halfLoad = false;
bool delayTimeLED = false;
byte prevReading = B11111111;
bool startCycle = false;
bool prevEcoDry = false;
bool prevHalfLoad = false;
//SIMPLIFIED FUNCTION TO WRITE TO PCF8574
void writePCF(uint8_t bits)
{
Wire.beginTransmission(PCF_address);
Wire.write(bits);
Wire.endTransmission();
}
//FUNCTION TO CONTROL LEDs ON THE CONTROL PANEL
void controlLED() {
byte bits = B11111111;
bitWrite(bits, 1, !ecoDry);
bitWrite(bits, 2, !halfLoad);
bitWrite(bits, 3, !delayTimeLED);
writePCF(bits);
}
//FUNCTION TO READ BUTTONS FROM THE CONTROL PANEL
byte checkButtons() {
writePCF(B11111111); // PCF8574 require us to set all outputs to 1 before doing a read.
Wire.beginTransmission(0x20);
Wire.requestFrom(0x20, 1); // Ask for 1 byte from slave
byte bits = Wire.read(); // read that one byte
Wire.endTransmission();
//Serial.println(bits, BIN);
//if (bits != prevReading) {
// prevReading = bits;
return bits;
//}
}
//FUNCTION TO IMPLEMENT READING BUTTONS (20 TIMES A SECOND) AND READING LEDs
byte controlPCF()//scrive i led, poi 20 volte al secondo fa un check del pulsante
{
static unsigned long lastButtonCheck = millis();
if (millis() - lastButtonCheck >= 50) {
lastButtonCheck = millis();
return checkButtons();
}
controlLED();
}
void errorFunction(byte fromState) {//based on the button that triggered the error, the leds will be blinked (eg. ecoDry -> ecoDry led flashes)
static unsigned long lastBlink;
static byte counter = 0;
if (millis() - lastBlink < 500) {
display.clear();
display.setCursor(1, 1);
display.setColonOn(false);
display.print("Err");
switch (fromState) {
case 1:
ecoDry = 1;
break;
case 2:
halfLoad = 1;
break;
}
} else if (millis() - lastBlink < 1000) {
display.clear();
ecoDry = prevEcoDry;
halfLoad = prevHalfLoad;
} else {
lastBlink = millis();
counter++;
}
if (counter == 4) {
counter = 0;
controlPanelState = prevControlPanelState;
ecoDry = prevEcoDry;
halfLoad = prevHalfLoad;
}
}
void setButtonPresses(bool &ecoDry, bool &halfLoad) {
static unsigned long lastButtonRead = millis();
static byte prevButtonReading = 0b11111111;
reading = controlPCF();
if (reading != prevButtonReading && reading != B11111111) {
switch (reading) {
case PROG_SEL_BTN: //program selection button
controlPanelState = 0;
prevControlPanelState = 0;
if (progIndex < 8) {
progIndex++;
ecoDry = false;
halfLoad = false;
}
else
{
progIndex = 1;
}
break;
case ECO_DRY_BTN: //eco dry button pressed
if (isCompatible[0][progIndex - 1] == 1) {
controlPanelState = 1;
ecoDry = !ecoDry;
prevEcoDry = true;
}
else
{
controlPanelState = 5;
prevEcoDry = false;
}
break;
case HALF_LOAD_BTN: //half load button pressed
if (isCompatible[1][progIndex - 1] == 1) {
controlPanelState = 2;
halfLoad = !halfLoad;
prevHalfLoad = true;
}
else
{
controlPanelState = 6;
prevHalfLoad=false;
}
break;
case DELAY_TIMER_BTN: //delayTimeLED button pressed
controlPanelState = 4;
prevControlPanelState = 4;
if (delayTime < 24) {
delayTime++;
}
else
{
delayTime = 0;
}
if (delayTime > 0) {
delayTimeLED = 1;
}
else {
delayTimeLED = 0;
}
break;
case START_BTN: //start button pressed
!startCycle;
break;
}
}
prevButtonReading = reading;
}
void controlPanel() {
static unsigned long lastPanelUpdate = millis();
setButtonPresses(ecoDry, halfLoad);
if (millis() - lastPanelUpdate > 250) {
switch (controlPanelState) {
case 0:
display.clear();
display.setColonOn(true);
display.setCursor(1, 1);
display.print("P ");
display.setCursor(1, 3);
display.print(progIndex);
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
display.clear();
display.setCursor(1, 1);
display.print("h");
display.setColonOn(true);
if (delayTime < 10) {
display.setCursor(1, 3);
}
else
{
display.setCursor(1, 2);
}
display.print(delayTime);
break;
case 5:
errorFunction(1);
break;
case 6:
errorFunction(2);
break;
case 7:
display.clear();
display.setColonOn(true);
display.print(" ---");
break;
}
lastPanelUpdate = millis();
}
}
#endif
file cycleProperties (quello postato sopra, definisce le proprietà dei cicli come la presenza o meno di alcune fasi, la temperatura, la durata ecc. ecc.)
#ifndef cycleproperties_h
#define cycleproperties_h
#define numOfPrograms 8
#define K 60000UL //convert from minutes to millis
#define heatK 2.5 //increase of temperature every minute
#define inletWaterTemp 10 //°C
/*
PROGRAM CYCLES ORDER
1: RINSE AND HOLD
2: INTENSIVE 70°C
3: NORMAL 65°C
4: ECO 55°C
5: 1h 65°C
6: GLASSWARE 45°C
7: QUICK 45°C
8: PLATEWARMER
*/
typedef struct Cycle {
byte startPhase = 0;
bool heatedPrewash = 0;
byte prewashTemp = inletWaterTemp ;
byte prewashDuration1 = 0; //in minutes
byte prewashDuration2 = 0;
byte washTemp = inletWaterTemp;
byte washTime1 = 0; //in minutes //cold wash
byte washTime2 = 0; //in minutes //wash at 45°C
byte washTime3 = 0; //in minutes //wash at temp 2 (eg. 55°C)
byte washTime4 = 0; // in minutes //wash at final temp (eg. 65°C)
bool secondHeating = 0; //reheat water yes or no
byte secondHeatingTemp = inletWaterTemp;
bool thirdHeating = 0;
byte thirdHeatingTemp = inletWaterTemp;
bool withRinse1 = 0;
bool heatedRinse1 = 0;
byte rinse1Duration = 0;
bool withRinse2 = 0;
bool heatedRinse2 = 0;
byte rinse2Duration = 0;
bool heatedRinse3 = 0;
byte rinse3Duration = 0;
byte rinse3Temp = inletWaterTemp;
byte dryingDuration = 0;
byte endPhase = 27;
};
Cycle cycleArray[numOfPrograms];
void assignParameters() {
//PREWASH / RINSE AND HOLD / SOAK PROGRAM
cycleArray[0].startPhase = 0;
cycleArray[0].heatedPrewash = false;
cycleArray[0].prewashDuration1 = 10;//minutes
cycleArray[0].endPhase = 6;//last phase run before ending the cycle (prewash only)
//1h 65°C
cycleArray[4].startPhase = 6;//first phase of the cycle (prewash skipped)
cycleArray[4].washTemp = 45;
cycleArray[4].washTime1 = 2; //cold water
cycleArray[4].washTime2 = 4; //at 45°C
cycleArray[4].secondHeating = true;
cycleArray[4].secondHeatingTemp = 65;
cycleArray[4].washTime3 = 1; //at 65°C
cycleArray[4].withRinse1 = true;
cycleArray[4].heatedRinse1 = true;
cycleArray[4].rinse1Duration = 5; //minutes
cycleArray[4].heatedRinse3 = true;
cycleArray[4].rinse3Temp = 55;
cycleArray[4].rinse3Duration = 2; //minutes
cycleArray[4].dryingDuration = 5;
cycleArray[4].endPhase = 27;//last phase run before ending the cycle (no drying)
//QUICK 45°C
cycleArray[6].startPhase = 6;//first phase of the cycle (prewash skipped)
cycleArray[6].washTemp = 45;
cycleArray[6].washTime2 = 2;//at 45°C
cycleArray[6].withRinse1 = true;
cycleArray[6].rinse1Duration = 4;//minutes
cycleArray[6].heatedRinse3 = true;
cycleArray[6].rinse3Temp = 50;//minutes
cycleArray[6].endPhase = 25;//last phase run before ending the cycle (no drying)
}
/* FUNCTIONS AND TIME CALCULATION */
long timeToHeat(byte temp) {
return (K * (temp - inletWaterTemp) / heatK);
}
long timeArray[27] = {K, 1.5 * K , cycleArray[progIndex].prewashDuration1 * K, cycleArray[progIndex].heatedPrewash * timeToHeat(cycleArray[progIndex].prewashTemp), cycleArray[progIndex].prewashDuration2 * K, //prewash
K, 1.5 * K, cycleArray[progIndex].washTime1 * K, timeToHeat(45), cycleArray[progIndex].washTime2 * K, cycleArray[progIndex].secondHeating * timeToHeat(cycleArray[progIndex].secondHeatingTemp - 45 ),
cycleArray[progIndex].washTime3 * K, cycleArray[progIndex].thirdHeating * timeToHeat(cycleArray[progIndex].thirdHeatingTemp - cycleArray[progIndex].secondHeatingTemp),
cycleArray[progIndex].washTime4 * K, 2.5 * K, //mainwash
1.5 * K, cycleArray[progIndex].rinse1Duration * K, K, //first rinse
1.5 * K, cycleArray[progIndex].rinse2Duration * K, K, //second rinse
1.5 * K, timeToHeat(cycleArray[progIndex].rinse3Temp), cycleArray[progIndex].rinse3Duration * K, K, //third and final rinse
cycleArray[progIndex].dryingDuration * K, K //drying
};
long calculateTime(byte progIndex) {
long totalTime = 0;
assignParameters();
for (int i = cycleArray[progIndex].startPhase; i < cycleArray[progIndex].endPhase; i++) {
totalTime += timeArray[i];
Serial.println("Time array value pos ");
Serial.print (i);
Serial.print ("= ");
Serial.println(timeArray[i]);
}
Serial.println(totalTime);
return totalTime;
}
#endif
L'importate che è capire ciò che viene risolto dal compilatore al momento della compilazione e ciò che invece accade durante l'esecuzione del programma.
Questo punto è focale per non inciampare nuovamente.
Il consiglio che ti do al momento non è radicale.
Sarà radicale il cambiamento dell'applicazione finale, ma ci
arriverai per gradi.
Per adesso si tratta di scrivere codice di test per fare eseguire un lavaggio, cioè basta un solo programma per sketch. La versione definitiva dovrebbe avere una istanza di struct (o anche classe) che è il programma selezionato il quale attende la chiamata alla funzione start(). I dati relativi ad ogni programma possono stare in memoria flash o in eeprom. In eeprom c'è il vantaggio che se hai un programmatore hardware tramite ISP puoi scrivere la eeprom da PC. Quando l'utente seleziona il programma, si popola l'istanza del lavaggio corrente (la struct o classe) leggendo i dati da eeprom (o flash).
Io penso che sia proprio il caso di fare eseguire un lavaggio di tipo più complesso possibile e che questo ci dice come modellare la classe.
Per finire dai uno lettura al mio blog, in particolare come aggiornare le informazioni sul display tramite sprintf, per evitare sfarfallio.
[EDIT] Scusa o postato troppo presto e non ho letto il codice completo.
Ciao.
@Mattia9914: per evitare problemi ... assumo che tutto questo discorso sia solo per un "modellino" di lavatrice funzionante a bassissima tensione e NON per una reale lavatrice di casa.
Se è per un "modellino" a bassissima tensione, fatto per scopi didattici, si può proseguire, se invece fosse per una reale lavatrice dovrei immediatamente chiudere il thread, sia perché sarebbe in violazione del REGOLAMENTO, punto 15 e seguenti, sia perché, legalmente, NON è permesso manomettere apparecchi commerciali/industriali.
Quindi, cortesemnete, confermami che si tratta solo di un'applicazione didattica per far funzionare un "modellino" di lavatrice che opra esclusivamente a bassissima tensione. Grazie.
Guglielmo
Certo Guglielmo, si tratta di un modello dove al posto di pompa, pressostati ed elettrovalvole collegherò semplicemente dei LED
Grazie mille per la conferma ... si può proseguire ![]()
Guglielmo
Mauro perdona ma non ti seguo, cosa dovrei fare?
La struct (non ho mai lavorato con le classi) saprei già come definirla, qui un esempio di programma lungo e completo
Bene finché non si parla di 230Vac è un modellino, per cui proseguiamo. Ho aggiornato il programmino su wokwi, dove ho aggiunto una funzione per inizializzare l'array timeArray a run-time.
Ciao.
Mauro ti ringrazio moltissimo per la pazienza che stai dimostrando
Provo a modificare il codice e vediamo cosa viene fuori
Prego, ma interessa anche me.
Ciao.
FUNZIONA! ![]()
#ifndef cycleproperties_h
#define cycleproperties_h
#define numOfPrograms 8
#define K 60000UL //convert from minutes to millis
#define heatK 2.5 //increase of temperature every minute
#define inletWaterTemp 10 //°C
/*
PROGRAM CYCLES ORDER
1: RINSE AND HOLD
2: INTENSIVE 70°C
3: NORMAL 65°C
4: ECO 55°C
5: 1h 65°C
6: GLASSWARE 45°C
7: QUICK 45°C
8: PLATEWARMER
*/
typedef struct Cycle {
byte startPhase = 0;
bool heatedPrewash = 0;
byte prewashTemp = inletWaterTemp ;
byte prewashDuration1 = 0; //in minutes
byte prewashDuration2 = 0;
byte washTemp = inletWaterTemp;
byte washTime1 = 0; //in minutes //cold wash
byte washTime2 = 0; //in minutes //wash at 45°C
byte washTime3 = 0; //in minutes //wash at temp 2 (eg. 55°C)
byte washTime4 = 0; // in minutes //wash at final temp (eg. 65°C)
bool secondHeating = 0; //reheat water yes or no
byte secondHeatingTemp = inletWaterTemp;
bool thirdHeating = 0;
byte thirdHeatingTemp = inletWaterTemp;
bool withRinse1 = 0;
bool heatedRinse1 = 0;
byte rinse1Duration = 0;
bool withRinse2 = 0;
bool heatedRinse2 = 0;
byte rinse2Duration = 0;
bool heatedRinse3 = 0;
byte rinse3Duration = 0;
byte rinse3Temp = inletWaterTemp;
byte dryingDuration = 0;
byte endPhase = 27;
};
Cycle cycleArray[numOfPrograms];
void assignParameters() {
//PREWASH / RINSE AND HOLD / SOAK PROGRAM
cycleArray[0].startPhase = 0;
cycleArray[0].heatedPrewash = false;
cycleArray[0].prewashDuration1 = 10;//minutes
cycleArray[0].endPhase = 6;//last phase run before ending the cycle (prewash only)
//1h 65°C
cycleArray[4].startPhase = 6;//first phase of the cycle (prewash skipped)
cycleArray[4].washTemp = 45;
cycleArray[4].washTime1 = 2; //cold water
cycleArray[4].washTime2 = 4; //at 45°C
cycleArray[4].secondHeating = true;
cycleArray[4].secondHeatingTemp = 65;
cycleArray[4].washTime3 = 1; //at 65°C
cycleArray[4].withRinse1 = true;
cycleArray[4].heatedRinse1 = true;
cycleArray[4].rinse1Duration = 5; //minutes
cycleArray[4].heatedRinse3 = true;
cycleArray[4].rinse3Temp = 55;
cycleArray[4].rinse3Duration = 2; //minutes
cycleArray[4].dryingDuration = 5;
cycleArray[4].endPhase = 27;//last phase run before ending the cycle (no drying)
//QUICK 45°C
cycleArray[6].startPhase = 6;//first phase of the cycle (prewash skipped)
cycleArray[6].washTemp = 45;
cycleArray[6].washTime2 = 2;//at 45°C
cycleArray[6].withRinse1 = true;
cycleArray[6].rinse1Duration = 4;//minutes
cycleArray[6].heatedRinse3 = true;
cycleArray[6].rinse3Temp = 50;//minutes
cycleArray[6].endPhase = 25;//last phase run before ending the cycle (no drying)
}
/* FUNCTIONS AND TIME CALCULATION */
long timeToHeat(byte temp) {
return (K * (temp - inletWaterTemp) / heatK);
}
long timeArray[27];
void initTimeArray () {
Cycle cycle = cycleArray[progIndex];
timeArray[0] = K; //first drain
timeArray[1] = 1.5 * K; //prewash water fill
timeArray[2] = cycle.prewashDuration1 * K; // prewash with cold water
timeArray[3] = cycle.heatedPrewash * timeToHeat(cycle.prewashTemp); //prewash heating phase
timeArray[4] = cycle.prewashDuration2 * K; //prewash in hot water
timeArray[5] = K; //prewash drain
timeArray[6] = 1.5 * K; //mainwash fill
timeArray[7] = cycle.washTime1 * K; //wash in cold water
timeArray[8] = timeToHeat(45); //heat to 45°C
timeArray[9] = cycle.washTime2 * K; //wash at 45°C
timeArray[10] = cycle.secondHeating * timeToHeat(cycle.secondHeatingTemp - 45 ); // heat to second temperature (eg. 55°C for enzymes)
timeArray[11] = cycle.washTime3 * K; //wash at second temperature
timeArray[12] = cycle.thirdHeating * timeToHeat(cycle.thirdHeatingTemp - cycle.secondHeatingTemp);// heat at third temperature (eg. 65°C for whitening agents)
timeArray[13] = cycle.washTime4 * K; //wash at final temperature
timeArray[14] = 2.5 * K; //drain and filter flush
timeArray[15] = 1.5 * K; //fill for first rinse
timeArray[16] = cycle.rinse1Duration * K; //rinse 1
timeArray[17] = K; //drain first rinse water
timeArray[18] = 1.5 * K; //fill for second rinse
timeArray[19] = cycle.rinse2Duration * K; //rinse 2
timeArray[20] = 2.5 * K; //drain second rinse water and filter flush
timeArray[21] = 1.5 * K; //fill for final rinse
timeArray[22] = timeToHeat(cycle.rinse3Temp); //heat water to desired temperature
timeArray[23] = cycle.rinse3Duration * K; //rinse with hot water
timeArray[24] = K;//drain final rinse water
timeArray[25] = cycle.dryingDuration * K; //drying stage
timeArray[26] = K;//final drain
}
long calculateTime(byte progIndex) {
long totalTime = 0;
assignParameters();
initTimeArray();
for (byte i = 0; i < sizeof(timeArray) / sizeof(long); i++) {
Serial.print(i);
Serial.print("\t");
Serial.println(timeArray[i]);
}
}
#endif
Grazie ancora Mauro per la pazienza
Domanda: il software così è già predisposto per gli 8 programmi, giusto?
Si sembra predisposto per gli otto programmi, però non sono sceso nel dettaglio, non so se si dovranno fare porcherie per gestire le differenze tra gli otto programmi oppure si riesce a continuare. In sostanza se l'architettura software che hai messo in piedi e solida, robusta e flessibile lo puoi scoprire solo continuando su questa strada.
Riguardo alle classi, ti stupirai, controlla il link al progetto e vedrai come ho trasformato la struct in class.
Così:
class Cycle {
public:
byte prewashDuration1 = 0; //in minutes
};
Ovviamente avere variabili pubbliche per una classe è cosa sconsigliata, infatti era solo per mostrare che con il C++ di arduino struct e class sono dei contenitori di base molto simili. La differenza è che i membri di struct sono tutti pubblici, mentre i membri di class possono essere pubblici, privati o protetti.
Ciao.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
