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

Move analog watch face background into resources #1819

Closed
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
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RUN pip3 install cbor
RUN npm i [email protected] -g

RUN npm i [email protected] -g
RUN npm i @swc/core -g
RUN npm i @swc/core@1.2.160 -g
RUN npm i [email protected] -g

# build.sh knows how to compile
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ list(APPEND SOURCE_FILES
displayapp/screens/settings/SettingBluetooth.cpp

## Watch faces
displayapp/icons/bg_clock.c
displayapp/screens/WatchFaceAnalog.cpp
displayapp/screens/WatchFaceDigital.cpp
displayapp/screens/WatchFaceInfineat.cpp
Expand Down
272 changes: 0 additions & 272 deletions src/displayapp/icons/bg_clock.c

This file was deleted.

15 changes: 12 additions & 3 deletions src/displayapp/screens/WatchFaceAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "components/settings/Settings.h"
#include "displayapp/InfiniTimeTheme.h"

LV_IMG_DECLARE(bg_clock);

using namespace Pinetime::Applications::Screens;

namespace {
Expand Down Expand Up @@ -61,7 +59,7 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
sSecond = 99;

lv_obj_t* bg_clock_img = lv_img_create(lv_scr_act(), nullptr);
lv_img_set_src(bg_clock_img, &bg_clock);
lv_img_set_src(bg_clock_img, "F:/images/bg_clock.bin");
lv_obj_align(bg_clock_img, nullptr, LV_ALIGN_CENTER, 0, 0);

batteryIcon.Create(lv_scr_act());
Expand Down Expand Up @@ -232,3 +230,14 @@ void WatchFaceAnalog::Refresh() {
}
}
}

bool WatchFaceAnalog::IsAvailable(Pinetime::Controllers::FS& filesystem) {
lfs_file file = {};

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

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

void Refresh() override;

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

private:
uint8_t sHour, sMinute, sSecond;

Expand Down
3 changes: 2 additions & 1 deletion src/displayapp/screens/settings/SettingWatchFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "displayapp/screens/CheckboxList.h"
#include "displayapp/screens/WatchFaceInfineat.h"
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
#include "displayapp/screens/WatchFaceAnalog.h"

namespace Pinetime {

Expand Down Expand Up @@ -42,7 +43,7 @@ namespace Pinetime {

std::array<Screens::CheckboxList::Item, settingsPerScreen * nScreens> watchfaces {
{{"Digital face", true},
{"Analog face", true},
{"Analog face", Applications::Screens::WatchFaceAnalog::IsAvailable(filesystem)},
{"PineTimeStyle", true},
{"Terminal", true},
{"Infineat face", Applications::Screens::WatchFaceInfineat::IsAvailable(filesystem)},
Expand Down
6 changes: 4 additions & 2 deletions src/resources/generate-img.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import argparse
import subprocess

def gen_lvconv_line(lv_img_conv: str, dest: str, color_format: str, output_format: str, binary_format: str, sources: str):
args = [lv_img_conv, sources, '--force', '--output-file', dest, '--color-format', color_format, '--output-format', output_format, '--binary-format', binary_format]
def gen_lvconv_line(lv_img_conv: str, dest: str, color_format: str, output_format: str, sources: str, binary_format: str | None = None):
args = [lv_img_conv, sources, '--force', '--output-file', dest, '--color-format', color_format, '--output-format', output_format]
if binary_format is not None:
args.extend(['--binary-format', binary_format])

return args

Expand Down
6 changes: 6 additions & 0 deletions src/resources/images.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
"output_format": "bin",
"binary_format": "ARGB8565_RBSWAP",
"target_path": "/images/"
},
"bg_clock": {
"sources": "images/bg_clock.png",
"color_format": "CF_INDEXED_2_BIT",
"output_format": "bin",
"target_path": "/images/"
}
}
Binary file added src/resources/images/bg_clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading