-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #290 from Open-Smartwatch/develop
New release
- Loading branch information
Showing
182 changed files
with
8,080 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
if [ "$1" = "--default-lang" ]; then | ||
# default_lang | ||
echo $(X=$(if [ -e include/locales/en-US.h ]; then X=$(ls include/locales/en-US.h); else X=$(ls include/locales/*.h -1 | head -1); fi; echo ${X:16:5});X=($X);jq --compact-output --null-input '$ARGS.positional' --args -- "${X[@]}") | ||
elif [ "$1" = "--default-mod" ]; then | ||
# default_mod | ||
echo $(X=$(X=$(cat platformio.ini | grep "defau"); echo "${X:15}");X=($X);jq --compact-output --null-input '$ARGS.positional' --args -- "${X[@]}") | ||
elif [ "$1" = "--get-flag" ]; then | ||
# get_flag | ||
echo $(X=$(curl https://api.github.com/repos/Open-smartwatch/open-smartwatch.github.io/contents/docs/resources/firmware.md | jq -r ".content" | base64 --decode | grep -o '^-.*` |'); X=$(echo $X | tr '` |-' ' ');X=($X);jq --compact-output --null-input '$ARGS.positional' --args -- "${X[@]}") | ||
elif [ "$1" = "--get-models" ]; then | ||
# get_models | ||
echo $(X=$(cat platformio.ini | grep "\[\env:" | sed -e 's/\[\env://' | tr ']\n' ' ');X=($X);jq --compact-output --null-input '$ARGS.positional' --args -- "${X[@]}") | ||
elif [ "$1" = "--get-languages" ]; then | ||
# get_languages | ||
echo $(cd include/locales/; X=$(ls *.h -1 | sed -e 's/\.h$//' | tr '\n' ' ');X=($X);jq --compact-output --null-input '$ARGS.positional' --args -- "${X[@]}") | ||
else | ||
echo "Try, again ! $(date +%F)" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: OSW-EMULATOR-test | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
pull_request: | ||
branches: [ master, develop ] | ||
|
||
jobs: | ||
build-EMULATOR: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout repository and submodules | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- name: Update packages | ||
run: sudo apt-get update && sudo apt-get upgrade -y | ||
- name: Install packages | ||
run: sudo apt-get -y install gcc g++ cmake libsdl2-dev libsdl2-image-dev | ||
- name: Create build directory | ||
run: mkdir build | ||
- name: CMake (debug) | ||
run: cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. | ||
- name: Make | ||
run: cd build && make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ firmware.elf | |
bin | ||
/*.png | ||
screenshots/ | ||
build/ | ||
emulator_nvs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "GDB: Emulator", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/build/emulator.run", | ||
"args": [], | ||
"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 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
cmake_minimum_required (VERSION 3.10) | ||
project (OSW-OS-Emulator) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
|
||
# Prepare some defines, which are normally evaluated using some Python snippets... | ||
execute_process(COMMAND "git" "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE GIT_COMMIT_HASH) | ||
execute_process(COMMAND "git" "log" "-1" "--pretty=format:%cd" "--date=format:%Y-%m-%dT%H:%M:%S%z" OUTPUT_VARIABLE GIT_COMMIT_TIME) | ||
execute_process(COMMAND "git" "rev-parse" "--abbrev-ref" "HEAD" OUTPUT_VARIABLE GIT_BRANCH_NAME) | ||
string(STRIP ${GIT_COMMIT_HASH} GIT_COMMIT_HASH) | ||
string(STRIP ${GIT_COMMIT_TIME} GIT_COMMIT_TIME) | ||
string(STRIP ${GIT_BRANCH_NAME} GIT_BRANCH_NAME) | ||
|
||
# For threads | ||
set(THREADS_PREFER_PTHREAD_FLAG ON) | ||
find_package(Threads REQUIRED) | ||
|
||
# This uses pkg-config, as sdl2-image does not has any CMake bindings (and the sdl2 package via vcpkg is just broken under Linux) | ||
INCLUDE(FindPkgConfig) | ||
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2>=2.0.20) | ||
PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image) | ||
|
||
# Pngle | ||
file(GLOB_RECURSE SOURCES_Pngle ./lib/pngle/*.c) | ||
add_library(Pngle ${SOURCES_Pngle}) | ||
target_include_directories(Pngle PUBLIC ./lib/pngle/src/) | ||
|
||
# ArduinoJSON | ||
add_subdirectory(emulator/lib/ArduinoJson) | ||
|
||
# Jzon | ||
add_library(Jzon emulator/lib/Jzon/Jzon.cpp) | ||
target_include_directories(Jzon PUBLIC emulator/lib/Jzon/) | ||
|
||
# ImGUI | ||
add_library(ImGUI | ||
emulator/lib/ImGUI/imgui.cpp | ||
emulator/lib/ImGUI/imgui_draw.cpp | ||
emulator/lib/ImGUI/imgui_widgets.cpp | ||
emulator/lib/ImGUI/imgui_tables.cpp | ||
emulator/lib/ImGUI/backends/imgui_impl_sdl.cpp | ||
emulator/lib/ImGUI/backends/imgui_impl_sdlrenderer.cpp | ||
) | ||
target_include_directories(ImGUI PUBLIC | ||
emulator/lib/ImGUI/ | ||
emulator/lib/ImGUI/backends | ||
${SDL2_INCLUDE_DIRS} | ||
) | ||
target_link_libraries(ImGUI LINK_PUBLIC | ||
${SDL2_LIBRARY} | ||
${SDL2IMAGE_LIBRARIES} | ||
) | ||
|
||
# Emulator | ||
file(GLOB_RECURSE SOURCES_OSW ./src/*.cpp) | ||
file(GLOB_RECURSE SOURCES_OSW_EMULATOR ./emulator/src/*.cpp) | ||
add_executable(emulator.run | ||
${SOURCES_OSW} | ||
${SOURCES_OSW_EMULATOR} | ||
) | ||
target_include_directories(emulator.run PUBLIC | ||
./emulator/include | ||
./include | ||
./lib/lib-open-smartwatch | ||
emulator/lib/Jzon/ | ||
${SDL2_INCLUDE_DIRS} | ||
${SDL2IMAGE_INCLUDE_DIRS} | ||
) | ||
target_link_libraries(emulator.run LINK_PUBLIC | ||
Pngle | ||
ArduinoJson | ||
Threads::Threads | ||
Jzon | ||
${SDL2_LIBRARY} | ||
${SDL2IMAGE_LIBRARIES} | ||
ImGUI | ||
) | ||
target_compile_definitions(emulator.run PUBLIC | ||
OSW_TARGET_PLATFORM_HEADER="platform/EMULATOR.h" | ||
OSW_EMULATOR=1 | ||
GIT_COMMIT_HASH="${GIT_COMMIT_HASH}" | ||
GIT_COMMIT_TIME="${GIT_COMMIT_TIME}" | ||
GIT_BRANCH_NAME="${GIT_BRANCH_NAME}" | ||
PIO_ENV_NAME="VIRTUAL" | ||
$<$<CONFIG:Debug>: | ||
DEBUG=1 # Just for legacy reasons | ||
> | ||
$<$<CONFIG:Release>: | ||
NDEBUG=1 | ||
> | ||
# Comment these as you wish... | ||
OSW_FEATURE_STATS_STEPS | ||
) | ||
target_compile_options(emulator.run PUBLIC | ||
$<$<CONFIG:Debug>: | ||
-O0 | ||
-g3 | ||
-Wall | ||
> | ||
$<$<CONFIG:Release>: | ||
-O4 | ||
> | ||
) | ||
|
||
# Including SDL2 using the system libraries is broken under MacOS, so we have to add this path manually... | ||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
link_directories(/usr/local/lib) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "DataTypes.h" | ||
#include "Defines.h" | ||
|
||
unsigned long millis(); | ||
long random(int howbig); | ||
long random(int howsmall, int howbig); | ||
void delay(long millis); | ||
int32_t min(int32_t a, int32_t b); | ||
int32_t max(int32_t a, int32_t b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "DataTypes.h" | ||
|
||
// Code for Arduino_G was copy-pasted from Arduino_GFX | ||
|
||
class Arduino_G { | ||
public: | ||
Arduino_G(int16_t w, int16_t h): WIDTH(w), HEIGHT(h) {}; // Constructor | ||
|
||
// This MUST be defined by the subclass: | ||
virtual void begin(int32_t speed = 0) = 0; | ||
|
||
virtual void drawBitmap(int16_t x, int16_t y, uint8_t* bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg) = 0; | ||
virtual void drawIndexedBitmap(int16_t x, int16_t y, uint8_t* bitmap, uint16_t* color_index, int16_t w, int16_t h) = 0; | ||
virtual void draw3bitRGBBitmap(int16_t x, int16_t y, uint8_t* bitmap, int16_t w, int16_t h) = 0; | ||
virtual void draw16bitRGBBitmap(int16_t x, int16_t y, uint16_t* bitmap, int16_t w, int16_t h) = 0; | ||
virtual void draw24bitRGBBitmap(int16_t x, int16_t y, uint8_t* bitmap, int16_t w, int16_t h) = 0; | ||
|
||
protected: | ||
int16_t | ||
WIDTH, ///< This is the 'raw' display width - never changes | ||
HEIGHT; ///< This is the 'raw' display height - never changes | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
class Graphics2DPrint; | ||
typedef Graphics2DPrint Arduino_GFX; | ||
|
||
#include "Arduino_G.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
void setCpuFrequencyMhz(int); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include <cstdint> | ||
#include <math.h> | ||
|
||
#define RTC_DATA_ATTR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include <iostream> | ||
|
||
#define PI 3.1415926535897932384626433832795 | ||
#define HALF_PI 1.5707963267948966192313216916398 | ||
#define TWO_PI 6.283185307179586476925286766559 | ||
#define DEG_TO_RAD 0.017453292519943295769236907684886 | ||
#define RAD_TO_DEG 57.295779513082320876798154814105 | ||
#define EULER 2.718281828459045235360287471352 | ||
|
||
#define OSW_EMULATOR_THIS_IS_NOT_IMPLEMENTED std::cerr << "FIXME: " << __FILE__ << ":" << __LINE__ << "->" << __FUNCTION__ << "() Not implemented!" << std::endl; |
Oops, something went wrong.