-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbadge_basic.yaml
151 lines (133 loc) · 3.81 KB
/
badge_basic.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
# Copyright 2025 Vinicius Fortuna
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file defines the hardware of the badge. All functionality
# should be in your deployment or application configuration that
# depends on this file.
# Note on RMT symbols:
# ESP32-C3 has memory for only 192 RMT symbols, only half of which is available to transmitters.
# We have the following defaults:
# - esp32_rmt_led_strip: 96
# - remote_transmitter: 48
# - remote_receiver: 192
# We change it to the following allocation:
# - esp32_rmt_led_strip: 48
# - remote_transmitter: 48
# - remote_receiver: 86
# The badge is a custom board, not explicitly supported by PlatformIO.
# We choose esp32-c3-devkitm-1 as the base board, which is similar enough to work here.
# However, that board uses flash mode QIO, while the badge uses DIO, so it can free up
# SPIHD/GPIO12 and SPIWD/GPIO13 for use as GPIO pins. For that reason we override the flash mode in the
# board definition.
# Definition for esp32-c3-devkitm-1: https://github.com/platformio/platform-espressif32/blob/master/boards/esp32-c3-devkitm-1.json
# ESP32 flash modes: https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/spi-flash-modes.html
esphome:
platformio_options:
board_build.flash_mode: dio
esp32:
board: esp32-c3-devkitm-1
variant: esp32c3
framework:
type: esp-idf
i2c:
sda: GPIO21
scl: GPIO20
id: badge_i2c
# INPUTS
binary_sensor:
# Buttons 1 and 2 conflict with USB, which requires special handling to flash.
# See the README.
- id: button_1
platform: gpio
name: Button 1 (SW3)
pin:
number: GPIO19 # USB_D+
inverted: true
mode:
input: true
pullup: true
- id: button_2
platform: gpio
name: Button 2 (SW4)
pin:
number: GPIO18 # USB_D-
inverted: true
mode:
input: true
pullup: true
- id: button_3
platform: gpio
name: Button 3 (SW1)
pin:
number: GPIO10
inverted: true
mode:
input: true
pullup: true
- id: button_4
platform: gpio
name: Button 4 (SW2)
pin:
number: GPIO09 # Strapping Pin (BOOT)
inverted: true
mode:
input: true
pullup: true
remote_receiver:
- id: ir_receiver
pin:
number: GPIO03
inverted: true
mode:
input: true
pullup: true
rmt_symbols: 86
# OUTPUTS
light:
- id: board_led
name: Board LED
platform: monochromatic
output: board_led_output
initial_state:
state: OFF
- id: led_strip
name: LED Strip
# restore_mode: RESTORE_DEFAULT_ON
platform: esp32_rmt_led_strip
rgb_order: GRB
pin: GPIO8 # Strapping Pin
num_leds: 16
chipset: ws2812
rmt_symbols: 48
remote_transmitter:
- id: ir_transmitter
pin: GPIO02
# Infrared remotes use a 50% carrier signal.
carrier_duty_percent: 50%
rmt_symbols: 48
output:
- id: board_led_output
platform: ledc
pin:
number: GPIO13
ignore_pin_validation_error: true
switch:
- id: vibration_motor
name: Vibration Motor
platform: gpio
pin:
# The badge uses DIO flash mode instead of QIO, making the SPI pins GPIO12 and GPIO13 free to use.
# See https://github.com/esphome/issues/issues/3744.
number: GPIO12
ignore_pin_validation_error: true
restore_mode: ALWAYS_OFF