|
- #include "weight_controller.h"
-
- void WeightController::init(String name, double min, double max) {
- this->name = name;
- this->val_min = min;
- this->val_max = max;
- }
-
- int WeightController::compare(double weight) const {
- if (val_min > weight) {
- return -1;
- }
- else if (val_max < weight) {
- return 1;
- }
- return 0;
- }
-
-
- void WeightControllerPool::next() {
- if (current == 0) {
- controller_displayed = true;
- }
-
- current++;
- if (current - 1 >= max) {
- controller_displayed = false;
- current = 0;
- }
- }
-
- WeightController& WeightControllerPool::get() {
- return items[current - 1];
- }
-
- WeightController& WeightControllerPool::get(int index) {
- if (index < 0) {
- return items[0];
- }
- else if (index > max) {
- return items[max];
- }
-
- return items[index];
- }
|