2025-01-27 08:29:11 -05:00
|
|
|
#include "AdafruitVfdDisplay.hpp"
|
|
|
|
|
|
|
|
AdafruitVfdDisplay::AdafruitVfdDisplay(UART& lcdUart) : m_lcdUart{lcdUart} {}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::createChar(uint8_t id, uint8_t* c) {
|
|
|
|
|
2025-02-09 14:57:02 -05:00
|
|
|
// todo: prolly doesnt work
|
|
|
|
uint8_t createChar[] = {0xfe, 0x4e, id};
|
|
|
|
m_lcdUart.write_raw(createChar, sizeof(createChar));
|
|
|
|
m_lcdUart.write_raw(c, 8);
|
2025-01-27 08:29:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::drawBlinker() {
|
2025-02-09 14:57:02 -05:00
|
|
|
uint8_t blockCursorOn[] = {0xfe, 0x53};
|
|
|
|
m_lcdUart.write_raw(blockCursorOn, sizeof(blockCursorOn));
|
2025-01-27 08:29:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::clearBlinker() {
|
2025-02-09 14:57:02 -05:00
|
|
|
uint8_t blockCursorOff[] = {0xfe, 0x54};
|
|
|
|
m_lcdUart.write_raw(blockCursorOff, sizeof(blockCursorOff));
|
2025-01-27 08:29:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::begin() {
|
|
|
|
delay(500);
|
|
|
|
clear();
|
2025-02-09 14:57:02 -05:00
|
|
|
show();
|
|
|
|
uint8_t noAutoScroll[] = {0xFE, 0x52};
|
|
|
|
m_lcdUart.write_raw(noAutoScroll, sizeof(noAutoScroll));
|
2025-01-27 08:29:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::clear() {
|
2025-02-09 14:57:02 -05:00
|
|
|
uint8_t clearCmd[] = {0xfe, 0x58, 0xfe, 0x48};
|
2025-01-27 08:29:11 -05:00
|
|
|
m_lcdUart.write_raw(clearCmd, sizeof(clearCmd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::show() {
|
2025-02-09 14:57:02 -05:00
|
|
|
uint8_t dispOn[] = {0xfe, 42};
|
|
|
|
m_lcdUart.write_raw(dispOn, sizeof(dispOn));
|
|
|
|
uint8_t brightnessUp[] = {0xfe, 0x99, 100};
|
|
|
|
m_lcdUart.write_raw(brightnessUp, sizeof(brightnessUp));
|
2025-01-27 08:29:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::hide() {
|
2025-02-09 14:57:02 -05:00
|
|
|
uint8_t dispOff[] = {0xfe, 0x46};
|
|
|
|
m_lcdUart.write_raw(dispOff, sizeof(dispOff));
|
2025-01-27 08:29:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::draw(uint8_t byte) {
|
2025-02-09 14:57:02 -05:00
|
|
|
m_lcdUart.write(byte);
|
2025-01-27 08:29:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::draw(const char* text) {
|
2025-02-09 14:57:02 -05:00
|
|
|
m_lcdUart.write(text);
|
2025-01-27 08:29:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::setCursor(uint8_t col, uint8_t row) {
|
2025-02-09 14:57:02 -05:00
|
|
|
uint8_t setCursorCmd[] = {0xfe, 0x47, col+1, row+1};
|
|
|
|
m_lcdUart.write_raw(setCursorCmd, sizeof(setCursorCmd));
|
2025-01-27 08:29:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdafruitVfdDisplay::setBacklight(bool enabled) {
|
|
|
|
uint8_t backlightCmd[] = {0xfe, 0x99, enabled ? 150 : 50};
|
|
|
|
m_lcdUart.write_raw(backlightCmd, sizeof(backlightCmd));
|
|
|
|
}
|