Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LYT8266 Bulb #213

Closed
xoseperez opened this issue Sep 12, 2017 · 6 comments
Closed

Add support for LYT8266 Bulb #213

xoseperez opened this issue Sep 12, 2017 · 6 comments

Comments

@xoseperez
Copy link
Owner

Originally reported by: Joe Biellik (Bitbucket: JoeBiellik, GitHub: JoeBiellik)


I've been running ESPurna on a Sonoff S20 and wanted to port it to a LYT8266 LED bulb.

The bulb is a basic ESP8266 with 1Mb flash, RGBW LEDs.

The bulb has a pin which turns on and off all the LEDs. I've got it running but had to make a couple of changes as I couldn't see a way to do it built in.

I added a new relay type and code to switch the pin and set the light state:

#!arduino

   // Relays
    #define RELAY1_PIN          15      // Pin to turn on/off all LEDs
    #define RELAY1_TYPE         RELAY_TYPE_LIGHT_SWITCH

    // Channels
    #define LIGHT_CH1_PIN       13      // RED
    #define LIGHT_CH2_PIN       12      // GREEN
    #define LIGHT_CH3_PIN       14      // BLUE
    #define LIGHT_CH4_PIN       2       // WHITE

#!arduino
} else if (_relays[id].type == RELAY_TYPE_LIGHT_SWITCH) {
        lightState(status);
        lightUpdate(true, true);
        digitalWrite(_relays[id].pin, status);
}

Is there an easier way to achieve this? If not would you accept a pull request?

Thanks for the great firmware.

@xoseperez
Copy link
Owner Author

I think a better option would be to use them as normal switches (ON/OFF):

#!cpp
// Relays
    #define RELAY1_PIN          13
    #define RELAY2_PIN          12
    #define RELAY3_PIN          14
    #define RELAY4_PIN          2

    #define RELAY1_TYPE         RELAY_TYPE_NORMAL
    #define RELAY2_TYPE         RELAY_TYPE_NORMAL
    #define RELAY3_TYPE         RELAY_TYPE_NORMAL
    #define RELAY4_TYPE         RELAY_TYPE_NORMAL

Probably a nice add on would be to be able to rename the switches on the webUI, so intead of "switch 1", "switch 2",... you could have "Red", "Green", ...

@xoseperez
Copy link
Owner Author

Original comment by Joe Biellik (Bitbucket: JoeBiellik, GitHub: JoeBiellik):


Thanks for the reply, but that's not helped the issue.
Your code gives me a UI switch for each LED channel, but that doesn't solve the issue that on this device the LED enable pin (15) has to be set for any of the LED channels to be switched on.

I could add the LED enable pin as a normal relay but if I don't use RELAY_PROVIDER_LIGHT then lightUpdate is never called and the LEDs don't get power.
If I don't use RELAY_PROVIDER_RELAY then the enable pin is never set, which is why I added the new RELAY_TYPE_LIGHT_SWITCH to trigger both.

@xoseperez
Copy link
Owner Author

Wouldn't it be simpler to use a RELAY_PROVIDER_LIGHT and add the option to define a LIGHT_ENABLE_PIN than would be sync'd with the status?

Something like this: 8bad421

@xoseperez
Copy link
Owner Author

I have released the code with 1.9.6, can anyone test the proposed solution?

@xoseperez
Copy link
Owner Author

Original comment by Joe Biellik (Bitbucket: JoeBiellik, GitHub: JoeBiellik):


Sorry for the slow reply and thanks for addressing this. I'll give your changes a try ASAP.

@xoseperez
Copy link
Owner Author

Original comment by Joe Biellik (Bitbucket: JoeBiellik, GitHub: JoeBiellik):


I can confirm the latest version works, setting the enable pin was exactly what was needed.

Thanks again for adding support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant