Class Ds323x
Base class for DS323x family of real-time clocks
Assembly: Ds323x.dll
View Source
public class Ds323x : PollingSensorBase<Temperature>, IObservable<IChangeResult<Temperature>>, ISamplingSensor<Temperature>, ISensor<Temperature>, ISensor, ISamplingSensor, IRealTimeClock, II2cPeripheral, IDisposable
Inheritance: System.Object
-> Meadow.Foundation.ObservableBase<UNIT>
Derived:
Meadow.Foundation.RTCs.Ds3231
Implements:
System.IObservable<Meadow.IChangeResult<Meadow.Units.Temperature>>
, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Temperature>
, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Temperature>
, Meadow.Peripherals.Sensors.ISensor
, Meadow.Peripherals.Sensors.ISamplingSensor
, Meadow.Hardware.IRealTimeClock
, Meadow.Hardware.II2cPeripheral
, System.IDisposable
Properties
DefaultI2cAddress
The default I2C address for the peripheral
View Source
public byte DefaultI2cAddress { get; }
IsRunning
Stops or starts the clock oscillator
View Source
public bool IsRunning { get; set; }
IsDisposed
Is the object disposed
View Source
public bool IsDisposed { get; }
CurrentDateTime
Get / Set the current date and time.
View Source
public DateTimeOffset CurrentDateTime { get; set; }
Temperature
Get the current die temperature.
View Source
public Temperature Temperature { get; }
InterruptPort
Interrupt port attached to the DS323x RTC module.
View Source
protected IDigitalInterruptPort? InterruptPort { get; }
ControlRegister
Control register.
View Source
protected byte ControlRegister { get; set; }
ControlStatusRegister
Control and status register.
View Source
protected byte ControlStatusRegister { get; set; }
WhichAlarm
Determine which alarm has been raised.
View Source
protected Ds323x.Alarm WhichAlarm { get; }
Fields
i2cComms
I2C Communication bus used to communicate with the i2cComms
View Source
protected II2cCommunications i2cComms
Methods
ReadSensor()
Read value from sensor
View Source
protected override Task<Temperature> ReadSensor()
Returns
System.Threading.Tasks.Task<Meadow.Units.Temperature>
: unitized value### GetTime()
Reads the RTC time
View Source
public DateTimeOffset GetTime()
Returns
System.DateTimeOffset
SetTime(DateTimeOffset)
Sets the RTC time
View Source
public void SetTime(DateTimeOffset time)
Parameters
Type | Name |
---|---|
System.DateTimeOffset | time |
DecodeDateTimeRegisters(Span<byte>)
Get the the date and time register contents
View Source
protected DateTimeOffset DecodeDateTimeRegisters(Span<byte> data)
Returns
System.DateTimeOffset
: DateTimeOffset object version of the data.
Parameters
Type | Name | Description |
---|---|---|
System.Span<System.Byte> | data | Register contents. |
EncodeDateTimeRegisters(DateTimeOffset)
Encode the a DateTime object into the format used by the DS323x chips.
View Source
protected byte[] EncodeDateTimeRegisters(DateTimeOffset dt)
Returns
System.Byte[]
: Bytes to send to the DS323x chip.
Parameters
Type | Name | Description |
---|---|---|
System.DateTimeOffset | dt | DateTime object to encode. |
DayOfWeekToByte(DayOfWeek)
Convert the day of the week to a byte.
View Source
protected byte DayOfWeekToByte(DayOfWeek day)
Returns
System.Byte
: Byte representation of the day of the week (Sunday = 1).
Parameters
Type | Name | Description |
---|---|---|
System.DayOfWeek | day | Day of the week |
SetAlarm(Alarm, DateTimeOffset, AlarmType)
Set one of the two alarms on the DS323x module.
View Source
public void SetAlarm(Ds323x.Alarm alarm, DateTimeOffset time, Ds323x.AlarmType type)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Foundation.RTCs.Ds323x.Alarm | alarm | Define the alarm to be set. |
System.DateTimeOffset | time | Date and time for the alarm. |
Meadow.Foundation.RTCs.Ds323x.AlarmType | type | Type of alarm to set. |
EnableDisableAlarm(Alarm, bool)
Enable or disable the specified alarm.
View Source
public void EnableDisableAlarm(Ds323x.Alarm alarm, bool enable)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Foundation.RTCs.Ds323x.Alarm | alarm | Alarm to enable / disable. |
System.Boolean | enable | Alarm state, true = on, false = off. |
ClearInterrupt(Alarm)
Clear the alarm interrupt flag for the specified alarm.
View Source
public void ClearInterrupt(Ds323x.Alarm alarm)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Foundation.RTCs.Ds323x.Alarm | alarm | Alarm to clear. |
DisplayRegisters()
Display the registers.
View Source
public void DisplayRegisters()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
View Source
public void Dispose()
Dispose(bool)
Dispose of the object
View Source
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Is disposing |
Events
OnAlarm1Raised
Event raised when Alarm1 is triggered.
View Source
public event Ds323x.AlarmRaised OnAlarm1Raised
Event Type
Meadow.Foundation.RTCs.Ds323x.AlarmRaised
OnAlarm2Raised
Event raised when Alarm2 is triggered.
View Source
public event Ds323x.AlarmRaised OnAlarm2Raised
Event Type
Meadow.Foundation.RTCs.Ds323x.AlarmRaised
Implements
System.IObservable<Meadow.IChangeResult<Meadow.Units.Temperature>>
Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Temperature>
Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Temperature>
Meadow.Peripherals.Sensors.ISensor
Meadow.Peripherals.Sensors.ISamplingSensor
Meadow.Hardware.IRealTimeClock
Meadow.Hardware.II2cPeripheral
System.IDisposable