Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of rtc_class by
Date.cpp@4:a4d39c018c65, 2015-04-20 (annotated)
- Committer:
- bulmecisco
- Date:
- Mon Apr 20 08:35:58 2015 +0000
- Revision:
- 4:a4d39c018c65
- Parent:
- 3:c6081814064d
- Child:
- 5:fc8c66a7c87a
to_String added to class Date
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bulmecisco | 3:c6081814064d | 1 | #include "mbed.h" |
| bulmecisco | 3:c6081814064d | 2 | #include "Date.h" |
| bulmecisco | 3:c6081814064d | 3 | |
| bulmecisco | 3:c6081814064d | 4 | // http://developer.mbed.org/teams/HIMBED_3AHELI/code/rtc_func/wiki/Homepage |
| bulmecisco | 3:c6081814064d | 5 | uint8_t Date::bcdToUint(uint8_t const nybbles) |
| bulmecisco | 3:c6081814064d | 6 | { |
| bulmecisco | 3:c6081814064d | 7 | uint8_t result; |
| bulmecisco | 3:c6081814064d | 8 | result = (nybbles>>4)*10 + (nybbles & 0x0F); |
| bulmecisco | 3:c6081814064d | 9 | return result; |
| bulmecisco | 3:c6081814064d | 10 | } |
| bulmecisco | 3:c6081814064d | 11 | |
| bulmecisco | 4:a4d39c018c65 | 12 | string Date::toString(uint8_t value) |
| bulmecisco | 4:a4d39c018c65 | 13 | { |
| bulmecisco | 4:a4d39c018c65 | 14 | //return std::to_string(value); // ab C++ version 11 |
| bulmecisco | 4:a4d39c018c65 | 15 | char buffer[2]; |
| bulmecisco | 4:a4d39c018c65 | 16 | sprintf (buffer, "%d", value); // ToString() |
| bulmecisco | 4:a4d39c018c65 | 17 | return buffer; |
| bulmecisco | 4:a4d39c018c65 | 18 | } |
| bulmecisco | 4:a4d39c018c65 | 19 | |
| bulmecisco | 3:c6081814064d | 20 | uint8_t Date::GetDay() |
| bulmecisco | 3:c6081814064d | 21 | { |
| bulmecisco | 3:c6081814064d | 22 | uint8_t day = rtc_read(DAYS); |
| bulmecisco | 3:c6081814064d | 23 | return bcdToUint(day & 0x3F); |
| bulmecisco | 3:c6081814064d | 24 | } |
