ds1302-read

cesars/ds1302/ds1302-read

No description
ds1302-read
@/ds1302-read
1302@/ds1302-dev
GETpulse
ds1302-read
Year
Month
Day
WeekDay
Hour
Minute
Second
1302
GET
Secondnumber
Minutenumber
Hournumber
WeekDaynumber
Daynumber
Monthnumber
Yearnumber
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_GET

node {
    void evaluate(Context ctx) {

        auto rtc = getValue<input_1302>(ctx);
        if (!isInputDirty<input_GET>(ctx)) return;

        if (rtc->isHalted())
        {
            DS1302::DateTime dt = {
                .year = 20,
                .month = DS1302::MONTH_OCT,
                .day = 3,
                .hour = 4,
                .minute = 51,
                .second = 30,
                .dow = DS1302::DOW_TUE
            };

            rtc->setDateTime(&dt);
        }

        DS1302::DateTime now;
        rtc->getDateTime(&now);
        static uint8_t last_second = 0;
        if (last_second != now.second)
        {
            last_second = now.second;
            emitValue<output_Year>(ctx, now.year);
            if (now.month < 10);
            emitValue<output_Month>(ctx, now.month);
            if (now.day < 10);
            emitValue<output_Day>(ctx, now.day);
            emitValue<output_WeekDay>(ctx, now.dow);
            if (now.hour < 10);
            emitValue<output_Hour>(ctx, now.hour);
            if (now.minute < 10);
            emitValue<output_Minute>(ctx, now.minute);;
            if (now.second < 10);
            emitValue<output_Second>(ctx, now.second);
        }
    }
}