2022-02-20 09:17:55 +00:00
|
|
|
use ds323x::{DateTimeAccess, Ds323x, NaiveDate, Rtcc};
|
2020-07-10 20:24:29 +00:00
|
|
|
use linux_embedded_hal::I2cdev;
|
2018-10-28 09:32:41 +00:00
|
|
|
|
|
|
|
fn main() {
|
2020-07-10 20:24:29 +00:00
|
|
|
let dev = I2cdev::new("/dev/i2c-1").unwrap();
|
2018-10-28 09:32:41 +00:00
|
|
|
let mut rtc = Ds323x::new_ds3231(dev);
|
2023-07-16 11:43:46 +00:00
|
|
|
let datetime = NaiveDate::from_ymd_opt(2020, 5, 1)
|
|
|
|
.unwrap()
|
|
|
|
.and_hms_opt(19, 59, 58)
|
|
|
|
.unwrap();
|
2018-11-16 16:36:15 +00:00
|
|
|
rtc.set_datetime(&datetime).unwrap();
|
|
|
|
// do something else...
|
2022-02-20 09:17:55 +00:00
|
|
|
let time = rtc.time().unwrap();
|
2020-05-02 09:36:42 +00:00
|
|
|
println!("Time: {}", time);
|
2018-11-16 18:48:56 +00:00
|
|
|
|
2018-11-16 18:42:47 +00:00
|
|
|
let _dev = rtc.destroy_ds3231();
|
2018-10-28 09:32:41 +00:00
|
|
|
}
|