1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-19 08:15:49 +00:00
Files
esphome/esphome/components/lcd_base/lcd_display.h
Otto Winter 8e75980ebd Cleanup dashboard JS (#491)
* Cleanup dashboard JS

* Add vscode

* Save start_mark/end_mark

* Updates

* Updates

* Remove need for cv.nameable

It's a bit hacky but removes so much bloat from integrations

* Add enum helper

* Document APIs, and Improvements

* Fixes

* Fixes

* Update PULL_REQUEST_TEMPLATE.md

* Updates

* Updates

* Updates
2019-04-22 21:56:30 +02:00

66 lines
2.1 KiB
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/core/defines.h"
#ifdef USE_TIME
#include "esphome/components/time/real_time_clock.h"
#endif
namespace esphome {
namespace lcd_base {
class LCDDisplay;
using lcd_writer_t = std::function<void(LCDDisplay &)>;
class LCDDisplay : public PollingComponent {
public:
void set_writer(lcd_writer_t &&writer) { this->writer_ = std::move(writer); }
void set_dimensions(uint8_t columns, uint8_t rows) {
this->columns_ = columns;
this->rows_ = rows;
}
void setup() override;
float get_setup_priority() const override;
void update() override;
void display();
/// Print the given text at the specified column and row.
void print(uint8_t column, uint8_t row, const char *str);
/// Print the given string at the specified column and row.
void print(uint8_t column, uint8_t row, const std::string &str);
/// Print the given text at column=0 and row=0.
void print(const char *str);
/// Print the given string at column=0 and row=0.
void print(const std::string &str);
/// Evaluate the printf-format and print the text at the specified column and row.
void printf(uint8_t column, uint8_t row, const char *format, ...) __attribute__((format(printf, 4, 5)));
/// Evaluate the printf-format and print the text at column=0 and row=0.
void printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
#ifdef USE_TIME
/// Evaluate the strftime-format and print the text at the specified column and row.
void strftime(uint8_t column, uint8_t row, const char *format, time::ESPTime time)
__attribute__((format(strftime, 4, 0)));
/// Evaluate the strftime-format and print the text at column=0 and row=0.
void strftime(const char *format, time::ESPTime time) __attribute__((format(strftime, 2, 0)));
#endif
protected:
virtual bool is_four_bit_mode() = 0;
virtual void write_n_bits(uint8_t value, uint8_t n) = 0;
virtual void send(uint8_t value, bool rs) = 0;
void command_(uint8_t value);
uint8_t columns_;
uint8_t rows_;
uint8_t *buffer_{nullptr};
lcd_writer_t writer_;
};
} // namespace lcd_base
} // namespace esphome