|
- #include "lcd.h"
-
- LCD::LCD() {}
-
- LCD::~LCD() {
- delete lcd;
- }
-
- void LCD::init() {
- lcd = new LiquidCrystal_I2C(0x27, columns, rows);
- lcd->init();
- lcd->backlight();
- lcd->setBacklight(HIGH);
- }
-
- void LCD::print_init_message(int calibration_weight) const {
- lcd->setCursor(0, 0);
- lcd->print(F("YCM Scale"));
- lcd->setCursor(0, 1);
- lcd->print(F("Scaled to: "));
- lcd->print(calibration_weight);
- lcd->print(F("g"));
- delay(1500);
- }
-
- void LCD::print_calibration(int calib_weight) const {
- lcd->setCursor(0, 1);
- lcd->print("Calibration: ");
- lcd->print(calib_weight);
- lcd->print(" g");
- delay(800);
- clear_row(1);
- }
-
- void LCD::print_weight(double weight, int precision, const char* unit) const {
- //
- // MAKE SURE NEGATIVE AND POSITIVE VALUES DON'T JUMP
- //
- if (weight > 0) {
- lcd->print(" ");
- }
-
- //
- // PRINT
- //
- lcd->print(weight, precision);
- lcd->print(" ");
- lcd->print(unit);
- }
-
- void LCD::print_weights(double grams, double grains) const {
- lcd->setCursor(0, 0);
- print_weight(grams, 3, "g ");
- lcd->setCursor(0, 1);
- print_weight(grains, 2, "grn ");
- }
-
- void LCD::print_control_result(String name, double val_min, double val_max, int result) {
- lcd->setCursor(0, 0);
- lcd->print(name);
- lcd->print(" ");
- lcd->print(val_min, 2);
- lcd->print("-");
- lcd->print(val_max, 2);
-
- lcd->setCursor(0, 1);
-
- if (result == -1) {
- lcd->print("TOO LITTLE");
- }
- else if (result == 1) {
- lcd->print("TOO MUCH ");
- }
- else {
- lcd->print("PASSED ");
- }
- }
-
- void LCD::clear_row(int row) const {
- lcd->setCursor(0, row);
- for (int i = 0; i < columns; i++) {
- lcd->print(" ");
- }
- lcd->setCursor(0, row);
- }
-
- void LCD::clear() const {
- lcd->clear();
- }
|