mirror of https://github.com/eldruin/ds323x-rs
15 lines
431 B
Rust
15 lines
431 B
Rust
use ds323x::{Ds323x, NaiveDate, Rtcc};
|
|
use linux_embedded_hal::I2cdev;
|
|
|
|
fn main() {
|
|
let dev = I2cdev::new("/dev/i2c-1").unwrap();
|
|
let mut rtc = Ds323x::new_ds3231(dev);
|
|
let datetime = NaiveDate::from_ymd(2020, 5, 1).and_hms(19, 59, 58);
|
|
rtc.set_datetime(&datetime).unwrap();
|
|
// do something else...
|
|
let time = rtc.get_time().unwrap();
|
|
println!("Time: {}", time);
|
|
|
|
let _dev = rtc.destroy_ds3231();
|
|
}
|