-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbottle_filler.h
More file actions
76 lines (56 loc) · 1.93 KB
/
bottle_filler.h
File metadata and controls
76 lines (56 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Couleurs 8bits
// https://www.rapidtables.com/web/color/RGB_Color.html
// Pins
const uint8_t pin_SDA = 16;
const uint8_t pin_SCL = 17;
const int pwmPin = 26; // GPIO de sortie (ex: 26, 25, 19... éviter 34-39 car entrée seule)
// PWM parameters
const int pwmChannel = 0; // Canal PWM (0-15)
const int pwmFreq = 10000; // Fréquence : 10 kHz
const int pwmResolution = 10; // Résolution : 10 bits (0-1023)
const int low_duty = 70; // Résolution : 10 bits (0-1023)
const int full_duty = 100; // Résolution : 10 bits (0-1023)
int last_percent_duty;
// Bottle parameters
int bottle_position_x, bottle_position_y, D1, D2, H1, HG, H2;
int b, ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy, gx, gy, hx, hy;
int i = 0;
float poids = 0.0, old_poids = 0.0, poids_bouteille = 0.0, poids_final = 0.0, poids_estime = 0.0, old_poids_estime = 0.0, max_tmp_h = 0.0;
float mg_to_fill = 0.0;
float bottle_scaling = 1.7;
// Elements pour UI
#define TFT_GREY 0x5AEB
#define TFT_RED_STOP 0xE36D // Red boutton stop color
#define TFT_BEER 0xD9840D // Beer color
const int transparent_color = 0x0120;
float kf_weight;
// Fifo
float moving_average;
float last_moving_average;
float moving_average_sum;
float lastDrawnWeight;
float lastDrawnAverage;
float currentWeight;
float weight;
// scale and NAU702 Parameters
float scale, offset;
int calib_weight;
int raw_data;
bool calibrationInProgress;
float bottle_weight;
float ml_to_fill;
float old_beer_height, new_beer_height;
int fill_percentage, last_fill_percentage;
int nb_values_read;
float saved_beer_gravity;
int saved_calib_weight;
float beer_gravity;
constexpr int SCALE_SPS = 40;
constexpr int MAX_FIFO_SIZE = SCALE_SPS;
String bottle_size;
constexpr float BOTTLE_33CL_MIN = 190.0f;
constexpr float BOTTLE_33CL_MAX = 265.0f;
constexpr float BOTTLE_50CL_MIN = 265.0f;
constexpr float BOTTLE_50CL_MAX = 430.0f;
constexpr float BOTTLE_75CL_MIN = 500.0f;
constexpr float BOTTLE_75CL_MAX = 600.0f;