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

Tutorial, Icons, better rendering & more #358

Merged
merged 115 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
d17afc8
Updated old class name
simonmicro Feb 22, 2023
aba2b70
Fixed broken include reference
simonmicro Feb 23, 2023
5ff1a2a
Implemented new example for OswAppV2 - and started integration of it
simonmicro Feb 23, 2023
45dc1aa
Extended example with a counter
simonmicro Feb 23, 2023
02cb143
Corrected wrong background color
simonmicro Feb 23, 2023
35bb713
Cleanup
simonmicro Feb 24, 2023
37671d2
Implemented asset translator and OswIcon
simonmicro Feb 24, 2023
904ff1d
Fixed debug overlay
simonmicro Feb 24, 2023
ef733ba
Fixed default icon color
simonmicro Feb 24, 2023
6ac3b81
Started tutorial implementation
simonmicro Feb 24, 2023
9c3dca3
Fixed crash due to uninitialized ImGui in headless debug loop
simonmicro Feb 24, 2023
63cfc90
Deprecated superseeded button methods in HAL
simonmicro Feb 24, 2023
4f3de8a
Implemented OswAppV2::onButton and updated OswAppTutorial
simonmicro Feb 24, 2023
afabd46
Added example to listen to double presses
simonmicro Feb 24, 2023
4c7e299
Extended button event logging
simonmicro Feb 24, 2023
b2fdff9
Added tutorial step for different button modes
simonmicro Feb 24, 2023
ecc3e8d
Added battery-calibration notice
simonmicro Feb 24, 2023
a74b5c2
Implemented proper handoff after the tutorial app
simonmicro Feb 24, 2023
9648ded
Fixed no-init arrays
simonmicro Feb 24, 2023
80f1ea0
Implemented tutorial show/hide hooks
simonmicro Feb 24, 2023
8628068
Scale based on 16px icons
simonmicro Feb 24, 2023
b2c737d
Corrected icon sizes and added new (empty) page
simonmicro Feb 24, 2023
d0ace2e
Added hardware-problems screen
simonmicro Feb 24, 2023
be22c60
Added package build instructions
simonmicro Feb 24, 2023
fc83ac8
Implemented tutorial app timeout
simonmicro Feb 24, 2023
a13e6fe
Integrated prebuild script into cmake run
simonmicro Mar 1, 2023
edf1dc5
Added missing Python packages
simonmicro Mar 1, 2023
4cefe13
Added shebang-header
simonmicro Mar 1, 2023
d178b1b
Added LFS clone
simonmicro Mar 1, 2023
127273d
Ignored unknown args
simonmicro Mar 1, 2023
a42d082
Respect key length limits
simonmicro Mar 2, 2023
46efeb7
Added button names
simonmicro Mar 2, 2023
a8a5407
Removed OswHal pointer cache and replaced it with a proxy
simonmicro Mar 2, 2023
9f5286e
Introduced app-overlay concept
simonmicro Mar 2, 2023
fe3e326
Implemented v2 button indicators
simonmicro Mar 2, 2023
10d92b2
Unified button pixel positions (and alignment)
simonmicro Mar 2, 2023
45b0adc
Fixed too aggressive clean
simonmicro Mar 2, 2023
477c086
Recreated OswAppV1 example and renamed v2 one
simonmicro Mar 25, 2023
5ec41c1
Implemented OswAppV2 compat layer for OswAppV1
simonmicro Mar 25, 2023
975a74e
Moved icons into subfolder
simonmicro Mar 28, 2023
07ca5df
Added static assets and fixed typo
simonmicro Mar 28, 2023
ca8d2ff
Added static image asset read&draw
simonmicro Mar 28, 2023
7552c05
Fixed label background-colors
simonmicro Mar 28, 2023
f2a581e
Added deprecation warning
simonmicro Mar 28, 2023
18e99b3
Added KEEP_DISPLAY_ON flag
simonmicro Mar 28, 2023
0a651c4
Removed display timeout on tutorial/example apps
simonmicro Mar 28, 2023
b2a3769
Corrected swapped up/down buttons
simonmicro Mar 29, 2023
411f52e
Implemented ignore-fps-limit for v1 apps
simonmicro Mar 29, 2023
f27d2a3
Cross-sync button detection state across apps
simonmicro Mar 29, 2023
81ce87e
Exposed base size for icons
simonmicro Mar 29, 2023
e6118c6
Simplified & synced colors for example apps
simonmicro Mar 29, 2023
488a6e6
Implemented osw app drawer
simonmicro Mar 29, 2023
ae8fafc
Optional drawer defaults
simonmicro Mar 29, 2023
0c8d444
Updated main for drawer
simonmicro Mar 29, 2023
8980a20
Implemented app instance cleanup
simonmicro Mar 29, 2023
7230fbf
Put presses together
simonmicro Mar 29, 2023
9ed574d
Implemented sleep-persistant indices
simonmicro Apr 1, 2023
f3de49f
Fixed copy-ref crash
simonmicro Apr 1, 2023
40fd501
Fixed broken buttons in app v2
simonmicro Apr 1, 2023
8e6ca61
Simplified default-app selection for drawer
simonmicro Apr 1, 2023
7bbd695
Readded all apps via compat-layer
simonmicro Apr 1, 2023
b711a87
Added missing assert
simonmicro Apr 1, 2023
a611802
Do not report any buttons by default - require explicit registration
simonmicro Apr 1, 2023
791b4ea
Allow indirect casting
simonmicro Apr 1, 2023
4066737
Ported analog watchface to v2
simonmicro Apr 1, 2023
133e376
Ported digital watchface to v2
simonmicro Apr 1, 2023
0ba204a
Corrected wrong legacy-numbering of buttons
simonmicro Apr 1, 2023
c7fa20b
Fixed missing state-filter for button events on up-states
simonmicro Apr 1, 2023
e0c805c
Added missing masking for default buttons
simonmicro Apr 1, 2023
cb44d09
Fix broken include
simonmicro Apr 1, 2023
d53b1c6
Do not show button animation if not supported
simonmicro Apr 2, 2023
224d932
Corrected swapped button assignments
simonmicro Apr 2, 2023
0010ace
Added check to reduce invisible redraws
simonmicro Apr 2, 2023
d1bfae1
Added note for the app-drawer
simonmicro Apr 2, 2023
856972f
Show button names on navigation screen
simonmicro Apr 2, 2023
08eaf2e
Fixed compiler problem
simonmicro Apr 2, 2023
b1c3486
Auto-skip hw-problems screen if non are found
simonmicro Apr 2, 2023
847799b
More debug-vars on tutorial
simonmicro Apr 2, 2023
e9827f1
Stable category ordering in drawer
simonmicro Apr 2, 2023
6b1e46b
Fixed problem with disappearing const-char strings on real hardware
simonmicro Apr 2, 2023
3cbe234
Updated documentation with references to example-apps and overall lan…
simonmicro Apr 2, 2023
b19a584
Migrated button names, pins and number into pins header
simonmicro Apr 2, 2023
a0b1b6d
Fall-back to english for unknown keys
simonmicro Apr 2, 2023
f4842ee
Added translation to emulator UI
simonmicro Apr 2, 2023
a1a245e
Moved init to work with button number
simonmicro Apr 2, 2023
60ca559
Fixed empty button-bitmask on start
simonmicro Apr 2, 2023
02748eb
More drawer-bitmask fixes...
simonmicro Apr 2, 2023
8930929
Translated example apps
simonmicro Apr 2, 2023
8335a92
Translated Tutorial app
simonmicro Apr 2, 2023
9ea1228
Translated two watchface names
simonmicro Apr 2, 2023
f8ca726
Translated app categories
simonmicro Apr 2, 2023
d1e04c4
Corrected comment
simonmicro Apr 2, 2023
22d1756
Fixed incorrect button id datatype
simonmicro Apr 2, 2023
e341679
Migrated overlay config parameters to their new meaning
simonmicro Apr 2, 2023
593ed03
Removed overlay from analog watchface
simonmicro Apr 2, 2023
8c238c2
Added readme for beginners
simonmicro Apr 2, 2023
ad0b24f
Added button timings into config
simonmicro Apr 2, 2023
b3bbf4e
Just some comments (to comments)
simonmicro Apr 2, 2023
016faba
Migrated mix-watchface to app v2
simonmicro May 6, 2023
334a842
Translation of mix-watchface name
simonmicro May 6, 2023
98e2ab9
Ported dual-time watchface
simonmicro May 12, 2023
6e47311
Ported fitness watchface
simonmicro May 12, 2023
3020e91
Ported binary watchface
simonmicro May 12, 2023
e61af8f
Ported mono watchface
simonmicro May 12, 2023
6a9a5b0
Added note for tutorial skipping
simonmicro Jun 4, 2023
41b3148
Allow keeping screen on with compact app layer
simonmicro Jun 4, 2023
6a434cf
Changed OswIcon to interface
simonmicro Jun 4, 2023
f2daed4
Added special case handling to map VERY_LONG to LONG if VERY_LONG is …
simonmicro Jun 4, 2023
3c8992c
Added app id length warning
simonmicro Jun 4, 2023
5409fa6
Ported Flashlight + icon
simonmicro Jun 5, 2023
2b7a7d3
Moved icons into const-static memory segment & pre-create class insta…
simonmicro Jun 18, 2023
842132d
Added icon support to compat layer
simonmicro Jun 18, 2023
901f141
Added a ton of icons for legacy apps
simonmicro Jun 18, 2023
c782992
Fixed build script for Python 3.8
simonmicro Jun 18, 2023
04cfef4
Cleanup and update dependencies
simonmicro Jun 20, 2023
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
7 changes: 5 additions & 2 deletions .github/workflows/test-EMULATOR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ jobs:
uses: nschloe/action-cached-lfs-checkout@v1.2.1
with:
submodules: recursive
lfs: 'true'
- name: Update packages
run: sudo apt-get update && sudo apt-get upgrade -y
run: sudo apt-get update
- name: Install packages
run: sudo apt-get -y install gcc g++ cmake libsdl2-dev libsdl2-image-dev
run: sudo apt-get -y install gcc g++ cmake libsdl2-dev libsdl2-image-dev python3 python3-pip
- name: Install python packages
run: pip3 install --user -r scripts/requirements.txt
- name: Create build directory
run: mkdir build
- name: CMake ${{ matrix.build-configuration }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-FEATURE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
uses: nschloe/action-cached-lfs-checkout@v1.2.1
with:
submodules: recursive
lfs: 'true'
- id: get-flag
run: |
echo "feature=$(python3 .github/getWorkflowMatrix.py all_flags)" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -56,6 +57,7 @@ jobs:
uses: nschloe/action-cached-lfs-checkout@v1.2.1
with:
submodules: recursive
lfs: 'true'
- name: Cache pip
uses: actions/cache@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-OS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
uses: nschloe/action-cached-lfs-checkout@v1.2.1
with:
submodules: recursive
lfs: 'true'
- uses: dorny/paths-filter@v2.11.1
id: filter
with:
Expand Down Expand Up @@ -49,6 +50,7 @@ jobs:
uses: nschloe/action-cached-lfs-checkout@v1.2.1
with:
submodules: recursive
lfs: 'true'
- name: Cache pip
uses: actions/cache@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-OSW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
uses: nschloe/action-cached-lfs-checkout@v1.2.1
with:
submodules: recursive
lfs: 'true'
- uses: dorny/paths-filter@v2.11.1
id: filter
with:
Expand Down Expand Up @@ -62,6 +63,7 @@ jobs:
uses: nschloe/action-cached-lfs-checkout@v1.2.1
with:
submodules: recursive
lfs: 'true'
- name: Cache pip
uses: actions/cache@v3
with:
Expand Down
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.10)
cmake_minimum_required (VERSION 3.12)
project (OSW-OS-Emulator)

set(CMAKE_CXX_STANDARD 20)
Expand Down Expand Up @@ -60,13 +60,27 @@ target_link_libraries(ImGUI LINK_PUBLIC
${SDL2IMAGE_LIBRARIES}
)

# OSW custom prebuild-scripts
find_package(Python3 REQUIRED COMPONENTS Interpreter)
file(GLOB_RECURSE INCLUDE_OSW_ASSETS ./include/assets/img/** ./include/assets/www/**)
add_custom_target(
osw_script_prebuild_assets ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/build/prebuild_assets.py --output-asset-path ${CMAKE_CURRENT_SOURCE_DIR}/include/assets
BYPRODUCTS ${INCLUDE_OSW_ASSETS}
COMMENT "Generating OSW assets..."
)

# 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}
)
add_dependencies(emulator.run
osw_script_prebuild_assets
)
target_include_directories(emulator.run PUBLIC
./emulator/include
./include
Expand Down Expand Up @@ -99,8 +113,11 @@ target_compile_definitions(emulator.run PUBLIC
$<$<CONFIG:Release>:
NDEBUG=1
>
# Uncomment the following line to use a different locale (only for the emulator, for the whole OS use the config variable!)
# LOCALE="locales/en-US.h"
# Comment these as you wish...
OSW_FEATURE_STATS_STEPS
OSW_APPS_EXAMPLES=1
GAME_SNAKE=1
GAME_BRICK_BREAKER=1
TOOL_FLASHLIGHT=1
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# How to contribute to Open-smartwatch

In case the `develop` branch is ahead of the `master` branch and the `develop` branch is stabile enough, we periodically merge it into the `master`.
In case the `develop` branch is ahead of the `master` branch and the `develop` branch is stable enough, we periodically merge it into the `master`.

In order to contribute new or updated documentation, you must first create a GitHub account and fork the original repository to your own account. You can make changes, save them in your repository and then create a pull request against this repository.

Unless you are opening a pull request which only makes small corrections (for instance correcting a typo), you are more likely to get traction for your changes if you open an issue first to discuss the proposed changes.

**IMPORTANT** If you want to create a pull request, please work based on the `develop` branch - so we don't have to rebase it...
**IMPORTANT** If you want to create a pull request, please work based on the most recent `develop` branch - so we don't have to rebase it...

If you are reading this page, you are possibly interested in contributing to our project 😄 . We have an active (and friendly) developer group and would love to get your help! Some common ways you can support us are:

* Testing the code
* Filing issues on GitHub, if you see a problem (or adding detail to existing issues that effect you)
* Reporting issues on GitHub, if you see a problem (or adding detail to existing issues that also affect you)
* Fixing issues 😁
* Adding new features
* Reviewing existing pull requests and possibly also contributing to them.
* Translation. Always a good idea...
* Reviewing existing pull requests and possibly also contributing to them
* Translations are always a good idea...

## How to make a good bug report

Submit according to the bug report form. Attach the debug log if necessary. [Read more here!](https://open-smartwatch.github.io/howto/contribute/#how-to-open-an-issue)

## Submitting patches

Please also see our [wiki](https://open-smartwatch.github.io/howto/contribute/) article for that.
Please also see our [wiki](https://open-smartwatch.github.io/howto/contribute/) article for that.
5 changes: 4 additions & 1 deletion docs/firmware/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ If you have cloned the repo without the recurse option, run `git submodule updat

!!! note "Tip"
After changing or updating/pulling a branch, run the command again to also update dependencies:
`git submodule update`
```bash
git pull
git submodule update --init --recursive
```

Then, open the directory with Visual Studio Code.

Expand Down
7 changes: 5 additions & 2 deletions docs/firmware/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ Check the driver insertion.
You did not clone the repository with the `--recursive-submodules` flag.

!!! note "Tip"
After changing the branch, follow the command :
`git submodule update`
After changing or updating/pulling a branch, run the command again to also update dependencies:
```bash
git pull
git submodule update --init --recursive
```

## Failed to connect to ESP32: Timed out waiting for packet header

Expand Down
10 changes: 6 additions & 4 deletions emulator/include/Emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <variant>
#include <list>
#include <map>
#include <hal/buttons.h>
#include <osw_pins.h> // for button definitions

#include "Jzon.h"

Expand Down Expand Up @@ -46,8 +48,8 @@ class OswEmulator {
void run();
void exit();

void setButton(unsigned id, bool state);
bool getButton(unsigned id);
void setButton(Button id, bool state);
bool getButton(Button id);
uint8_t getBatteryRaw();
bool isCharging();

Expand All @@ -67,8 +69,8 @@ class OswEmulator {
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!
std::array<std::atomic_bool, BTN_NUMBER> buttons;
std::array<bool, BTN_NUMBER> buttonCheckboxes; // These are just state caches of the buttons for their respective checkboxes!
bool buttonResetAfterMultiPress = true;
uint8_t batRaw = 0;
bool charging = true;
Expand Down
55 changes: 30 additions & 25 deletions emulator/src/Emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ static void shutdownEmulatorByInterruptSignal(int s) {
}

OswEmulator::OswEmulator(bool headless, std::string configPath, std::string imguiPath): isHeadless(headless) {
// Initialize variables
for(size_t i = 0; i < BTN_NUMBER; i++)
this->buttonCheckboxes[i] = false;

// Load emulator config
this->configPath = configPath;
this->imguiPath = imguiPath;
Expand Down Expand Up @@ -256,13 +260,13 @@ void OswEmulator::run() {

// Present the fake-display texture as an ImGUI window
if(!this->isHeadless) {
ImGui::Begin("Display");
ImGui::Begin(LANG_IMGUI_DISPLAY "###display");
// Using ImGui::BeginChild() to set the size of the inner window properly
ImGui::BeginChild("##FakeDisplayTexture", ImVec2(fakeDisplayInstance->width, fakeDisplayInstance->height));
if(fakeDisplayInstance->isEnabled())
ImGui::Image((void*) fakeDisplayInstance->getTexture(), ImVec2(fakeDisplayInstance->width, fakeDisplayInstance->height));
else
ImGui::Text("Display is not active.");
ImGui::Text(LANG_IMGUI_DISPLAY_NOPE);
ImGui::EndChild();
ImGui::End();
}
Expand Down Expand Up @@ -358,12 +362,12 @@ void OswEmulator::requestSleep(RequestSleepState state) {
this->requestedSleepState = state;
}

void OswEmulator::setButton(unsigned id, bool state) {
void OswEmulator::setButton(Button id, bool state) {
this->buttonCheckboxes.at(id) = state;
this->buttons.at(id) = state;
};

bool OswEmulator::getButton(unsigned id) {
bool OswEmulator::getButton(Button id) {
return this->buttons.at(id);
};

Expand Down Expand Up @@ -397,48 +401,49 @@ void OswEmulator::addGUIHelp(const char* msg) {

void OswEmulator::renderGUIFrameEmulator() {
// Emulator control
ImGui::Begin("Emulator");
ImGui::Text("CPU: %s", this->cpustate == CPUState::active ? "Active" : (this->cpustate == CPUState::light ? "Light Sleep" : "Deep Sleep"));
ImGui::Begin(LANG_IMGUI_EMULATOR "###emulator");
ImGui::Text("CPU: %s", this->cpustate == CPUState::active ? LANG_EMULATOR_CPU_ACTIVE : (this->cpustate == CPUState::light ? LANG_EMULATOR_CPU_LIGHT_SLEEP : LANG_EMULATOR_CPU_DEEP_SLEEP));
ImGui::PlotLines("FPS Emulator", (float*) this->frameCountsEmulator.data() + 1, this->frameCountsEmulator.size() - 1);
ImGui::PlotLines("FPS OSW-UI", (float*) this->frameCountsOsw.data() + 1, this->frameCountsOsw.size() - 1);
ImGui::PlotLines("loop()", (float*) this->timesLoop.data(), this->timesLoop.size());
ImGui::Separator();
ImGui::Checkbox("Keep-Awake", &this->autoWakeUp);
this->addGUIHelp("This will always wakeup the watch for the next frame.");
ImGui::Checkbox(LANG_EMULATOR_WAKELOCK, &this->autoWakeUp);
this->addGUIHelp(LANG_EMULATOR_WAKELOCK_HELP);
if(this->cpustate == CPUState::active) { // If false, the ui instance could be unavailable
ImGui::Checkbox("FPS Limiter", &OswUI::getInstance()->mEnableTargetFPS);
this->addGUIHelp("This will limit the FPS to the target FPS set in the OswUI class.");
ImGui::Checkbox(LANG_EMULATOR_FPSLIMIT, &OswUI::getInstance()->mEnableTargetFPS);
this->addGUIHelp(LANG_EMULATOR_FPSLIMIT_HELP);
}
if(!this->autoWakeUp and this->cpustate != CPUState::active and ImGui::Button("Wake Up"))
this->manualWakeUp = true;
ImGui::End();

// Button Control
ImGui::Begin("Buttons");
if(ImGui::Button("Button PWR")) {
ImGui::Begin(LANG_IMGUI_BUTTONS "###buttons");
if(ImGui::Button(LANG_EMULATOR_BTN " PWR")) {
this->enterSleep(true);
this->manualWakeUp = true;
}
this->addGUIHelp("This button will interrupt the power to the CPU and reset the OS (as from deep sleep).");
this->addGUIHelp(LANG_EMULATOR_BTN_PWR_HELP);
for(size_t buttonId = 0; buttonId < this->buttons.size(); ++buttonId) {
ImGui::Button(("Button " + std::to_string(buttonId + 1)).c_str());
// Due to this checkbox-alignment they are always one frame behind the button state (but this is not a problem)
ImGui::Checkbox(("##btn" + std::to_string(buttonId + 1)).c_str(), &this->buttonCheckboxes.at(buttonId)); // "##" as prefix hides the label, but still allows for unique ids
ImGui::SameLine();
ImGui::Button((std::string(LANG_EMULATOR_BTN " ") + ButtonNames[buttonId]).c_str());
if(ImGui::IsItemActivated() or ImGui::IsItemDeactivated()) // Only use the button to control the button state, if it changed during the last frame
this->buttonCheckboxes.at(buttonId) = ImGui::IsItemActive();
if(ImGui::IsItemDeactivated() and this->buttonResetAfterMultiPress) {
for(size_t bId = 0; bId < this->buttonCheckboxes.size(); ++bId)
if(this->buttonCheckboxes.at(bId))
this->setButton(bId, false);
this->setButton((Button) bId, false);
}
ImGui::SameLine();
ImGui::Checkbox(("##btn" + std::to_string(buttonId + 1)).c_str(), &this->buttonCheckboxes.at(buttonId)); // "##" as prefix hides the label, but still allows for unique ids
this->setButton(buttonId, this->buttonCheckboxes.at(buttonId));
this->setButton((Button) buttonId, this->buttonCheckboxes.at(buttonId));
}
ImGui::Checkbox("Release after multi-press", &this->buttonResetAfterMultiPress);
this->addGUIHelp("Whenever you press-and-hold any butten(s) by activating their checkbox(es) and then click-and-release any button normally, all other held buttons will also be released.");
ImGui::Checkbox(LANG_EMULATOR_MBTN, &this->buttonResetAfterMultiPress);
this->addGUIHelp(LANG_EMULATOR_MBTN_HELP);
ImGui::End();

// Virtual Sensors
ImGui::Begin("Virtual Sensors");
ImGui::Begin(LANG_IMGUI_VIRTUAL_SENSORS "###virtual_sensors");
if(OswHal::getInstance()->devices() and OswHal::getInstance()->devices()->virtualDevice) {
ImGui::InputFloat("Temperature", &OswHal::getInstance()->devices()->virtualDevice->values.temperature, 1, 10);
ImGui::InputFloat("Pressure", &OswHal::getInstance()->devices()->virtualDevice->values.pressure, 1, 10);
Expand All @@ -449,10 +454,10 @@ void OswEmulator::renderGUIFrameEmulator() {
ImGui::InputInt("Magnetometer Azimuth", &OswHal::getInstance()->devices()->virtualDevice->values.magnetometerAzimuth, 1, 10);
ImGui::InputInt("Steps", (int*) &OswHal::getInstance()->devices()->virtualDevice->values.steps, 1, 10); // Warning - negative values will cause an underflow... ImGui has no conventient way of limiting the input range...
} else
ImGui::Text("The virtual sensors are only available, while the virtual device is active.");
ImGui::Text(LANG_IMGUI_VIRTUAL_SENSORS_NOPE);
ImGui::End();

ImGui::Begin("Configuration");
ImGui::Begin(LANG_IMGUI_CONFIGURATION "###configuration");
if(this->configValuesCache.size()) {
for(auto& [label, keyIds] : this->configSectionsToIdCache) {
if(ImGui::CollapsingHeader(label.c_str()))
Expand Down Expand Up @@ -515,7 +520,7 @@ void OswEmulator::renderGUIFrameEmulator() {
}
}

ImGui::Button("Save");
ImGui::Button(LANG_SAVE);
if(ImGui::IsItemActive()) {
OswConfig::getInstance()->enableWrite();
for(size_t keyId = 0; keyId < oswConfigKeysCount; ++keyId) {
Expand Down Expand Up @@ -553,7 +558,7 @@ void OswEmulator::renderGUIFrameEmulator() {
OswConfig::getInstance()->notifyChange();
}
} else
ImGui::Text("The configuration is not initialized yet.");
ImGui::Text(LANG_IMGUI_CONFIGURATION_NOPE);
ImGui::End();
}

Expand Down
7 changes: 4 additions & 3 deletions emulator/src/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "Emulator.hpp"
#include OSW_TARGET_PLATFORM_HEADER
#include "hal/buttons.h"
#include "osw_pins.h" // Used for BTN_*

void pinMode(int pin, int mode) {
Expand All @@ -24,13 +25,13 @@ uint8_t digitalRead(int pin) {
const uint8_t buttonClickStates[] = BTN_STATE_ARRAY;
switch (pin) {
case BTN_1:
return ((OswEmulator::instance->getButton(0) ? LOW : HIGH) == buttonClickStates[0]) ? LOW : HIGH;
return ((OswEmulator::instance->getButton(Button::BUTTON_SELECT) ? LOW : HIGH) == buttonClickStates[Button::BUTTON_SELECT]) ? LOW : HIGH;
break;
case BTN_2:
return ((OswEmulator::instance->getButton(1) ? LOW : HIGH) == buttonClickStates[1]) ? LOW : HIGH;
return ((OswEmulator::instance->getButton(Button::BUTTON_UP) ? LOW : HIGH) == buttonClickStates[Button::BUTTON_UP]) ? LOW : HIGH;
break;
case BTN_3:
return ((OswEmulator::instance->getButton(2) ? LOW : HIGH) == buttonClickStates[2]) ? LOW : HIGH;
return ((OswEmulator::instance->getButton(Button::BUTTON_DOWN) ? LOW : HIGH) == buttonClickStates[Button::BUTTON_DOWN]) ? LOW : HIGH;
break;
case OSW_DEVICE_TPS2115A_STATPWR:
return OswEmulator::instance->isCharging() ? 1 : 0;
Expand Down
2 changes: 2 additions & 0 deletions emulator/src/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ bool Preferences::begin(const char* name, bool readOnly) {
// Init "NVS"
nvs_flash_init();
this->name = std::string(name);
if(this->name.length() > 15)
return false; // Name too long (max 15 chars, as specified for nvs_open())
// Init Jzon tree by loading (existing) file
this->path = std::filesystem::path(preferencesFolderName) / (this->name + ".json");
if(std::filesystem::exists(this->path)) {
Expand Down
3 changes: 1 addition & 2 deletions emulator/src/tests/OswAppAlarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class TestAlarm {

// Helpers
static OswAppAlarm createAlarm() {
std::shared_ptr<OswAppSwitcher> mockSwitcher = std::make_shared<OswAppSwitcher>(BUTTON_1, SHORT_PRESS, false, false, nullptr);
OswAppAlarm alarm{mockSwitcher.get()};
OswAppAlarm alarm;
return alarm;
}

Expand Down
3 changes: 1 addition & 2 deletions emulator/src/tests/OswAppTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class TestTimer {

// Helpers
static OswAppTimer createTimer() {
std::shared_ptr<OswAppSwitcher> mockSwitcher = std::make_shared<OswAppSwitcher>(BUTTON_1, SHORT_PRESS, false, false, nullptr);
OswAppTimer timer{mockSwitcher.get()};
OswAppTimer timer;
return timer;
}

Expand Down
1 change: 1 addition & 0 deletions img/icons/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.xcf
Loading
Loading