Skip to content

Commit

Permalink
Merge pull request #5 from hasenradball/develop
Browse files Browse the repository at this point in the history
Add Status Badges to Readme.md file
  • Loading branch information
hasenradball authored Dec 5, 2023
2 parents 2c78c0d + 7c8a344 commit 6f9a3b2
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compile_examples.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Compile examples folder
name: Compile Examples

on:
- push
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/spell_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Spell Check

on:
pull_request:
push:
schedule:
# Run every Saturday at 3 AM UTC to catch new misspelling detections resulting from dictionary updates.
- cron: "0 3 * * 6"
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:

jobs:
spellcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

# See: https://github.com/codespell-project/actions-codespell/blob/master/README.md
- name: Spell check
uses: codespell-project/actions-codespell@master
2 changes: 1 addition & 1 deletion Documentation/Alarms.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ bool checkIfAlarm(byte Alarm);

NOTE TO PROGRAMMERS: this version of the method always overwrites the value of the alarm flag to zero. An alternate version, below, allows programs an option to preserve the value of the flag in the DS3231.

It may be desirable to do so in programs that re-use a single alarm repeatedly.
It may be desirable to do so in programs that reuse a single alarm repeatedly.

The flag value is returned to the program, where it may be assigned to a program variable for later evaluation and use.

Expand Down
2 changes: 1 addition & 1 deletion Documentation/Utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ An algorithm is developed to divide the 65,536 interrupts into ten, nearly-equal

Dividing by other values can be approached similarly. The program writer would need to work out the applicable numbers of steps and interval lengths.

Comments in the example provide additional documentaiton.
Comments in the example provide additional documentation.

```
#include <DS3231-RTC.h>
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# DS3231-RTC Library
![](https://github.com/hasenradball/DS3231-RTC/actions/workflows/spell_checker.yml/badge.svg)
![](https://github.com/hasenradball/DS3231-RTC/actions/workflows/compile_examples.yml/badge.svg)

The **great** C++ Library for the DS3231 real-time clock (RTC) module.

## Description
Expand All @@ -17,8 +20,8 @@ You do have to install the Library in your Arduino IDE environment before you ca
This library was based on the master branch of [NorthernWidget/DS3231](https://github.com/NorthernWidget/DS3231) Library in Oct/2023. It was reworked and refractured with respect of the following main topics:
* using standardized functions of the `time.h` library.
* introduce a `struct tm` which holds all relevant date and time values.
* restrucure comments, so that syntax highlighting works fine.
* add a `show_DateTime()` function with can be used to print a user specific(self defined) DateTime string easily.
* restructure comments, so that syntax highlighting works fine.
* add a `strf_DateTime()` function with can be used to print a user specific(self defined) DateTime string easily.

## Contents

Expand Down Expand Up @@ -83,7 +86,7 @@ The Library incorporates two other classes to assist with managing `date` and `t
* `DateTime` class enables a object for managing date and time data.
* `RTClib` class institutes a convenient `RTClib::now()` function for receiving a date/time snapshot, as a DateTime object, from the DS3231 device.

The `DateTime` class can be instanciated by a specific date and time in three different ways:
The `DateTime` class can be instantiated by a specific date and time in three different ways:

* 1.) by distinct values for:<br>
year, month, day, hour, minute and second
Expand All @@ -94,7 +97,7 @@ year, month, day, hour, minute and second

* 3.) by giving a separate `const char *` string for Date and Time like:<br>
`"Feb 16 2022"` and `"14:05:00"`<br>
This can be also achived by usage on the precomoiler Tags `__DATE__` and `__TIME__`.
This can be also achieved by usage on the precompiler Tags `__DATE__` and `__TIME__`.



Expand Down Expand Up @@ -275,7 +278,7 @@ further lists the DateTime class methods (for Documentation look into the src fi
- getWeekDay()
- getYearDay()
- getDST()
- show_DateTime()
- strf_DateTime()
- getUnixTime()
- getY2KTime()

Expand All @@ -290,7 +293,7 @@ The function returns a DateTime object. To use it in your program, declare a Dat
The value of `currentMoment` can then be accessed as either:
* getting an unsigned integer containing the number of seconds since a certain reference date (Unix-Time or Y2K-Time)
* distinct values out of the `struct tm` for Year, Month, Day, Date, Hour, Minute, Second etc...<br>
see [Definiton of struct tm](https://en.cppreference.com/w/c/chrono/tm).
see [Definition of struct tm](https://en.cppreference.com/w/c/chrono/tm).

[back to the list of functions](#functions)<br>
[back to top](#ds3231-rtc-library)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void setup () {
//auto tic{micros()};
DateTime datetime = myRTC.now();
//auto toc {micros()};
//Serial.print("\n\nDateTime Class instatiation duration: ");
//Serial.print("\n\nDateTime Class instantiation duration: ");
//Serial.print(toc-tic);
//Serial.println(" µs");

Expand Down Expand Up @@ -122,9 +122,9 @@ void setup () {
Serial.print("\n\nPrint Data via function <showTimeFormated> of Struct tm:\n\t");
showTimeFormated(tstmp);

Serial.print("\nPrint Data via DataTime function <show_DateTime>:\n\t");
Serial.print("\nPrint Data via DataTime function <strf_DateTime>:\n\t");
char buffer[80];
datetime.show_DateTime(buffer, sizeof(buffer));
datetime.strf_DateTime(buffer, sizeof(buffer));
Serial.println(buffer);

//Serial.print("\nPrint __DATE__ and __TIME__:\n");
Expand Down
4 changes: 2 additions & 2 deletions examples/setEpoch/setEpoch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ void setup () {
showTimeFormated(tstmp);

// Use smart print function from DateTime class
Serial.print("\nUse show_DateTime function:\n ");
Serial.print("\nUse strf_DateTime function:\n ");
// provide a buffer
char buffer[80];
datetime.show_DateTime(buffer, sizeof(buffer));
datetime.strf_DateTime(buffer, sizeof(buffer));
Serial.println(buffer);
}

Expand Down
8 changes: 4 additions & 4 deletions extras/bytemap/bytemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct bits3231 {
unsigned :1; // skip high bit
// 01h time minutes 00 - 59
unsigned timeMin:4; // minutes digit 0 - 9
unsigned timeMin10:3; // tens of minuts digit 0 - 5
unsigned timeMin10:3; // tens of minutes digit 0 - 5
unsigned: 1; // skip high bit
// 02h time hour 1 - 12 or 0 - 23
unsigned timeHour:4; // hours digit 0 - 9
Expand Down Expand Up @@ -35,7 +35,7 @@ struct bits3231 {
unsigned A1M1:1; // Alarm 1 Bit 1
// 08h Alarm 1 minutes 00 - 59
unsigned A1Min:4; // minutes digit 0 - 9
unsigned A1Min10:3; // tens of minuts digit 0 - 5
unsigned A1Min10:3; // tens of minutes digit 0 - 5
unsigned: A1M2; // Alarm 1 Bit 2
// 09h Alarm 1 hour 1 - 12 or 0 - 23
unsigned A1Hour:4; // hours digit 0 - 9
Expand All @@ -53,7 +53,7 @@ struct bits3231 {
//
// 0Bh Alarm 2 minutes 00 - 59
unsigned A2Min:4; // minutes digit 0 - 9
unsigned A2Min10:3; // tens of minuts digit 0 - 5
unsigned A2Min10:3; // tens of minutes digit 0 - 5
unsigned: A2M2; // Alarm 2 Bit 2
// 0Ch Alarm 2 hour 1 - 12 or 0 - 23
unsigned A2Hour:4; // hours digit 0 - 9
Expand All @@ -73,7 +73,7 @@ struct bits3231 {
unsigned RS2:1; // set square wave frequency
unsigned RS1:1; // set square wave frequency
unsigned INTCN:1; // interrupt control, high enables interrupt output
unsigned A2IE:1; // enbable interrupt on A2 match
unsigned A2IE:1; // enable interrupt on A2 match
unsigned A1IE:1; // enable interrupt on A1 match
// 0Fh Device control / status register
unsigned OSF:1; // oscillator stop flag
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DateTime KEYWORD1
now KEYWORD2
getY2kTime KEYWORD2
getUnixTime KEYWORD2
strf_DateTime KEYWORD2
getWeekDay KEYWORD2
getDST KEYWORD2
getSecond KEYWORD2
Expand Down
12 changes: 7 additions & 5 deletions src/DS3231-RTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,17 @@ void DateTime::set_timstamps() {
}

/**
* @brief smart time print function based on the standard strftime function
* see: https://en.cppreference.com/w/cpp/chrono/c/strftime
* @brief function to format a DateTime string in an buffer based on the standard strftime function
*
* see: https://cplusplus.com/reference/ctime/strftime/
* or: https://en.cppreference.com/w/cpp/chrono/c/strftime
*
* @param buffer buffer for time string
* @param buffersize size of buffer
* @param formatSpec define format see strftime
* @return size_t lenth of used buffer
* @return size_t length of used buffer
*/
size_t DateTime::show_DateTime(char *buffer, size_t buffersize, const char *formatSpec) {
size_t DateTime::strf_DateTime(char *buffer, size_t buffersize, const char *formatSpec) {
size_t len {strftime(buffer, buffersize, formatSpec, &_tm)};
return len;
}
Expand Down Expand Up @@ -178,7 +180,7 @@ DateTime RTClib::now(TwoWire & _Wire) {
int16_t yday = calcYearDay(year, month, day);
int16_t dst = -1;

// REMARK: add DST calculation if needed, but therfore timezone info is needed!
// REMARK: add DST calculation if needed, but therefore timezone info is needed!
// use the complete set also yearday and dst for having a complete struct tm
return DateTime{year, month, day, hour, min, sec, wday, yday, dst};
}
Expand Down
4 changes: 2 additions & 2 deletions src/DS3231-RTC.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DateTime {
int8_t getWeekDay() const { return _tm.tm_wday; }
int16_t getYearDay() const { return _tm.tm_yday; }
int16_t getDST() const { return _tm.tm_isdst; }
size_t show_DateTime(char *buffer, size_t buffersize, const char *formatSpec = "%a %h %d %T %Y");
size_t strf_DateTime(char *buffer, size_t buffersize, const char *formatSpec = "%a %h %d %T %Y");

// time_t value as seconds since 1/1/2000
time_t getY2kTime() const { return _y2k_timestamp; }
Expand Down Expand Up @@ -167,7 +167,7 @@ class DS3231 {
* 1 0 0 0 Alarm when DoW, hour, min match
*
* Note: byte AlarmBits is not explicitly cleared for the getAXTime methods to
* support sequential retreival of both alarms with the same byte AlarmBits.
* support sequential retrieval of both alarms with the same byte AlarmBits.
* Use the flag bool clearAlarmBits=True to explicitly clear byte AlarmBits on
* call to getAXTime.
*/
Expand Down

0 comments on commit 6f9a3b2

Please sign in to comment.