mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
40 lines
1 KiB
YAML
40 lines
1 KiB
YAML
spi:
|
|
- id: spi_main_lcd
|
|
clk_pin: 16
|
|
mosi_pin: 17
|
|
miso_pin: 15
|
|
|
|
display:
|
|
- platform: ili9xxx
|
|
id: main_lcd
|
|
model: ili9342
|
|
cs_pin: 12
|
|
dc_pin: 13
|
|
reset_pin: 21
|
|
invert_colors: false
|
|
lambda: |-
|
|
// Draw an analog clock in the center of the screen
|
|
int centerX = it.get_width() / 2;
|
|
int centerY = it.get_height() / 2;
|
|
int radius = min(it.get_width(), it.get_height()) / 4;
|
|
|
|
// Draw border
|
|
it.circle(centerX, centerY, radius);
|
|
|
|
// Draw hour ticks
|
|
for(int h = 0; h < 12; h++) {
|
|
int hourAngle = (h * 30) - 90;
|
|
|
|
it.line_at_angle(centerX, centerY, hourAngle, radius - 10, radius);
|
|
}
|
|
|
|
// Draw minute ticks
|
|
for(int m = 0; m < 60; m++) {
|
|
int minuteAngle = (m * 6) - 90;
|
|
|
|
it.line_at_angle(centerX, centerY, minuteAngle, radius - 5, radius);
|
|
}
|
|
|
|
// Nice ring around and some gauge
|
|
it.filled_ring(centerX, centerY, radius+5, radius+8);
|
|
it.filled_gauge(centerX, centerY, radius/2, radius/2-5, 66);
|