For now only the proportional (Kp) and derivative (Kd) components are used, the integral term is 0.
40 lines
753 B
C
40 lines
753 B
C
/* Copyright (c) 2025 Rodrigo Arias Mallo <rodarima@gmail.com>
|
|
* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
|
|
#ifndef BARISTA_HEATER_H
|
|
#define BARISTA_HEATER_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
enum heater_state {
|
|
HEATER_OFF = 0,
|
|
HEATER_ON,
|
|
};
|
|
|
|
enum heater_cycle {
|
|
CYCLE_ON = 0,
|
|
CYCLE_OFF,
|
|
};
|
|
|
|
struct heater {
|
|
enum heater_state st;
|
|
enum heater_cycle cycle;
|
|
unsigned long t0_on; /* current cycle time on */
|
|
unsigned long t0_off; /* current cycle time off */
|
|
|
|
/* Next cycle */
|
|
unsigned long next_on_dt; /* in ms */
|
|
};
|
|
|
|
void heater_on(struct heater *h, unsigned long t_ms, float duty);
|
|
void heater_off(struct heater *h);
|
|
int heater_state(struct heater *h, unsigned long t_ms);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* BARISTA_HEATER_H */
|