mirror of https://github.com/sqfmi/Watchy.git
Merge branch 'master' into patch-1
commit
b0ff996341
|
@ -0,0 +1,15 @@
|
||||||
|
# How to contribute
|
||||||
|
|
||||||
|
### Check out the issue tracker
|
||||||
|
|
||||||
|
Search through [Issue tracker](https://github.com/sqfmi/Watchy/issues) for matching topics. It is also recommended to check with current [Pull requests](https://github.com/sqfmi/Watchy/pulls).
|
||||||
|
|
||||||
|
### Issue Pull Request
|
||||||
|
|
||||||
|
1. Fork this repo and branch out from `dev`.
|
||||||
|
2. Push commits.
|
||||||
|
3. Issue pull request.
|
||||||
|
|
||||||
|
## Community
|
||||||
|
|
||||||
|
- [Discord](https://discord.gg/ZXDegGV8E7)
|
|
@ -1,140 +1,141 @@
|
||||||
#include "Watchy_7_SEG.h"
|
#include "Watchy_7_SEG.h"
|
||||||
|
|
||||||
#define DARKMODE true
|
#define DARKMODE true
|
||||||
|
|
||||||
const uint8_t BATTERY_SEGMENT_WIDTH = 7;
|
const uint8_t BATTERY_SEGMENT_WIDTH = 7;
|
||||||
const uint8_t BATTERY_SEGMENT_HEIGHT = 11;
|
const uint8_t BATTERY_SEGMENT_HEIGHT = 11;
|
||||||
const uint8_t BATTERY_SEGMENT_SPACING = 9;
|
const uint8_t BATTERY_SEGMENT_SPACING = 9;
|
||||||
const uint8_t WEATHER_ICON_WIDTH = 48;
|
const uint8_t WEATHER_ICON_WIDTH = 48;
|
||||||
const uint8_t WEATHER_ICON_HEIGHT = 32;
|
const uint8_t WEATHER_ICON_HEIGHT = 32;
|
||||||
|
|
||||||
Watchy7SEG::Watchy7SEG(){} //constructor
|
Watchy7SEG::Watchy7SEG(){} //constructor
|
||||||
|
|
||||||
void Watchy7SEG::drawWatchFace(){
|
void Watchy7SEG::drawWatchFace(){
|
||||||
display.fillScreen(DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);
|
display.fillScreen(DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);
|
||||||
display.setTextColor(DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.setTextColor(DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
drawTime();
|
drawTime();
|
||||||
drawDate();
|
drawDate();
|
||||||
drawSteps();
|
drawSteps();
|
||||||
drawWeather();
|
drawWeather();
|
||||||
drawBattery();
|
drawBattery();
|
||||||
display.drawBitmap(120, 77, WIFI_CONFIGURED ? wifi : wifioff, 26, 18, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.drawBitmap(120, 77, WIFI_CONFIGURED ? wifi : wifioff, 26, 18, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
if(BLE_CONFIGURED){
|
if(BLE_CONFIGURED){
|
||||||
display.drawBitmap(100, 75, bluetooth, 13, 21, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.drawBitmap(100, 75, bluetooth, 13, 21, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Watchy7SEG::drawTime(){
|
void Watchy7SEG::drawTime(){
|
||||||
display.setFont(&DSEG7_Classic_Bold_53);
|
display.setFont(&DSEG7_Classic_Bold_53);
|
||||||
display.setCursor(5, 53+5);
|
display.setCursor(5, 53+5);
|
||||||
if(currentTime.Hour < 10){
|
if(currentTime.Hour < 10){
|
||||||
display.print("0");
|
display.print("0");
|
||||||
}
|
}
|
||||||
display.print(currentTime.Hour);
|
display.print(currentTime.Hour);
|
||||||
display.print(":");
|
display.print(":");
|
||||||
if(currentTime.Minute < 10){
|
if(currentTime.Minute < 10){
|
||||||
display.print("0");
|
display.print("0");
|
||||||
}
|
}
|
||||||
display.println(currentTime.Minute);
|
display.println(currentTime.Minute);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Watchy7SEG::drawDate(){
|
void Watchy7SEG::drawDate(){
|
||||||
display.setFont(&Seven_Segment10pt7b);
|
display.setFont(&Seven_Segment10pt7b);
|
||||||
|
|
||||||
int16_t x1, y1;
|
int16_t x1, y1;
|
||||||
uint16_t w, h;
|
uint16_t w, h;
|
||||||
|
|
||||||
String dayOfWeek = dayStr(currentTime.Wday);
|
String dayOfWeek = dayStr(currentTime.Wday);
|
||||||
display.getTextBounds(dayOfWeek, 5, 85, &x1, &y1, &w, &h);
|
display.getTextBounds(dayOfWeek, 5, 85, &x1, &y1, &w, &h);
|
||||||
display.setCursor(85 - w, 85);
|
display.setCursor(85 - w, 85);
|
||||||
display.println(dayOfWeek);
|
display.println(dayOfWeek);
|
||||||
|
|
||||||
String month = monthShortStr(currentTime.Month);
|
String month = monthShortStr(currentTime.Month);
|
||||||
display.getTextBounds(month, 60, 110, &x1, &y1, &w, &h);
|
display.getTextBounds(month, 60, 110, &x1, &y1, &w, &h);
|
||||||
display.setCursor(85 - w, 110);
|
display.setCursor(85 - w, 110);
|
||||||
display.println(month);
|
display.println(month);
|
||||||
|
|
||||||
display.setFont(&DSEG7_Classic_Bold_25);
|
display.setFont(&DSEG7_Classic_Bold_25);
|
||||||
display.setCursor(5, 120);
|
display.setCursor(5, 120);
|
||||||
if(currentTime.Day < 10){
|
if(currentTime.Day < 10){
|
||||||
display.print("0");
|
display.print("0");
|
||||||
}
|
}
|
||||||
display.println(currentTime.Day);
|
display.println(currentTime.Day);
|
||||||
display.setCursor(5, 150);
|
display.setCursor(5, 150);
|
||||||
display.println(currentTime.Year + YEAR_OFFSET);// offset from 1970, since year is stored in uint8_t
|
display.println(currentTime.Year + YEAR_OFFSET);// offset from 1970, since year is stored in uint8_t
|
||||||
}
|
}
|
||||||
void Watchy7SEG::drawSteps(){
|
void Watchy7SEG::drawSteps(){
|
||||||
// reset step counter at midnight
|
// reset step counter at midnight
|
||||||
if (currentTime.Hour == 0 && currentTime.Minute == 0){
|
if (currentTime.Hour == 0 && currentTime.Minute == 0){
|
||||||
sensor.resetStepCounter();
|
sensor.resetStepCounter();
|
||||||
}
|
}
|
||||||
uint32_t stepCount = sensor.getCounter();
|
uint32_t stepCount = sensor.getCounter();
|
||||||
display.drawBitmap(10, 165, steps, 19, 23, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.drawBitmap(10, 165, steps, 19, 23, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
display.setCursor(35, 190);
|
display.setCursor(35, 190);
|
||||||
display.println(stepCount);
|
display.println(stepCount);
|
||||||
}
|
}
|
||||||
void Watchy7SEG::drawBattery(){
|
void Watchy7SEG::drawBattery(){
|
||||||
display.drawBitmap(154, 73, battery, 37, 21, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.drawBitmap(154, 73, battery, 37, 21, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
display.fillRect(159, 78, 27, BATTERY_SEGMENT_HEIGHT, DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);//clear battery segments
|
display.fillRect(159, 78, 27, BATTERY_SEGMENT_HEIGHT, DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);//clear battery segments
|
||||||
int8_t batteryLevel = 0;
|
int8_t batteryLevel = 0;
|
||||||
float VBAT = getBatteryVoltage();
|
float VBAT = getBatteryVoltage();
|
||||||
if(VBAT > 4.1){
|
if(VBAT > 4.1){
|
||||||
batteryLevel = 3;
|
batteryLevel = 3;
|
||||||
}
|
}
|
||||||
else if(VBAT > 3.95 && VBAT <= 4.1){
|
else if(VBAT > 3.95 && VBAT <= 4.1){
|
||||||
batteryLevel = 2;
|
batteryLevel = 2;
|
||||||
}
|
}
|
||||||
else if(VBAT > 3.80 && VBAT <= 3.95){
|
else if(VBAT > 3.80 && VBAT <= 3.95){
|
||||||
batteryLevel = 1;
|
batteryLevel = 1;
|
||||||
}
|
}
|
||||||
else if(VBAT <= 3.80){
|
else if(VBAT <= 3.80){
|
||||||
batteryLevel = 0;
|
batteryLevel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int8_t batterySegments = 0; batterySegments < batteryLevel; batterySegments++){
|
for(int8_t batterySegments = 0; batterySegments < batteryLevel; batterySegments++){
|
||||||
display.fillRect(159 + (batterySegments * BATTERY_SEGMENT_SPACING), 78, BATTERY_SEGMENT_WIDTH, BATTERY_SEGMENT_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.fillRect(159 + (batterySegments * BATTERY_SEGMENT_SPACING), 78, BATTERY_SEGMENT_WIDTH, BATTERY_SEGMENT_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Watchy7SEG::drawWeather(){
|
void Watchy7SEG::drawWeather(){
|
||||||
|
|
||||||
weatherData currentWeather = getWeatherData();
|
weatherData currentWeather = getWeatherData();
|
||||||
|
|
||||||
int8_t temperature = currentWeather.temperature;
|
int8_t temperature = currentWeather.temperature;
|
||||||
int16_t weatherConditionCode = currentWeather.weatherConditionCode;
|
int16_t weatherConditionCode = currentWeather.weatherConditionCode;
|
||||||
|
|
||||||
display.setFont(&DSEG7_Classic_Regular_39);
|
display.setFont(&DSEG7_Classic_Regular_39);
|
||||||
int16_t x1, y1;
|
int16_t x1, y1;
|
||||||
uint16_t w, h;
|
uint16_t w, h;
|
||||||
display.getTextBounds(String(temperature), 100, 150, &x1, &y1, &w, &h);
|
display.getTextBounds(String(temperature), 0, 0, &x1, &y1, &w, &h);
|
||||||
if (temperature >= 10 && temperature < 20) {
|
if(159 - w - x1 > 87){
|
||||||
display.setCursor(135 - w, 150);
|
display.setCursor(159 - w - x1, 150);
|
||||||
}
|
}else{
|
||||||
else {
|
display.setFont(&DSEG7_Classic_Bold_25);
|
||||||
display.setCursor(155 - w, 150);
|
display.getTextBounds(String(temperature), 0, 0, &x1, &y1, &w, &h);
|
||||||
}
|
display.setCursor(159 - w - x1, 136);
|
||||||
display.println(temperature);
|
}
|
||||||
display.drawBitmap(165, 110, strcmp(TEMP_UNIT, "metric") == 0 ? celsius : fahrenheit, 26, 20, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.println(temperature);
|
||||||
const unsigned char* weatherIcon;
|
display.drawBitmap(165, 110, strcmp(TEMP_UNIT, "metric") == 0 ? celsius : fahrenheit, 26, 20, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
|
const unsigned char* weatherIcon;
|
||||||
//https://openweathermap.org/weather-conditions
|
|
||||||
if(weatherConditionCode > 801){//Cloudy
|
//https://openweathermap.org/weather-conditions
|
||||||
weatherIcon = cloudy;
|
if(weatherConditionCode > 801){//Cloudy
|
||||||
}else if(weatherConditionCode == 801){//Few Clouds
|
weatherIcon = cloudy;
|
||||||
weatherIcon = cloudsun;
|
}else if(weatherConditionCode == 801){//Few Clouds
|
||||||
}else if(weatherConditionCode == 800){//Clear
|
weatherIcon = cloudsun;
|
||||||
weatherIcon = sunny;
|
}else if(weatherConditionCode == 800){//Clear
|
||||||
}else if(weatherConditionCode >=700){//Atmosphere
|
weatherIcon = sunny;
|
||||||
weatherIcon = cloudy;
|
}else if(weatherConditionCode >=700){//Atmosphere
|
||||||
}else if(weatherConditionCode >=600){//Snow
|
weatherIcon = cloudy;
|
||||||
weatherIcon = snow;
|
}else if(weatherConditionCode >=600){//Snow
|
||||||
}else if(weatherConditionCode >=500){//Rain
|
weatherIcon = snow;
|
||||||
weatherIcon = rain;
|
}else if(weatherConditionCode >=500){//Rain
|
||||||
}else if(weatherConditionCode >=300){//Drizzle
|
weatherIcon = rain;
|
||||||
weatherIcon = rain;
|
}else if(weatherConditionCode >=300){//Drizzle
|
||||||
}else if(weatherConditionCode >=200){//Thunderstorm
|
weatherIcon = rain;
|
||||||
weatherIcon = rain;
|
}else if(weatherConditionCode >=200){//Thunderstorm
|
||||||
}else
|
weatherIcon = rain;
|
||||||
return;
|
}else
|
||||||
display.drawBitmap(145, 158, weatherIcon, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
return;
|
||||||
}
|
display.drawBitmap(145, 158, weatherIcon, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
|
}
|
||||||
|
|
|
@ -841,7 +841,7 @@ void Watchy::showUpdateFW(){
|
||||||
display.setFont(&FreeMonoBold9pt7b);
|
display.setFont(&FreeMonoBold9pt7b);
|
||||||
display.setTextColor(GxEPD_WHITE);
|
display.setTextColor(GxEPD_WHITE);
|
||||||
display.setCursor(0, 30);
|
display.setCursor(0, 30);
|
||||||
display.println("Please Visit");
|
display.println("Please visit");
|
||||||
display.println("watchy.sqfmi.com");
|
display.println("watchy.sqfmi.com");
|
||||||
display.println("with a Bluetooth");
|
display.println("with a Bluetooth");
|
||||||
display.println("enabled device");
|
display.println("enabled device");
|
||||||
|
|
Loading…
Reference in New Issue