Browse Source

initial working draft

main
Julia Luna 1 year ago
commit
11c621eb5d
Signed by: julia GPG Key ID: 6A0C04FA9A7D7582
  1. 3
      .gitignore
  2. 18
      platformio.ini
  3. 125
      src/Watchy_Julia.cpp
  4. 49
      src/Watchy_Julia.h
  5. 159
      src/icons.h
  6. 9
      src/main.cpp

3
.gitignore

@ -0,0 +1,3 @@
.pio
CMakeListsPrivate.txt
cmake-build-*/

18
platformio.ini

@ -0,0 +1,18 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
board_build.partitions = min_spiffs.csv
lib_deps =
Watchy
lib_ldf_mode = deep+

125
src/Watchy_Julia.cpp

@ -0,0 +1,125 @@
//
// Created by julia on 12.06.21.
//
#include "Watchy_Julia.h"
bool DARK = SIMPLE_DARKMODE;
#define BG (DARK ? GxEPD_BLACK : GxEPD_WHITE)
#define FG (DARK ? GxEPD_WHITE : GxEPD_BLACK)
WatchyJulia::WatchyJulia() = default;
void WatchyJulia::drawWatchFace() {
if (ADAPTIVE_DARKMODE) {
setAdaptiveDarkmode();
}
display.fillScreen(BG);
display.setTextColor(FG);
drawStatusBar();
drawTime();
drawDate();
}
void WatchyJulia::drawTime() {
display.setFont(&DSEG7_Classic_Bold_53);
display.setCursor(5, 96);
if(currentTime.Hour < 10){
display.print("0");
}
display.print(currentTime.Hour);
display.print(":");
if(currentTime.Minute < 10){
display.print("0");
}
display.println(currentTime.Minute);
}
void WatchyJulia::drawDate() {
display.setFont(&FreeSans18pt7b);
display.setCursor(10, 124);
String dayOfWeek = dayStr(currentTime.Wday);
display.print(currentTime.Year + YEAR_OFFSET);
display.print("-");
if (currentTime.Month < 10) {
display.print("0");
}
display.print(currentTime.Month);
display.print("-");
if (currentTime.Day < 10) {
display.print("0");
}
display.print(currentTime.Day);
display.setFont(&FreeSans12pt7b);
display.setCursor(10, 146);
display.print(dayOfWeek);
}
int16_t statusbarYOffset(int16_t height) {
return (STATUSBAR_HEIGHT - height) / 2;
}
void WatchyJulia::drawStatusBar() {
display.fillRect(0, STATUSBAR_HEIGHT, 200, 5, FG);
drawBattery(0, false);
uint8_t offset = 200;
if (BLE_CONFIGURED) {
offset -= drawSBIcon(bluetooth, offset, true);
}
if (WIFI_CONFIGURED) {
offset -= drawSBIcon(wifi, offset, true);
}
// if (UNREAD_NOTIFS) {
if (true) { // debug purposes
offset -= drawSBIcon(bell, offset, true);
}
}
int16_t WatchyJulia::drawBattery(int16_t x, bool reverseSpace) {
if (reverseSpace) {
x -= (battery.width + STATUSBAR_SPACE);
} else {
x += STATUSBAR_SPACE;
}
int16_t y = statusbarYOffset(battery.height);
int8_t batteryLevel = 0;
float vBat = getBatteryVoltage();
if (vBat > BATTERY_THRESHOLD_3) {
batteryLevel = 3;
} else if (vBat > BATTERY_THRESHOLD_2) {
batteryLevel = 2;
} else if (vBat > BATTERY_THRESHOLD_1) {
batteryLevel = 1;
}
display.drawBitmap(x, y, battery.data, battery.width, battery.height, FG);
int16_t segX = x + 3;
int16_t segY = y + 5 + 3 * (BATTERY_SEGMENT_HEIGHT + BATTERY_SEGMENT_GAP);
for (int8_t i = 0; i < batteryLevel; i++, segY -= (BATTERY_SEGMENT_HEIGHT + BATTERY_SEGMENT_GAP)) {
display.fillRect(segX, segY, BATTERY_SEGMENT_WIDTH, BATTERY_SEGMENT_HEIGHT, FG);
}
return 2 * STATUSBAR_SPACE + battery.width;
}
int16_t WatchyJulia::drawSBIcon(const icon &i, int16_t x, bool reverseSpace) {
if (reverseSpace) {
x -= (i.width + STATUSBAR_SPACE);
} else {
x += STATUSBAR_SPACE;
}
display.drawBitmap(x, statusbarYOffset(i.height),
i.data, i.width, i.height, FG);
return 2 * STATUSBAR_SPACE + i.width;
}
void WatchyJulia::setAdaptiveDarkmode() {
DARK = (6 >= currentTime.Hour && 21 <= currentTime.Hour);
}

49
src/Watchy_Julia.h

@ -0,0 +1,49 @@
//
// Created by julia on 12.06.21.
//
#ifndef PAIN_WATCHY_JULIA_H
#define PAIN_WATCHY_JULIA_H
#include <Watchy.h>
#include "icons.h"
#include <Fonts/FreeSans18pt7b.h>
#include <Fonts/FreeSans12pt7b.h>
#define ADAPTIVE_DARKMODE true
#define SIMPLE_DARKMODE true // doesn't matter if ADAPTIVE_DARKMODE is true
#define STATUSBAR_SPACE 4
#define STATUSBAR_HEIGHT 30
#define BATTERY_SEGMENT_WIDTH 9
#define BATTERY_SEGMENT_HEIGHT 4
#define BATTERY_SEGMENT_GAP 1
#define BATTERY_THRESHOLD_3 4.1
#define BATTERY_THRESHOLD_2 3.95
#define BATTERY_THRESHOLD_1 3.8
#define GOTIFY_SERVER_URL "https://push.julia.network"
#define GOTIFY_CLIENT_TOKEN "CBd************"
#define GOTIFY_PRIORITY_APP_ID 10
class WatchyJulia : public Watchy {
public:
WatchyJulia();
void drawWatchFace() override;
void drawTime();
void drawDate();
void drawStatusBar();
// void getNotifs();
private:
int16_t drawBattery(int16_t x, bool reverseSpace);
int16_t drawSBIcon(const icon &i, int16_t x, bool reverseSpace);
void setAdaptiveDarkmode();
};
//extern RTC_DATA_ATTR bool UNREAD_NOTIFS;
#endif //PAIN_WATCHY_JULIA_H

159
src/icons.h

@ -0,0 +1,159 @@
//
// Created by julia on 12.06.21.
//
#ifndef PAIN_ICONS_H
#define PAIN_ICONS_H
typedef struct icon {
int16_t height;
int16_t width;
const unsigned char *data;
} icon;
// battery, 15x22px
const unsigned char batteryData [] PROGMEM = {
B00001111, B11100000,
B00001111, B11100000,
B11111111, B11111110,
B11111111, B11111110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11000000, B00000110,
B11111111, B11111110,
B11111111, B11111110,
};
const icon battery PROGMEM = {
.height = 22,
.width = 15,
.data = batteryData
};
// wifi, 23x17px
const unsigned char wifiData [] PROGMEM = {
B00000000, B11111110, B00000000,
B00000111, B11111111, B11000000,
B00011111, B10000011, B11110000,
B00111100, B00000000, B01111000,
B01110000, B01111100, B00011100,
B01100011, B11111111, B00001100,
B11100111, B10000011, B11001110,
B11001110, B00000000, B11100110,
B01011100, B01111100, B01110100,
B00011001, B11111111, B00110000,
B00111011, B11000111, B10111000,
B00010011, B00000001, B10010000,
B00000111, B00111001, B11000000,
B00000110, B01111100, B11000000,
B00000010, B01111100, B10000000,
B00000000, B01111100, B00000000,
B00000000, B00111000, B00000000,
};
const icon wifi PROGMEM = {
.height = 17,
.width = 23,
.data = wifiData
};
// bluetooth, 15x26px
const unsigned char bluetoothData [] PROGMEM = {
B00000001, B00000000,
B00000011, B10000000,
B00000011, B11000000,
B00000011, B11100000,
B00000011, B01110000,
B01000011, B00111000,
B11100011, B00011100,
B01110011, B00001110,
B00111011, B00011100,
B00011111, B00111000,
B00001111, B01110000,
B00000111, B11100000,
B00000011, B11000000,
B00000011, B11000000,
B00000111, B11100000,
B00001111, B01110000,
B00011111, B00111000,
B00111011, B00011100,
B01110011, B00001110,
B11100011, B00011100,
B01000011, B00111000,
B00000011, B01110000,
B00000011, B11100000,
B00000011, B11000000,
B00000011, B10000000,
B00000001, B00000000,
};
const icon bluetooth PROGMEM = {
.height = 26,
.width = 15,
.data = bluetoothData
};
const unsigned char bellData [] PROGMEM = {
B00000001, B10000000,
B00000011, B11000000,
B00000111, B11100000,
B00000111, B11100000,
B00001111, B11110000,
B00001111, B11110000,
B00001111, B11110000,
B00011111, B11111000,
B00011111, B11111000,
B00011111, B11111000,
B00011111, B11111000,
B00111111, B11111100,
B00111111, B11111100,
B01111111, B11111110,
B11111111, B11111111,
B11111111, B11111111,
B11111111, B11111111,
B00000011, B11000000,
};
const icon bell PROGMEM = {
.height = 18,
.width = 16,
.data = bellData
};
// strikethrough, 20x20px, 2 layers
const unsigned char strikethroughEraseData [] PROGMEM = {
0xF8, 0x00, 0x00, 0xFC, 0x00, 0x00, 0xFE, 0x00, 0x00, 0xFF, 0x00, 0x00,
0xFF, 0x80, 0x00, 0x7F, 0xC0, 0x00, 0x3F, 0xE0, 0x00, 0x1F, 0xF0, 0x00,
0x0F, 0xF8, 0x00, 0x07, 0xFC, 0x00, 0x03, 0xFE, 0x00, 0x01, 0xFF, 0x00,
0x00, 0xFF, 0x80, 0x00, 0x7F, 0xC0, 0x00, 0x3F, 0xE0, 0x00, 0x1F, 0xF0,
0x00, 0x0F, 0xF0, 0x00, 0x07, 0xF0, 0x00, 0x03, 0xF0, 0x00, 0x01, 0xF0
};
const icon strikethroughErase PROGMEM = {
.height = 20,
.width = 20,
.data = strikethroughEraseData
};
const unsigned char strikethroughLineData [] PROGMEM = {
0xC0, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x70, 0x00, 0x00, 0x38, 0x00, 0x00,
0x1C, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x07, 0x00, 0x00, 0x03, 0x80, 0x00,
0x01, 0xC0, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x70, 0x00, 0x00, 0x38, 0x00,
0x00, 0x1C, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x07, 0x00, 0x00, 0x03, 0x80,
0x00, 0x01, 0xC0, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x70, 0x00, 0x00, 0x30
};
const icon strikethroughLine PROGMEM = {
.height = 20,
.width = 20,
.data = strikethroughLineData
};
#endif //PAIN_ICONS_H

9
src/main.cpp

@ -0,0 +1,9 @@
#include "Watchy_Julia.h"
WatchyJulia watchy;
void setup(){
watchy.init();
}
void loop(){}
Loading…
Cancel
Save