Skip to content

Commit

Permalink
Merge branch 'InfiniTimeOrg:develop' into dice
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufmte authored Oct 16, 2022
2 parents 8020132 + d3ba184 commit e789622
Show file tree
Hide file tree
Showing 22 changed files with 217 additions and 96 deletions.
39 changes: 36 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ jobs:
with:
fetch-depth: 1000

- name: Configure git
run: |
git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF" --depth=1000
- name: Fetch base branch
run: git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF"

- name: Install clang-format
run: |
Expand All @@ -35,3 +34,37 @@ jobs:
with:
name: Patches
path: ./*.patch
test-clang-tidy:
runs-on: ubuntu-latest
container:
image: infinitime/infinitime-build
steps:
# This workaround fixes the error "unsafe repository (REPO is owned by someone else)".
# See https://github.com/actions/checkout/issues/760 and https://github.com/actions/checkout/issues/766
# The fix in "actions/checkout@v2" was not sufficient as the build process also uses git (to get the current
# commit hash, for example).
- name: Workaround permission issues
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout source files
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1000
- name: Fetch base branch
run: git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF"
- name: Install clang-tidy
run: |
apt-get update
apt-get -y install clang-tidy-12
- name: Prepare environment
shell: bash
env:
SOURCES_DIR: .
run: |
. docker/build.sh
GetGcc
# I guess these already exist inside the docker?
#GetNrfSdk
#GetMcuBoot
CmakeGenerate
- run: tests/test-tidy.sh
8 changes: 7 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ jobs:
with:
name: InfiniTime MCUBoot image ${{ github.head_ref }}
path: ./build/output/pinetime-mcuboot-app-image-*.bin
- name: Upload resources artifacts
uses: actions/upload-artifact@v3
with:
name: InfiniTime resources ${{ github.head_ref }}
path: ./build/output/infinitime-resources-*.zip

build-simulator:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -75,8 +80,9 @@ jobs:
git -C InfiniSim submodule update --init lv_drivers libpng
- name: CMake
# disable BUILD_RESOURCES as this is already done when building the firmware
run: |
cmake -G Ninja -S InfiniSim -B build_lv_sim -DInfiniTime_DIR="${PWD}"
cmake -G Ninja -S InfiniSim -B build_lv_sim -DInfiniTime_DIR="${PWD}" -DBUILD_RESOURCES=OFF
- name: Build simulator executable
run: |
Expand Down
4 changes: 2 additions & 2 deletions doc/InfiniTimeVision.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ InfiniTime is not to be used for medical or other health tracking purposes.
- Easy and simple navigation
- Behaviour should be predictable and easy to understand
- Prefer solid default experience over customization
- Personalization is achieved through custom watchfaces.
- Personalization is achieved through custom watch faces.
More options may be available through a companion app.
- Use standard protocols and methods

## Long term vision

The perfect version of InfiniTime would include:

- Capability to sideload apps and watchfaces
- Capability to sideload apps and watch faces
- Only a minimal feature set in the flashed firmware.
Users would add the features they want.
- Ports to other devices
Expand Down
2 changes: 1 addition & 1 deletion doc/MemoryAnalysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void* __wrap_malloc(size_t size) {

Now, your function `__wrap_malloc()` will be called instead of `malloc()`. You can call the actual malloc from the stdlib by calling `__real_malloc()`.

Using this technique, I was able to trace all malloc calls at boot (boot -> digital watchface):
Using this technique, I was able to trace all malloc calls at boot (boot -> digital watch face):

- system task = 3464 bytes (SystemTask could potentially be declared as a global variable to avoid heap allocation here)
- string music = 31 (maybe we should not use std::string when not needed, as it does heap allocation)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/gettingStarted/gettingStarted-1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ It is highly recommended to update the firmware to the latest version when you r

### Setting the time

By default, InfiniTime starts on the digital watchface. It'll probably display the epoch time (1 Jan 1970, 00:00).
By default, InfiniTime starts on the digital watch face. It'll probably display the epoch time (1 Jan 1970, 00:00).

You can sync the time using companion apps.

Expand Down
4 changes: 2 additions & 2 deletions doc/gettingStarted/updating-software.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ If you just want to flash or upgrade InfiniTime on your PineTime, this page is f

## Checking the version of InfiniTime

You can check the InfiniTime version by first swiping right on the watchface to open quick settings, tapping the cogwheel to open settings, swipe up until you find an entry named "About" and tap on it.
You can check the InfiniTime version by first swiping right on the watch face to open quick settings, tapping the cogwheel to open settings, swipe up until you find an entry named "About" and tap on it.

![InfiniTime 1.0 version](version-1.0.jpg)

Expand Down Expand Up @@ -35,7 +35,7 @@ Firmware updates must be manually validated. If the firmware isn't validated and

You can validate your updated firmware on InfiniTime >= 1.0 by following this simple procedure:

- From the watchface, swipe **right** to display the *quick settings menu*
- From the watch face, swipe **right** to display the *quick settings menu*
- Open settings by tapping the cogwheel on the bottom right
- Swipe up until you find an entry named **Firmware** and tap on it
- If the firmware is not validated yet, you can either validate the running firmware, or reset and revert to the previous firmware version
Expand Down
6 changes: 3 additions & 3 deletions src/components/ble/weather/WeatherData.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ namespace Pinetime {
* In order to represent bursts of wind instead of constant wind,
* you have minimum and maximum speeds.
*
* As direction can fluctuate wildly and some watchfaces might wish to display it nicely,
* As direction can fluctuate wildly and some watch faces might wish to display it nicely,
* we're following the aerospace industry weather report option of specifying a range.
*/
class Wind : public TimelineHeader {
Expand Down Expand Up @@ -283,7 +283,7 @@ namespace Pinetime {
* as it usually is, but it could change during a trip for ex.
* so we allow changing it dynamically.
*
* Location info can be for some kind of map watchface
* Location info can be for some kind of map watch face
* or daylight calculations, should those be required.
*
*/
Expand Down Expand Up @@ -331,7 +331,7 @@ namespace Pinetime {
*
* These events are a bit more complex because the topic is not simple,
* the intention is to heavy-lift the annoying preprocessing from the watch
* this allows watchface or watchapp makers to generate accurate alerts and graphics
* this allows watch face or watchapp makers to generate accurate alerts and graphics
*
* If this needs further enforced standardization, pull requests are welcome
*/
Expand Down
13 changes: 5 additions & 8 deletions src/components/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ namespace Pinetime {

Settings(Pinetime::Controllers::FS& fs);

Settings(const Settings&) = delete;
Settings& operator=(const Settings&) = delete;
Settings(Settings&&) = delete;
Settings& operator=(Settings&&) = delete;

void Init();
void SaveSettings();

Expand Down Expand Up @@ -135,14 +140,6 @@ namespace Pinetime {
appMenu = menu;
};

void SetWatchfacesMenu(uint8_t menu) {
watchFacesMenu = menu;
};

uint8_t GetWatchfacesMenu() const {
return watchFacesMenu;
};

uint8_t GetAppMenu() const {
return appMenu;
};
Expand Down
4 changes: 2 additions & 2 deletions src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ using namespace Pinetime::Applications;
using namespace Pinetime::Applications::Display;

namespace {
static inline bool in_isr(void) {
inline bool in_isr() {
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
}
}
Expand Down Expand Up @@ -391,7 +391,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
case Apps::SettingWatchFace:
currentScreen = std::make_unique<Screens::SettingWatchFace>(this, settingsController);
currentScreen = std::make_unique<Screens::SettingWatchFace>(this, settingsController, filesystem);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
case Apps::SettingTimeFormat:
Expand Down
41 changes: 19 additions & 22 deletions src/displayapp/screens/CheckboxList.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "displayapp/screens/CheckboxList.h"
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/CheckboxList.h"
#include "displayapp/screens/Styles.h"

using namespace Pinetime::Applications::Screens;
Expand All @@ -9,27 +9,17 @@ namespace {
CheckboxList* screen = static_cast<CheckboxList*>(obj->user_data);
screen->UpdateSelected(obj, event);
}

}

CheckboxList::CheckboxList(const uint8_t screenID,
const uint8_t numScreens,
DisplayApp* app,
Controllers::Settings& settingsController,
const char* optionsTitle,
const char* optionsSymbol,
void (Controllers::Settings::*SetOptionIndex)(uint8_t),
uint8_t (Controllers::Settings::*GetOptionIndex)() const,
std::array<const char*, MaxItems> options)
: Screen(app),
screenID {screenID},
settingsController {settingsController},
SetOptionIndex {SetOptionIndex},
GetOptionIndex {GetOptionIndex},
options {options} {

settingsController.SetWatchfacesMenu(screenID);

uint32_t originalValue,
std::function<void(uint32_t)> OnValueChanged,
std::array<Item, MaxItems> options)
: Screen(app), screenID {screenID}, OnValueChanged {std::move(OnValueChanged)}, options {options}, value {originalValue} {
// Set the background to Black
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);

Expand All @@ -39,7 +29,7 @@ CheckboxList::CheckboxList(const uint8_t screenID,
pageIndicatorBasePoints[1].x = LV_HOR_RES - 1;
pageIndicatorBasePoints[1].y = LV_VER_RES;

pageIndicatorBase = lv_line_create(lv_scr_act(), NULL);
pageIndicatorBase = lv_line_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints.data(), 2);
Expand All @@ -52,7 +42,7 @@ CheckboxList::CheckboxList(const uint8_t screenID,
pageIndicatorPoints[1].x = LV_HOR_RES - 1;
pageIndicatorPoints[1].y = indicatorPos + indicatorSize;

pageIndicator = lv_line_create(lv_scr_act(), NULL);
pageIndicator = lv_line_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_line_set_points(pageIndicator, pageIndicatorPoints.data(), 2);
Expand Down Expand Up @@ -82,14 +72,17 @@ CheckboxList::CheckboxList(const uint8_t screenID,
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);

for (unsigned int i = 0; i < options.size(); i++) {
if (strcmp(options[i], "")) {
if (strcmp(options[i].name, "")) {
cbOption[i] = lv_checkbox_create(container1, nullptr);
lv_checkbox_set_text(cbOption[i], options[i]);
lv_checkbox_set_text(cbOption[i], options[i].name);
if (!options[i].enabled) {
lv_checkbox_set_disabled(cbOption[i]);
}
cbOption[i]->user_data = this;
lv_obj_set_event_cb(cbOption[i], event_handler);
SetRadioButtonStyle(cbOption[i]);

if (static_cast<unsigned int>((settingsController.*GetOptionIndex)() - MaxItems * screenID) == i) {
if (static_cast<unsigned int>(originalValue - MaxItems * screenID) == i) {
lv_checkbox_set_checked(cbOption[i], true);
}
}
Expand All @@ -98,18 +91,22 @@ CheckboxList::CheckboxList(const uint8_t screenID,

CheckboxList::~CheckboxList() {
lv_obj_clean(lv_scr_act());
OnValueChanged(value);
}

void CheckboxList::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) {
for (unsigned int i = 0; i < options.size(); i++) {
if (strcmp(options[i], "")) {
if (strcmp(options[i].name, "")) {
if (object == cbOption[i]) {
lv_checkbox_set_checked(cbOption[i], true);
(settingsController.*SetOptionIndex)(MaxItems * screenID + i);
value = MaxItems * screenID + i;
} else {
lv_checkbox_set_checked(cbOption[i], false);
}
if (!options[i].enabled) {
lv_checkbox_set_disabled(cbOption[i]);
}
}
}
}
Expand Down
32 changes: 15 additions & 17 deletions src/displayapp/screens/CheckboxList.h
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
#pragma once

#include <lvgl/lvgl.h>
#include "displayapp/Apps.h"
#include "displayapp/screens/Screen.h"
#include <array>
#include <cstdint>
#include <functional>
#include <lvgl/lvgl.h>
#include <memory>
#include <array>
#include "displayapp/screens/Screen.h"
#include "displayapp/Apps.h"
#include "components/settings/Settings.h"

namespace Pinetime {
namespace Applications {
namespace Screens {
class CheckboxList : public Screen {
public:
static constexpr size_t MaxItems = 4;
struct Item {
const char* name;
bool enabled;
};

CheckboxList(const uint8_t screenID,
const uint8_t numScreens,
DisplayApp* app,
Controllers::Settings& settingsController,
const char* optionsTitle,
const char* optionsSymbol,
void (Controllers::Settings::*SetOptionIndex)(uint8_t),
uint8_t (Controllers::Settings::*GetOptionIndex)() const,
std::array<const char*, MaxItems> options);

uint32_t originalValue,
std::function<void(uint32_t)> OnValueChanged,
std::array<Item, MaxItems> options);
~CheckboxList() override;

void UpdateSelected(lv_obj_t* object, lv_event_t event);

private:
const uint8_t screenID;
Controllers::Settings& settingsController;
const char* optionsTitle;
const char* optionsSymbol;
void (Controllers::Settings::*SetOptionIndex)(uint8_t);
uint8_t (Controllers::Settings::*GetOptionIndex)() const;
std::array<const char*, MaxItems> options;
std::function<void(uint32_t)> OnValueChanged;
std::array<Item, MaxItems> options;
std::array<lv_obj_t*, MaxItems> cbOption;
std::array<lv_point_t, 2> pageIndicatorBasePoints;
std::array<lv_point_t, 2> pageIndicatorPoints;
lv_obj_t* pageIndicatorBase;
lv_obj_t* pageIndicator;
uint32_t value;
};
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,23 @@ void WatchFaceCasioStyleG7710::Refresh() {
lv_obj_realign(stepIcon);
}
}
bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) {
lfs_file file = {};

if (filesystem.FileOpen(&file, "/fonts/lv_font_dots_40.bin", LFS_O_RDONLY) < 0) {
return false;
}

filesystem.FileClose(&file);
if (filesystem.FileOpen(&file, "/fonts/7segments_40.bin", LFS_O_RDONLY) < 0) {
return false;
}

filesystem.FileClose(&file);
if (filesystem.FileOpen(&file, "/fonts/7segments_115.bin", LFS_O_RDONLY) < 0) {
return false;
}

filesystem.FileClose(&file);
return true;
}
2 changes: 2 additions & 0 deletions src/displayapp/screens/WatchFaceCasioStyleG7710.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace Pinetime {

void Refresh() override;

static bool IsAvailable(Pinetime::Controllers::FS& filesystem);

private:
uint8_t displayedHour = -1;
uint8_t displayedMinute = -1;
Expand Down
Loading

0 comments on commit e789622

Please sign in to comment.