|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #ifndef WEIGHT_CONTROLLER_H
- #define WEIGHT_CONTROLLER_H
-
- #include <Arduino.h>
-
- class WeightController {
- private:
- String name;
- double val_min;
- double val_max;
-
- public:
- void init(String name, double min, double max);
- int compare(double weight) const;
-
- String get_name() const {
- return name;
- }
-
- double get_val_min() const {
- return val_min;
- }
-
- double get_val_max() const {
- return val_max;
- }
-
- void set_name(String name) {
- this->name = name;
- }
-
- void set_min(double min) {
- this->val_min = min;
- }
-
- void set_max(double max) {
- this->val_max = max;
- }
- };
-
- class WeightControllerPool {
- private:
- int max = 4;
- WeightController items[4];
-
- int current = 0;
- bool controller_displayed = false;
-
- public:
- void init() {
- items[0].init("9mm", 190, 200);
- items[1].init(".223", 0, 1);
- items[2].init("6.5", 200, 300);
- items[3].init(".308", 2, 3);
- }
-
- void set_item(int index, String name, double min, double max) {
- WeightController &controller = items[index];
- controller.set_name(name);
- controller.set_min(min);
- controller.set_max(max);
- }
-
- bool is_controller_displayed() const {
- return controller_displayed;
- }
-
- int get_max() const{
- return max;
- }
-
- void next();
- WeightController &get();
- WeightController &get(int index);
- };
-
- #endif
|