train_controller/lib/matrix_orbital/AdafruitVfdDisplay.cpp

65 lines
1.8 KiB
C++
Raw Normal View History

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) {
// 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() {
uint8_t blockCursorOn[] = {0xfe, 0x53};
m_lcdUart.write_raw(blockCursorOn, sizeof(blockCursorOn));
2025-01-27 08:29:11 -05:00
}
void AdafruitVfdDisplay::clearBlinker() {
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();
show();
uint8_t noAutoScroll[] = {0xFE, 0x52};
m_lcdUart.write_raw(noAutoScroll, sizeof(noAutoScroll));
2025-01-27 08:29:11 -05:00
}
void AdafruitVfdDisplay::clear() {
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() {
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() {
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) {
m_lcdUart.write(byte);
2025-01-27 08:29:11 -05:00
}
void AdafruitVfdDisplay::draw(const char* text) {
m_lcdUart.write(text);
2025-01-27 08:29:11 -05:00
}
void AdafruitVfdDisplay::setCursor(uint8_t col, uint8_t row) {
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));
}