mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Support for muzi works R1 Neo device.
Support for R1 Neo hardware. New variant and baseboard class. * Known issues: - power management is not currently supported - power off via long button press is not implemented Add support for Epson Seiko RX8130CE I2C Real-time clock.
This commit is contained in:
parent
2715d3a113
commit
5d1f5139ae
10 changed files with 853 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "AutoDiscoverRTCClock.h"
|
||||
#include "RTClib.h"
|
||||
#include <Melopero_RV3028.h>
|
||||
#include "RTC_RX8130CE.h"
|
||||
|
||||
static RTC_DS3231 rtc_3231;
|
||||
static bool ds3231_success = false;
|
||||
|
|
@ -11,9 +12,13 @@ static bool rv3028_success = false;
|
|||
static RTC_PCF8563 rtc_8563;
|
||||
static bool rtc_8563_success = false;
|
||||
|
||||
static RTC_RX8130CE rtc_8130;
|
||||
static bool rtc_8130_success = false;
|
||||
|
||||
#define DS3231_ADDRESS 0x68
|
||||
#define RV3028_ADDRESS 0x52
|
||||
#define PCF8563_ADDRESS 0x51
|
||||
#define RX8130CE_ADDRESS 0x32
|
||||
|
||||
bool AutoDiscoverRTCClock::i2c_probe(TwoWire& wire, uint8_t addr) {
|
||||
wire.beginTransmission(addr);
|
||||
|
|
@ -25,6 +30,7 @@ void AutoDiscoverRTCClock::begin(TwoWire& wire) {
|
|||
if (i2c_probe(wire, DS3231_ADDRESS)) {
|
||||
ds3231_success = rtc_3231.begin(&wire);
|
||||
}
|
||||
|
||||
if (i2c_probe(wire, RV3028_ADDRESS)) {
|
||||
rtc_rv3028.initI2C(wire);
|
||||
rtc_rv3028.writeToRegister(0x35, 0x00);
|
||||
|
|
@ -32,15 +38,24 @@ void AutoDiscoverRTCClock::begin(TwoWire& wire) {
|
|||
rtc_rv3028.set24HourMode(); // Set the device to use the 24hour format (default) instead of the 12 hour format
|
||||
rv3028_success = true;
|
||||
}
|
||||
if(i2c_probe(wire,PCF8563_ADDRESS)){
|
||||
|
||||
if (i2c_probe(wire, PCF8563_ADDRESS)) {
|
||||
rtc_8563_success = rtc_8563.begin(&wire);
|
||||
}
|
||||
|
||||
if (i2c_probe(wire, RX8130CE_ADDRESS)) {
|
||||
MESH_DEBUG_PRINTLN("RX8130CE: Found");
|
||||
rtc_8130.begin(&wire);
|
||||
rtc_8130_success = true;
|
||||
MESH_DEBUG_PRINTLN("RX8130CE: Initialized");
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AutoDiscoverRTCClock::getCurrentTime() {
|
||||
if (ds3231_success) {
|
||||
return rtc_3231.now().unixtime();
|
||||
}
|
||||
|
||||
if (rv3028_success) {
|
||||
return DateTime(
|
||||
rtc_rv3028.getYear(),
|
||||
|
|
@ -51,9 +66,16 @@ uint32_t AutoDiscoverRTCClock::getCurrentTime() {
|
|||
rtc_rv3028.getSecond()
|
||||
).unixtime();
|
||||
}
|
||||
if(rtc_8563_success){
|
||||
|
||||
if (rtc_8563_success) {
|
||||
return rtc_8563.now().unixtime();
|
||||
}
|
||||
|
||||
if (rtc_8130_success) {
|
||||
MESH_DEBUG_PRINTLN("RX8130CE: Reading time");
|
||||
return rtc_8130.now().unixtime();
|
||||
}
|
||||
|
||||
return _fallback->getCurrentTime();
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +88,9 @@ void AutoDiscoverRTCClock::setCurrentTime(uint32_t time) {
|
|||
rtc_rv3028.setTime(dt.year(), dt.month(), weekday, dt.day(), dt.hour(), dt.minute(), dt.second());
|
||||
} else if (rtc_8563_success) {
|
||||
rtc_8563.adjust(DateTime(time));
|
||||
} else if (rtc_8130_success) {
|
||||
MESH_DEBUG_PRINTLN("RX8130CE: Setting time");
|
||||
rtc_8130.adjust(DateTime(time));
|
||||
} else {
|
||||
_fallback->setCurrentTime(time);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue