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

RTC: Implement RTC detection for devices that have it (newer MM+) #1665

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions static/build/.tmp_update/runtime.sh
Aemiii91 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -763,14 +763,22 @@ save_settings() {
}

update_time() {
# Give hardware modders an option to disable time restore
if [ -f $sysdir/config/.noTimeRestore ]; then
# Detect RTC, if available, do not restore time
rtc_treshold=15 # usually around 3-5 at this point
current_time=$(date +%s)

if [ "$current_time" -gt "$rtc_treshold" ]; then
log "RTC available, not restoring time. Current time: $current_time"
return
else
log "RTC not available, restoring time. Current time: $current_time"
fi

timepath=/mnt/SDCARD/Saves/CurrentProfile/saves/currentTime.txt
currentTime=0
# Load current time
if [ -f $timepath ]; then
log "Restoring time"
currentTime=$(cat $timepath)
fi
date +%s -s @$currentTime
Expand Down
3 changes: 1 addition & 2 deletions website/docs/07-apps/01-included-in-onion/clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ description: Set your Onion's time
## Presentation

Simple clock app which allows you to manually set the clock of your device. Especially useful for the Miyoo Mini which doesn't have an internal RTC (which means that the time is reset at each boot). By default, Onion preserves the current time during shutdown, and upon the subsequent boot, it is restored with 4 hours added.

If you don't want the device to restore the time on boot (e.g. you have modded your device to have hardware RTC), you can create the file `SDCARD\.tmp_update\config\.noTimeRestore`. Doing so will prevent the time restore.
If RTC is present, which is the case with newer Miyoo Mini+, or if it is modded in, the time is not restored or advanced but will instead be set by RTC.

![](./assets/clock.png)

Expand Down
Loading