25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

weight_controller.h 1.4KB

3 ay önce
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef WEIGHT_CONTROLLER_H
  2. #define WEIGHT_CONTROLLER_H
  3. #include <Arduino.h>
  4. class WeightController {
  5. private:
  6. String name;
  7. double val_min;
  8. double val_max;
  9. public:
  10. void init(String name, double min, double max);
  11. int compare(double weight) const;
  12. String get_name() const {
  13. return name;
  14. }
  15. double get_val_min() const {
  16. return val_min;
  17. }
  18. double get_val_max() const {
  19. return val_max;
  20. }
  21. void set_name(String name) {
  22. this->name = name;
  23. }
  24. void set_min(double min) {
  25. this->val_min = min;
  26. }
  27. void set_max(double max) {
  28. this->val_max = max;
  29. }
  30. };
  31. class WeightControllerPool {
  32. private:
  33. int max = 4;
  34. WeightController items[4];
  35. int current = 0;
  36. bool controller_displayed = false;
  37. public:
  38. void init() {
  39. items[0].init("9mm", 190, 200);
  40. items[1].init(".223", 0, 1);
  41. items[2].init("6.5", 200, 300);
  42. items[3].init(".308", 2, 3);
  43. }
  44. void set_item(int index, String name, double min, double max) {
  45. WeightController &controller = items[index];
  46. controller.set_name(name);
  47. controller.set_min(min);
  48. controller.set_max(max);
  49. }
  50. bool is_controller_displayed() const {
  51. return controller_displayed;
  52. }
  53. int get_max() const{
  54. return max;
  55. }
  56. void next();
  57. WeightController &get();
  58. WeightController &get(int index);
  59. };
  60. #endif