zerog2k / stc_diyclock

STC DIY Clock redux (STC15F204EA, STC15W404AS, STC15W408AS)
MIT License
170 stars 67 forks source link

Brightness level #63

Closed in-sympathy closed 1 year ago

in-sympathy commented 2 years ago

Hi. Could you please release an update that would significantly lower the bottom brightness value? Would be awesome if it was closer to the original Chinese firmware where the clock is barely visible at night. Currently it's too bright for the bedroom and really disrupts sleeping, decreasing melatonin levels and so on and so forth :)

Thanks a lot in advance and really appreciate your amazing work 👍🏻

zerog2k commented 2 years ago

The dimming is controlled somewhat creatively to get around some limitations (like running in ISR)- controlled here: https://github.com/zerog2k/stc_diyclock/blob/master/src/main.c#L234

    if (displaycounter % lightval < 4 ) {

you can try playing around with different values (instead of 4), like 3? from memory, lightval is raw ldr circuit adc values, and (I think?) it should be from 0-1023, and decrease (toward zero) when bright, and increase (toward 1023) when dark ? this number here is trying to divide the raw adc lightval such that it skips lighting when displaycounter % (lightval < 4) == 0 if that's helpful

I don't have a way to test currently, but you can play around with this, and build/upload using platformio pretty easily

in-sympathy commented 2 years ago

thanks, but it doesn't work:

setting if (displaycounter % lightval < 3 ) {

would lead to weird display refresh misbehavior, especially with the 4th digit

any other ideas on how to make the brightness level in the dark as low as possible?

zerog2k commented 2 years ago

Ok apologies, I think I was looking at that ISR conditional wrongly. I think this is the proper place to look for dimming: https://github.com/zerog2k/stc_diyclock/blob/master/src/main.c#L491-L500 note that we are decimating the raw adc value from 8 to 5 bits so from 256-0 (darkest to brightest) mapped to 32-0

I think this lightval acts sort of like a variable denominator in the fraction of duty cycle of led lighting. Larger denominator, shorter duty cycle; smaller denominator, longer duty cycle.

So perhaps try changing lightval = getADCResult8(ADC_LIGHT) >> 3; to lightval = getADCResult8(ADC_LIGHT) >> 2; such that it's bottom range is 64 (darkest) instead of 32

in-sympathy commented 2 years ago

thanks a lot, this seems to be doing the trick. would setting the value to 1 make it even darker then?

zerog2k commented 2 years ago

You can try it and let me know how well it works.

in-sympathy commented 2 years ago

Sounds like a plan- did just that and pretty happy with the results - the display is now a tad dim for some, but should not be a distraction at night anymore, so I guess mission accomplished - thank you so much for your help and for this awesome firmware 🙏🏻👍🏻

p23f commented 1 year ago

I solved the brightness problem by 3d printing a thin 0.6mm thick screen to fit in the bottom of the acrylic case to cover the leds.