Rtc class

Dependencies:   RTC8563 mbed

Fork of rtc_class by HIMBED_3AHELI

Date.cpp

Committer:
bulmecisco
Date:
2015-04-20
Revision:
4:a4d39c018c65
Parent:
3:c6081814064d
Child:
5:fc8c66a7c87a

File content as of revision 4:a4d39c018c65:

#include "mbed.h"
#include "Date.h"

// http://developer.mbed.org/teams/HIMBED_3AHELI/code/rtc_func/wiki/Homepage
uint8_t Date::bcdToUint(uint8_t const nybbles)
{
    uint8_t result;
    result = (nybbles>>4)*10 + (nybbles & 0x0F);
    return result;
}

string Date::toString(uint8_t value)
{
    //return std::to_string(value); // ab C++ version 11
    char buffer[2];
    sprintf (buffer, "%d", value);  // ToString()
    return buffer;
}    

uint8_t Date::GetDay()
{
    uint8_t day = rtc_read(DAYS);
    return bcdToUint(day & 0x3F);
}