Adding short delay and LED indicator to show that the app is running
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
@@ -259,7 +259,7 @@ def register_ha_discovery(mqtt):
|
|||||||
|
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# Main Execution Loop
|
# Instantiate Wi-Fi connection
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
def connect_wifi():
|
def connect_wifi():
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
@@ -277,6 +277,21 @@ def connect_wifi():
|
|||||||
print(f"Wi-Fi connected. IP: {wlan.ifconfig()[0]}")
|
print(f"Wi-Fi connected. IP: {wlan.ifconfig()[0]}")
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------------------------
|
||||||
|
# Panic when the sensor isn't ready
|
||||||
|
# -------------------------------------------------------------
|
||||||
|
def panic(err=None):
|
||||||
|
"""Signals a fatal fault by blinking the onboard LED continuously."""
|
||||||
|
if err:
|
||||||
|
print(f"Fatal error: {err}")
|
||||||
|
led = Pin("LED", Pin.OUT)
|
||||||
|
while True:
|
||||||
|
led.toggle()
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
# -------------------------------------------------------------
|
||||||
|
# Main Execution Loop
|
||||||
|
# -------------------------------------------------------------
|
||||||
def main():
|
def main():
|
||||||
# Adjust SDA/SCL pins according to your wiring
|
# Adjust SDA/SCL pins according to your wiring
|
||||||
i2c = SoftI2C(sda=Pin(16), scl=Pin(17), freq=100000)
|
i2c = SoftI2C(sda=Pin(16), scl=Pin(17), freq=100000)
|
||||||
@@ -322,4 +337,13 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
# Allow 3.3V power rails and I2C registers to settle on cold boot
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# Indicate startup has begun
|
||||||
|
Pin("LED", Pin.OUT).on()
|
||||||
|
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
except Exception as e:
|
||||||
|
panic(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user