-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrccar.yaml
151 lines (129 loc) · 3.6 KB
/
rccar.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
substitutions:
devicename: rccar
updatetimeoutms: "700"
esphome:
name: $devicename
platform: ESP32
board: esp32dev
on_boot:
priority: -100
then:
- lambda: |-
static HighFrequencyLoopRequester hfloop;
//hfloop.start();
on_loop:
then:
- lambda: |-
const uint32_t now = millis();
if (now - id(lastupdate) > $updatetimeoutms) { // timeout! reset to a safe state
id(hbridge_en1).set_level(0);
id(hbridge_en2).set_level(0);
}
logger:
#level: DEBUG
baud_rate: 0 #disable UART to reuse the GPIO
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
# - ssid: !secret wifi_ssid2
# password: !secret wifi_password2
# - ssid: !secret wifi_ssid3
# password: !secret wifi_password3
ap:
ssid: "$devicename AP"
password: !secret ap_password
channel: 10
reboot_timeout: 0s
ota:
globals:
- id: lastupdate
type: uint32_t
restore_value: no
initial_value: '0'
api:
services:
- service: hbridge
variables:
index: int # index of the hbridge starting with 0
strength: float # -1.0 .. +1.0
brake: bool # true for braking
then:
- lambda: |-
id(lastupdate) = millis();
if (index == 0){ // driving
if ((strength > 0) || brake)
id(hbridge_in3).turn_on();
else
id(hbridge_in3).turn_off();
if ((strength < 0) || brake)
id(hbridge_in4).turn_on();
else
id(hbridge_in4).turn_off();
id(hbridge_en2).set_level(abs(strength));
} else if (index == 1){ // steering
if ((strength > 0) || brake)
id(hbridge_in1).turn_on();
else
id(hbridge_in1).turn_off();
if ((strength < 0) || brake)
id(hbridge_in2).turn_on();
else
id(hbridge_in2).turn_off();
id(hbridge_en1).set_level(abs(strength));
} else if (index == 2){ // white led
id(gpio_whiteled).set_level(abs(strength));
} else {
ESP_LOGD("hbridge", " index=%i strength=%f brake=%i millis=%i", index, strength, brake, millis() );
}
esp32_camera:
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
name: "$devicename Camera"
output:
- platform: ledc
channel: 2 #not setting this breaks the camera!
pin: GPIO04
id: gpio_whiteled
inverted: False
max_power: 0.3
#https://www.st.com/resource/en/datasheet/l298.pdf
- platform: gpio
pin: GPIO3
id: hbridge_in1
inverted: False
- platform: gpio
pin: GPIO2
id: hbridge_in2
inverted: False
- platform: gpio
pin: GPIO14
id: hbridge_in3
inverted: False
- platform: gpio
pin: GPIO15
id: hbridge_in4
inverted: False
- platform: ledc
channel: 3 #not setting this breaks the camera!
pin: GPIO12
id: hbridge_en1
inverted: False
max_power: 0.9
frequency: 100kHz
- platform: ledc
channel: 4 #not setting this breaks the camera!
pin: GPIO13
id: hbridge_en2
inverted: False
max_power: 0.9
frequency: 100kHz