Adafruit character display basics are working with LcdMenu library
This commit is contained in:
parent
d9f03d0a2d
commit
9f1ce934e4
5 changed files with 142 additions and 36 deletions
|
@ -2,47 +2,60 @@
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
void AdafruitVfdDisplay::drawBlinker() {
|
||||
|
||||
uint8_t blockCursorOn[] = {0xfe, 0x53};
|
||||
m_lcdUart.write_raw(blockCursorOn, sizeof(blockCursorOn));
|
||||
}
|
||||
|
||||
void AdafruitVfdDisplay::clearBlinker() {
|
||||
|
||||
uint8_t blockCursorOff[] = {0xfe, 0x54};
|
||||
m_lcdUart.write_raw(blockCursorOff, sizeof(blockCursorOff));
|
||||
}
|
||||
|
||||
void AdafruitVfdDisplay::begin() {
|
||||
delay(500);
|
||||
clear();
|
||||
show();
|
||||
uint8_t noAutoScroll[] = {0xFE, 0x52};
|
||||
m_lcdUart.write_raw(noAutoScroll, sizeof(noAutoScroll));
|
||||
}
|
||||
|
||||
void AdafruitVfdDisplay::clear() {
|
||||
uint8_t clearCmd[] = {0xfe, 0x58};
|
||||
uint8_t clearCmd[] = {0xfe, 0x58, 0xfe, 0x48};
|
||||
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));
|
||||
}
|
||||
|
||||
void AdafruitVfdDisplay::hide() {
|
||||
|
||||
uint8_t dispOff[] = {0xfe, 0x46};
|
||||
m_lcdUart.write_raw(dispOff, sizeof(dispOff));
|
||||
}
|
||||
|
||||
void AdafruitVfdDisplay::draw(uint8_t byte) {
|
||||
|
||||
m_lcdUart.write(byte);
|
||||
}
|
||||
|
||||
void AdafruitVfdDisplay::draw(const char* text) {
|
||||
|
||||
m_lcdUart.write(text);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void AdafruitVfdDisplay::setBacklight(bool enabled) {
|
||||
|
|
|
@ -21,15 +21,24 @@ class AdafruitVfdDisplay : public CharacterDisplayInterface {
|
|||
void clearBlinker() override;
|
||||
void begin() override;
|
||||
void clear() override;
|
||||
|
||||
/// @brief turn display on, showing previously displayed text
|
||||
void show() override;
|
||||
|
||||
/// @brief turn display off so text is no longer visible (but still present).
|
||||
void hide() override;
|
||||
void draw(uint8_t byte) override;
|
||||
void draw(const char* text) override;
|
||||
|
||||
/// @brief Move display cursor to specified position
|
||||
/// TODO: 0 based or 1-based col/row position???
|
||||
/// @param col
|
||||
/// @param row
|
||||
void setCursor(uint8_t col, uint8_t row) override;
|
||||
void setBacklight(bool enabled) override;
|
||||
|
||||
private:
|
||||
UART m_lcdUart;
|
||||
UART &m_lcdUart;
|
||||
};
|
||||
|
||||
#endif /* __ADAFRUITVFDDISPINTERFACE_H__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue