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

Use antialiased circles, arcs and lines #395

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 20 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ project (OSW-OS-Emulator)

set(CMAKE_CXX_STANDARD 20)

find_program(CCACHE "ccache")
if(CCACHE)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE}")
endif()

# 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)
Expand All @@ -25,6 +30,15 @@ file(GLOB_RECURSE SOURCES_Pngle ./lib/pngle/*.c)
add_library(Pngle ${SOURCES_Pngle})
target_include_directories(Pngle PUBLIC ./lib/pngle/src/)

# LUA
file(GLOB_RECURSE SOURCES_LUA ./lib/LUA/*.c)
## remove onelua.c luac.c form build list
list(FILTER SOURCES_LUA EXCLUDE REGEX "onelua.c")
list(FILTER SOURCES_LUA EXCLUDE REGEX "luac.c")
#MESSAGE(STATUS "${SOURCES_LUA}")
add_library(LUA ${SOURCES_LUA})
target_include_directories(LUA PUBLIC ./lib/LUA/)

# ArduinoJSON
add_subdirectory(emulator/lib/ArduinoJson)

Expand Down Expand Up @@ -109,11 +123,13 @@ target_include_directories(emulator.run PUBLIC
./include
./lib/lib-open-smartwatch
emulator/lib/Jzon/
./lib/LUA/
${SDL2_INCLUDE_DIRS}
${SDL2IMAGE_INCLUDE_DIRS}
)
target_link_libraries(emulator.run LINK_PUBLIC
Pngle
LUA
ArduinoJson
Threads::Threads
Jzon
Expand Down Expand Up @@ -157,6 +173,9 @@ target_compile_options(emulator.run PUBLIC
-O0
-g3
-Wall
-Wdouble-promotion
-fpermissive
-Wno-deprecated-declarations
>
$<$<CONFIG:Release>:
-O4
Expand All @@ -171,4 +190,4 @@ endif()
# And add unit testing, as we broke our stuff often enough...
enable_testing()
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)
add_test(NAME emulator.run COMMAND emulator.run --unit_tests --headless)
Binary file added data/lua/apps/twilight.lua
Binary file not shown.
Binary file added data/lua/libs/suntime.lua
Binary file not shown.
4 changes: 3 additions & 1 deletion emulator/include/Serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ class Serial_t {
int read();

void println();

void flush() {}
private:
std::list<char> inputBuffer;
int bauds = 0;
bool buffered = false;
bool addBufferNewline = true;
};

extern Serial_t Serial;
extern Serial_t Serial;
9 changes: 9 additions & 0 deletions emulator/include/driver/uart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
typedef struct {
int baud_rate; /*!< UART baud rate*/
unsigned int data_bits; /*!< UART byte size*/
unsigned int parity; /*!< UART parity mode*/
unsigned int stop_bits; /*!< UART stop bits*/
unsigned int flow_ctrl; /*!< UART HW flow control mode (cts/rts)*/
unsigned int rx_flow_ctrl_thresh; /*!< UART HW RTS threshold*/
unsigned int source_clk; /*!< UART source clock selection */
} uart_config_t;
6 changes: 3 additions & 3 deletions emulator/src/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

void setCpuFrequencyMhz(unsigned int) {
// I mean... How? And why?!
OSW_EMULATOR_THIS_IS_NOT_IMPLEMENTED;
//OSW_EMULATOR_THIS_IS_NOT_IMPLEMENTED;
}

unsigned int getCpuFrequencyMhz() {
// I mean... How? And why?!
OSW_EMULATOR_THIS_IS_NOT_IMPLEMENTED;
//OSW_EMULATOR_THIS_IS_NOT_IMPLEMENTED;
return 0;
}
}
1 change: 1 addition & 0 deletions include/OswAppV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class OswAppV2 {

virtual const ViewFlags& getViewFlags();
virtual bool getNeedsRedraw();
virtual void setNeedsRedraw();
virtual void resetNeedsRedraw();
protected:
class OswHalProxy {
Expand Down
18 changes: 12 additions & 6 deletions include/apps/main/luaapp.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#pragma once

#ifdef OSW_FEATURE_LUA
#include <osw_hal.h>
#include <osw_lua.h>
Expand All @@ -10,10 +8,18 @@
#define LUA_LOOP_FUNC "loop"
#define LUA_STOP_FUNC "stop"

#define LUA_APP_PATH FS_MOUNT_POINT "/lua/apps/"
#define lUA_APP_SEARCH_PATH FS_MOUNT_POINT LUA_APP_PATH "?.lua"
#define lUA_LIB_SEARCH_PATH FS_MOUNT_POINT "/lua/libs/?.lua"
#define LUA_PACKAGE_CMD "package.path = package.path .. ';" lUA_APP_SEARCH_PATH ";" lUA_LIB_SEARCH_PATH "'"
#ifdef OSW_EMULATOR
#define LUA_PATH "../data/lua/"
#else
#define LUA_PATH FS_MOUNT_POINT "/lua/"
#endif

#define LUA_APP_PATH LUA_PATH "apps/"
#define LUA_LIB_PATH LUA_PATH "libs/"

#define LUA_APP_SEARCH_PATH LUA_APP_PATH "?.lua"
#define LUA_LIB_SEARCH_PATH LUA_LIB_PATH "?.lua"
#define LUA_PACKAGE_CMD "package.path = package.path .. ';" LUA_APP_SEARCH_PATH ";" LUA_LIB_SEARCH_PATH "'"

class OswLuaApp : public OswApp {
public:
Expand Down
3 changes: 3 additions & 0 deletions include/apps/watchfaces/OswAppWatchfaceFitnessAnalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ class OswAppWatchfaceFitnessAnalog : public OswAppV2 {
private:
time_t lastTime = 0;
unsigned screen = 0;
unsigned long lastShortPressTime;


void showFitnessTracking(OswHal* hal);
void drawWatchFace(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second, bool afterNoon);
void drawDateFace(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second, bool afterNoon);
void drawFitnessFace(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second, bool afterNoon);

#ifdef GIF_BG
OswAppGifPlayer* bgGif = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion include/apps/watchfaces/OswAppWatchfaceMix.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class OswAppWatchfaceMix : public OswAppV2 {
public:
constexpr static const char* APP_ID = "osw.wf.mx";
constexpr static const char* APP_ID = "osw.wf.mix";

const char* getAppId() override;
const char* getAppName() override;
Expand Down
74 changes: 74 additions & 0 deletions include/apps/watchfaces/OswAppWatchfaceZwilight.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include <osw_hal.h>
#include <osw_ui.h>
#include <OswAppV2.h>

#ifdef OSW_FEATURE_LUA
#include <osw_lua.h>
#ifdef OSW_EMULATOR
#define LUA_PATH "../data/lua/"
#else
#define LUA_PATH FS_MOUNT_POINT "/lua/"
#endif

#define LUA_APP_PATH LUA_PATH "apps/"
#define LUA_LIB_PATH LUA_PATH "libs/"

#define LUA_APP_SEARCH_PATH LUA_APP_PATH "?.lua"
#define LUA_LIB_SEARCH_PATH LUA_LIB_PATH "?.lua"
#define LUA_PACKAGE_CMD "package.path = package.path .. ';" LUA_APP_SEARCH_PATH ";" LUA_LIB_SEARCH_PATH "'"
#endif

enum SUNTIMES
{
SUNTIME_ERROR = 0,
LAST_MIDNIGHT,
ASTRONOMIC_DAWN,
NAUTIC_DAWN,
CIVIL_DAWN,
SUN_RISE,
NOON,
SUN_SET,
CIVIL_DUSK,
NAUTIC_DUSK,
ASTRONOMIC_DUSK,
MIDNIGHT
};

class OswAppWatchfaceZwilight : public OswAppV2 {
public:
constexpr static const char* APP_ID = "osw.wf.zwilight";
const char* getAppId() override;
const char* getAppName() override;

void onStart() override;
void onLoop() override;
void onDraw() override;
void onStop() override;
void onButton(Button id, bool up, ButtonStateNames state) override;

OswAppWatchfaceZwilight() {
lastTime = 0;
#ifdef OSW_FEATURE_LUA
luaState = nullptr;
#endif
}

~OswAppWatchfaceZwilight() {
cleanupLuaState();
}

private:
time_t lastTime = 0;

void displayWeekDay2(const char* weekday);
void drawWatch(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second);

bool getTwilights();
void cleanupLuaState();
void printLuaError();

float sunTimes[12];
#ifdef OSW_FEATURE_LUA
lua_State* luaState = nullptr;
#endif
};
Loading
Loading