This shows you the differences between two versions of the page.
|
iothings:laboratoare:2025_code:lab5_2 [2025/10/22 10:49] dan.tudose created |
iothings:laboratoare:2025_code:lab5_2 [2025/10/22 11:34] (current) dan.tudose |
||
|---|---|---|---|
| Line 5: | Line 5: | ||
| #include "Zigbee.h" | #include "Zigbee.h" | ||
| - | constexpr uint8_t BOOT_PIN = 9; | + | constexpr uint8_t SWITCH_PIN = 9; |
| constexpr uint32_t FACTORY_RESET_HOLD_MS = 3000; | constexpr uint32_t FACTORY_RESET_HOLD_MS = 3000; | ||
| constexpr uint32_t BUTTON_DEBOUNCE_MS = 50; | constexpr uint32_t BUTTON_DEBOUNCE_MS = 50; | ||
| Line 11: | Line 11: | ||
| #if defined(SPARROW_SWITCH) | #if defined(SPARROW_SWITCH) | ||
| - | #include "ZigbeeSwitch.h" | + | #include "ep/ZigbeeSwitch.h" |
| constexpr uint8_t SWITCH_ENDPOINT = 1; | constexpr uint8_t SWITCH_ENDPOINT = 1; | ||
| Line 24: | Line 24: | ||
| void setup() { | void setup() { | ||
| Serial.begin(115200); | Serial.begin(115200); | ||
| - | pinMode(BOOT_PIN, INPUT_PULLUP); | + | pinMode(SWITCH_PIN, INPUT_PULLUP); |
| switchEp.setManufacturerAndModel("Sparrow", "Switch"); | switchEp.setManufacturerAndModel("Sparrow", "Switch"); | ||
| Line 47: | Line 47: | ||
| void loop() { | void loop() { | ||
| uint32_t now = millis(); | uint32_t now = millis(); | ||
| - | bool reading = digitalRead(BOOT_PIN); | + | bool reading = digitalRead(SWITCH_PIN); |
| if (reading != lastButtonLevel && (now - lastButtonChangeMs) >= BUTTON_DEBOUNCE_MS) { | if (reading != lastButtonLevel && (now - lastButtonChangeMs) >= BUTTON_DEBOUNCE_MS) { | ||
| Line 76: | Line 76: | ||
| #include <Adafruit_NeoPixel.h> | #include <Adafruit_NeoPixel.h> | ||
| - | #include "ZigbeeLight.h" | + | #include "ep/ZigbeeLight.h" |
| constexpr uint8_t LIGHT_ENDPOINT = 1; | constexpr uint8_t LIGHT_ENDPOINT = 1; | ||
| Line 145: | Line 145: | ||
| void setup() { | void setup() { | ||
| Serial.begin(115200); | Serial.begin(115200); | ||
| - | pinMode(BOOT_PIN, INPUT_PULLUP); | + | pinMode(SWITCH_PIN, INPUT_PULLUP); |
| statusPixel.begin(); | statusPixel.begin(); | ||
| Line 193: | Line 193: | ||
| } | } | ||
| - | bool reading = digitalRead(BOOT_PIN); | + | bool reading = digitalRead(SWITCH_PIN); |
| if (reading != lastButtonLevel && (now - lastButtonChangeMs) >= BUTTON_DEBOUNCE_MS) { | if (reading != lastButtonLevel && (now - lastButtonChangeMs) >= BUTTON_DEBOUNCE_MS) { | ||
| lastButtonChangeMs = now; | lastButtonChangeMs = now; | ||