Skip to content
Snippets Groups Projects
Commit 94f04368 authored by Jens Nolte's avatar Jens Nolte
Browse files

Implement basic character lcd support

parent dac7defd
No related branches found
No related tags found
No related merge requests found
#include "lcd.h"
#include "mqtt.h"
#include <vector>
#include <sstream>
#include "Arduino.h"
#include "LiquidCrystal.h"
const uint8_t rs = 22, en = 23, d4 = 5, d5 = 18, d6 = 19, d7 = 21;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
LiquidCrystal lcd(-1, -1, -1, -1, -1, -1);
void enable_lcd(const std::string& topic, uint8_t rs, uint8_t en, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) {
lcd = LiquidCrystal(rs, en, d4, d5, d6, d7);
void add_lcd(const std::string& topic) {
lcd.begin(16, 2);
lcd.clear();
lcd.print("qthing");
lcd.setCursor(0, 1);
lcd.print("Hello World!");
add_message_callback(topic, [](std::string message) {
lcd.clear();
std::istringstream stream(message);
std::string line;
std::getline(stream, line);
lcd.setCursor(0,0);
lcd.print(message.c_str());
lcd.setCursor(0,1);
lcd.print(message.c_str());
lcd.print(line.c_str());
if (std::getline(stream, line)) {
lcd.setCursor(0,1);
lcd.print(line.c_str());
}
});
}
#ifndef LCD_H
#define LCD_H
#include <string>
void add_lcd(const std::string& topic);
#endif
\ No newline at end of file
#endif
......@@ -55,6 +55,8 @@ void add_button(gpio_num_t gpio, std::function<void()> on_press = NULL, std::fun
void add_button(gpio_num_t gpio, std::string topic, std::string message);
void add_relay(const std::string& topic, gpio_num_t gpio_off, gpio_num_t gpio_on);
void enable_lcd(const std::string& topic, uint8_t rs, uint8_t en, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
// event handler
void add_wlan_connection_status_handler(connection_status_callback_t handler);
void add_mqtt_connection_status_handler(connection_status_callback_t handler);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment