Add display_type property to DisplayBuffer (#3430)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
guillempages 2022-06-03 05:39:04 +02:00 committed by GitHub
parent 6349b5f654
commit d0dda48932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 43 additions and 0 deletions

View File

@ -40,6 +40,8 @@ class AddressableLightDisplay : public display::DisplayBuffer, public PollingCom
void setup() override; void setup() override;
void display(); void display();
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
protected: protected:
int get_width_internal() override; int get_width_internal() override;
int get_height_internal() override; int get_height_internal() override;

View File

@ -85,6 +85,12 @@ enum ImageType {
IMAGE_TYPE_RGB565 = 4, IMAGE_TYPE_RGB565 = 4,
}; };
enum DisplayType {
DISPLAY_TYPE_BINARY = 1,
DISPLAY_TYPE_GRAYSCALE = 2,
DISPLAY_TYPE_COLOR = 3,
};
enum DisplayRotation { enum DisplayRotation {
DISPLAY_ROTATION_0_DEGREES = 0, DISPLAY_ROTATION_0_DEGREES = 0,
DISPLAY_ROTATION_90_DEGREES = 90, DISPLAY_ROTATION_90_DEGREES = 90,
@ -361,6 +367,11 @@ class DisplayBuffer {
virtual int get_width_internal() = 0; virtual int get_width_internal() = 0;
DisplayRotation get_rotation() const { return this->rotation_; } DisplayRotation get_rotation() const { return this->rotation_; }
/** Get the type of display that the buffer corresponds to. In case of dynamically configurable displays,
* returns the type the display is currently configured to.
*/
virtual DisplayType get_display_type() = 0;
protected: protected:
void vprintf_(int x, int y, Font *font, Color color, TextAlign align, const char *format, va_list arg); void vprintf_(int x, int y, Font *font, Color color, TextAlign align, const char *format, va_list arg);

View File

@ -48,6 +48,8 @@ class ILI9341Display : public PollingComponent,
this->initialize(); this->initialize();
} }
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
protected: protected:
void draw_absolute_pixel_internal(int x, int y, Color color) override; void draw_absolute_pixel_internal(int x, int y, Color color) override;
void setup_pins_(); void setup_pins_();

View File

@ -86,6 +86,10 @@ class Inkplate6 : public PollingComponent, public display::DisplayBuffer, public
void block_partial() { this->block_partial_ = true; } void block_partial() { this->block_partial_ = true; }
display::DisplayType get_display_type() override {
return get_greyscale() ? display::DisplayType::DISPLAY_TYPE_GRAYSCALE : display::DisplayType::DISPLAY_TYPE_BINARY;
}
protected: protected:
void draw_absolute_pixel_internal(int x, int y, Color color) override; void draw_absolute_pixel_internal(int x, int y, Color color) override;
void display1b_(); void display1b_();

View File

@ -93,6 +93,8 @@ class MAX7219Component : public PollingComponent,
uint8_t strftimedigit(const char *format, time::ESPTime time) __attribute__((format(strftime, 2, 0))); uint8_t strftimedigit(const char *format, time::ESPTime time) __attribute__((format(strftime, 2, 0)));
#endif #endif
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_BINARY; }
protected: protected:
void send_byte_(uint8_t a_register, uint8_t data); void send_byte_(uint8_t a_register, uint8_t data);
void send_to_all_(uint8_t a_register, uint8_t data); void send_to_all_(uint8_t a_register, uint8_t data);

View File

@ -52,6 +52,8 @@ class PCD8544 : public PollingComponent,
this->initialize(); this->initialize();
} }
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_BINARY; }
protected: protected:
void draw_absolute_pixel_internal(int x, int y, Color color) override; void draw_absolute_pixel_internal(int x, int y, Color color) override;

View File

@ -48,6 +48,8 @@ class SSD1306 : public PollingComponent, public display::DisplayBuffer {
float get_setup_priority() const override { return setup_priority::PROCESSOR; } float get_setup_priority() const override { return setup_priority::PROCESSOR; }
void fill(Color color) override; void fill(Color color) override;
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_BINARY; }
protected: protected:
virtual void command(uint8_t value) = 0; virtual void command(uint8_t value) = 0;
virtual void write_display_data() = 0; virtual void write_display_data() = 0;

View File

@ -30,6 +30,8 @@ class SSD1322 : public PollingComponent, public display::DisplayBuffer {
float get_setup_priority() const override { return setup_priority::PROCESSOR; } float get_setup_priority() const override { return setup_priority::PROCESSOR; }
void fill(Color color) override; void fill(Color color) override;
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_GRAYSCALE; }
protected: protected:
virtual void command(uint8_t value) = 0; virtual void command(uint8_t value) = 0;
virtual void data(uint8_t value) = 0; virtual void data(uint8_t value) = 0;

View File

@ -35,6 +35,8 @@ class SSD1325 : public PollingComponent, public display::DisplayBuffer {
float get_setup_priority() const override { return setup_priority::PROCESSOR; } float get_setup_priority() const override { return setup_priority::PROCESSOR; }
void fill(Color color) override; void fill(Color color) override;
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_BINARY; }
protected: protected:
virtual void command(uint8_t value) = 0; virtual void command(uint8_t value) = 0;
virtual void write_display_data() = 0; virtual void write_display_data() = 0;

View File

@ -30,6 +30,8 @@ class SSD1327 : public PollingComponent, public display::DisplayBuffer {
float get_setup_priority() const override { return setup_priority::PROCESSOR; } float get_setup_priority() const override { return setup_priority::PROCESSOR; }
void fill(Color color) override; void fill(Color color) override;
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_GRAYSCALE; }
protected: protected:
virtual void command(uint8_t value) = 0; virtual void command(uint8_t value) = 0;
virtual void write_display_data() = 0; virtual void write_display_data() = 0;

View File

@ -25,6 +25,8 @@ class SSD1331 : public PollingComponent, public display::DisplayBuffer {
float get_setup_priority() const override { return setup_priority::PROCESSOR; } float get_setup_priority() const override { return setup_priority::PROCESSOR; }
void fill(Color color) override; void fill(Color color) override;
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
protected: protected:
virtual void command(uint8_t value) = 0; virtual void command(uint8_t value) = 0;
virtual void write_display_data() = 0; virtual void write_display_data() = 0;

View File

@ -31,6 +31,8 @@ class SSD1351 : public PollingComponent, public display::DisplayBuffer {
float get_setup_priority() const override { return setup_priority::PROCESSOR; } float get_setup_priority() const override { return setup_priority::PROCESSOR; }
void fill(Color color) override; void fill(Color color) override;
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
protected: protected:
virtual void command(uint8_t value) = 0; virtual void command(uint8_t value) = 0;
virtual void data(uint8_t value) = 0; virtual void data(uint8_t value) = 0;

View File

@ -53,6 +53,8 @@ class ST7735 : public PollingComponent,
void set_dc_pin(GPIOPin *value) { dc_pin_ = value; } void set_dc_pin(GPIOPin *value) { dc_pin_ = value; }
size_t get_buffer_length(); size_t get_buffer_length();
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
protected: protected:
void sendcommand_(uint8_t cmd, const uint8_t *data_bytes, uint8_t num_data_bytes); void sendcommand_(uint8_t cmd, const uint8_t *data_bytes, uint8_t num_data_bytes);
void senddata_(const uint8_t *data_bytes, uint8_t num_data_bytes); void senddata_(const uint8_t *data_bytes, uint8_t num_data_bytes);

View File

@ -126,6 +126,8 @@ class ST7789V : public PollingComponent,
void write_display_data(); void write_display_data();
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
protected: protected:
GPIOPin *dc_pin_; GPIOPin *dc_pin_;
GPIOPin *reset_pin_{nullptr}; GPIOPin *reset_pin_{nullptr};

View File

@ -29,6 +29,8 @@ class ST7920 : public PollingComponent,
void fill(Color color) override; void fill(Color color) override;
void write_display_data(); void write_display_data();
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_BINARY; }
protected: protected:
void draw_absolute_pixel_internal(int x, int y, Color color) override; void draw_absolute_pixel_internal(int x, int y, Color color) override;
int get_height_internal() override; int get_height_internal() override;

View File

@ -36,6 +36,8 @@ class WaveshareEPaper : public PollingComponent,
void on_safe_shutdown() override; void on_safe_shutdown() override;
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_BINARY; }
protected: protected:
void draw_absolute_pixel_internal(int x, int y, Color color) override; void draw_absolute_pixel_internal(int x, int y, Color color) override;