aFewBits / stc-led-clock

Replacement firmware for STC 8051 based DIY LED clock kits
MIT License
55 stars 20 forks source link

Refreshing digits appears very slow #3

Closed JohnOH closed 7 years ago

JohnOH commented 7 years ago

Currently I only have access to STCGAL and have been using -t to set the frequency to 22.1184Mhz. The result is a very bright white display that appears to refresh digits after maybe 100ms.

Do you have access to the genuine STC-ISP?

JohnOH commented 7 years ago

The "slow refresh" is a function of the brightness.

Button debounce is quite a challenge.

aFewBits commented 7 years ago

I use both STC-ISP V6.86 and STCGAL with no problems whatsoever.

I'm not sure what you mean by slow refresh. At 22.1184mhz, the clock rate is 20khz/50us. There are 64 clock ticks allocated for each digit which translates to 3.2ms per digit. If the LED is on for all 64 ticks, you get the maximum brightness. At minimum brightness, the LED is on for 1 tick and off for 63. The four digits are updated in a fixed period of 12.8ms or 78hz which should have no perceptible visual flicker. The minimum value of one may be too dim for some LED's, the orange being the dimmest of the them all from what I've seen. The blue and the white are the brightest and have acceptably dim digits (IMO) in total darkness with this timing scheme.

There may be issues with LDR's that fall outside the normal range. Measure the voltage at the junction of the LDR and 10K resistor, this is the value the A/D sees. It should be very close to zero volts at full brightness and at least 4.5 volts in the dark. The A/D value from the LDR is only resolved to 8 bits which is then right shifted down to 6 bits, hence the maximum value of 64. This value from the LDR is then mapped to the brightness values set in the BRT configuration. The left value, 1-64, is the maximum brightness when the LDR is fully illuminated, the right value is the setting for a dark LDR, the range is 1 to brightness max.

I have seen cases of corrupt ram causing the refresh rate to go wonky as I don't validate the values before use, only check them when the user changes the brightness settings in the CFG menu. My thinking on that issue is that you've usually got bigger problems when ram gets corrupted so a reset to defaults is the only way to recover.

In the future, please do not use the Issue feature to ask questions or general conversation about the software, raising an issue is primarily for bug reports. General topics and questions can be better handled in the gitter chat room for this project here: Join the chat at https://gitter.im/stc-clock/Lobby

You will also find a link to the gitter chat on the home page for the project. Left hand side, little black and green link icons that says "chat on gitter". Each project can have its individual discussion thread, it's a very nice feature of Github.