-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmax7219.yaml
153 lines (131 loc) · 3.54 KB
/
max7219.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
substitutions:
devicename: max7219
upper_devicename: max7219
esphome:
name: "${devicename}"
platform: esp8266
board: d1_mini
logger:
api:
password: !secret api_pass
ota:
password: !secret ota_pass
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
sensor:
- platform: wifi_signal
name: ${upper_devicename} Wifi
update_interval: 60s
id: wifi_signal_db
entity_category: "diagnostic"
- platform: copy # Reports the WiFi signal strength in %
source_id: wifi_signal_db
name: ${upper_devicename} WiFi Percent
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: "diagnostic"
spi:
clk_pin: D2
mosi_pin: D4
font:
- file: "font/pixelmix.ttf"
id: digit_font
size: 8
display:
- platform: max7219digit
cs_pin: D3
num_chips: 4
update_interval: 0.25 s
lambda: |-
//точки
static int i = 0;
i++;
if ( i <= 4) {
it.print(15, 0, id(digit_font), ":");
it.print(16, 0, id(digit_font), ":");
}
else
if ( i == 8)
i = 0;
// Разбираем Часы
uint8_t HH = (id(sntp_time).now().hour);
uint8_t HD = HH / 10;
uint8_t h = HH % 10;
static uint8_t HDk;
static uint8_t hk;
// Разбираем минуты
uint8_t MM = (id(sntp_time).now().minute);
uint8_t MD = MM / 10;
uint8_t m = MM % 10;
static uint8_t MDk;
static uint8_t mk;
// Разбираем секунды
//uint8_t SS = (id(sntp_time).now().second);
//uint8_t SD = SS / 10;
//uint8_t s = SS % 10;
//static uint8_t SDk = 0;
//static uint8_t sk = 0;
// Выводим часы
if (h != hk) {
static int hi = 0;
it.printf(12,hi-4, id(digit_font), TextAlign::CENTER,"%u", h );
it.printf(12, hi+4, id(digit_font), TextAlign::CENTER,"%u", hk );
hi++;
if (hi == 8) {
hi = 0;
hk = h;
}
}
else
it.printf(12, 4, id(digit_font), TextAlign::CENTER,"%u", h );
// Выводим десятки часов
if ( HD != HDk ) {
static int HDi = 0;
it.printf(5, HDi-4, id(digit_font), TextAlign::CENTER, "%u", HD );
it.printf(5, HDi+4, id(digit_font), TextAlign::CENTER,"%u", HDk );
HDi++;
if (HDi == 8) {
HDi = 0;
HDk = HD;
}
}
else
it.printf(5, 4, id(digit_font), TextAlign::CENTER,"%u", HD );
// Выводим минуты
if (m != mk) {
static int mi = 0;
it.printf(28,mi-4, id(digit_font), TextAlign::CENTER,"%u", m );
it.printf(28, mi+4, id(digit_font), TextAlign::CENTER,"%u", mk );
mi++;
if (mi == 8) {
mi = 0;
mk = m;
}
}
else
it.printf(28, 4, id(digit_font), TextAlign::CENTER,"%u", m );
// Выводим десятки минут
if (MD != MDk) {
static int MDi = 0;
it.printf(21, MDi-4, id(digit_font), TextAlign::CENTER,"%u", MD );
it.printf(21, MDi+4, id(digit_font), TextAlign::CENTER,"%u", MDk );
MDi++;
if (MDi == 8) {
MDi = 0;
MDk = MD;
}
}
else
it.printf(21, 4, id(digit_font), TextAlign::CENTER,"%u", MD );
time:
- platform: sntp
id: sntp_time
servers:
- 0.pool.ntp.org
web_server:
port: 80
auth:
username: !secret web_user
password: !secret web_pass