Compare commits

...

28 Commits

Author SHA1 Message Date
sqfmi a454e65ba2 add NTP to menu 2021-12-30 01:50:13 -05:00
sqfmi 12915a48e6 Native NTP support & bug fixes
- Added native NTP sync support
- Fixed bug with WiFi AP not working due to busy lightsleep callback
- Removed year offsets and use TimeLib macros for consistency
2021-12-29 02:06:38 -05:00
SQFMI 1bfbc55f4a
Merge pull request #130 from gudnithor/bugfix-issue-129
Fixes issue #129 - stops writing over previous text
2021-12-26 21:16:32 -05:00
Guðni Þ. Björgvinsson 9434ffd1fc Fixes issue #129 - stops writing over previous text 2021-12-26 20:17:21 +00:00
SQFMI 0f585268d4
Merge pull request #119 from kylepotts/patch-1
Point Rtc_Pcf863 at same library Arduino is using
2021-12-13 17:47:16 -05:00
Kyle Potts 069d18f1cc
Update library.json 2021-12-13 17:33:47 -05:00
Kyle Potts 678614aff9
Point Rtc_Pcf863 at same library Arduino is using 2021-12-13 17:31:34 -05:00
SQFMI f8d92f21be
update links 2021-12-12 20:51:25 -05:00
sqfmi 48d06b9661 bump version 2021-12-12 17:17:28 -05:00
SQFMI 35eb14fadd
Merge pull request #116 from DarkZeros/light_sleep_display
Optimize display update
2021-12-12 17:15:22 -05:00
SQFMI afb2e23dea
Merge branch 'master' into light_sleep_display 2021-12-12 17:12:31 -05:00
SQFMI b794d8ee79
Moved clear alarm function 2021-12-12 16:43:38 -05:00
SQFMI c6483eebe0
Merge pull request #117 from DarkZeros/avoid_leaks
Set all pins to INPUT before deep sleep
2021-12-12 16:00:23 -05:00
Daniel Ansorregui 76e202739d Set all pins to INPUT before deep sleep
* Some pins otherwise are left as output
  And their value is kept in deep sleep
  This can cause power usage in deep sleep
* From my measurements 0.13mA
  Or, 3mAh / day extra usage
2021-12-11 16:19:09 +00:00
Daniel Ansorregui d66f848ba6 Optimize display update
* Hibernate should only be called before deep sleep
* Init should only be called once and notify the last init
* Set up init properly with 10ms reset and pulldown
* Use GxEDP2 1.4.0 library new busy callback
  to trigger a lightsleep in the mean time
  Saving 600ms of CPU time per update, (12mAs/minute)
  That is -4mAh per day savings
2021-12-11 14:32:29 +00:00
sqfmi ac82f48c45 fixed freeze bug 2021-12-03 11:11:00 -05:00
sqfmi e34fbac279 fixed wednesday 2021-12-01 22:09:11 -05:00
sqfmi 8fb1902cbe fixed setting datetime 2021-12-01 22:04:52 -05:00
SQFMI ca8e170147
Merge pull request #113 from Metaln00b/feature/add-additional-weathericons
7_SEG: Add additional weather icons
2021-12-01 18:39:40 -05:00
sqfmi 7a28210b41 fixed bugs and change temp. sensor 2021-12-01 18:34:42 -05:00
Metaln00b ff48d8a241 7_SEG: Add additional weather icons 2021-12-01 23:40:10 +01:00
sqfmi 6363caeac2 auto switch ADC pin 2021-11-29 17:01:25 -05:00
SQFMI c6085ad483
Update README.md 2021-11-29 02:41:09 -05:00
SQFMI bec2c895af
Merge pull request #101 from elasticdotventures/patch-2
Update README.md
2021-11-29 02:38:58 -05:00
SQFMI 6f918e5d4d
Merge pull request #109 from sqfmi/RTC
Fix RTC
2021-11-29 02:35:04 -05:00
sqfmi 241f568e71 Fix RTC
- Added RTC scan
- Support for both RTCs in abstraction lib
2021-11-29 02:34:21 -05:00
elasticdotventures f3e7c73eff
Update README.md
cheers, 🚀
2021-11-05 14:11:49 +11:00
SQFMI 3e69aad334
Merge pull request #100 from sqfmi/dev
Update to v1.2.7
2021-10-30 12:55:32 -04:00
10 changed files with 1207 additions and 986 deletions

View File

@ -2,13 +2,18 @@
![Watchy](https://watchy.sqfmi.com/img/watchy_render.png)
[**Pre-order Watchy!**](https://www.crowdsupply.com/sqfmi/watchy)
Now with injection molded or CNC'd aluminum case
[**Buy Watchy!**](https://www.mouser.com/ProductDetail/SQFMI/SQFMI-WATCHY-10?qs=DRkmTr78QARN9VSJRzqRxw%3D%3D)
[**Watchy Case & Accessories**](https://shop.sqfmi.com)
Visit [**https://watchy.sqfmi.com**](https://watchy.sqfmi.com) for documentation, hardware design files, and more!
## Setup
1. In the Arduino IDE Boards Manager, install support for the ESP32. You can find instructions here: https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md
1. In the Arduino IDE Boards Manager, install support for the ESP32. You can find instructions here: https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html
* Arduino > Preferences > Additional Board Manager URL's
* ```https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json```
2. Install this library (search for **Watchy** in the library manager), and any other depdencies when prompted
3. Check out the examples under ```Examples``` -> ```Watchy```
4. Compile & Upload with these board settings:

View File

@ -52,6 +52,9 @@ void Watchy7SEG::drawDate(){
String dayOfWeek = dayStr(currentTime.Wday);
display.getTextBounds(dayOfWeek, 5, 85, &x1, &y1, &w, &h);
if(currentTime.Wday == 4){
w = w - 5;
}
display.setCursor(85 - w, 85);
display.println(dayOfWeek);
@ -67,7 +70,7 @@ void Watchy7SEG::drawDate(){
}
display.println(currentTime.Day);
display.setCursor(5, 150);
display.println(currentTime.Year + YEAR_OFFSET);// offset from 1970, since year is stored in uint8_t
display.println(tmYearToCalendar(currentTime.Year));// offset from 1970, since year is stored in uint8_t
}
void Watchy7SEG::drawSteps(){
// reset step counter at midnight
@ -132,15 +135,15 @@ void Watchy7SEG::drawWeather(){
}else if(weatherConditionCode == 800){//Clear
weatherIcon = sunny;
}else if(weatherConditionCode >=700){//Atmosphere
weatherIcon = cloudy;
weatherIcon = atmosphere;
}else if(weatherConditionCode >=600){//Snow
weatherIcon = snow;
}else if(weatherConditionCode >=500){//Rain
weatherIcon = rain;
}else if(weatherConditionCode >=300){//Drizzle
weatherIcon = rain;
weatherIcon = drizzle;
}else if(weatherConditionCode >=200){//Thunderstorm
weatherIcon = rain;
weatherIcon = thunderstorm;
}else
return;
display.drawBitmap(145, 158, weatherIcon, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);

View File

@ -105,6 +105,51 @@ const unsigned char sunny [] PROGMEM = {
0xc0, 0x00, 0x00, 0x18, 0x20, 0x10, 0x60, 0x00, 0x00, 0x00, 0x21, 0x08, 0x00, 0x00, 0x00, 0x00,
0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00
};
// 'atmosphere', 48x32px
const unsigned char atmosphere[] PROGMEM = {
0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x03, 0x81, 0x80, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60,
0x00, 0x00, 0x00, 0x08, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x30,
0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00, 0x18, 0x00, 0x00, 0x20, 0x00, 0x00, 0x08, 0x00,
0x00, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x40, 0x00, 0x00, 0x07, 0x80, 0x00, 0xc0, 0x00, 0x00,
0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10, 0x04, 0x00,
0x00, 0x00, 0x00, 0x18, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08,
0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x00, 0x00, 0x00,
0x00, 0x08, 0x04, 0x07, 0xff, 0xf8, 0xf0, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x80,
0x00, 0x00, 0x00, 0x60, 0x00, 0x9f, 0x1f, 0xff, 0xfc, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0xff, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'drizzle', 48x32px
const unsigned char drizzle[] PROGMEM = {
0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x03, 0x81, 0x80, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60,
0x00, 0x00, 0x00, 0x08, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x30,
0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00, 0x18, 0x00, 0x00, 0x20, 0x00, 0x00, 0x08, 0x00,
0x00, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x40, 0x00, 0x00, 0x07, 0x80, 0x00, 0xc0, 0x00, 0x00,
0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10, 0x04, 0x00,
0x00, 0x00, 0x00, 0x18, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08,
0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x00, 0x00, 0x00,
0x00, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x80,
0x00, 0x00, 0x00, 0x60, 0x00, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x08, 0x00, 0x00
};
// 'thunderstorm', 48x32px
const unsigned char thunderstorm[] PROGMEM = {
0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x03, 0x81, 0x80, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60,
0x00, 0x00, 0x00, 0x08, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x30,
0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00, 0x18, 0x00, 0x00, 0x20, 0x00, 0x00, 0x08, 0x00,
0x00, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x40, 0x00, 0x00, 0x07, 0x80, 0x00, 0xc0, 0x0f, 0x80,
0x00, 0xc0, 0x03, 0x00, 0x0f, 0x80, 0x00, 0x20, 0x02, 0x00, 0x1f, 0x00, 0x00, 0x10, 0x04, 0x00,
0x1e, 0x00, 0x00, 0x18, 0x04, 0x00, 0x3e, 0x00, 0x00, 0x08, 0x08, 0x00, 0x3c, 0x00, 0x00, 0x08,
0x08, 0x00, 0x7c, 0x00, 0x00, 0x08, 0x04, 0x00, 0x78, 0x00, 0x00, 0x08, 0x04, 0x00, 0xf8, 0x00,
0x00, 0x08, 0x04, 0x00, 0xff, 0x00, 0x00, 0x10, 0x02, 0x00, 0x1f, 0x00, 0x00, 0x30, 0x01, 0x80,
0x1e, 0x00, 0x00, 0x60, 0x00, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'steps', 19x23px
const unsigned char steps [] PROGMEM = {
0x00, 0x03, 0xc0, 0x00, 0x07, 0xe0, 0x00, 0x07, 0xe0, 0x00, 0x0f, 0xe0, 0x78, 0x0f, 0xe0, 0xfc,

View File

@ -1,6 +1,6 @@
{
"name": "Watchy",
"version": "1.2.7",
"version": "1.3.0",
"description": "Watchy - An Open Source E-Paper Watch by SQFMI",
"authors": [
{
@ -19,6 +19,10 @@
{ "name": "Adafruit GFX Library" },
{ "name": "Arduino_JSON" },
{ "name": "DS3232RTC" },
{
"name": "Rtc_Pcf8563",
"version": "https://github.com/orbitalair/Rtc_Pcf8563.git#master"
},
{ "name": "GxEPD2" },
{
"name": "WiFiManager",

View File

@ -1,5 +1,5 @@
name=Watchy
version=1.2.7
version=1.3.0
author=SQFMI
maintainer=SQFMI
sentence=Watchy - An Open Source E-Paper Watch by SQFMI
@ -7,4 +7,4 @@ paragraph=This library contains drivers and code samples for Watchy
category=Other
url=https://watchy.sqfmi.com
architectures=esp32
depends=Adafruit GFX Library,Arduino_JSON,DS3232RTC,GxEPD2,WiFiManager
depends=Adafruit GFX Library,Arduino_JSON,DS3232RTC,Rtc_Pcf8563,GxEPD2,WiFiManager

File diff suppressed because it is too large Load Diff

View File

@ -5,14 +5,14 @@
#include <WiFiManager.h>
#include <HTTPClient.h>
#include <Arduino_JSON.h>
#include <DS3232RTC.h>
#include <GxEPD2_BW.h>
#include <Wire.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "DSEG7_Classic_Bold_53.h"
#include "WatchyRTC.h"
#include "BLE.h"
#include "bma.h"
#include "config.h"
#include "config.h"
typedef struct weatherData{
int8_t temperature;
@ -21,13 +21,14 @@ typedef struct weatherData{
class Watchy {
public:
static DS3232RTC RTC;
static WatchyRTC RTC;
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
tmElements_t currentTime;
public:
Watchy();
void init(String datetime = "");
void deepSleep();
static void displayBusyCallback(const void*);
float getBatteryVoltage();
void vibMotor(uint8_t intervalMs = 100, uint8_t length = 20);
@ -39,6 +40,7 @@ class Watchy {
void showAccelerometer();
void showUpdateFW();
void setTime();
void syncNTP();
void setupWifi();
bool connectWiFi();
weatherData getWeatherData();
@ -48,7 +50,6 @@ class Watchy {
virtual void drawWatchFace(); //override this method for different watch faces
private:
void _rtcConfig(String datetime);
void _bmaConfig();
static void _configModeCallback(WiFiManager *myWiFiManager);
static uint16_t _readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len);

164
src/WatchyRTC.cpp Normal file
View File

@ -0,0 +1,164 @@
#include "WatchyRTC.h"
WatchyRTC::WatchyRTC()
: rtc_ds(false) {}
void WatchyRTC::init(){
byte error;
Wire.beginTransmission(RTC_DS_ADDR);
error = Wire.endTransmission();
if(error == 0){
rtcType = DS3231;
}else{
Wire.beginTransmission(RTC_PCF_ADDR);
error = Wire.endTransmission();
if(error == 0){
rtcType = PCF8563;
}else{
//RTC Error
}
}
}
void WatchyRTC::config(String datetime){ //String datetime format is YYYY:MM:DD:HH:MM:SS
if(rtcType == DS3231){
_DSConfig(datetime);
}else{
_PCFConfig(datetime);
}
}
void WatchyRTC::clearAlarm(){
if(rtcType == DS3231){
rtc_ds.alarm(ALARM_2);
}else{
int nextAlarmMinute = 0;
rtc_pcf.clearAlarm(); //resets the alarm flag in the RTC
nextAlarmMinute = rtc_pcf.getMinute();
nextAlarmMinute = (nextAlarmMinute == 59) ? 0 : (nextAlarmMinute + 1); //set alarm to trigger 1 minute from now
rtc_pcf.setAlarm(nextAlarmMinute, 99, 99, 99);
}
}
void WatchyRTC::read(tmElements_t &tm){
if(rtcType == DS3231){
rtc_ds.read(tm);
}else{
tm.Year = y2kYearToTm(rtc_pcf.getYear());
tm.Month = rtc_pcf.getMonth();
tm.Day = rtc_pcf.getDay();
tm.Wday = rtc_pcf.getWeekday() + 1; //TimeLib & DS3231 has Wday range of 1-7, but PCF8563 stores day of week in 0-6 range
tm.Hour = rtc_pcf.getHour();
tm.Minute = rtc_pcf.getMinute();
tm.Second = rtc_pcf.getSecond();
}
}
void WatchyRTC::set(tmElements_t tm){
if(rtcType == DS3231){
time_t t = makeTime(tm);
rtc_ds.set(t);
}else{
time_t t = makeTime(tm); //make and break to calculate tm.Wday
breakTime(t, tm);
//day, weekday, month, century(1=1900, 0=2000), year(0-99)
rtc_pcf.setDate(tm.Day, tm.Wday - 1, tm.Month, 0, tmYearToY2k(tm.Year)); //TimeLib & DS3231 has Wday range of 1-7, but PCF8563 stores day of week in 0-6 range
//hr, min, sec
rtc_pcf.setTime(tm.Hour, tm.Minute, tm.Second);
clearAlarm();
}
}
uint8_t WatchyRTC::temperature(){
if(rtcType == DS3231){
return rtc_ds.temperature();
}else{
return 255; //error
}
}
void WatchyRTC::_DSConfig(String datetime){ //String datetime is YYYY:MM:DD:HH:MM:SS
if(datetime != ""){
tmElements_t tm;
tm.Year = CalendarYrToTm(_getValue(datetime, ':', 0).toInt()); //YYYY - 1970
tm.Month = _getValue(datetime, ':', 1).toInt();
tm.Day = _getValue(datetime, ':', 2).toInt();
tm.Hour = _getValue(datetime, ':', 3).toInt();
tm.Minute = _getValue(datetime, ':', 4).toInt();
tm.Second = _getValue(datetime, ':', 5).toInt();
time_t t = makeTime(tm);
rtc_ds.set(t);
}
//https://github.com/JChristensen/DS3232RTC
rtc_ds.squareWave(SQWAVE_NONE); //disable square wave output
rtc_ds.setAlarm(ALM2_EVERY_MINUTE, 0, 0, 0, 0); //alarm wakes up Watchy every minute
rtc_ds.alarmInterrupt(ALARM_2, true); //enable alarm interrupt
}
void WatchyRTC::_PCFConfig(String datetime){ //String datetime is YYYY:MM:DD:HH:MM:SS
if(datetime != ""){
tmElements_t tm;
tm.Year = CalendarYrToTm(_getValue(datetime, ':', 0).toInt()); //YYYY - 1970
tm.Month = _getValue(datetime, ':', 1).toInt();
tm.Day = _getValue(datetime, ':', 2).toInt();
tm.Hour = _getValue(datetime, ':', 3).toInt();
tm.Minute = _getValue(datetime, ':', 4).toInt();
tm.Second = _getValue(datetime, ':', 5).toInt();
time_t t = makeTime(tm); //make and break to calculate tm.Wday
breakTime(t, tm);
//day, weekday, month, century(1=1900, 0=2000), year(0-99)
rtc_pcf.setDate(tm.Day, tm.Wday - 1, tm.Month, 0, tmYearToY2k(tm.Year)); //TimeLib & DS3231 has Wday range of 1-7, but PCF8563 stores day of week in 0-6 range
//hr, min, sec
rtc_pcf.setTime(tm.Hour, tm.Minute, tm.Second);
}
//on POR event, PCF8563 sets month to 0, which will give an error since months are 1-12
clearAlarm();
}
bool WatchyRTC::syncNtpTime(){ //NTP sync - call after connecting to WiFi and remember to turn it back off
configTime(GMT_OFFSET_SEC, DST_OFFSET_SEC, NTP_SERVER);
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
return false; //NTP sync failed
}
/****************************************************
struct tm
{
int tm_sec; // Seconds [0,60].
int tm_min; // Minutes [0,59].
int tm_hour; // Hour [0,23].
int tm_mday; // Day of month [1,31].
int tm_mon; // Month of year [0,11].
int tm_year; // Years since 1900.
int tm_wday; // Day of week [0,6] (Sunday =0).
int tm_yday; // Day of year [0,365].
int tm_isdst; // Daylight Savings flag.
}
****************************************************/
tmElements_t tm;
tm.Year = CalendarYrToTm(timeinfo.tm_year + 1900);
tm.Month = timeinfo.tm_mon + 1; //tm.Month 1 - 12
tm.Day = timeinfo.tm_mday;
tm.Hour = timeinfo.tm_hour;
tm.Minute = timeinfo.tm_min;
tm.Second = timeinfo.tm_sec;
set(tm);
return true;
}
String WatchyRTC::_getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = {0, -1};
int maxIndex = data.length()-1;
for(int i=0; i<=maxIndex && found<=index; i++){
if(data.charAt(i)==separator || i==maxIndex){
found++;
strIndex[0] = strIndex[1]+1;
strIndex[1] = (i == maxIndex) ? i+1 : i;
}
}
return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
}

37
src/WatchyRTC.h Normal file
View File

@ -0,0 +1,37 @@
#ifndef WATCHY_RTC_H
#define WATCHY_RTC_H
#include <DS3232RTC.h>
#include <Rtc_Pcf8563.h>
#include "config.h"
#include "time.h"
#define DS3231 0
#define PCF8563 1
#define RTC_DS_ADDR 0x68
#define RTC_PCF_ADDR 0x51
#define YEAR_OFFSET_DS 1970
#define YEAR_OFFSET_PCF 2000
class WatchyRTC {
public:
DS3232RTC rtc_ds;
Rtc_Pcf8563 rtc_pcf;
uint8_t rtcType;
public:
WatchyRTC();
void init();
void config(String datetime); //String datetime format is YYYY:MM:DD:HH:MM:SS
void clearAlarm();
void read(tmElements_t &tm);
void set(tmElements_t tm);
bool syncNtpTime();
uint8_t temperature();
private:
void _DSConfig(String datetime);
void _PCFConfig(String datetime);
int _getDayOfWeek(int d, int m, int y);
String _getValue(String data, char separator, int index);
};
#endif

View File

@ -4,7 +4,8 @@
//pins
#define SDA 21
#define SCL 22
#define ADC_PIN 33
#define V10_ADC_PIN 33 //OG v1.0 Watchy
#define V15_ADC_PIN 35 //v1.5 Watchy with PCF8563 RTC
#define RTC_PIN GPIO_NUM_27
#define CS 5
#define DC 10
@ -39,16 +40,18 @@
#define MAIN_MENU_STATE 0
#define APP_STATE 1
#define FW_UPDATE_STATE 2
#define MENU_HEIGHT 30
#define MENU_LENGTH 6
#define MENU_HEIGHT 25
#define MENU_LENGTH 7
//set time
#define SET_HOUR 0
#define SET_MINUTE 1
#define SET_YEAR 2
#define SET_MONTH 3
#define SET_DAY 4
#define YEAR_OFFSET 1970
#define HOUR_12_24 24
#define NTP_SERVER "pool.ntp.org"
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5
#define DST_OFFSET_SEC 3600
//BLE OTA
#define BLE_DEVICE_NAME "Watchy BLE OTA"
#define WATCHFACE_NAME "Watchy 7 Segment"
@ -58,4 +61,4 @@
#define HARDWARE_VERSION_MAJOR 1
#define HARDWARE_VERSION_MINOR 0
#endif
#endif