Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion components/byte90/include/byte90.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ class Byte90 : public BaseComponent {
/// \return A shared pointer to the display
std::shared_ptr<Display<Pixel>> display() const;

/// Get a shared pointer to the low-level display driver
/// \return A shared pointer to the display driver
const std::shared_ptr<DisplayDriver> &display_driver() const { return display_driver_; }

/// Set the brightness of the backlight
/// \param brightness The brightness of the backlight as a percentage (0 - 100)
void brightness(float brightness);
Expand Down Expand Up @@ -215,6 +219,17 @@ class Byte90 : public BaseComponent {
void write_lcd_frame(const uint16_t x, const uint16_t y, const uint16_t width,
const uint16_t height, uint8_t *data);

/// Write lines to the LCD
Comment thread
finger563 marked this conversation as resolved.
/// \param xs The x start coordinate
/// \param ys The y start coordinate
/// \param xe The x end coordinate
/// \param ye The y end coordinate
/// \param data The data to write
/// \param user_data User data to pass to the SPI transaction callback
/// \note This method queues the panel transfer asynchronously and may return
/// before the write has completed.
void write_lcd_lines(int xs, int ys, int xe, int ye, const uint8_t *data, uint32_t user_data);

protected:
Byte90();

Expand Down Expand Up @@ -330,7 +345,7 @@ class Byte90 : public BaseComponent {

// display
std::shared_ptr<Display<Pixel>> display_;
std::unique_ptr<DisplayDriver> display_driver_;
std::shared_ptr<DisplayDriver> display_driver_{static_cast<DisplayDriver *>(nullptr)};
static constexpr int spi_queue_size = 6;
std::unique_ptr<Spi> lcd_spi_;
std::unique_ptr<SpiPanelIo> lcd_;
Expand Down
37 changes: 36 additions & 1 deletion components/byte90/src/display.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "byte90.hpp"

#include <array>

using namespace espp;

////////////////////////
Expand Down Expand Up @@ -56,7 +58,7 @@ bool Byte90::initialize_lcd() {
return false;
}

display_driver_ = std::make_unique<DisplayDriver>(
display_driver_ = std::make_shared<DisplayDriver>(
espp::display_drivers::Config{.panel_io = lcd_.get(),
.write_command = nullptr,
.read_command = nullptr,
Expand Down Expand Up @@ -153,6 +155,39 @@ void Byte90::write_lcd_frame(const uint16_t xs, const uint16_t ys, const uint16_
}
}

void Byte90::write_lcd_lines(int xs, int ys, int xe, int ye, const uint8_t *data,
uint32_t user_data) {
if (!lcd_) {
return;
}
if (data == nullptr) {
logger_.error("lcd_send_lines: Null data for ({},{}) to ({},{})", xs, ys, xe, ye);
return;
}
Comment thread
finger563 marked this conversation as resolved.
if (xs < 0 || ys < 0 || xe < xs || ye < ys) {
logger_.error("lcd_send_lines: Bad region: ({},{}) to ({},{})", xs, ys, xe, ye);
return;
}
size_t width = static_cast<size_t>(xe - xs + 1);
size_t height = static_cast<size_t>(ye - ys + 1);
size_t length = width * height * lcd_bytes_per_pixel;
lcd_->wait();
std::array<uint8_t, 2> window = {
static_cast<uint8_t>(xs & 0xff),
static_cast<uint8_t>(xe & 0xff),
};
lcd_->queue_command(static_cast<uint8_t>(DisplayDriver::Command::caset));
lcd_->queue_data(window);
window = {
static_cast<uint8_t>(ys & 0xff),
static_cast<uint8_t>(ye & 0xff),
};
lcd_->queue_command(static_cast<uint8_t>(DisplayDriver::Command::raset));
lcd_->queue_data(window);
lcd_->queue_command(static_cast<uint8_t>(DisplayDriver::Command::ramwr));
lcd_->queue_pixels(data, length, user_data);
}

Byte90::Pixel *Byte90::vram0() const {
if (!display_) {
return nullptr;
Expand Down
17 changes: 16 additions & 1 deletion components/esp-box/include/esp-box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ class EspBox : public BaseComponent {
/// \return A shared pointer to the display
std::shared_ptr<Display<Pixel>> display() const { return display_; }

/// Get a shared pointer to the low-level display driver
/// \return A shared pointer to the display driver
const std::shared_ptr<DisplayDriver> &display_driver() const { return display_driver_; }

/// Set the brightness of the backlight
/// \param brightness The brightness of the backlight as a percentage (0 - 100)
/// \note This function will only work after initialize_lcd() has been called
Expand Down Expand Up @@ -234,6 +238,17 @@ class EspBox : public BaseComponent {
void write_lcd_frame(const uint16_t x, const uint16_t y, const uint16_t width,
const uint16_t height, uint8_t *data);

/// Write lines to the LCD
Comment thread
finger563 marked this conversation as resolved.
/// \param xs The x start coordinate
/// \param ys The y start coordinate
/// \param xe The x end coordinate
/// \param ye The y end coordinate
/// \param data The data to write
/// \param user_data User data to pass to the SPI transaction callback
/// \note This method queues the panel transfer asynchronously and may return
/// before the write has completed.
void write_lcd_lines(int xs, int ys, int xe, int ye, const uint8_t *data, uint32_t user_data);

/////////////////////////////////////////////////////////////////////////////
// Button
/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -502,7 +517,7 @@ class EspBox : public BaseComponent {
std::vector<Led::ChannelConfig> backlight_channel_configs_;
std::shared_ptr<Led> backlight_;
std::shared_ptr<Display<Pixel>> display_;
std::unique_ptr<DisplayDriver> display_driver_;
std::shared_ptr<DisplayDriver> display_driver_{static_cast<DisplayDriver *>(nullptr)};
std::unique_ptr<Spi> lcd_spi_;
std::unique_ptr<SpiPanelIo> lcd_;
uint8_t *frame_buffer0_{nullptr};
Expand Down
41 changes: 40 additions & 1 deletion components/esp-box/src/video.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "esp-box.hpp"

#include <array>

using namespace espp;

////////////////////////
Expand Down Expand Up @@ -65,7 +67,7 @@ bool EspBox::initialize_lcd() {
lcd_spi_.reset();
return false;
}
display_driver_ = std::make_unique<DisplayDriver>(
display_driver_ = std::make_shared<DisplayDriver>(
espp::display_drivers::Config{.panel_io = lcd_.get(),
.write_command = nullptr,
.read_command = nullptr,
Expand Down Expand Up @@ -167,6 +169,43 @@ void EspBox::write_lcd_frame(const uint16_t xs, const uint16_t ys, const uint16_
}
}

void EspBox::write_lcd_lines(int xs, int ys, int xe, int ye, const uint8_t *data,
uint32_t user_data) {
if (!lcd_) {
return;
}
if (data == nullptr) {
logger_.error("lcd_send_lines: Null data for ({},{}) to ({},{})", xs, ys, xe, ye);
return;
}
if (xs < 0 || ys < 0 || xe < xs || ye < ys) {
logger_.error("lcd_send_lines: Bad region: ({},{}) to ({},{})", xs, ys, xe, ye);
return;
}
Comment thread
finger563 marked this conversation as resolved.
size_t width = static_cast<size_t>(xe - xs + 1);
size_t height = static_cast<size_t>(ye - ys + 1);
size_t length = width * height * lcd_bytes_per_pixel;
lcd_->wait();
std::array<uint8_t, 4> window = {
Comment thread
finger563 marked this conversation as resolved.
static_cast<uint8_t>((xs >> 8) & 0xff),
static_cast<uint8_t>(xs & 0xff),
static_cast<uint8_t>((xe >> 8) & 0xff),
static_cast<uint8_t>(xe & 0xff),
};
lcd_->queue_command(static_cast<uint8_t>(DisplayDriver::Command::caset));
lcd_->queue_data(window);
window = {
static_cast<uint8_t>((ys >> 8) & 0xff),
static_cast<uint8_t>(ys & 0xff),
static_cast<uint8_t>((ye >> 8) & 0xff),
static_cast<uint8_t>(ye & 0xff),
};
lcd_->queue_command(static_cast<uint8_t>(DisplayDriver::Command::raset));
lcd_->queue_data(window);
lcd_->queue_command(static_cast<uint8_t>(DisplayDriver::Command::ramwr));
lcd_->queue_pixels(data, length, user_data);
}

EspBox::Pixel *EspBox::vram0() const {
if (!display_) {
return nullptr;
Expand Down
20 changes: 19 additions & 1 deletion components/m5stack-tab5/include/m5stack-tab5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class M5StackTab5 : public BaseComponent {
/// Alias for the pixel type used by the Tab5 display
using Pixel = lv_color16_t;

/// Alias for the low-level display driver interface
using DisplayDriver = espp::display_drivers::Controller;

/// Enum for display controller type
enum class DisplayController { UNKNOWN, ILI9881, ST7123 };

Expand Down Expand Up @@ -240,6 +243,21 @@ class M5StackTab5 : public BaseComponent {
/// \return The display height in pixels, according to the current orientation
size_t rotated_display_height() const;

/// Get a shared pointer to the low-level display driver
/// \return A shared pointer to the display driver
const std::shared_ptr<DisplayDriver> &display_driver() const { return display_driver_; }

/// Write lines to the LCD
Comment thread
finger563 marked this conversation as resolved.
/// \param xs The x start coordinate
/// \param ys The y start coordinate
/// \param xe The x end coordinate
/// \param ye The y end coordinate
/// \param data The data to write
/// \param user_data User data to pass to the lower-level transport
/// \note This method queues the panel transfer asynchronously and may return
/// before the write has completed.
void write_lcd_lines(int xs, int ys, int xe, int ye, const uint8_t *data, uint32_t user_data);

/////////////////////////////////////////////////////////////////////////////
// Audio System
/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -736,7 +754,7 @@ class M5StackTab5 : public BaseComponent {

// Display state
std::shared_ptr<Display<Pixel>> display_;
std::unique_ptr<display_drivers::Controller> display_driver_;
std::shared_ptr<DisplayDriver> display_driver_{static_cast<DisplayDriver *>(nullptr)};
std::shared_ptr<Led> backlight_;
std::vector<Led::ChannelConfig> backlight_channel_configs_;
struct LcdHandles {
Expand Down
17 changes: 15 additions & 2 deletions components/m5stack-tab5/src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ bool M5StackTab5::initialize_lcd() {
display_driver_.reset();
if (detected_controller == DisplayController::ILI9881) {
logger_.info("Initializing as ILI9881");
auto display_driver = std::make_unique<espp::Ili9881>(display_config);
auto display_driver = std::make_shared<espp::Ili9881>(display_config);
if (display_driver->initialize()) {
logger_.info("Successfully initialized ILI9881 display controller");
display_driver_ = std::move(display_driver);
display_controller_ = DisplayController::ILI9881;
}
} else if (detected_controller == DisplayController::ST7123) {
logger_.info("Initializing as ST7123");
auto display_driver = std::make_unique<espp::St7123>(display_config);
auto display_driver = std::make_shared<espp::St7123>(display_config);
if (display_driver->initialize()) {
logger_.info("Successfully initialized ST7123 display controller");
display_driver_ = std::move(display_driver);
Expand Down Expand Up @@ -333,6 +333,19 @@ size_t M5StackTab5::rotated_display_height() const {
}
}

void M5StackTab5::write_lcd_lines(int xs, int ys, int xe, int ye, const uint8_t *data,
uint32_t user_data) {
(void)user_data;
if (lcd_handles_.panel == nullptr || data == nullptr) {
return;
}
if (xs < 0 || ys < 0 || xe < xs || ye < ys) {
logger_.error("write_lcd_lines: Bad region: ({},{}) to ({},{})", xs, ys, xe, ye);
return;
}
esp_lcd_panel_draw_bitmap(lcd_handles_.panel, xs, ys, xe + 1, ye + 1, data);
}

void M5StackTab5::brightness(float brightness) {
brightness = std::clamp(brightness, 0.0f, 100.0f);
if (backlight_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ class MatouchRotaryDisplay : public BaseComponent {
/// \return A shared pointer to the display
std::shared_ptr<Display<Pixel>> display() const;

/// Get a shared pointer to the low-level display driver
/// \return A shared pointer to the display driver
const std::shared_ptr<DisplayDriver> &display_driver() const { return display_driver_; }

/// Set the brightness of the backlight
/// \param brightness The brightness of the backlight as a percentage (0 - 100)
/// \note This function will only work after initialize_lcd() has been called
Expand Down Expand Up @@ -236,6 +240,17 @@ class MatouchRotaryDisplay : public BaseComponent {
void write_lcd_frame(const uint16_t x, const uint16_t y, const uint16_t width,
const uint16_t height, uint8_t *data);

/// Write lines to the LCD
Comment thread
finger563 marked this conversation as resolved.
/// \param xs The x start coordinate
/// \param ys The y start coordinate
/// \param xe The x end coordinate
/// \param ye The y end coordinate
/// \param data The data to write
/// \param user_data User data to pass to the SPI transaction callback
/// \note This method queues the panel transfer asynchronously and may return
/// before the write has completed.
void write_lcd_lines(int xs, int ys, int xe, int ye, const uint8_t *data, uint32_t user_data);

protected:
MatouchRotaryDisplay();
bool update_cst816();
Expand Down Expand Up @@ -339,7 +354,7 @@ class MatouchRotaryDisplay : public BaseComponent {
std::shared_ptr<Display<Pixel>> display_;
std::vector<espp::Led::ChannelConfig> backlight_channel_configs_{};
std::shared_ptr<espp::Led> backlight_{};
std::unique_ptr<DisplayDriver> display_driver_;
std::shared_ptr<DisplayDriver> display_driver_{static_cast<DisplayDriver *>(nullptr)};
std::unique_ptr<Spi> lcd_spi_;
std::unique_ptr<SpiPanelIo> lcd_;
uint8_t *frame_buffer0_{nullptr};
Expand Down
41 changes: 40 additions & 1 deletion components/matouch-rotary-display/src/matouch-rotary-display.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "matouch-rotary-display.hpp"

#include <array>

using namespace espp;

MatouchRotaryDisplay::MatouchRotaryDisplay()
Expand Down Expand Up @@ -247,7 +249,7 @@ bool MatouchRotaryDisplay::initialize_lcd() {
lcd_spi_.reset();
return false;
}
display_driver_ = std::make_unique<DisplayDriver>(
display_driver_ = std::make_shared<DisplayDriver>(
espp::display_drivers::Config{.panel_io = lcd_.get(),
.write_command = nullptr,
.read_command = nullptr,
Expand Down Expand Up @@ -363,6 +365,43 @@ void MatouchRotaryDisplay::write_lcd_frame(const uint16_t xs, const uint16_t ys,
}
}

void MatouchRotaryDisplay::write_lcd_lines(int xs, int ys, int xe, int ye, const uint8_t *data,
uint32_t user_data) {
if (!lcd_) {
return;
}
if (data == nullptr) {
logger_.error("lcd_send_lines: Null data for ({},{}) to ({},{})", xs, ys, xe, ye);
return;
}
Comment thread
finger563 marked this conversation as resolved.
if (xs < 0 || ys < 0 || xe < xs || ye < ys) {
logger_.error("lcd_send_lines: Bad region: ({},{}) to ({},{})", xs, ys, xe, ye);
return;
}
size_t width = static_cast<size_t>(xe - xs + 1);
size_t height = static_cast<size_t>(ye - ys + 1);
size_t length = width * height * lcd_bytes_per_pixel;
lcd_->wait();
std::array<uint8_t, 4> window = {
static_cast<uint8_t>((xs >> 8) & 0xff),
static_cast<uint8_t>(xs & 0xff),
static_cast<uint8_t>((xe >> 8) & 0xff),
static_cast<uint8_t>(xe & 0xff),
};
lcd_->queue_command(static_cast<uint8_t>(DisplayDriver::Command::caset));
lcd_->queue_data(window);
window = {
static_cast<uint8_t>((ys >> 8) & 0xff),
static_cast<uint8_t>(ys & 0xff),
static_cast<uint8_t>((ye >> 8) & 0xff),
static_cast<uint8_t>(ye & 0xff),
};
lcd_->queue_command(static_cast<uint8_t>(DisplayDriver::Command::raset));
lcd_->queue_data(window);
lcd_->queue_command(static_cast<uint8_t>(DisplayDriver::Command::ramwr));
lcd_->queue_pixels(data, length, user_data);
}

MatouchRotaryDisplay::Pixel *MatouchRotaryDisplay::vram0() const {
if (!display_) {
return nullptr;
Expand Down
Loading
Loading