Skip to content

Commit

Permalink
New Release (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmicro authored Mar 18, 2023
2 parents 92bb5f1 + 8fbd963 commit 7a5c4c1
Show file tree
Hide file tree
Showing 138 changed files with 11,136 additions and 9,560 deletions.
1 change: 1 addition & 0 deletions .github/buildEverything.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def doBuild(makeDebug):
exit(3)
if res.returncode != 0:
logging.error('COMPILATION FAILED')
logging.error(res.stdout.decode())
logging.error(res.stderr.decode())
exit(2)
# "Export" firmware.bin
Expand Down
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
.pio
.vscode/
.vscode
.DS_Store
firmware.elf
bin
/*.png
screenshots/
build/
emulator_nvs/
screenshots
/build
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@
[submodule "emulator/lib/utest"]
path = emulator/lib/utest
url = https://github.com/sheredom/utest.h.git
[submodule "lib/open-smartwatch-web"]
path = lib/open-smartwatch-web
url = https://github.com/Open-Smartwatch/open-smartwatch-web.git
branch = dist
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@
}
]
},
{
"name": "GDB: Headless Emulator",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/emulator.run",
"args": ["--headless"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"name": "GDB: Unit-Test Emulator",
"type": "cppdbg",
Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ add_library(ImGUI
emulator/lib/ImGUI/imgui_tables.cpp
emulator/lib/ImGUI/backends/imgui_impl_sdl.cpp
emulator/lib/ImGUI/backends/imgui_impl_sdlrenderer.cpp
emulator/lib/ImGUI/misc/cpp/imgui_stdlib.cpp
)
target_include_directories(ImGUI PUBLIC
emulator/lib/ImGUI/
Expand Down Expand Up @@ -106,6 +107,7 @@ target_compile_definitions(emulator.run PUBLIC
TOOL_CALCULATOR=1
TOOL_STOPWATCH=1
TOOL_WATERLEVEL=1
TOOL_CLOCK=1
)
target_compile_options(emulator.run PUBLIC
$<$<CONFIG:Debug>:
Expand All @@ -125,5 +127,5 @@ endif()

# And add unit testing, as we broke our stuff often enough...
enable_testing()
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")
add_test(NAME emulator.run COMMAND emulator.run --unit_tests)
list(APPEND CMAKE_CTEST_ARGUMENTS "--verbose") # this will always show the logs and not only on failure, like "--output-on-failure" does
add_test(NAME emulator.run COMMAND emulator.run --unit_tests --headless)
3 changes: 0 additions & 3 deletions docs/assets/apps/tools/www_config_app_1.png

This file was deleted.

3 changes: 0 additions & 3 deletions docs/assets/apps/tools/www_config_app_2.png

This file was deleted.

3 changes: 0 additions & 3 deletions docs/assets/apps/tools/www_config_app_3.png

This file was deleted.

3 changes: 0 additions & 3 deletions docs/assets/apps/tools/www_config_app_4.png

This file was deleted.

3 changes: 3 additions & 0 deletions docs/assets/apps/tools/www_config_app_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/assets/apps/tools/www_config_app_info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/assets/apps/tools/www_config_app_login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/assets/apps/tools/www_config_app_ota.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/firmware/apps/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
Open the webpage `http://192.168.1.119/` (the IP will change according to your local WiFi network), in your browser. Use the username `admin` as well as the password shown on the watch screen to authenticate.

* Source: [OswAppWebserver.cpp](https://github.com/Open-Smartwatch/open-smartwatch-os/blob/master/src/apps/tools/OswAppWebserver.cpp)
* Authors: [Simonmicro](https://github.com/Simonmicro), [pauls-3d-things](https://github.com/pauls-3d-things)
* Authors: [simonmicro](https://github.com/simonmicro), [pauls-3d-things](https://github.com/pauls-3d-things)

<a href="/assets/apps/tools/www_config_app_1.png" target="_blank"><img src="/assets/apps/tools/www_config_app_1.png" width="320px" style="float:left; margin-right:20px"/></a>
<a href="/assets/apps/tools/www_config_app_4.png" target="_blank"><img src="/assets/apps/tools/www_config_app_4.png" width="320px" style="float:left; margin-right:20px"/></a>
<a href="/assets/apps/tools/www_config_app_3.png" target="_blank"><img src="/assets/apps/tools/www_config_app_3.png" width="320px" style="float:left; margin-right:20px"/></a>
<a href="/assets/apps/tools/www_config_app_2.png" target="_blank"><img src="/assets/apps/tools/www_config_app_2.png" width="320px" style="float:left; margin-right:20px"/></a>
<a href="/assets/apps/tools/www_config_app_login.png" target="_blank"><img src="/assets/apps/tools/www_config_app_login.png" width="320px" style="float:left; margin-right:20px"/></a>
<a href="/assets/apps/tools/www_config_app_config.png" target="_blank"><img src="/assets/apps/tools/www_config_app_config.png" width="320px" style="float:left; margin-right:20px"/></a>
<a href="/assets/apps/tools/www_config_app_ota.png" target="_blank"><img src="/assets/apps/tools/www_config_app_ota.png" width="320px" style="float:left; margin-right:20px"/></a>
<a href="/assets/apps/tools/www_config_app_info.png" target="_blank"><img src="/assets/apps/tools/www_config_app_info.png" width="320px" style="float:left; margin-right:20px"/></a>


<div style="clear: both; margin-bottom:20px"></div>
Expand Down
23 changes: 22 additions & 1 deletion emulator/include/DataTypes.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
#pragma once

#include <cstdint>
#include <math.h>

#define RTC_DATA_ATTR
#define RTC_DATA_ATTR

enum esp_err_t: int {
ESP_FAIL = -1,
ESP_OK = 0
// Add more as needed...
};

enum esp_sleep_ext1_wakeup_mode_t: int {
ESP_EXT1_WAKEUP_ALL_LOW,
ESP_EXT1_WAKEUP_ANY_HIGH
};

enum esp_sleep_source_t {
ESP_SLEEP_WAKEUP_UNDEFINED,
ESP_SLEEP_WAKEUP_TIMER
// Add more as needed...
};

typedef esp_sleep_source_t esp_sleep_wakeup_cause_t;
7 changes: 6 additions & 1 deletion emulator/include/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
#define TWO_PI 6.283185307179586476925286766559
#define DEG_TO_RAD 0.017453292519943295769236907684886
#define RAD_TO_DEG 57.295779513082320876798154814105
#define EULER 2.718281828459045235360287471352
#define EULER 2.718281828459045235360287471352

#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
18 changes: 13 additions & 5 deletions emulator/include/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

class FakeDisplay : public Arduino_G {
public:
FakeDisplay(int width, int height, SDL_Window* window, SDL_Renderer* renderer);
const int width;
const int height;

FakeDisplay(int width, int height, SDL_Renderer* renderer);
~FakeDisplay();

void displayOn();
Expand All @@ -24,12 +27,17 @@ class FakeDisplay : public Arduino_G {
void draw3bitRGBBitmap(int16_t x, int16_t y, uint8_t* bitmap, int16_t w, int16_t h) override;
void draw16bitRGBBitmap(int16_t x, int16_t y, uint16_t* bitmap, int16_t w, int16_t h) override;
void draw24bitRGBBitmap(int16_t x, int16_t y, uint8_t* bitmap, int16_t w, int16_t h) override;

SDL_Texture* getTexture() const {
return this->mainTexture;
};
bool isEnabled() const {
return this->mIsEnabled;
};
private:
SDL_Window* mainWindow;
SDL_Renderer* mainRenderer;
const int width;
const int height;
bool isEnabled = false;
SDL_Texture* mainTexture = nullptr;
bool mIsEnabled = false;
};

extern std::unique_ptr<FakeDisplay> fakeDisplayInstance;
4 changes: 1 addition & 3 deletions emulator/include/ESP.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ class ESP_t {
}
};

extern ESP_t ESP;

#define ESP_OK true
extern ESP_t ESP;
56 changes: 43 additions & 13 deletions emulator/include/Emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,28 @@ class OswEmulator {
class EmulatorSleep {
// This is a dummy class so the execution of the loop() function can be instantly aborted whenever the emulator enters "sleep" mode
};
enum class CPUState {
active,
light,
deep
};
enum class RequestSleepState {
nothing,
light,
deep
};
enum class BootReason {
undefined,
byUser,
byAuto,
byTimer
};

static OswEmulator* instance; // "Singleton"
const bool isHeadless;
bool autoWakeUp = true;

OswEmulator();
OswEmulator(bool headless, std::string configPath = "config.json", std::string imguiPath = "imgui.ini");
~OswEmulator();

void run();
Expand All @@ -33,41 +51,53 @@ class OswEmulator {
uint8_t getBatteryRaw();
bool isCharging();

void cleanup();
void reboot();
void enterSleep(bool toDeepSleep);
bool fromDeepSleep();
BootReason getBootReason();
void requestSleep(RequestSleepState state);
CPUState getCpuState();

// Following functions are only used by the emulator / OS main loop itself
void scheduleWakeupAfterSleep(unsigned long microseconds);
void enterSleep(bool toDeepSleep);
private:
enum class CPUState {
active,
lightSpleep,
deepSleep
};

SDL_Window* mainWindow = nullptr; // Do not delete() this, this is done by SDL2
SDL_Surface* mainSurface = nullptr; // Only used in headless mode
SDL_Renderer* mainRenderer = nullptr;
std::atomic_bool running = true;
std::array<std::atomic_bool, 3> buttons; // TODO This length should come from the platform itself!
std::array<bool, 3> buttonCheckboxes = { false, false, false }; // These are just state caches of the buttons for their respective checkboxes!
bool buttonResetAfterMultiPress = true;
uint8_t batRaw = 0;
bool charging = true;
CPUState cpustate = CPUState::deepSleep;
bool autoWakeUp = true;
bool wakeUpNow = false;
CPUState cpustate = CPUState::deep;
bool manualWakeUp = false;
bool wantCleanup = false;
std::vector<std::variant<bool, float, int, std::string, std::array<float, 3>, short>> configValuesCache;
std::map<std::string, std::list<size_t>> configSectionsToIdCache;
unsigned int lastUiFlush = 0;
RequestSleepState requestedSleepState = RequestSleepState::nothing;
unsigned long selfWakeUpInMicroseconds = 0;
time_t selfWakeUpAtTimestamp = 0;
BootReason bootReason = BootReason::undefined;

// ImGui and window style / sizes
const float guiPadding = 10;
const float guiWidth = 256;

// Timings
std::array<float, 128> timesLoop;
std::array<float, 128> timesFrames;
std::array<float, 128> timesLoop{0.0f};
std::array<float, 129> frameCountsEmulator{0.0f}; // One more frame count to not count current value
std::array<float, 129> frameCountsOsw{0.0f};
time_t frameCountsLastUpdate = 0;

std::string configPath = "config.json";
std::string configPath;
std::string imguiPath;
Jzon::Node config;

void doCleanup();
void renderGUIFrameEmulator();
void addGUIHelp(const char* msg);
};
6 changes: 5 additions & 1 deletion emulator/include/FakeMe.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ void sleep(int);
int rtc_get_reset_reason(int);
void randomSeed(long l);
void esp_deep_sleep_start();
void esp_light_sleep_start();
esp_err_t esp_light_sleep_start();
esp_err_t esp_sleep_enable_timer_wakeup(unsigned long time_in_us);
esp_err_t esp_sleep_enable_ext0_wakeup(unsigned long gpio_num, int level);
esp_err_t esp_sleep_enable_ext1_wakeup(unsigned long gpio_num, int level);
esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause();
4 changes: 0 additions & 4 deletions emulator/include/IO.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#define GPIO_NUM_0 255 // TODO FIX THIS!!!
#define GPIO_NUM_34 255 // TODO FIX THIS!!!

#define esp_sleep_enable_ext0_wakeup(...)
#define esp_sleep_enable_ext1_wakeup(...)
#define esp_sleep_enable_timer_wakeup(...)

void pinMode(int, int);
uint8_t digitalRead(int);
uint8_t analogRead(int);
Expand Down
8 changes: 6 additions & 2 deletions emulator/include/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@

class Preferences {
public:
static const char* preferencesFolderName;
static std::string preferencesFolderName;

Preferences() {};
~Preferences() {};

bool begin(const char* name, bool);
bool begin(const char* name, bool readOnly);
void end() {};

bool clear();
bool remove(const char* key);

#define _PUT_DATA(F, T) inline size_t F(const char* key, T value) { \
if(this->isKey(key)) \
this->node.remove(key); \
Expand Down Expand Up @@ -92,6 +95,7 @@ class Preferences {
};
private:
std::string name;
bool readOnly = true;
std::filesystem::path path;
Jzon::Node node;

Expand Down
Loading

0 comments on commit 7a5c4c1

Please sign in to comment.