Files
evaluation/esp32_readout/display.cpp
2025-04-13 22:55:55 +02:00

37 lines
934 B
C++

#include "display.h"
#include <Adafruit_SharpMem.h>
Display::Display() {
this->_display = new Adafruit_SharpMem(SHARP_SCK, SHARP_MOSI, SHARP_SS, DISPLAY_HEIGHT, DISPLAY_WIDTH);
this->mid_x = DISPLAY_WIDTH / 2;
this->mid_y = DISPLAY_HEIGHT / 2;
}
void Display::setup() {
// start & clear the display
this->_display->begin();
this->_display->clearDisplay();
this->_display->setRotation(2);
this->_display->setTextColor(BLACK, WHITE);
this->_display->setTextSize(FONT_SIZE);
this->_display->setFont(FONT);
this->print("Smaage");
}
void Display::print(const char* text) {
this->_display->clearDisplay();
this->_display->setCursor(12, this->mid_x);
this->_display->println(text);
this->_display->refresh();
}
void Display::print_weight(double val) {
this->_display->clearDisplay();
this->_display->setCursor(12, this->mid_x);
this->_display->printf("%.2f g", val);
this->_display->refresh();
}