shufps / diy-projector-clock

DIY Projector Clock
118 stars 8 forks source link

Clock doesn't reset to 0:00 after 23:59. It keeps counting the hours to 24, 25, 26... #3

Closed SmallestLeslie closed 4 years ago

SmallestLeslie commented 4 years ago

I would like to ask for your help. I'm trying to build the projector clock project I found here as a Chirstmas gift for my brother and I encountered some strange behavior with the firmware. When it is in the time adjust mode it works as it should but during normal operation mode after 23:59 the date doesn't increment and the clock doesn't turn over to 0:00. Rather it keeps incrementing the hours to 24, 25 and so on.

I would like to ask if you encountered a similar behavior and if you have an updated firmware.

shufps commented 4 years ago

Oh, interesting observation! :see_no_evil:

Have to admit - my girlfriend didn't want me to use the projector-clock in the bed-room, so it didn't ever run so long :/

Hmm, oh that is this silly STM32F103 microcontroller ... it really doesn't care about overflows at 24:00.

Could you retry by changing this line: https://github.com/shufps/diy-projector-clock/blob/master/src/src/main.cpp#L233

from: rtc_getTime24(&RTC_TimeStructure); rtc_getDate(&RTC_DateStructure);

to: rtc_checkUpdateDate(&RTC_TimeStructure, &RTC_DateStructure); rtc_getTime24(&RTC_TimeStructure); rtc_getDate(&RTC_DateStructure);

The checkUpdateDate-function also is used when reconnecting the main-power while the RTC run on battery-backup. The seconds count continuosly up. When reconnecting the clock to the main-power it has to figure out how many days have passed and it adjusts the date accordingly by calling this function.

The same has to be done for the clock not running on battery. After the RTC-counter reaches 86400 seconds, it has to be reset and the date has to be adjusted.

I hope this solves your issues :)

Btw, I would looooooove seeing a picture of your clock :heart_eyes:

PS: Do you need a compiled binary?

shufps commented 4 years ago

You can use the binary from this branch which has the fix: https://github.com/shufps/diy-projector-clock/tree/24hoursbug

If it works, I'll merge into the master-branch :)

SmallestLeslie commented 4 years ago

Unfortunately I haven't been able to compile even the original source due to the lack of unistd.h in my system (windows). I would be happy if you could compile it for me. Am I correct that you did compile on linux?

Oh, and one more question. In the rtc_checkUpdateDate is the "switch (date->RTC_Date)" correct? Shouldn't it be RTC_Month?

SmallestLeslie commented 4 years ago

Thank you very much for the binary! I will try it tonight.

shufps commented 4 years ago

Oh yes, you are right! I changed it and updated the branch :)

Yes, I'm using Linux - never tried Windows, sorry :thinking: :man_shrugging:

SmallestLeslie commented 4 years ago

I haven't made a casing for it but I want to do it in the following days. Then I will post a picture I promise.

never tried Windows, sorry

I shouldn't have either :)

Thank you for your help! You saved me.

SmallestLeslie commented 4 years ago

I burned the modified FW into the MCU last night and it works now. Thank you very much.

If it is possible I would like to ask you for a small modification. Could you please change the names of the days as the following? Monday = H Tuesday = K Wednesday = Sze Thursday = Cs Friday = P Saturday = Szo Sunday = V

If I'm correct the line "char dayNames[][12] = { "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So" };" should be modified in the main.cpp to "char dayNames[][12] = { "H", "K", "Sze", "Cs", "P", "Szo", "V" };".

Unfortunately in our language it is not common to use abbreviations of names of the days with uniform length and furthermore there are special characters like: é á ö ő ü. It is fine for now if the text is not aligned dynamically. I will take care of it once I'm able to setup a working toolchain.

Thank you once more!

shufps commented 4 years ago

Try this one: https://github.com/shufps/diy-projector-clock/tree/altweekdaynames

I tried to center the text - but couldn't test it :man_shrugging:

SmallestLeslie commented 4 years ago

It works and it is perfect! Finally I finished the casing. I am inexperienced so I messed up multiple times but at the end it seems I was able to finish it. I don't have a 3d printer so I made the casing out of 3 and 5 mm thick ABS plastic sheets and then glued and screwed together. I bought a lens for this project but it turned out to be useless so I had to improvise. The box should be lower but I made it based on a wrong version of the drawings. The clock still needs a better fitting knob. 1_1 2_1 3_1 4_1 5_1 6_1 7_1

shufps commented 4 years ago

wow gratulation! love it :heart: