mirror of https://github.com/eldruin/ds323x-rs
Extend linux example
parent
ce7463fc51
commit
9ce8d106ce
|
@ -3,10 +3,22 @@ extern crate linux_embedded_hal;
|
||||||
extern crate ds323x;
|
extern crate ds323x;
|
||||||
|
|
||||||
use linux_embedded_hal::I2cdev;
|
use linux_embedded_hal::I2cdev;
|
||||||
use ds323x::Ds323x;
|
use ds323x::{ Ds323x, DateTime, Hours };
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let dev = I2cdev::new("/dev/i2c-1").unwrap();
|
let dev = I2cdev::new("/dev/i2c-1").unwrap();
|
||||||
let mut rtc = Ds323x::new_ds3231(dev);
|
let mut rtc = Ds323x::new_ds3231(dev);
|
||||||
println!("Seconds: {}", rtc.get_seconds().unwrap());
|
let datetime = DateTime {
|
||||||
|
year: 2018,
|
||||||
|
month: 08,
|
||||||
|
day: 20,
|
||||||
|
weekday: 4,
|
||||||
|
hour: Hours::H24(19),
|
||||||
|
minute: 59,
|
||||||
|
second: 58
|
||||||
|
};
|
||||||
|
rtc.set_datetime(&datetime).unwrap();
|
||||||
|
// do something else...
|
||||||
|
let seconds = rtc.get_seconds().unwrap();
|
||||||
|
println!("Seconds: {}", seconds);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue