set time w/ seconds
This commit is contained in:
parent
d456c3321c
commit
99c5d23d35
|
@ -216,7 +216,7 @@ impl Pli {
|
|||
let now = chrono::Local::now();
|
||||
let timestamp = (((now.hour() * 10) + (now.minute() / 6)) & 0xFF) as u8;
|
||||
let min = (now.minute() % 6) as u8;
|
||||
log::warn!("Setting time: {now} corresponds to {timestamp} + minutes {min}");
|
||||
let sec = (now.second() / 2).min(29) as u8;
|
||||
if self
|
||||
.write_ram(PlRamAddress::Hour, timestamp)
|
||||
.some_or_print_with("Setting time")
|
||||
|
@ -224,9 +224,19 @@ impl Pli {
|
|||
{
|
||||
return;
|
||||
}
|
||||
let _ = self
|
||||
if self
|
||||
.write_ram(PlRamAddress::Min, min)
|
||||
.some_or_print_with("Setting time (minutes)");
|
||||
.some_or_print_with("Setting time (minutes)")
|
||||
.is_none()
|
||||
{
|
||||
return;
|
||||
}
|
||||
let _ = self
|
||||
.write_ram(PlRamAddress::Sec, sec)
|
||||
.some_or_print_with("Setting time (seconds)");
|
||||
log::warn!(
|
||||
"Set time: {now} corresponds to {timestamp} + minutes {min} + seconds {sec}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,6 +314,7 @@ impl Pli {
|
|||
|
||||
enum PlRamAddress {
|
||||
Dutycyc,
|
||||
Sec,
|
||||
Min,
|
||||
Hour,
|
||||
Batv,
|
||||
|
@ -318,6 +329,7 @@ impl From<PlRamAddress> for u8 {
|
|||
fn from(value: PlRamAddress) -> Self {
|
||||
match value {
|
||||
PlRamAddress::Dutycyc => 39,
|
||||
PlRamAddress::Sec => 46,
|
||||
PlRamAddress::Min => 47,
|
||||
PlRamAddress::Hour => 48,
|
||||
PlRamAddress::Batv => 50,
|
||||
|
|
Loading…
Reference in a new issue