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

Moonphase #264

Open
wants to merge 54 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2b16794
Just one update on render for everything.
crossplatformdev Jul 5, 2024
4aecc15
Added functions get and is for darkMode
crossplatformdev Jul 5, 2024
9e6325e
Add USB detection
sqfmi Jul 6, 2024
992df52
Merge branch 'sqfmi:master' into custom
crossplatformdev Jul 6, 2024
d1c6d90
fix GHA builds
sqfmi Jul 6, 2024
c1c9ddc
update GHA for v3
sqfmi Jul 6, 2024
cee857b
add to GHA
sqfmi Jul 6, 2024
71457b5
updated version in config.h
sqfmi Jul 7, 2024
e32eb01
Merge branch 'sqfmi:master' into custom
crossplatformdev Jul 7, 2024
a9a7169
Set GMT timezone in run time and location based timezone in compile t…
crossplatformdev Jul 8, 2024
25e43ca
Merge pull request #1 from crossplatformdev/custom
crossplatformdev Jul 8, 2024
e5fce3b
Update README.md
sqfmi Jul 13, 2024
9f3accd
Update library.json
sqfmi Jul 14, 2024
1fe685a
Merge branch 'sqfmi:master' into master
crossplatformdev Jul 14, 2024
af19065
Added platformio.ini and updated gitignore.
crossplatformdev Jul 19, 2024
261390a
Added MoonPhase library
crossplatformdev Jul 21, 2024
c515c75
Merge pull request #4 from crossplatformdev/master
crossplatformdev Jul 21, 2024
0422175
Added Moon Phase menu app.
crossplatformdev Jul 21, 2024
2a2fb3e
Merge pull request #5 from crossplatformdev/moonphase
crossplatformdev Jul 21, 2024
f63f561
Formatting and some better management of timezones array
crossplatformdev Jul 22, 2024
ddf69e7
Make gmtOffset effectively displayed.
crossplatformdev Jul 22, 2024
fb1c5a9
Merge pull request #6 from crossplatformdev/custom
crossplatformdev Jul 22, 2024
211abb2
Added PipBoy
crossplatformdev Jul 22, 2024
c7b67f3
Merge branch 'master' of https://github.com/crossplatformdev/Watchy
crossplatformdev Jul 22, 2024
83cd39e
Update dev.actions.yml
crossplatformdev Jul 22, 2024
735c075
Update v3.actions.yml
crossplatformdev Jul 22, 2024
4abca73
Update main.actions.yml
crossplatformdev Jul 22, 2024
3d8236a
Update dev.actions.yml
crossplatformdev Jul 22, 2024
a290025
Update main.actions.yml
crossplatformdev Jul 22, 2024
67e3735
Update v3.actions.yml
crossplatformdev Jul 22, 2024
0bdc561
Update platformio.ini
crossplatformdev Jul 22, 2024
72fd470
Update platformio.ini
crossplatformdev Jul 22, 2024
2397437
Create test.actions.yml
crossplatformdev Jul 22, 2024
2e1bb8e
Update test.actions.yml
crossplatformdev Jul 22, 2024
d3978c0
Update dev.actions.yml
crossplatformdev Jul 22, 2024
d7a36ef
Update test.actions.yml
crossplatformdev Jul 22, 2024
c0012df
Update test.actions.yml
crossplatformdev Jul 22, 2024
e6b0457
Update v3.actions.yml
crossplatformdev Jul 22, 2024
6c22dd8
Update main.actions.yml
crossplatformdev Jul 22, 2024
ccfad54
Update dev.actions.yml
crossplatformdev Jul 22, 2024
e57f0ac
Update charge level for v3
crossplatformdev Aug 5, 2024
789dedb
Delete .github/workflows/test.actions.yml
crossplatformdev Aug 18, 2024
8f1123c
Update dev.actions.yml
crossplatformdev Aug 18, 2024
b0d35ce
Update main.actions.yml
crossplatformdev Aug 18, 2024
a53f871
Update v3.actions.yml
crossplatformdev Aug 18, 2024
276c535
Update main.actions.yml
crossplatformdev Aug 18, 2024
c3d9fc6
Update dev.actions.yml
crossplatformdev Aug 18, 2024
5fa333b
Update dev.actions.yml
crossplatformdev Aug 18, 2024
ac3341e
Update dev.actions.yml
crossplatformdev Aug 18, 2024
3f78cca
Update dev.actions.yml
crossplatformdev Aug 18, 2024
cc7bbac
Update Watchy.cpp
crossplatformdev Aug 18, 2024
d95f6bb
Error in compilation
crossplatformdev Aug 18, 2024
925d17e
Update platformio.ini
crossplatformdev Aug 18, 2024
7d9f8af
Merge branch 'master' into moonphase
crossplatformdev Aug 18, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/dev.actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
arduino-board-fqbn: esp32:esp32:watchy:Revision=v20,PartitionScheme=min_spiffs,UploadSpeed=921600,DebugLevel=none,EraseFlash=none
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
arduino-platform: esp32:[email protected].17
arduino-platform: esp32:[email protected].12
required-libraries: Adafruit GFX Library,Arduino_JSON,DS3232RTC,NTPClient,Rtc_Pcf8563,GxEPD2,WiFiManager
set-build-path: true
- uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@master
- uses: ArminJo/arduino-test-compile@v3
with:
arduino-board-fqbn: esp32:esp32:watchy:Revision=${{ matrix.board-revisions }},PartitionScheme=min_spiffs,UploadSpeed=921600,DebugLevel=none,EraseFlash=none
arduino-board-fqbn: esp32:esp32:watchy:Revision=${{ matrix.board-revisions }},PartitionScheme=default_8MB,UploadSpeed=921600,DebugLevel=none,EraseFlash=none
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
arduino-platform: esp32:[email protected]
required-libraries: Adafruit GFX Library,Arduino_JSON,DS3232RTC,NTPClient,Rtc_Pcf8563,GxEPD2,WiFiManager
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/v3.actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ReleaseV3
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
release:
name: Build and Release
runs-on: ubuntu-latest
strategy:
matrix:
board-revisions: [v30]
steps:
- uses: actions/checkout@master
- uses: ArminJo/arduino-test-compile@v3
with:
arduino-board-fqbn: esp32:esp32:esp32s3:FlashSize=8M,PartitionScheme=default_8MB,UploadSpeed=921600,DebugLevel=none,EraseFlash=none
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
arduino-platform: esp32:[email protected]
required-libraries: Adafruit GFX Library,Arduino_JSON,DS3232RTC,NTPClient,Rtc_Pcf8563,GxEPD2,WiFiManager
set-build-path: true
- name: Rename binaries with board revision
run: |
parent_dir="${{ github.workspace }}/examples/WatchFaces"
for dir in "$parent_dir"/*; do
if [ -d "$dir" ]; then
cd "$dir/build"
for file in *; do
name="${file%%.*}"
ext="${file#$name.}"
mv "$file" "$name-${{ matrix.board-revisions }}.$ext"
done
cd -
fi
done
- uses: softprops/action-gh-release@v1
with:
name: "Watchy Arduino Library ${{ github.ref_name }}"
files: ${{ github.workspace }}/examples/WatchFaces/**/build/*.bin
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.pio/
.vscode/
app/bin/
app/pde.jar
build/macosx/work/
Expand Down
20 changes: 3 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,15 @@

![Watchy](https://watchy.sqfmi.com/img/watchy_render.png)

**Buy Watchy from [The Pi Hut](https://thepihut.com/collections/sqfmi), [Crowd Supply](https://www.crowdsupply.com/sqfmi/watchy), and [Mouser](https://www.mouser.com/ProductDetail/SQFMI/SQFMI-WATCHY-10?qs=DRkmTr78QARN9VSJRzqRxw%3D%3D)!**
**Buy Watchy from [Mouser](https://www.mouser.com/ProductDetail/SQFMI/SQFMI-WATCHY-10?qs=DRkmTr78QARN9VSJRzqRxw%3D%3D), [The Pi Hut](https://thepihut.com/collections/sqfmi), and [Crowd Supply](https://www.crowdsupply.com/sqfmi/watchy)**

[**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](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html).
* Arduino > Preferences > Additional Board Manager URLs
* ```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 dependencies when prompted
3. Check out the examples under ```Examples``` -> ```Watchy```
4. Compile & Upload with these board settings:
* Board: "Watchy"
* Partition Scheme: "Huge App"
* Board Revision: Choose your Watchy version
* All Other Settings: leave to default

You may also have to install the [CP2104 USB to Serial drivers](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers) if the port is not automatically detected.
## Getting Started Guide
Follow the instructions here https://watchy.sqfmi.com/docs/getting-started

### Have Fun! :)


### Got Questions?

Join our [Discord](https://discord.gg/ZXDegGV8E7)
Expand Down
32 changes: 26 additions & 6 deletions examples/WatchFaces/7_SEG/Watchy_7_SEG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ void Watchy7SEG::drawWatchFace(){
drawSteps();
drawWeather();
drawBattery();
display.drawBitmap(120, 77, WIFI_CONFIGURED ? wifi : wifioff, 26, 18, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.drawBitmap(116, 75, WIFI_CONFIGURED ? wifi : wifioff, 26, 18, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
if(BLE_CONFIGURED){
display.drawBitmap(100, 75, bluetooth, 13, 21, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.drawBitmap(100, 73, bluetooth, 13, 21, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
}
#ifdef ARDUINO_ESP32S3_DEV
if(USB_PLUGGED_IN){
display.drawBitmap(140, 75, charge, 16, 18, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
}
#endif
}

void Watchy7SEG::drawTime(){
Expand Down Expand Up @@ -81,10 +86,11 @@ void Watchy7SEG::drawSteps(){
display.println(stepCount);
}
void Watchy7SEG::drawBattery(){
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.drawBitmap(158, 73, battery, 37, 21, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.fillRect(163, 78, 27, BATTERY_SEGMENT_HEIGHT, DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);//clear battery segments
int8_t batteryLevel = 0;
float VBAT = getBatteryVoltage();
#ifndef ARDUINO_ESP32S3_DEV
if(VBAT > 4.1){
batteryLevel = 3;
}
Expand All @@ -97,9 +103,23 @@ void Watchy7SEG::drawBattery(){
else if(VBAT <= 3.80){
batteryLevel = 0;
}
#else
if (VBAT > 3.90) {
batteryLevel = 3;
}
else if (VBAT > 3.75 && VBAT <= 3.90) {
batteryLevel = 2;
}
else if (VBAT > 3.60 && VBAT <= 3.75) {
batteryLevel = 1;
}
else if (VBAT <= 3.60) {
batteryLevel = 0;
}
#endif

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(163 + (batterySegments * BATTERY_SEGMENT_SPACING), 78, BATTERY_SEGMENT_WIDTH, BATTERY_SEGMENT_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
}
}

Expand Down Expand Up @@ -150,4 +170,4 @@ void Watchy7SEG::drawWeather(){
}

display.drawBitmap(145, 158, weatherIcon, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
}
}
8 changes: 8 additions & 0 deletions examples/WatchFaces/7_SEG/icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ const unsigned char wifioff [] PROGMEM = {
0x01, 0xff, 0xc0, 0x00, 0x07, 0xe1, 0xc0, 0x00, 0x0f, 0xc0, 0x80, 0x00, 0x1f, 0x0c, 0x00, 0x00,
0x3c, 0x1e, 0x00, 0x00, 0xf8, 0x0c, 0x00, 0x00
};

// 'charge', 16x18px
const unsigned char charge [] PROGMEM = {
0x00, 0x10, 0x00, 0x70, 0x00, 0xe0, 0x01, 0xe0, 0x03, 0xe0, 0x07, 0xc0, 0x0f, 0xc0, 0x1f, 0xff,
0x3f, 0xfe, 0x7f, 0xfc, 0x7f, 0xf8, 0x03, 0xf0, 0x03, 0xe0, 0x07, 0xc0, 0x07, 0x80, 0x07, 0x00,
0x0e, 0x00, 0x0c, 0x00
};

// 'chip', 48x32px
const unsigned char chip [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
207 changes: 207 additions & 0 deletions examples/WatchFaces/pipboy/WatchyPipBoy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
#include "WatchyPipBoy.h"

#define DARKMODE true
#define STEPSGOAL 5000

const uint8_t WEATHER_ICON_WIDTH = 48;
const uint8_t WEATHER_ICON_HEIGHT = 32;

RTC_DATA_ATTR uint8_t vaultBoyNum;

void WatchyPipBoy::drawWatchFace(){
//top menu bar
display.fillScreen(DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);
display.setFont(&monofonto8pt7b);
display.setTextColor(DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.setCursor(22, 14);
display.print("STAT INV DATA MAP");
display.drawBitmap(0, 10, menubar, 200, 9, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);

//bottom text
display.setFont(&monofonto8pt7b);
display.setCursor(10, 195);
display.println("PIP-BOY 3000 ROBCO IND.");

drawTime();
drawDate();
drawSteps();
drawWeather();
drawBattery();
// display.drawBitmap(120, 77, WIFI_CONFIGURED ? wifi : wifioff, 26, 18, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
// if(BLE_CONFIGURED){
// display.drawBitmap(100, 75, bluetooth, 13, 21, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
// }
}

void WatchyPipBoy::drawTime(){

//draw random vault boy every 15mins
if(currentTime.Minute % 15 == 0){
vaultBoyNum = random(0, 3);
}

switch(vaultBoyNum){
case 0:
display.drawBitmap(70, 50, vaultboy, 57, 100, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
break;
case 1:
display.drawBitmap(70, 50, vaultboypoint, 57, 100, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
break;
case 2:
display.drawBitmap(60, 50, vaultboysmile, 67, 100, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
break;
}

//time border
display.drawLine(137, 28, 200, 28, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.drawLine(137, 28, 137, 132, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.drawLine(137, 132, 157, 132, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.drawLine(180, 132, 200, 132, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);

//draw time
display.setFont(&monofonto28pt7b);
display.setCursor(141, 75);

int displayHour;
if(HOUR_12_24==12){
displayHour = ((currentTime.Hour+11)%12)+1;
} else {
displayHour = currentTime.Hour;
}
if(displayHour < 10){
display.print("0");
}
display.print(displayHour);

display.setCursor(141, 125);
if(currentTime.Minute < 10){
display.print("0");
}
display.print(currentTime.Minute);

//AMPM
display.setFont(&monofonto8pt7b);
display.setCursor(160, 140);
display.print(currentTime.Hour < 11 ? "AM" : "PM");
}

void WatchyPipBoy::drawDate(){

display.setFont(&monofonto10pt7b);
int16_t x1, y1;
uint16_t w, h;
String dayOfWeek = dayStr(currentTime.Wday);
dayOfWeek.toUpperCase();
display.setTextColor(DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);
display.getTextBounds(dayOfWeek, 7, 42, &x1, &y1, &w, &h);
display.setCursor(7, 42);
display.fillRect(x1-2, y1-2, w+4, h+4, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.print(dayOfWeek);

display.setFont(&monofonto10pt7b);
display.setTextColor(DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.setCursor(7, 62);
display.print(monthShortStr(currentTime.Month));
display.print(" ");
display.print(currentTime.Day);
display.setCursor(7, 78);
display.print(tmYearToCalendar(currentTime.Year));
}

void WatchyPipBoy::drawSteps(){
// reset step counter at midnight
if (currentTime.Hour == 0 && currentTime.Minute == 0){
sensor.resetStepCounter();
}

//draw progress bar
uint32_t stepCount = sensor.getCounter();
uint8_t progress = (uint8_t)(stepCount * 100.0 / STEPSGOAL);
progress = progress > 100 ? 100 : progress;
display.drawBitmap(60, 155, gauge, 73, 10, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.fillRect(60+13, 155+5, (progress/2)+5, 4, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);

//show step count
display.setFont(&monofonto8pt7b);
display.setTextColor(DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.setCursor(150, 160);
display.print("STEPS");
display.setCursor(150, 175);
display.print(stepCount);
}

void WatchyPipBoy::drawBattery(){
display.drawBitmap(10, 150, battery, 37, 21, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.fillRect(15, 155, 27, 11, DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);//clear battery segments
int8_t batteryLevel = 0;
float VBAT = getBatteryVoltage();
#ifndef ARDUINO_ESP32S3_DEV
if(VBAT > 4.1){
batteryLevel = 3;
}
else if(VBAT > 3.95 && VBAT <= 4.1){
batteryLevel = 2;
}
else if(VBAT > 3.80 && VBAT <= 3.95){
batteryLevel = 1;
}
else if(VBAT <= 3.80){
batteryLevel = 0;
}
#else
if (VBAT > 3.90) {
batteryLevel = 3;
}
else if (VBAT > 3.75 && VBAT <= 3.90) {
batteryLevel = 2;
}
else if (VBAT > 3.60 && VBAT <= 3.75) {
batteryLevel = 1;
}
else if (VBAT <= 3.60) {
batteryLevel = 0;
}
#endif

for(int8_t batterySegments = 0; batterySegments < batteryLevel; batterySegments++){
display.fillRect(15 + (batterySegments * 9), 155, 7, 11, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
}
}

void WatchyPipBoy::drawWeather(){

weatherData currentWeather = getWeatherData();

int8_t temperature = currentWeather.temperature;
int16_t weatherConditionCode = currentWeather.weatherConditionCode;

display.setFont(&monofonto10pt7b);
display.setTextColor(DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
display.setCursor(12, 133);


display.print(temperature);
display.print(currentWeather.isMetric ? "C" : "F");
const unsigned char* weatherIcon;

//https://openweathermap.org/weather-conditions
if(weatherConditionCode > 801){//Cloudy
weatherIcon = cloudy;
}else if(weatherConditionCode == 801){//Few Clouds
weatherIcon = cloudsun;
}else if(weatherConditionCode == 800){//Clear
weatherIcon = sunny;
}else if(weatherConditionCode >=700){//Atmosphere
weatherIcon = atmosphere;
}else if(weatherConditionCode >=600){//Snow
weatherIcon = snow;
}else if(weatherConditionCode >=500){//Rain
weatherIcon = rain;
}else if(weatherConditionCode >=300){//Drizzle
weatherIcon = drizzle;
}else if(weatherConditionCode >=200){//Thunderstorm
weatherIcon = thunderstorm;
}else
return;
display.drawBitmap(5, 85, weatherIcon, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
}
Loading