-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from raihei/ams-button
sync with main
Showing
6 changed files
with
357 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
esp32_touch: | ||
setup_mode: False | ||
measurement_duration: 0.25ms | ||
|
||
binary_sensor: | ||
- platform: esp32_touch | ||
id: touchbutton_ams_1 | ||
name: "Touch button AMS 1" | ||
pin: ${touchbutton_ams_1} | ||
threshold: 100000 | ||
on_press: | ||
then: | ||
- if: | ||
condition: | ||
and: | ||
- not: | ||
script.is_running: timer_slotselect | ||
- not: | ||
script.is_running: timer_spoolscan | ||
- not: | ||
script.is_running: timer_spoolinstall | ||
then: | ||
- logger.log: "Keypress detected. Waiting for further key presses." | ||
- script.execute: start_timer_slotselect | ||
- script.execute: | ||
id: set_led_yellow | ||
led_number: 0 | ||
else: | ||
- if: | ||
condition: | ||
script.is_running: timer_slotselect | ||
then: | ||
- globals.set: | ||
id: slotselect_timeout | ||
value: "0" | ||
- if: | ||
condition: | ||
lambda: "return id(slotselect_counter) < 4;" | ||
then: | ||
- globals.set: | ||
id: slotselect_counter | ||
value: !lambda "return id(slotselect_counter) + 1;" | ||
- logger.log: "Further key press detected." | ||
- script.execute: | ||
id: set_led_yellow | ||
led_number: !lambda "return id(slotselect_counter) - 1;" | ||
else: | ||
- globals.set: | ||
id: slotselect_counter | ||
value: "1" | ||
- logger.log: "Button pressed more than 4 times. Aborting." | ||
- script.execute: | ||
id: set_led_red | ||
led_number: -1 | ||
- script.stop: timer_slotselect | ||
- delay: 1s | ||
- script.execute: | ||
id: set_led_white | ||
led_number: -1 | ||
- if: | ||
condition: | ||
script.is_running: timer_spoolinstall | ||
then: | ||
- logger.log: "Transfering spool data to printer" | ||
- script.stop: timer_spoolinstall | ||
- light.turn_on: | ||
id: neopixel_light | ||
effect: none | ||
- script.execute: | ||
id: set_led_green | ||
led_number: -1 | ||
- delay: 500ms | ||
- script.execute: | ||
id: set_led_white | ||
led_number: -1 | ||
- mqtt.publish: | ||
topic: !lambda 'return "device/" + id(bambu_serial_number).state + "/request";' | ||
payload: !lambda "return bambulabs::generate_mqtt_payload( id(scanned_tag_data), 0, id(slotselect_counter) - 1 );" | ||
- globals.set: | ||
id: ams_scan_mode | ||
value: "false" | ||
- if: | ||
condition: | ||
script.is_running: timer_spoolscan | ||
then: | ||
- logger.log: "Key pressed without scanning spool. Aborting" | ||
- script.stop: timer_spoolscan | ||
- globals.set: | ||
id: ams_scan_mode | ||
value: "false" | ||
- script.execute: | ||
id: set_led_white | ||
led_number: -1 | ||
|
||
globals: | ||
- id: slotselect_timeout | ||
type: int | ||
initial_value: "0" | ||
- id: slotselect_counter | ||
type: int | ||
initial_value: "0" | ||
- id: slotselect_display_counter | ||
type: int | ||
initial_value: "0" | ||
- id: ams_scan_mode | ||
type: bool | ||
initial_value: "false" | ||
- id: spoolinstall_timeout | ||
type: int | ||
initial_value: "0" | ||
- id: spoolscan_timeout | ||
type: int | ||
initial_value: "0" | ||
- id: scanned_tag_data | ||
type: std::string | ||
max_restore_data_length: 160 | ||
initial_value: "" | ||
|
||
script: | ||
- id: timer_slotselect | ||
then: | ||
- while: | ||
condition: | ||
lambda: "return id(slotselect_timeout) < 3;" | ||
then: | ||
- globals.set: | ||
id: slotselect_timeout | ||
value: !lambda "return id(slotselect_timeout) + 1;" | ||
- logger.log: "Waiting for further key presses." | ||
- delay: 1s | ||
- logger.log: "Key press timeout." | ||
- logger.log: | ||
format: "Selected slot: AMS 1 slot %d " | ||
args: [ 'id(slotselect_counter)' ] | ||
- logger.log: "Waiting for spool scan (Timeout in 20 seconds)" | ||
- globals.set: | ||
id: ams_scan_mode | ||
value: "true" | ||
- repeat: | ||
count: !lambda "return id(slotselect_counter);" | ||
then: | ||
- logger.log: "green repeat" | ||
- script.execute: | ||
id: set_led_green | ||
led_number: !lambda "return id(slotselect_display_counter);" | ||
- globals.set: | ||
id: slotselect_display_counter | ||
value: !lambda "return id(slotselect_display_counter) + 1;" | ||
- script.execute: start_timer_spoolscan | ||
- script.stop: timer_slotselect | ||
|
||
- id: start_timer_slotselect | ||
then: | ||
- globals.set: | ||
id: slotselect_timeout | ||
value: "0" | ||
- globals.set: | ||
id: slotselect_counter | ||
value: "1" | ||
- globals.set: | ||
id: slotselect_display_counter | ||
value: "0" | ||
- script.execute: timer_slotselect | ||
|
||
- id: timer_spoolinstall | ||
then: | ||
- while: | ||
condition: | ||
lambda: "return id(spoolinstall_timeout) < 120;" | ||
then: | ||
- globals.set: | ||
id: spoolinstall_timeout | ||
value: !lambda "return id(spoolinstall_timeout) + 1;" | ||
- logger.log: "Waiting for spool install confirmation." | ||
- delay: 1s | ||
- logger.log: "Spool install timeout!" | ||
- globals.set: | ||
id: ams_scan_mode | ||
value: "false" | ||
- script.execute: | ||
id: set_led_red | ||
led_number: -1 | ||
- delay: 1s | ||
- script.execute: | ||
id: set_led_semioff | ||
led_number: -1 | ||
- delay: 500ms | ||
- script.execute: | ||
id: set_led_white | ||
led_number: -1 | ||
- script.stop: timer_spoolinstall | ||
|
||
- id: start_timer_spoolinstall | ||
then: | ||
- globals.set: | ||
id: spoolinstall_timeout | ||
value: "0" | ||
- script.stop: timer_spoolscan | ||
- logger.log: "Spool scanned. Please install spool and press button to confirm. (Timeout in 120 seconds)" | ||
- delay: 1s | ||
- script.execute: | ||
id: set_led_breathing_green | ||
led_number: -1 | ||
- delay: 2s | ||
- script.execute: | ||
id: set_led_breathing_green | ||
led_number: -1 | ||
- script.execute: timer_spoolinstall | ||
|
||
- id: timer_spoolscan | ||
then: | ||
- while: | ||
condition: | ||
lambda: "return id(spoolscan_timeout) < 20;" | ||
then: | ||
- globals.set: | ||
id: spoolscan_timeout | ||
value: !lambda "return id(spoolscan_timeout) + 1;" | ||
- logger.log: "Waiting for spool scan." | ||
- delay: 1s | ||
- logger.log: "Spool scan timeout!" | ||
- globals.set: | ||
id: ams_scan_mode | ||
value: "false" | ||
- light.turn_on: | ||
id: neopixel_light | ||
effect: none | ||
- script.execute: | ||
id: set_led_white | ||
led_number: -1 | ||
- script.stop: timer_spoolscan | ||
|
||
- id: start_timer_spoolscan | ||
then: | ||
- globals.set: | ||
id: spoolscan_timeout | ||
value: "0" | ||
- script.execute: timer_spoolscan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
esp32: | ||
board: esp32-s3-devkitc-1 | ||
|
||
substitutions: | ||
hide_ams_sensors: 'false' | ||
led_pin: GPIO2 | ||
neopixel_pin: '48' #some boards have this on pin 38 | ||
touchbutton_ams_1: GPIO04 | ||
|
||
spi2_type: SPI2 | ||
spi2_clk_pin: GPIO10 | ||
spi2_miso_pin: GPIO11 | ||
spi2_mosi_pin: GPIO12 | ||
|
||
rfid0_spi_interface: SPI2 | ||
rfid0_ss_pin: GPIO13 | ||
|
||
rfid1_spi_interface: SPI2 | ||
rfid1_ss_pin: GPIO05 | ||
|
||
rfid2_spi_interface: SPI2 | ||
rfid2_ss_pin: GPIO06 | ||
|
||
rfid3_spi_interface: SPI2 | ||
rfid3_ss_pin: GPIO07 | ||
|
||
# rfid4_spi_interface: SPI2 | ||
# rfid4_ss_pin: GPIO05 | ||
|
||
# rfid5_spi_interface: SPI2 | ||
# rfid5_ss_pin: GPIO04 | ||
|
||
# spi3_type: SPI3 | ||
# spi3_clk_pin: GPIO18 | ||
# spi3_miso_pin: GPIO17 | ||
# spi3_mosi_pin: GPIO16 | ||
|
||
# rfid6_spi_interface: SPI3 | ||
# rfid6_ss_pin: GPIO15 | ||
|
||
# rfid7_spi_interface: SPI3 | ||
# rfid7_ss_pin: GPIO9 | ||
|
||
# rfid8_spi_interface: SPI3 | ||
# rfid8_ss_pin: GPI14 # TODO: Verify this is compatible | ||
|
||
packages: | ||
openspool-ams: !include openspool-ams.yaml | ||
improv-serial: !include conf.d/improv-serial.yaml | ||
#improv-bluetooth: !include conf.d/improv-bluetooth.yaml | ||
#led-internal: !include conf.d/led-internal.yaml | ||
extra: !include conf.d/extra.yaml | ||
button: !include conf.d/button.yaml | ||
touch: !include conf.d/touch.yaml | ||
|
||
dashboard_import: | ||
package_import_url: github://spuder/openspool/firmware/esp32-s3-zero.yaml@main | ||
import_full_config: false |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.