Initial commit

This commit is contained in:
Sameer Rahmani 2021-08-07 01:20:38 +01:00
commit 7f61520933
11 changed files with 1192 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.pio
.clang_complete
.ccls
.cache/
*~

782
compile_commands.json Normal file

File diff suppressed because one or more lines are too long

38
include/Face.h Normal file
View File

@ -0,0 +1,38 @@
/* -*- C++ -*-
* Euler - A watchy firmware for crazy people.
*
* Copyright (c) 2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EULER_FACE_H
#define EULER_FACE_H
#include <Watchy.h>
//#include <Fonts/FreeMonoOblique9pt7b.h>
//#include <Fonts/FreeMono12pt7b.h>
namespace Euler {
class Face : public Watchy {
public:
void drawWatchFace();
};
} // namespace Euler
#endif

42
include/Home.h Normal file
View File

@ -0,0 +1,42 @@
/* -*- C++ -*-
* Euler - A watchy firmware for crazy people.
*
* Copyright (c) 2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EULER_HOME_H
#define EULER_HOME_H
#include "Screen.h"
#include <Fonts/FreeMono12pt7b.h>
class Watchy;
namespace Euler {
class Home : public Screen{
public:
Home(Watchy &w) : Screen(w) {};
uint8_t getBattery();
void draw() override;
};
} // namespace Euler
#endif

42
include/Screen.h Normal file
View File

@ -0,0 +1,42 @@
/* -*- C++ -*-
* Euler - A watchy firmware for crazy people.
*
* Copyright (c) 2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EULER_SCREEN_H
#define EULER_SCREEN_H
#include <Watchy.h>
namespace Euler {
class Screen {
protected:
Watchy &api;
Screen *parent;
public:
Screen(Watchy &api, Screen *parent = nullptr) : api(api), parent(parent) {};
virtual void draw();
};
}
#endif

46
lib/README Normal file
View File

@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

24
platformio.ini Normal file
View File

@ -0,0 +1,24 @@
; 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
lib_deps =
https://github.com/sqfmi/Watchy
lib_ldf_mode = deep+
board_build.partitions = min_spiffs.csv
;
upload_port = /dev/ttyUSB0
monitor_port = /dev/ttyUSB0
monitor_speed = 115200
monitor_filters = esp32_exception_decoder

9
src/Euler.ino Normal file
View File

@ -0,0 +1,9 @@
#include "Face.h"
Euler::Face face;
void setup(){
face.init();
}
void loop(){}

137
src/Face.cpp Normal file
View File

@ -0,0 +1,137 @@
/* -*- C++ -*-
* Euler - A watchy firmware for crazy people.
*
* Copyright (c) 2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "Face.h"
#include "Home.h"
#include "esp32-hal-cpu.h"
#include "stdint.h"
namespace Euler{
void Face::drawWatchFace(){
Home home(Home(*this));
home.draw();
}
// EulerFace::EulerFace(){}
// void EulerFace::drawWatchFace(){
// display.fillScreen(DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);
// display.setTextColor(DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
// 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 EulerFace::drawTime(){
// display.setFont(&DSEG7_Classic_Bold_53);
// display.setCursor(5, 53+5);
// 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 EulerFace::drawDate(){
// display.setFont(&Seven_Segment10pt7b);
// int16_t x1, y1;
// uint16_t w, h;
// String dayOfWeek = dayStr(currentTime.Wday);
// display.getTextBounds(dayOfWeek, 5, 85, &x1, &y1, &w, &h);
// display.setCursor(85 - w, 85);
// display.println(dayOfWeek);
// String month = monthShortStr(currentTime.Month);
// display.getTextBounds(month, 60, 110, &x1, &y1, &w, &h);
// display.setCursor(85 - w, 110);
// display.println(month);
// display.setFont(&DSEG7_Classic_Bold_25);
// display.setCursor(5, 120);
// if(currentTime.Day < 10){
// display.print("0");
// }
// display.println(currentTime.Day);
// display.setCursor(5, 150);
// display.println(currentTime.Year + YEAR_OFFSET);// offset from 1970,
// since year is stored in uint8_t
// }
// void EulerFace::drawSteps(){
// uint32_t stepCount = sensor.getCounter();
// display.drawBitmap(10, 165, steps, 19, 23, DARKMODE ? GxEPD_WHITE :
// GxEPD_BLACK); display.setCursor(35, 190); display.println(stepCount);
// }
// void EulerFace::drawWeather(){
// weatherData currentWeather = getWeatherData();
// int8_t temperature = currentWeather.temperature;
// int16_t weatherConditionCode = currentWeather.weatherConditionCode;
// display.setFont(&DSEG7_Classic_Regular_39);
// int16_t x1, y1;
// uint16_t w, h;
// display.getTextBounds(String(temperature), 100, 150, &x1, &y1, &w, &h);
// display.setCursor(155 - w, 150);
// display.println(temperature);
// 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
// weatherIcon = cloudy;
// }else if(weatherConditionCode == 801){//Few Clouds
// weatherIcon = cloudsun;
// }else if(weatherConditionCode == 800){//Clear
// weatherIcon = sunny;
// }else if(weatherConditionCode >=700){//Atmosphere
// weatherIcon = cloudy;
// }else if(weatherConditionCode >=600){//Snow
// weatherIcon = snow;
// }else if(weatherConditionCode >=500){//Rain
// weatherIcon = rain;
// }else if(weatherConditionCode >=300){//Drizzle
// weatherIcon = rain;
// }else if(weatherConditionCode >=200){//Thunderstorm
// weatherIcon = rain;
// }else
// return;
// display.drawBitmap(145, 158, weatherIcon, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
// }
}

56
src/Home.cpp Normal file
View File

@ -0,0 +1,56 @@
/* -*- C++ -*-
* Euler - A watchy firmware for crazy people.
*
* Copyright (c) 2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "Home.h"
#define DARKMODE true
namespace Euler {
uint8_t Home::getBattery() {
float VBAT = api.getBatteryVoltage();
if (VBAT > 3.95 && VBAT <= 4.1) {
return 2;
}
if (VBAT > 3.80 && VBAT <= 3.95) {
return 1;
}
if (VBAT <= 3.80) {
return 0;
}
return 3;
}
void Home::draw() {
api.display.setFont(&FreeMono12pt7b);
api.display.setCursor(0, 0);
api.display.print("\n");
api.display.printf("%02x %02x %02x %02x %02x", api.currentTime.Month,
api.currentTime.Day, api.currentTime.Hour,
api.currentTime.Minute, getBattery());
};
} // namespace Euler

11
test/README Normal file
View File

@ -0,0 +1,11 @@
This directory is intended for PlatformIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html