ds1302-write

cesars/ds1302/ds1302-write

No description
ds1302-write
@/ds1302-write
1302@/ds1302-dev
Yearnumber
Year value in range [1970, 2105]
Monthnumber
Month value in range [1, 12]
Daynumber
Days value in range [1, 28-31]
WeekDaynumber
Days value in range [1, 28-31]
Hournumber
Hours value in range [0, 23]
Minutenumber
Minutes value in range [0, 59]
Secondnumber
Seconds value in range [0, 59]
SETpulse
ds1302-write
1302
Year
Month
Day
WeekDay
Hour
Minute
Second
SET
1302'
DONE
DONEpulse
1302'@/ds1302-dev
To use the node in your project you should have the cesars/ds1302 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD evaluate_on_pin enable input_SET

node {
    void evaluate(Context ctx) {

        emitValue<output_1302U0027>(ctx, getValue<input_1302>(ctx));
        auto rtc = getValue<input_1302>(ctx);
        if (!isInputDirty<input_SET>(ctx)) return;

        DS1302::DateTime dt;

        dt.year = (uint8_t)getValue<input_Year>(ctx);
        dt.month = (uint8_t)getValue<input_Month>(ctx);
        dt.day = (uint8_t)getValue<input_Day>(ctx);
        dt.dow = (uint8_t)getValue<input_WeekDay>(ctx);
        dt.hour = (uint8_t)getValue<input_Hour>(ctx);
        dt.minute = (uint8_t)getValue<input_Minute>(ctx);
        dt.second = (uint8_t)getValue<input_Second>(ctx);
        // set the date and time
        rtc->setDateTime(&dt);

        emitValue<output_DONE>(ctx, 1);
    }
}