From c3d48acb4c7be340658ccacb225c18c4fdfa084b Mon Sep 17 00:00:00 2001 From: ezcGman Date: Sun, 17 Oct 2021 01:24:23 +0200 Subject: [PATCH] UM RGB-Rotary-Encoder: Properly used PinOwner --- usermods/rgb-rotary-encoder/rgb-rotary-encoder.h | 6 +++--- wled00/const.h | 1 + wled00/pin_manager.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/usermods/rgb-rotary-encoder/rgb-rotary-encoder.h b/usermods/rgb-rotary-encoder/rgb-rotary-encoder.h index cde220121..e57641bf9 100644 --- a/usermods/rgb-rotary-encoder/rgb-rotary-encoder.h +++ b/usermods/rgb-rotary-encoder/rgb-rotary-encoder.h @@ -40,7 +40,7 @@ class RgbRotaryEncoderUsermod : public Usermod void initRotaryEncoder() { PinManagerPinType pins[2] = { { eaIo, false }, { ebIo, false } }; - if (!pinManager.allocateMultiplePins(pins, 2, UM_RGBRotaryEncoder)) { + if (!pinManager.allocateMultiplePins(pins, 2, PinOwner::UM_RGBRotaryEncoder)) { eaIo = -1; ebIo = -1; cleanup(); @@ -208,7 +208,7 @@ class RgbRotaryEncoderUsermod : public Usermod lastKnownBri = bri; updateLeds(); - colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE); + colorUpdated(CALL_MODE_DIRECT_CHANGE); } // If the brightness is changed not with the rotary, update the rotary @@ -323,7 +323,7 @@ class RgbRotaryEncoderUsermod : public Usermod */ uint16_t getId() { - return 0x4711; + return USERMOD_RGB_ROTARY_ENCODER; } //More methods can be added in the future, this example will then be extended. diff --git a/wled00/const.h b/wled00/const.h index 854945a4d..b03595a57 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -62,6 +62,7 @@ #define USERMOD_ID_PWM_FAN 19 //Usermod "usermod_PWM_fan.h" #define USERMOD_ID_BH1750 20 //Usermod "usermod_bh1750.h" #define USERMOD_ID_SEVEN_SEGMENT_DISPLAY 21 //Usermod "usermod_v2_seven_segment_display.h" +#define USERMOD_RGB_ROTARY_ENCODER 22 //Usermod "rgb-rotary-encoder.h" //Access point behavior #define AP_BEHAVIOR_BOOT_NO_CONN 0 //Open AP when no connection after boot diff --git a/wled00/pin_manager.h b/wled00/pin_manager.h index 1dab2b09a..cb1da562f 100644 --- a/wled00/pin_manager.h +++ b/wled00/pin_manager.h @@ -36,7 +36,6 @@ enum struct PinOwner : uint8_t { DMX = 0x8A, // 'DMX' == hard-coded to IO2 // Use UserMod IDs from const.h here UM_Unspecified = USERMOD_ID_UNSPECIFIED, // 0x01 - UM_RGBRotaryEncoder = USERMOD_ID_UNSPECIFIED, // 0x01 // No define in const.h for this user module -- consider adding? UM_Example = USERMOD_ID_EXAMPLE, // 0x02 // Usermod "usermod_v2_example.h" UM_Temperature = USERMOD_ID_TEMPERATURE, // 0x03 // Usermod "usermod_temperature.h" // #define USERMOD_ID_FIXNETSERVICES // 0x04 // Usermod "usermod_Fix_unreachable_netservices.h" -- Does not allocate pins @@ -53,6 +52,7 @@ enum struct PinOwner : uint8_t { // #define USERMOD_ID_RTC // 0x0F // Usermod "usermod_rtc.h" -- Uses "standard" I2C pins ... TODO -- enable shared I2C bus use // #define USERMOD_ID_ELEKSTUBE_IPS // 0x10 // Usermod "usermod_elekstube_ips.h" -- Uses quite a few pins ... see Hardware.h and User_Setup.h // #define USERMOD_ID_SN_PHOTORESISTOR // 0x11 // Usermod "usermod_sn_photoresistor.h" -- Uses hard-coded pin (PHOTORESISTOR_PIN == A0), but could be easily updated to use pinManager + UM_RGBRotaryEncoder = USERMOD_RGB_ROTARY_ENCODER // 0x16 // Usermod "rgb-rotary-encoder.h" }; static_assert(0u == static_cast(PinOwner::None), "PinOwner::None must be zero, so default array initialization works as expected");