Skip to content
4 changes: 2 additions & 2 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if __has_include("Melopero_RV3028.h")
#include "Melopero_RV3028.h"
#endif
#if __has_include("pcf8563.h")
#include "pcf8563.h"
#if __has_include("SensorRtcHelper.hpp")
#include "SensorRtcHelper.hpp"
#endif

// -----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/detect/ScanI2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ ScanI2C::FoundDevice ScanI2C::firstScreen() const

ScanI2C::FoundDevice ScanI2C::firstRTC() const
{
ScanI2C::DeviceType types[] = {RTC_RV3028, RTC_PCF8563};
return firstOfOrNONE(2, types);
ScanI2C::DeviceType types[] = {RTC_RV3028, RTC_PCF8563, RTC_PCF85063};
return firstOfOrNONE(3, types);
}

ScanI2C::FoundDevice ScanI2C::firstKeyboard() const
Expand Down
1 change: 1 addition & 0 deletions src/detect/ScanI2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ScanI2C
SCREEN_ST7567,
RTC_RV3028,
RTC_PCF8563,
RTC_PCF85063,
CARDKB,
TDECKKB,
BBQ10KB,
Expand Down
4 changes: 4 additions & 0 deletions src/detect/ScanI2CTwoWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
SCAN_SIMPLE_CASE(PCF8563_RTC, RTC_PCF8563, "PCF8563", (uint8_t)addr.address)
#endif

#ifdef PCF85063_RTC
SCAN_SIMPLE_CASE(PCF85063_RTC, RTC_PCF85063, "PCF85063", (uint8_t)addr.address)
#endif

case CARDKB_ADDR:
// Do we have the RAK14006 instead?
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x04), 1);
Expand Down
48 changes: 29 additions & 19 deletions src/gps/RTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,26 @@ RTCSetResult readFromRTC()
currentQuality = RTCQualityDevice;
}
return RTCSetResultSuccess;
} else {
LOG_WARN("RTC not found (found address 0x%02X)", rtc_found.address);
}
#elif defined(PCF8563_RTC)
#elif defined(PCF8563_RTC) || defined(PCF85063_RTC)
#if defined(PCF8563_RTC)
if (rtc_found.address == PCF8563_RTC) {
#elif defined(PCF85063_RTC)
if (rtc_found.address == PCF85063_RTC) {
#endif
uint32_t now = millis();
PCF8563_Class rtc;
SensorRtcHelper rtc;

#if WIRE_INTERFACES_COUNT == 2
rtc.begin(rtc_found.port == ScanI2C::I2CPort::WIRE1 ? Wire1 : Wire);
#else
rtc.begin();
rtc.begin(Wire);
#endif

auto tc = rtc.getDateTime();
tm t;
t.tm_year = tc.year - 1900;
t.tm_mon = tc.month - 1;
t.tm_mday = tc.day;
t.tm_hour = tc.hour;
t.tm_min = tc.minute;
t.tm_sec = tc.second;
RTC_DateTime datetime = rtc.getDateTime();
tm t = datetime.toUnixTime();
tv.tv_sec = gm_mktime(&t);
tv.tv_usec = 0;
uint32_t printableEpoch = tv.tv_sec; // Print lib only supports 32 bit but time_t can be 64 bit on some platforms
Expand All @@ -100,14 +100,16 @@ RTCSetResult readFromRTC()
}
#endif

LOG_DEBUG("Read RTC time from PCF8563 getDateTime as %02d-%02d-%02d %02d:%02d:%02d (%ld)", t.tm_year + 1900, t.tm_mon + 1,
t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, printableEpoch);
LOG_DEBUG("Read RTC time from %s getDateTime as %02d-%02d-%02d %02d:%02d:%02d (%ld)", rtc.getChipName(), t.tm_year + 1900,
t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, printableEpoch);
if (currentQuality == RTCQualityNone) {
timeStartMsec = now;
zeroOffsetSecs = tv.tv_sec;
currentQuality = RTCQualityDevice;
}
return RTCSetResultSuccess;
} else {
LOG_WARN("RTC not found (found address 0x%02X)", rtc_found.address);
}
#else
if (!gettimeofday(&tv, NULL)) {
Expand Down Expand Up @@ -199,20 +201,28 @@ RTCSetResult perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpd
rtc.setTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_wday, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
LOG_DEBUG("RV3028_RTC setTime %02d-%02d-%02d %02d:%02d:%02d (%ld)", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec, printableEpoch);
} else {
LOG_WARN("RTC not found (found address 0x%02X)", rtc_found.address);
}
#elif defined(PCF8563_RTC)
#elif defined(PCF8563_RTC) || defined(PCF85063_RTC)
#if defined(PCF8563_RTC)
if (rtc_found.address == PCF8563_RTC) {
PCF8563_Class rtc;
#elif defined(PCF85063_RTC)
if (rtc_found.address == PCF85063_RTC) {
#endif
SensorRtcHelper rtc;

#if WIRE_INTERFACES_COUNT == 2
rtc.begin(rtc_found.port == ScanI2C::I2CPort::WIRE1 ? Wire1 : Wire);
#else
rtc.begin();
rtc.begin(Wire);
#endif
tm *t = gmtime(&tv->tv_sec);
rtc.setDateTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
LOG_DEBUG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d (%ld)", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec, printableEpoch);
rtc.setDateTime(*t);
LOG_DEBUG("%s setDateTime %02d-%02d-%02d %02d:%02d:%02d (%ld)", rtc.getChipName(), t->tm_year + 1900, t->tm_mon + 1,
t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, printableEpoch);
} else {
LOG_WARN("RTC not found (found address 0x%02X)", rtc_found.address);
}
#elif defined(ARCH_ESP32)
settimeofday(tv, NULL);
Expand Down
10 changes: 4 additions & 6 deletions src/motion/BMA423Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

#if !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && defined(HAS_BMA423) && __has_include(<SensorBMA423.hpp>)

using namespace MotionSensorI2C;

BMA423Sensor::BMA423Sensor(ScanI2C::FoundDevice foundDevice) : MotionSensor::MotionSensor(foundDevice) {}

bool BMA423Sensor::init()
{
if (sensor.begin(deviceAddress(), &MotionSensorI2C::readRegister, &MotionSensorI2C::writeRegister)) {
if (sensor.begin(Wire, deviceAddress())) {
sensor.configAccelerometer(sensor.RANGE_2G, sensor.ODR_100HZ, sensor.BW_NORMAL_AVG4, sensor.PERF_CONTINUOUS_MODE);
sensor.enableAccelerometer();
sensor.configInterrupt(BMA4_LEVEL_TRIGGER, BMA4_ACTIVE_HIGH, BMA4_PUSH_PULL, BMA4_OUTPUT_ENABLE, BMA4_INPUT_DISABLE);
sensor.configInterrupt();

#ifdef BMA423_INT
pinMode(BMA4XX_INT, INPUT);
Expand All @@ -26,7 +24,7 @@ bool BMA423Sensor::init()

#ifdef T_WATCH_S3
// Need to raise the wrist function, need to set the correct axis
sensor.setReampAxes(sensor.REMAP_TOP_LAYER_RIGHT_CORNER);
sensor.setRemapAxes(sensor.REMAP_TOP_LAYER_RIGHT_CORNER);
#else
sensor.setReampAxes(sensor.REMAP_BOTTOM_LAYER_BOTTOM_LEFT_CORNER);
#endif
Expand All @@ -50,7 +48,7 @@ bool BMA423Sensor::init()

int32_t BMA423Sensor::runOnce()
{
if (sensor.readIrqStatus() != DEV_WIRE_NONE) {
if (sensor.readIrqStatus()) {
if (sensor.isTilt() || sensor.isDoubleTap()) {
wakeScreen();
return 500;
Expand Down
26 changes: 0 additions & 26 deletions src/motion/MotionSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,6 @@ class MotionSensor
uint32_t endCalibrationAt = 0;
};

namespace MotionSensorI2C
{

static inline int readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint8_t len)
{
Wire.beginTransmission(address);
Wire.write(reg);
Wire.endTransmission();
Wire.requestFrom((uint8_t)address, (uint8_t)len);
uint8_t i = 0;
while (Wire.available()) {
data[i++] = Wire.read();
}
return 0; // Pass
}

static inline int writeRegister(uint8_t address, uint8_t reg, uint8_t *data, uint8_t len)
{
Wire.beginTransmission(address);
Wire.write(reg);
Wire.write(data, len);
return (0 != Wire.endTransmission());
}

} // namespace MotionSensorI2C

#endif

#endif
2 changes: 1 addition & 1 deletion variants/esp32/m5stack_coreink/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ build_flags =
lib_deps =
${esp32_base.lib_deps}
zinggjm/GxEPD2@^1.6.2
lewisxhe/PCF8563_Library@^1.0.1
lewisxhe/[email protected]
lib_ignore =
m5stack-coreink
monitor_filters = esp32_exception_decoder
Expand Down
1 change: 0 additions & 1 deletion variants/esp32/m5stack_coreink/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define LED_STATE_ON 1 // State when LED is lit
#define LED_PIN 10

#include "pcf8563.h"
// PCF8563 RTC Module
#define PCF8563_RTC 0x51
#define HAS_RTC 1
Expand Down
4 changes: 0 additions & 4 deletions variants/esp32s3/ELECROW-ThinkNode-M2/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@
#define HAS_SCREEN 1
#define USE_SH1106 1

// PCF8563 RTC Module
// #define PCF8563_RTC 0x51
// #define PIN_RTC_INT 48 // Interrupt from the PCF8563 RTC
#define HAS_RTC 0
#define HAS_GPS 0

#define BUTTON_PIN PIN_BUTTON1
1 change: 0 additions & 1 deletion variants/esp32s3/ELECROW-ThinkNode-M5/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ build_flags =

lib_deps = ${esp32s3_base.lib_deps}
https://github.com/meshtastic/GxEPD2/archive/1655054ba298e0e29fc2044741940f927f9c2a43.zip
lewisxhe/PCF8563_Library@^1.0.1
maxpromer/PCA9557-arduino @ ^1.0.0
3 changes: 0 additions & 3 deletions variants/esp32s3/ELECROW-ThinkNode-M5/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
#define PIN_SERIAL1_RX GPS_TX_PIN
#define PIN_SERIAL1_TX GPS_RX_PIN

// PCF8563 RTC Module
#define PCF8563_RTC 0x51

#define SX126X_CS 17
#define LORA_SCK 16
#define LORA_MOSI 15
Expand Down
1 change: 0 additions & 1 deletion variants/esp32s3/heltec_vision_master_e213/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ build_flags =
lib_deps =
${esp32s3_base.lib_deps}
https://github.com/meshtastic/GxEPD2/archive/1655054ba298e0e29fc2044741940f927f9c2a43.zip
lewisxhe/PCF8563_Library@^1.0.1
upload_speed = 115200

[env:heltec-vision-master-e213-inkhud]
Expand Down
1 change: 0 additions & 1 deletion variants/esp32s3/heltec_vision_master_e290/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ build_flags =
lib_deps =
${esp32s3_base.lib_deps}
https://github.com/meshtastic/GxEPD2/archive/448c8538129fde3d02a7cb5e6fc81971ad92547f.zip
lewisxhe/PCF8563_Library@^1.0.1
upload_speed = 115200

[env:heltec-vision-master-e290-inkhud]
Expand Down
1 change: 0 additions & 1 deletion variants/esp32s3/heltec_vision_master_t190/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ build_flags =
-D HELTEC_VISION_MASTER_T190
lib_deps =
${esp32s3_base.lib_deps}
lewisxhe/PCF8563_Library@^1.0.1
https://github.com/meshtastic/st7789/archive/bd33ea58ddfe4a5e4a66d53300ccbd38d66ac21f.zip
upload_speed = 921600
1 change: 0 additions & 1 deletion variants/esp32s3/heltec_wireless_paper/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ build_flags =
lib_deps =
${esp32s3_base.lib_deps}
https://github.com/meshtastic/GxEPD2/archive/1655054ba298e0e29fc2044741940f927f9c2a43.zip
lewisxhe/PCF8563_Library@^1.0.1
upload_speed = 115200

[env:heltec-wireless-paper-inkhud]
Expand Down
1 change: 0 additions & 1 deletion variants/esp32s3/heltec_wireless_paper_v1/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ build_flags =
lib_deps =
${esp32s3_base.lib_deps}
https://github.com/meshtastic/GxEPD2/archive/55f618961db45a23eff0233546430f1e5a80f63a.zip
lewisxhe/PCF8563_Library@^1.0.1
upload_speed = 115200
5 changes: 1 addition & 4 deletions variants/esp32s3/t-watch-s3/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ upload_protocol = esptool
build_flags = ${esp32_base.build_flags}
-DT_WATCH_S3
-Ivariants/esp32s3/t-watch-s3
-DPCF8563_RTC=0x51
-DHAS_BMA423=1

lib_deps = ${esp32s3_base.lib_deps}
lovyan03/LovyanGFX@^1.2.0
lewisxhe/[email protected]
lewisxhe/[email protected]
adafruit/Adafruit DRV2605 Library@^1.2.2
earlephilhower/ESP8266Audio@^1.9.9
earlephilhower/ESP8266SAM@^1.0.1
lewisxhe/[email protected]
3 changes: 3 additions & 0 deletions variants/esp32s3/t-watch-s3/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@

#define HAS_AXP2101

// PCF8563 RTC Module
#define PCF8563_RTC 0x51
#define HAS_RTC 1

#define I2C_SDA 10 // For QMC6310 sensors and screens
#define I2C_SCL 11 // For QMC6310 sensors and screens

#define HAS_BMA423 1
#define BMA4XX_INT 14 // Interrupt for BMA_423 axis sensor

#define HAS_GPS 0
Expand Down
3 changes: 1 addition & 2 deletions variants/esp32s3/tbeam-s3-core/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ board_check = true

lib_deps =
${esp32s3_base.lib_deps}
lewisxhe/[email protected]
lewisxhe/[email protected]

build_flags =
${esp32s3_base.build_flags}
-I variants/esp32s3/tbeam-s3-core
-D PCF8563_RTC=0x51 ;Putting definitions in variant.h does not compile correctly
5 changes: 2 additions & 3 deletions variants/esp32s3/tbeam-s3-core/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
// #define PMU_IRQ 40
#define HAS_AXP2101

// PCF8563 RTC Module
#define PCF8563_RTC 0x51
#define HAS_RTC 1

// Specify the PMU as Wire1. In the t-beam-s3 core, PCF8563 and PMU share the bus
Expand All @@ -58,9 +60,6 @@
#define HAS_SDCARD // Have SPI interface SD card slot
#define SDCARD_USE_SPI1

// PCF8563 RTC Module
// #define PCF8563_RTC 0x51 //Putting definitions in variant. h does not compile correctly

// has 32768 Hz crystal
#define HAS_32768HZ 1

Expand Down
3 changes: 1 addition & 2 deletions variants/esp32s3/tlora-pager/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ lib_deps = ${esp32s3_base.lib_deps}
earlephilhower/[email protected]
earlephilhower/[email protected]
adafruit/Adafruit DRV2605 [email protected]
lewisxhe/[email protected]
lewisxhe/[email protected]
lewisxhe/[email protected]
https://github.com/pschatzmann/arduino-audio-driver/archive/refs/tags/v0.1.3.zip
https://github.com/mverch67/BQ27220/archive/07d92be846abd8a0258a50c23198dac0858b22ed.zip
https://github.com/mverch67/RotaryEncoder/archive/25a59d5745a6645536f921427d80b08e78f886d4.zip
Expand Down
7 changes: 2 additions & 5 deletions variants/esp32s3/tlora-pager/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@
#define GPS_TX_PIN 12
#define PIN_GPS_PPS 13

// PCF8563 RTC Module
#if __has_include("pcf8563.h")
#include "pcf8563.h"
#endif
#define PCF8563_RTC 0x51
// PCF85063 RTC Module
#define PCF85063_RTC 0x51
#define HAS_RTC 1

// Rotary
Expand Down
4 changes: 1 addition & 3 deletions variants/nrf52840/ELECROW-ThinkNode-M1/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/ELECROW
lib_deps =
${nrf52840_base.lib_deps}
https://github.com/meshtastic/GxEPD2/archive/33db3fa8ee6fc47d160bdb44f8f127c9a9203a10.zip
lewisxhe/PCF8563_Library@^1.0.1
khoih-prog/nRF52_PWM@^1.0.1
;upload_protocol = fs

Expand All @@ -45,5 +44,4 @@ build_src_filter =
+<../variants/nrf52840/ELECROW-ThinkNode-M1>
lib_deps =
${inkhud.lib_deps} ; InkHUD libs first, so we get GFXRoot instead of AdafruitGFX
${nrf52840_base.lib_deps}
lewisxhe/PCF8563_Library@^1.0.1
${nrf52840_base.lib_deps}
Loading
Loading