Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rv 3032 c7 support #258

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
cdae247
Added new class RTC_RV3032C7 (based on RTC_DS3231) to RTClib.h
alx2009 Apr 27, 2022
9a90bdf
Added RTC_RV3032C7.cpp (based on RTC_DS3231.cpp)
alx2009 Apr 27, 2022
37e69bc
Implemented basic functions in RTC_RV3032C7.cpp (set/get time, temp.,…
alx2009 Apr 29, 2022
204a393
Added basic example (tested, works)
alx2009 Apr 29, 2022
fa00641
Added enum RV3032C7AlarmMode
alx2009 May 1, 2022
b6cede3
Moved RTC_RV-3032-C7 class after PFC8523
alx2009 May 1, 2022
13e2c7b
Updated Alarm definition in RTC_RV3032C7 (only 1 alarm)
alx2009 May 1, 2022
57e7533
Added enum RV3032C7EventType
alx2009 May 1, 2022
3eee698
Added RV3032C7EventType param to RTC_RV3032C7::setAlarm
alx2009 May 1, 2022
822d767
Fix RTC_RV3032C7.getTemperature()
alx2009 May 1, 2022
c582d35
Fixed spelling of RTC_RV3032C7_EV_PollClock
alx2009 May 1, 2022
a6e2f96
Implemented RTC_RV3032C7 alarm handling in RTC_RV3032C7.cpp
alx2009 May 1, 2022
e8f83de
moved RTC_RV3032C7 class before RTC_Millis
alx2009 May 2, 2022
61b59f4
implemented enable/disable/query CLKOUT in RTC_RV3032C7 class
alx2009 May 2, 2022
5ccf131
disabled EEPROM autorefresh in RV3032C7.begin()
alx2009 May 3, 2022
54adea4
Improved Doxigen comments for RV3032C7.cpp
alx2009 May 3, 2022
83194c9
Commented out debug statements in RV3032C7.cpp
alx2009 May 3, 2022
8ebf2a6
removed unsupported RV3032C7.write/readSqwPinMode()
alx2009 May 4, 2022
7a5f9b9
comments and formatting cleaup
alx2009 May 4, 2022
b4840ed
Fixed RV3032C7 Alarms (CLKF was not handled correctly)
alx2009 May 4, 2022
4924b10
Fixed RV3032C7 Power On flag, comments
alx2009 May 5, 2022
0603424
RV3032C7, minor change to comments
alx2009 May 5, 2022
df3b75f
Added example RV3032C7_alarm
alx2009 May 5, 2022
ac4c722
Updatede keywords including RV3032C7
alx2009 May 5, 2022
01f8820
Mentioned RV3032C7 in library.properties
alx2009 May 5, 2022
5cccbd0
Improved doxygen
alx2009 May 8, 2022
a778d02
Fixed clang formatting RTC_RV3032C7.cpp
alx2009 May 9, 2022
55c0cba
Fixed clang formatting for RV3032C7 in RTClib.h
alx2009 May 9, 2022
9d55296
Doxygen fix in RTC_RV3032C7.cpp
alx2009 May 9, 2022
d153478
Update RTC_RV3032C7.cpp
alx2009 May 9, 2022
b1eb37a
RTC_RV3032C7.begin() now activates switchover to backup power
alx2009 May 10, 2022
9ff8a39
Minor improvement to doxygen for RTC_RV3032-C7.lostPower()
alx2009 May 10, 2022
67148a7
Minor update to RV3032C7_alarm.ino example
alx2009 May 10, 2022
2e617b9
fixed a bug in RTC_RV3032C7::disableAlarm() causing INT to remain active
alx2009 May 11, 2022
a01813a
Delete src.ino
alx2009 May 11, 2022
cd6216a
Retry autodetect in RV3032C7.begin() if chip unresponsive
alx2009 May 12, 2022
c203971
Minor update to comment text
alx2009 May 12, 2022
916c849
Removed unused variable
alx2009 May 12, 2022
54acc50
Update src/RTC_RV3032C7.cpp boolean -> bool
alx2009 May 14, 2022
3419921
Merge branch 'adafruit:master' into add-RV-3032-C7-support
alx2009 May 16, 2022
d4ed07b
RV3032C7: Add support for fetching alarm values
alx2009 Sep 24, 2022
d5446c4
Merge branch 'adafruit:master' into add-RV-3032-C7-support
alx2009 Sep 24, 2022
1d66ee3
RV3032C7: Initial implementation of Periodic Countdown Timer
alx2009 Sep 28, 2022
b80ef44
RTC_RV3032C7: complete support for Periodic Countdown Timer
alx2009 Sep 28, 2022
53a1f53
RTC_RV3032C7: Added deconfigureAllTimers()
alx2009 Oct 2, 2022
903f36a
Fixed Clang/Doxygen issues
alx2009 Oct 2, 2022
e415395
RV3032C7: spelling of RV3032C7TimerClockFreq enum
alx2009 Oct 2, 2022
9a33dfe
RV3032C7: Added new keywords
alx2009 Oct 2, 2022
87bff46
RV3032C7: correct initial capital for countdownTimerFired
alx2009 Oct 2, 2022
8ef285d
RV3032C7 Minor formatting correction in example
alx2009 Oct 2, 2022
3d79fd7
RV3032C7 Bug fixes affecting Timers
alx2009 Oct 2, 2022
eac0654
RV3032C7: new example showing timers usage
alx2009 Oct 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions examples/RV3032C7/RV3032C7.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Date and time functions using a RV3032C7 RTC connected via I2C and Wire lib
#include "RTClib.h"

RTC_RV3032C7 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
Serial.begin(57600);

#ifndef ESP8266
while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
while (1) delay(10);
}

if (rtc.lostPower()) {
Serial.println("RTC lost power, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}

// When time needs to be re-set on a previously configured device, the
// following line sets the RTC to the date & time this sketch was compiled
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}

void loop () {
DateTime now = rtc.now();

Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();

Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");

// calculate a date which is 7 days, 12 hours, 30 minutes, 6 seconds into the future
DateTime future (now + TimeSpan(7,12,30,6));

Serial.print(" now + 7d + 12h + 30m + 6s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();

Serial.print("Temperature: ");
Serial.print(rtc.getTemperature());
Serial.println(" C");

Serial.println();
delay(3000);
}
125 changes: 125 additions & 0 deletions examples/RV3032C7_alarm/RV3032C7_alarm.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/* Example implementation of an alarm using RV3032C7
*
* VCC and GND of RTC should be connected to some power source
* SDA, SCL of RTC should be connected to SDA, SCL of arduino
* INT should be connected to RTC_INTERRUPT_PIN
* RTC_INTERRUPT_PIN needs to work with interrupts
*/

#include <RTClib.h>
// #include <Wire.h>

RTC_RV3032C7 rtc;

// the pin that is connected to INT
#define RTC_INTERRUPT_PIN 2

void setup() {
Serial.begin(9600);

// initializing the rtc
if(!rtc.begin()) {
Serial.println("Couldn't find RTC!");
Serial.flush();
while (1) delay(10);
}

if (rtc.lostPower()) {
// this will adjust to the date and time at compilation
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}

//we don't need the CLKOUT Pin, so disable it
rtc.disableClkOut();

// Making it so, that the alarm will trigger an interrupt
pinMode(RTC_INTERRUPT_PIN, INPUT_PULLUP); // pullup is needed with RV3032C7 INT pin
attachInterrupt(digitalPinToInterrupt(RTC_INTERRUPT_PIN), onAlarm, FALLING);

// set alarm flag to false (so alarm didn't happen so far)
// if not done, this easily leads to problems, as chip register aren't reset on reboot/recompile
rtc.clearAlarm();
rtc.disableAlarm();

// schedule an alarm 60 seconds in the future
if(!rtc.setAlarm(
rtc.now() + TimeSpan(60),
RV3032C7_A_Minute // this mode triggers the alarm when the minutes match. See Doxygen for other options
)) {
Serial.println("Error, alarm wasn't set!");
}else {
Serial.println("Alarm will happen within 60 seconds!");
}
}

void loop() {
// print current time
char date[10] = "hh:mm:ss";
rtc.now().toString(date);
Serial.print(date);

// the stored alarm value + mode + event type
DateTime alarm = rtc.getAlarm();
if (alarm==RV3032C7InvalidDate) {
Serial.print(" [Alarm: off]");
} else {
RV3032C7AlarmMode alarmMode = rtc.getAlarmMode();
RV3032C7EventType eventType = rtc.getAlarmEventType();
char alarmDate[12] = "DD hh:mm:ss";
alarm.toString(alarmDate);
Serial.print(" [Alarm: ");
Serial.print(alarmDate);
Serial.print(", Mode: ");
switch (alarmMode) {
case RV3032C7_A_PerMinute: Serial.print("PerMinute"); break;
case RV3032C7_A_Minute: Serial.print("Minute"); break;
case RV3032C7_A_Hour: Serial.print("Hour"); break;
case RV3032C7_A_MinuteHour: Serial.print("Minute&Hour"); break;
case RV3032C7_A_Date: Serial.print("Date"); break;
case RV3032C7_A_MinuteDate: Serial.print("Minute&Date"); break;
case RV3032C7_A_HourDate: Serial.print("Hour&Date"); break;
case RV3032C7_A_All: Serial.print("Minute&Hour&Date"); break;
}
Serial.print(", Event: ");
switch (eventType) {
case RV3032C7_EV_Poll: Serial.print("Poll"); break;
case RV3032C7_EV_Int: Serial.print("Int"); break;
case RV3032C7_EV_IntClock: Serial.print("Int+Clock"); break;
}
Serial.print("]");
}

// the value at INT-Pin (because of pullup 1 means no alarm)
Serial.print(" INT: ");
Serial.print(digitalRead(RTC_INTERRUPT_PIN));
// whether a alarm happened happened
Serial.print(" Alarm: ");
Serial.println(rtc.alarmFired());

// status register values (see https://www.microcrystal.com/fileadmin/Media/Products/RTC/App.Manual/RV-3028-C7_App-Manual.pdf page 22)
// Serial.print(" Control: 0d");
// Serial.println(read_i2c_register(0x51, 0xd), BIN);

// resetting INT and alarm 1 flag
// using setAlarm, the next alarm could now be configured
if (rtc.alarmFired()) {
rtc.clearAlarm(); Serial.println(" - Alarm cleared");
//rtc.disableAlarm(); Serial.println(" - Alarm disabled"); // uncomment to disable further alarms
}
Serial.println();

delay(2000);
}

void onAlarm() {
Serial.println("Alarm occured!");
}

/*static uint8_t read_i2c_register(uint8_t addr, uint8_t reg) {
Wire.beginTransmission(addr);
Wire.write((byte)reg);
Wire.endTransmission();

Wire.requestFrom(addr, (byte)1);
return Wire.read();
}*/
Loading