- Posts: 1433
Devo12: enabling builtin real time clock
- rbe2012
- Topic Author
- Offline
- So much to do, so little time...
Looking at the boards I have seen that the Devo12 has a complete functional clock (battery backed up) while the Devo8 lacks some components (crystal and battery). I decided to give it a try and here it is.
The parts for my Devo8 are ordered so I will later post a checklist to make it complete. But the RTC can be used also with the internal crystal and works as long as the tx is powered on.
I implemented a page for setting time and date. The RTC can be shown (only the time) in one of the boxes simply by selecting RTC as a timer type.
On the USB page I have added two boxes for time and date.
Internally the value is stored in the format "deviation epoch" (seconds since 01.01.2012, 0:00) and is saved in the tx.ini file to check if the clock was reset when the tx was powered off or stayed running.
I have no Devo12 to check if it works correctly. So I am looking for someone who is willing to test my work. You can get it at bitbucket ( deviation-rbe-rtc) ). I synched it regularly with PBs repo so it should contain the actual developement state including the additional work Hexperience and I have done for using the bigger screen.
Please Log in or Create an account to join the conversation.
- Hexperience
- Offline
- Posts: 588
Do you think I might need to do a make devo8 first? I've seen that fix filesystem problems...
---edit---
Turned on: #define ADDON_HAS_RTC 1
Now it's showing the pages...
I'll test the clock now...
---edit---
Wow... other than the year being 2025.. my clock was already set! It was about 1 minute off real time, and I don't ever recall setting it when I had the walkera software on there.
I set the correct year, and turned it off.. letting it sit for a few minutes...
---edit---
Powers up and the clock is correct...
There are 10 types of people in this world. Those that understand binary and those that don't.
Please Log in or Create an account to join the conversation.
- Hexperience
- Offline
- Posts: 588
There are 10 types of people in this world. Those that understand binary and those that don't.
Please Log in or Create an account to join the conversation.
- rbe2012
- Topic Author
- Offline
- So much to do, so little time...
- Posts: 1433
I will look why it did not compile. I built all with "make release", devo8 comes first so I did not mention this.
The #define is added to my repo now.
I put it in the boxes as a timer because it was "easy" to do and the user has a way to show it or not and even to stop running (the screen update). On the Devo12 screen there is enough space in the top line to put the time there, but not in Devo8.
Please Log in or Create an account to join the conversation.
- rbe2012
- Topic Author
- Offline
- So much to do, so little time...
- Posts: 1433
Hexperience wrote: other than the year being 2025.. my clock was already set! It was about 1 minute off real time, and I don't ever recall setting it when I had the walkera software on there.[/attachment]
This is obviously because Walkera uses 2000 as base while I decided to use 2012. The RTC is a counter who does only know the relative time, not absolute.
Please Log in or Create an account to join the conversation.
- RCadik
- Offline
- Posts: 8
All other values are correct.
Please Log in or Create an account to join the conversation.
- clearprop88
- Offline
- Posts: 94
Will it be incorporated into the next V3.0 release for my Devo 8?
Will it be possible to re-order the date to MON/DAY/YEAR, and 12 hr format?
I don't think am, and pm would be necessary.
Thanks for the effort on this.
Please Log in or Create an account to join the conversation.
- Hexperience
- Offline
- Posts: 588
None of this will be in 3.0. 3.0 will introduce the 12s for the first time in an official release. Up to now, the 12s has only been in the nightly builds.
There are 10 types of people in this world. Those that understand binary and those that don't.
Please Log in or Create an account to join the conversation.
- clearprop88
- Offline
- Posts: 94
Please Log in or Create an account to join the conversation.
- rbe2012
- Topic Author
- Offline
- So much to do, so little time...
- Posts: 1433
For my Devo8 I built in a battery and I can see that the value is stored when the tx is off. I also soldered a crystal and capacitors at the corresponding pins but I did not get it running until now (every time I choose LSE as clock source the MCU waits endlessly for the clock to be stable - the watchdog resets the tx after short time). So I'll work on but for now I must admit it does not work...
When the tx.ini is saved when powering off (e.g. when you changed some setting) the actual clock value is stored inside and read after waking up. So it looks like the clock does not count but preserves the value but in reality the value is lost and set after powering up.
I thought about 12/24 hour format but did not implement this because (1) I would also have to code a way to choose between 12 and 24 and (2) I used the existing code for showing the time which is originally for a counter which counts until 99:59:59. But it will not be too much work so I could do this.
I also thought about different date formats. The easiest way to achieve this would be a string like "M/D/Y" which would be translated in the different languages like "D.M.Y" for German. But this needs some more effort. The other way would be to make it configurable somehow (with gui or with editing the tx.ini).
Nothing of this gets into 3.0. I can provide a build based on 3.0 when it's official released where the rtc is integrated.
Please Log in or Create an account to join the conversation.
- rbe2012
- Topic Author
- Offline
- So much to do, so little time...
- Posts: 1433
EDIT: seems to be shown only here, not in the "Recent Topics" page...
Please Log in or Create an account to join the conversation.
- FDR
- Offline
EDIT: done...
Please Log in or Create an account to join the conversation.
- RCadik
- Offline
- Posts: 8
During the process of configuring, I changed the Date amongst many things. Today turned on the radio & the date was correct. Going back to my previous model, the Date is now correct there also.
Should I look at a ini. file for the cause of this saved change?
Please Log in or Create an account to join the conversation.
- rbe2012
- Topic Author
- Offline
- So much to do, so little time...
- Posts: 1433
RCadik: The value is read always when the tx.ini is read, but it is only applied when it is greater than the value read from the clock. So if the clock is running while the tx is shut down the value must be higher (at least until 2079) than the last saved value and will be kept.
The question is: why was it set to 2026 as you mentioned in your first post? I assume you did not set the date after installing my / Hexperiences build before shutting down the first time. Then the value from the clock (seconds since 1/1/2000 as Walkera has defined it, about 423036000) will be saved in the tx.ini. When you set the date later to the correct value (will be about 36806400 and therefor less than Walkera's value because my base is 1/1/2012) and this value is not written to the tx.ini (this does not happen every time when the tx is shut down, only if something in the config has changed!! A mistake, I know, but was simply for a tx whose clock stops when shutting off so I have a better start point...), after the next start the value is set to Walkera's and this will be interpreted as 3/13/2013+(2012-2000) and should result in a date in 2025.
So I have no clue why it should have been 2026.
I will take the saving out of the code (makes no sense yet) and provide a new build (in the build section) later / at the weekend.
Please Log in or Create an account to join the conversation.
- RCadik
- Offline
- Posts: 8
Part of the problem might be that I did not do a format of the drive before installing the file system. I will go through the procedure properly and see if I get the same or similar results.
Please Log in or Create an account to join the conversation.
- RCadik
- Offline
- Posts: 8
A nice addition to the Widescreen 12S display.
Thanks for your abilities and contributions to Deviation.
Please Log in or Create an account to join the conversation.
- Home
- Forum
- Development
- Development
- Devo12: enabling builtin real time clock