mirror of
https://github.com/esphome/esphome.git
synced 2026-05-30 23:54:04 +08:00
[mipi_dsi] Allow transform disable; fix warnings (#14216)
This commit is contained in:
committed by
Jesse Hills
parent
4b57ac3236
commit
efa39ae591
@@ -39,6 +39,7 @@ import esphome.config_validation as cv
|
|||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_COLOR_ORDER,
|
CONF_COLOR_ORDER,
|
||||||
CONF_DIMENSIONS,
|
CONF_DIMENSIONS,
|
||||||
|
CONF_DISABLED,
|
||||||
CONF_ENABLE_PIN,
|
CONF_ENABLE_PIN,
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
CONF_INIT_SEQUENCE,
|
CONF_INIT_SEQUENCE,
|
||||||
@@ -88,7 +89,8 @@ COLOR_DEPTHS = {
|
|||||||
def model_schema(config):
|
def model_schema(config):
|
||||||
model = MODELS[config[CONF_MODEL].upper()]
|
model = MODELS[config[CONF_MODEL].upper()]
|
||||||
model.defaults[CONF_SWAP_XY] = cv.UNDEFINED
|
model.defaults[CONF_SWAP_XY] = cv.UNDEFINED
|
||||||
transform = cv.Schema(
|
transform = cv.Any(
|
||||||
|
cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Required(CONF_MIRROR_X): cv.boolean,
|
cv.Required(CONF_MIRROR_X): cv.boolean,
|
||||||
cv.Required(CONF_MIRROR_Y): cv.boolean,
|
cv.Required(CONF_MIRROR_Y): cv.boolean,
|
||||||
@@ -96,6 +98,8 @@ def model_schema(config):
|
|||||||
"Axis swapping not supported by DSI displays"
|
"Axis swapping not supported by DSI displays"
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
),
|
||||||
|
cv.one_of(CONF_DISABLED, lower=True),
|
||||||
)
|
)
|
||||||
# CUSTOM model will need to provide a custom init sequence
|
# CUSTOM model will need to provide a custom init sequence
|
||||||
iseqconf = (
|
iseqconf = (
|
||||||
@@ -199,9 +203,9 @@ async def to_code(config):
|
|||||||
cg.add(var.set_vsync_pulse_width(config[CONF_VSYNC_PULSE_WIDTH]))
|
cg.add(var.set_vsync_pulse_width(config[CONF_VSYNC_PULSE_WIDTH]))
|
||||||
cg.add(var.set_vsync_back_porch(config[CONF_VSYNC_BACK_PORCH]))
|
cg.add(var.set_vsync_back_porch(config[CONF_VSYNC_BACK_PORCH]))
|
||||||
cg.add(var.set_vsync_front_porch(config[CONF_VSYNC_FRONT_PORCH]))
|
cg.add(var.set_vsync_front_porch(config[CONF_VSYNC_FRONT_PORCH]))
|
||||||
cg.add(var.set_pclk_frequency(int(config[CONF_PCLK_FREQUENCY] / 1e6)))
|
cg.add(var.set_pclk_frequency(config[CONF_PCLK_FREQUENCY] / 1.0e6))
|
||||||
cg.add(var.set_lanes(int(config[CONF_LANES])))
|
cg.add(var.set_lanes(int(config[CONF_LANES])))
|
||||||
cg.add(var.set_lane_bit_rate(int(config[CONF_LANE_BIT_RATE] / 1e6)))
|
cg.add(var.set_lane_bit_rate(config[CONF_LANE_BIT_RATE] / 1.0e6))
|
||||||
if reset_pin := config.get(CONF_RESET_PIN):
|
if reset_pin := config.get(CONF_RESET_PIN):
|
||||||
reset = await cg.gpio_pin_expression(reset_pin)
|
reset = await cg.gpio_pin_expression(reset_pin)
|
||||||
cg.add(var.set_reset_pin(reset))
|
cg.add(var.set_reset_pin(reset))
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ void MIPI_DSI::dump_config() {
|
|||||||
"\n Swap X/Y: %s"
|
"\n Swap X/Y: %s"
|
||||||
"\n Rotation: %d degrees"
|
"\n Rotation: %d degrees"
|
||||||
"\n DSI Lanes: %u"
|
"\n DSI Lanes: %u"
|
||||||
"\n Lane Bit Rate: %uMbps"
|
"\n Lane Bit Rate: %.0fMbps"
|
||||||
"\n HSync Pulse Width: %u"
|
"\n HSync Pulse Width: %u"
|
||||||
"\n HSync Back Porch: %u"
|
"\n HSync Back Porch: %u"
|
||||||
"\n HSync Front Porch: %u"
|
"\n HSync Front Porch: %u"
|
||||||
@@ -385,7 +385,7 @@ void MIPI_DSI::dump_config() {
|
|||||||
"\n Display Pixel Mode: %d bit"
|
"\n Display Pixel Mode: %d bit"
|
||||||
"\n Color Order: %s"
|
"\n Color Order: %s"
|
||||||
"\n Invert Colors: %s"
|
"\n Invert Colors: %s"
|
||||||
"\n Pixel Clock: %dMHz",
|
"\n Pixel Clock: %.1fMHz",
|
||||||
this->model_, this->width_, this->height_, YESNO(this->madctl_ & (MADCTL_XFLIP | MADCTL_MX)),
|
this->model_, this->width_, this->height_, YESNO(this->madctl_ & (MADCTL_XFLIP | MADCTL_MX)),
|
||||||
YESNO(this->madctl_ & (MADCTL_YFLIP | MADCTL_MY)), YESNO(this->madctl_ & MADCTL_MV), this->rotation_,
|
YESNO(this->madctl_ & (MADCTL_YFLIP | MADCTL_MY)), YESNO(this->madctl_ & MADCTL_MV), this->rotation_,
|
||||||
this->lanes_, this->lane_bit_rate_, this->hsync_pulse_width_, this->hsync_back_porch_,
|
this->lanes_, this->lane_bit_rate_, this->hsync_pulse_width_, this->hsync_back_porch_,
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class MIPI_DSI : public display::Display {
|
|||||||
|
|
||||||
void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
|
void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
|
||||||
void set_enable_pins(std::vector<GPIOPin *> enable_pins) { this->enable_pins_ = std::move(enable_pins); }
|
void set_enable_pins(std::vector<GPIOPin *> enable_pins) { this->enable_pins_ = std::move(enable_pins); }
|
||||||
void set_pclk_frequency(uint32_t pclk_frequency) { this->pclk_frequency_ = pclk_frequency; }
|
void set_pclk_frequency(float pclk_frequency) { this->pclk_frequency_ = pclk_frequency; }
|
||||||
int get_width_internal() override { return this->width_; }
|
int get_width_internal() override { return this->width_; }
|
||||||
int get_height_internal() override { return this->height_; }
|
int get_height_internal() override { return this->height_; }
|
||||||
void set_hsync_back_porch(uint16_t hsync_back_porch) { this->hsync_back_porch_ = hsync_back_porch; }
|
void set_hsync_back_porch(uint16_t hsync_back_porch) { this->hsync_back_porch_ = hsync_back_porch; }
|
||||||
@@ -58,7 +58,7 @@ class MIPI_DSI : public display::Display {
|
|||||||
void set_vsync_front_porch(uint16_t vsync_front_porch) { this->vsync_front_porch_ = vsync_front_porch; }
|
void set_vsync_front_porch(uint16_t vsync_front_porch) { this->vsync_front_porch_ = vsync_front_porch; }
|
||||||
void set_init_sequence(const std::vector<uint8_t> &init_sequence) { this->init_sequence_ = init_sequence; }
|
void set_init_sequence(const std::vector<uint8_t> &init_sequence) { this->init_sequence_ = init_sequence; }
|
||||||
void set_model(const char *model) { this->model_ = model; }
|
void set_model(const char *model) { this->model_ = model; }
|
||||||
void set_lane_bit_rate(uint16_t lane_bit_rate) { this->lane_bit_rate_ = lane_bit_rate; }
|
void set_lane_bit_rate(float lane_bit_rate) { this->lane_bit_rate_ = lane_bit_rate; }
|
||||||
void set_lanes(uint8_t lanes) { this->lanes_ = lanes; }
|
void set_lanes(uint8_t lanes) { this->lanes_ = lanes; }
|
||||||
void set_madctl(uint8_t madctl) { this->madctl_ = madctl; }
|
void set_madctl(uint8_t madctl) { this->madctl_ = madctl; }
|
||||||
|
|
||||||
@@ -95,8 +95,8 @@ class MIPI_DSI : public display::Display {
|
|||||||
uint16_t vsync_front_porch_ = 10;
|
uint16_t vsync_front_porch_ = 10;
|
||||||
const char *model_{"Unknown"};
|
const char *model_{"Unknown"};
|
||||||
std::vector<uint8_t> init_sequence_{};
|
std::vector<uint8_t> init_sequence_{};
|
||||||
uint16_t pclk_frequency_ = 16; // in MHz
|
float pclk_frequency_ = 16; // in MHz
|
||||||
uint16_t lane_bit_rate_{1500}; // in Mbps
|
float lane_bit_rate_{1500}; // in Mbps
|
||||||
uint8_t lanes_{2}; // 1, 2, 3 or 4 lanes
|
uint8_t lanes_{2}; // 1, 2, 3 or 4 lanes
|
||||||
|
|
||||||
bool invert_colors_{};
|
bool invert_colors_{};
|
||||||
|
|||||||
@@ -22,6 +22,23 @@ display:
|
|||||||
id: p4_86
|
id: p4_86
|
||||||
model: "WAVESHARE-P4-86-PANEL"
|
model: "WAVESHARE-P4-86-PANEL"
|
||||||
rotation: 180
|
rotation: 180
|
||||||
|
- platform: mipi_dsi
|
||||||
|
model: custom
|
||||||
|
id: custom_id
|
||||||
|
dimensions:
|
||||||
|
width: 400
|
||||||
|
height: 1280
|
||||||
|
hsync_back_porch: 40
|
||||||
|
hsync_pulse_width: 30
|
||||||
|
hsync_front_porch: 40
|
||||||
|
vsync_back_porch: 20
|
||||||
|
vsync_pulse_width: 10
|
||||||
|
vsync_front_porch: 20
|
||||||
|
pclk_frequency: 48Mhz
|
||||||
|
lane_bit_rate: 1.2Gbps
|
||||||
|
rotation: 180
|
||||||
|
transform: disabled
|
||||||
|
init_sequence:
|
||||||
i2c:
|
i2c:
|
||||||
sda: GPIO7
|
sda: GPIO7
|
||||||
scl: GPIO8
|
scl: GPIO8
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ def test_code_generation(
|
|||||||
in main_cpp
|
in main_cpp
|
||||||
)
|
)
|
||||||
assert "set_init_sequence({224, 1, 0, 225, 1, 147, 226, 1," in main_cpp
|
assert "set_init_sequence({224, 1, 0, 225, 1, 147, 226, 1," in main_cpp
|
||||||
assert "p4_nano->set_lane_bit_rate(1500);" in main_cpp
|
assert "p4_nano->set_lane_bit_rate(1500.0f);" in main_cpp
|
||||||
assert "p4_nano->set_rotation(display::DISPLAY_ROTATION_90_DEGREES);" in main_cpp
|
assert "p4_nano->set_rotation(display::DISPLAY_ROTATION_90_DEGREES);" in main_cpp
|
||||||
assert "p4_86->set_rotation(display::DISPLAY_ROTATION_0_DEGREES);" in main_cpp
|
assert "p4_86->set_rotation(display::DISPLAY_ROTATION_0_DEGREES);" in main_cpp
|
||||||
|
assert "custom_id->set_rotation(display::DISPLAY_ROTATION_180_DEGREES);" in main_cpp
|
||||||
# assert "backlight_id = new light::LightState(mipi_dsi_dsibacklight_id);" in main_cpp
|
# assert "backlight_id = new light::LightState(mipi_dsi_dsibacklight_id);" in main_cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user