Compare commits
2 Commits
55d0548ea8
...
402e1f4e43
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
402e1f4e43 | ||
|
|
14592c6f55 |
@ -22,7 +22,8 @@ enum machine_state {
|
|||||||
DEBOUNCE,
|
DEBOUNCE,
|
||||||
HEATING,
|
HEATING,
|
||||||
HOT,
|
HOT,
|
||||||
BREWING,
|
BREWING_HOT,
|
||||||
|
BREWING_COLD,
|
||||||
COOLING,
|
COOLING,
|
||||||
PANIC_OVERHEAT,
|
PANIC_OVERHEAT,
|
||||||
};
|
};
|
||||||
@ -186,7 +187,7 @@ void proc_buttons(struct state *state, const struct input *input)
|
|||||||
|
|
||||||
int red_min = 50;
|
int red_min = 50;
|
||||||
int red_state = red_min;
|
int red_state = red_min;
|
||||||
unsigned long brewing_time = 3000UL; /* 3 seconds */
|
unsigned long brewing_max_time = 3000UL; /* 3 seconds */
|
||||||
unsigned long cooling_time = 3000UL; /* 3 seconds */
|
unsigned long cooling_time = 3000UL; /* 3 seconds */
|
||||||
unsigned long overheat_time = 10000UL; /* 10 seconds */
|
unsigned long overheat_time = 10000UL; /* 10 seconds */
|
||||||
unsigned long max_heating_time = 60000UL; /* 60 seconds */
|
unsigned long max_heating_time = 60000UL; /* 60 seconds */
|
||||||
@ -196,7 +197,7 @@ void proc_machine(struct state *st)
|
|||||||
{
|
{
|
||||||
float temp = st->ntc_T;
|
float temp = st->ntc_T;
|
||||||
int on = (st->btn[BTN_ON].state == RELEASED);
|
int on = (st->btn[BTN_ON].state == RELEASED);
|
||||||
int hot = (st->btn[BTN_HOT].state == PRESSED);
|
int brew_hot = (st->btn[BTN_HOT].state == PRESSED);
|
||||||
|
|
||||||
Serial.print("t=");
|
Serial.print("t=");
|
||||||
Serial.print(millis());
|
Serial.print(millis());
|
||||||
@ -223,7 +224,12 @@ void proc_machine(struct state *st)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (st->mstate == SLEEPING) {
|
if (st->mstate == SLEEPING) {
|
||||||
if (on) {
|
/* Allow brewing cold at without turning the heater */
|
||||||
|
/* FIXME: Use the cold button instead */
|
||||||
|
if (brew_hot) {
|
||||||
|
st->mstate = BREWING_COLD;
|
||||||
|
Serial.println("brewing cold");
|
||||||
|
} else if (on) {
|
||||||
st->mstate = HEATING;
|
st->mstate = HEATING;
|
||||||
st->heating_t0 = millis();
|
st->heating_t0 = millis();
|
||||||
Serial.println("heating");
|
Serial.println("heating");
|
||||||
@ -240,20 +246,28 @@ void proc_machine(struct state *st)
|
|||||||
Serial.println("cannot heat, going to sleep");
|
Serial.println("cannot heat, going to sleep");
|
||||||
}
|
}
|
||||||
} else if (st->mstate == HOT) {
|
} else if (st->mstate == HOT) {
|
||||||
if (hot) {
|
if (brew_hot) {
|
||||||
st->mstate = BREWING;
|
st->mstate = BREWING_HOT;
|
||||||
st->brewing_t0 = millis();
|
st->brewing_t0 = millis();
|
||||||
Serial.println("brewing");
|
Serial.println("brewing");
|
||||||
} else if (millis() - st->hot_t0 > max_idle_time) {
|
} else if (millis() - st->hot_t0 > max_idle_time) {
|
||||||
st->mstate = SLEEPING;
|
st->mstate = SLEEPING;
|
||||||
Serial.println("idle timeout, going to sleep");
|
Serial.println("idle timeout, going to sleep");
|
||||||
}
|
}
|
||||||
} else if (st->mstate == BREWING) {
|
} else if (st->mstate == BREWING_HOT) {
|
||||||
if (millis() - st->brewing_t0 > brewing_time) {
|
/* Stop brewing if no longer pressing the brew button or we
|
||||||
|
* exceed the brew max time */
|
||||||
|
if (!brew_hot || millis() - st->brewing_t0 > brewing_max_time) {
|
||||||
st->mstate = COOLING;
|
st->mstate = COOLING;
|
||||||
st->cooling_t0 = millis();
|
st->cooling_t0 = millis();
|
||||||
Serial.println("cooling");
|
Serial.println("cooling");
|
||||||
}
|
}
|
||||||
|
} else if (st->mstate == BREWING_COLD) {
|
||||||
|
/* FIXME: Use cold button instead */
|
||||||
|
if (!brew_hot) {
|
||||||
|
st->mstate = SLEEPING;
|
||||||
|
Serial.println("going back to sleeping after cold brewing");
|
||||||
|
}
|
||||||
} else if (st->mstate == COOLING) {
|
} else if (st->mstate == COOLING) {
|
||||||
/* TODO: Wait a bit and go back to heating */
|
/* TODO: Wait a bit and go back to heating */
|
||||||
if (millis() - st->cooling_t0 > cooling_time) {
|
if (millis() - st->cooling_t0 > cooling_time) {
|
||||||
@ -316,7 +330,7 @@ output_leds(const struct state *st)
|
|||||||
} else if (st->mstate == PANIC_OVERHEAT) {
|
} else if (st->mstate == PANIC_OVERHEAT) {
|
||||||
setled(PIN_LED_RED, 1);
|
setled(PIN_LED_RED, 1);
|
||||||
setled(PIN_LED_GREEN, 0);
|
setled(PIN_LED_GREEN, 0);
|
||||||
} else if (st->mstate == BREWING) {
|
} else if (st->mstate == BREWING_HOT || st->mstate == BREWING_COLD) {
|
||||||
setled(PIN_LED_RED, 0);
|
setled(PIN_LED_RED, 0);
|
||||||
analogWrite(PIN_LED_GREEN, g);
|
analogWrite(PIN_LED_GREEN, g);
|
||||||
if (g >= 255)
|
if (g >= 255)
|
||||||
@ -333,7 +347,7 @@ output_leds(const struct state *st)
|
|||||||
void
|
void
|
||||||
output_heater(const struct state *st)
|
output_heater(const struct state *st)
|
||||||
{
|
{
|
||||||
if (st->mstate == HEATING || st->mstate == HOT || st->mstate == BREWING) {
|
if (st->mstate == HEATING || st->mstate == HOT || st->mstate == BREWING_HOT) {
|
||||||
if (st->ntc_T < TEMP_MIN)
|
if (st->ntc_T < TEMP_MIN)
|
||||||
relay(PIN_HEAT, ON);
|
relay(PIN_HEAT, ON);
|
||||||
else if (st->ntc_T > TEMP_MAX)
|
else if (st->ntc_T > TEMP_MAX)
|
||||||
@ -346,7 +360,7 @@ output_heater(const struct state *st)
|
|||||||
void
|
void
|
||||||
output_pump(const struct state *st)
|
output_pump(const struct state *st)
|
||||||
{
|
{
|
||||||
if (st->mstate == BREWING)
|
if (st->mstate == BREWING_HOT || st->mstate == BREWING_COLD)
|
||||||
relay(PIN_PUMP, ON);
|
relay(PIN_PUMP, ON);
|
||||||
else
|
else
|
||||||
relay(PIN_PUMP, OFF);
|
relay(PIN_PUMP, OFF);
|
||||||
@ -356,6 +370,7 @@ void do_output(const struct state *st)
|
|||||||
{
|
{
|
||||||
output_leds(st);
|
output_leds(st);
|
||||||
output_heater(st);
|
output_heater(st);
|
||||||
|
output_pump(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
|
|||||||
1770
barista/data/brew.csv
Normal file
1770
barista/data/brew.csv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user