Skip to content

Commit

Permalink
Merge remote-tracking branch 'mntm/dev' into js-app-internal
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Nov 5, 2024
2 parents 3107fa5 + 3ef2838 commit e63c0ab
Show file tree
Hide file tree
Showing 26 changed files with 186 additions and 79 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,22 @@ jobs:
dfu_size_new=$(du --apparent-size -B 1 artifacts/flipper-z-${TARGET}-full-*.dfu | cut -f1)
dfu_size_dev=$(du --apparent-size -B 1 dev.dfu | cut -f1)
dfu_size_diff=$((dfu_size_new - dfu_size_dev))
DFU_SIZE=$(echo ${dfu_size_new}B | sed -r 's/^([0-9]+)([0-9]{2})([0-9])B/\1.\2K/')
DFU_DIFF=$(echo ${dfu_size_diff}B | sed -r 's/^(-?[0-9]+)([0-9]{2})([0-9])B/\1.\2K/' | sed -r 's/^([^-])/+\1/')
DFU_SIZE=$(echo $dfu_size_new | numfmt --to=iec --format=%.2f)
DFU_DIFF=$(echo $dfu_size_diff | numfmt --to=iec --format=%.2f | sed -r 's/^([^-])/+\1/')
echo "DFU_SIZE=$DFU_SIZE" >> $GITHUB_ENV
echo "DFU_DIFF=$DFU_DIFF" >> $GITHUB_ENV
tar xzf build/core2_firmware.tgz
radio_addr=$(jq -r '.copro.radio.files[0].address' core2_firmware/Manifest.json)
flash_base=0x8000000
min_gap=$((2 * 4 * 1024))
flash_free_total=$((radio_addr - flash_base - dfu_size_new))
flash_free_usable=$((flash_free_total - min_gap))
FLASH_FREE=$(echo $flash_free_total | numfmt --to=iec --format=%.2f)
FLASH_USABLE=$(echo $flash_free_usable | numfmt --to=iec --format=%.2f)
echo "FLASH_FREE=$FLASH_FREE" >> $GITHUB_ENV
echo "FLASH_USABLE=$FLASH_USABLE" >> $GITHUB_ENV
- name: "Upload artifacts to update server"
env:
INDEXER_URL: ${{ secrets.INDEXER_URL }}
Expand Down Expand Up @@ -170,6 +181,7 @@ jobs:
- [☁️ Flipper Lab/App](https://lab.flipper.net/?url=${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=mntm-${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}})
- [📦 qFlipper Package](${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz)
- DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev)
- Free Flash: `${{ env.FLASH_FREE }}` (`${{ env.FLASH_USABLE }}` usable)
edit-mode: replace

- name: Send devbuild webhook
Expand Down
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@
- UL: W5500 Ethernet: Various fixes and improvements (by @xMasterX)
- OFW: SPI Mem Manager: Fixed UI rendering bug related to line breaks (by @portasynthinca3)
- OFW: USB/BT Remote: Mouse clicker option to click as fast as possible (by @sumukhj1219)
- CLI:
- Print plugin name on load fail (by @Willy-JL)
- Move more commands as plugins on SD, refactor plugin wrapper (#276 by @Willy-JL)
- NFC:
- NDEF Parser:
- Mifare Classic support (#265 by @luu176), protocol-agnostic rewrite and more improvements (#265 by @Willy-JL)
Expand Down Expand Up @@ -166,6 +163,10 @@
- OFW: Add TCL 75S451 to TV universal remote (by @christhetech131)
- OFW: Universal remote additions (by @jaylikesbunda)
- OFW: Heavily Expand Universal Remotes (by @jaylikesbunda)
- CLI:
- Print plugin name on load fail (by @Willy-JL)
- Move more commands as plugins on SD, refactor plugin wrapper (#276 by @Willy-JL)
- FBT: Optimize icons blob, scrub unused icons (#291 by @Willy-JL)
- OFW: BadKB: Improve ChromeOS and GNOME demo scripts (by @kowalski7cc)
- OFW: GUI: Change dialog_ex text ownership model (by @skotopes)
- OFW: CCID: App changes and improvements (by @kidbomb)
Expand Down Expand Up @@ -194,6 +195,7 @@
- Fix GPS "Latitute" typo, switch to "Lat" and "Lon" in .sub files (#246 by @m7i-org)
- UL: Fix zero issues in Princeton (by @xMasterX)
- UL: Code cleanup and fix for rare dupicated "Data" field cases (by @xMasterX)
- UL: Fix Nice One key display (by @xMasterX)
- Power: Suppress Shutdown on Idle While Charging / Plugged In (#244 by @luu176)
- Storage:
- Fallback SD format prompt when storage settings is unavailable (by @Willy-JL)
Expand Down
2 changes: 1 addition & 1 deletion applications/main/nfc/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ App(
"!plugins",
"!nfc_cli.c",
],
fap_libs=["mbedtls"],
fap_libs=["assets", "mbedtls"],
fap_icon="icon.png",
fap_category="NFC",
)
Expand Down
1 change: 1 addition & 0 deletions applications/settings/about/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ App(
stack_size=1 * 1024,
order=1000,
fap_category="assets",
fap_libs=["assets"],
)
1 change: 1 addition & 0 deletions applications/settings/power_settings_app/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ App(
stack_size=1 * 1024,
order=40,
fap_category="assets",
fap_libs=["assets"],
)
1 change: 1 addition & 0 deletions applications/settings/storage_settings/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ App(
stack_size=2 * 1024,
order=30,
fap_category="assets",
fap_libs=["assets"],
)
2 changes: 2 additions & 0 deletions applications/system/js_app/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ App(
# cdefines=["JS_RUNNER_FAP"],
fap_icon="icon.png",
fap_category="assets",
fap_libs=["assets"],
entry_point="js_app",
stack_size=2 * 1024,
resources="examples",
Expand Down Expand Up @@ -35,6 +36,7 @@ App(
"modules/js_flipper.c",
"modules/js_tests.c",
],
fap_libs=["assets"],
)

App(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export declare function getBatteryCharge(): number;
* @warning Do **NOT** use this to check the presence or absence of features. If
* you do, I'm gonna be sad :( Instead, refer to `checkSdkFeatures` and
* other similar mechanisms.
* @note Momentum firmware reports `"momentum"`.
* @note Momentum firmware reports `"momentum"`. / Official firmware reports `"flipperdevices"`.
* @version Added in JS SDK 0.1
*/
export declare const firmwareVendor: string;
Expand Down
26 changes: 24 additions & 2 deletions assets/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,26 @@ icons_path = (
if assetsenv["IS_BASE_FIRMWARE"]
else assetsenv["ASSETS_WORK_DIR"]
)
icons = assetsenv.CompileIcons(icons_path, assetsenv["ASSETS_SRC_DIR"].Dir("icons"))
icons = assetsenv.CompileIcons(
icons_path,
assetsenv["ASSETS_SRC_DIR"].Dir("icons"),
fw_bundle=True,
)
assetsenv.Alias("icons", icons)

# Extra icons lib so apps don't override asset packs to use fw icons not exposed to api
# Not used anywhere in code, apps still reference assets_icons.h, but if one of the
# icons they need is not exposed in api, they can link with fap_libs=["assets"] which
# will use this lib purely for linking as a drop-in for missing symbols.
# Should mean that apps made for OFW with fap_libs=["assets"], when compiled with
# this FBT, will still use asset packs at runtime and only link non-exposed icons.
if assetsenv["IS_BASE_FIRMWARE"]:
dropin_icons = assetsenv.CompileIcons(
assetsenv["ASSETS_WORK_DIR"],
assetsenv["ASSETS_SRC_DIR"].Dir("icons"),
icon_bundle_name="_assets_icons_dropin",
)


# Protobuf .proto -> .c + .h
proto_src = assetsenv.Glob("protobuf/*.proto", source=True)
Expand Down Expand Up @@ -59,9 +76,14 @@ assetsenv.Alias("proto_ver", proto_ver)
assets_parts = (icons, proto, dolphin_blocking, dolphin_internal, proto_ver)
env.Replace(FW_ASSETS_HEADERS=assets_parts)

assetslib = assetsenv.Library("${FW_LIB_NAME}", assets_parts)
assetslib = assetsenv.Library("fw${FW_LIB_NAME}", assets_parts)
assetsenv.Install("${LIB_DIST_DIR}", assetslib)

if assetsenv["IS_BASE_FIRMWARE"]:
dropin_parts = (dropin_icons, proto, dolphin_blocking, dolphin_internal, proto_ver)
dropin_assetslib = assetsenv.Library("${FW_LIB_NAME}", dropin_parts)
assetsenv.Install("${LIB_DIST_DIR}", dropin_assetslib)


# Resources for SD card
if assetsenv["IS_BASE_FIRMWARE"]:
Expand Down
Binary file removed assets/icons/Infrared/Play_25x27.png
Binary file not shown.
Binary file removed assets/icons/Infrared/Play_hvr_25x27.png
Binary file not shown.
Binary file removed assets/icons/Infrared/hourglass0_24x24.png
Binary file not shown.
Binary file removed assets/icons/Infrared/hourglass1_24x24.png
Binary file not shown.
Binary file removed assets/icons/Infrared/hourglass2_24x24.png
Binary file not shown.
Binary file removed assets/icons/Infrared/hourglass3_24x24.png
Binary file not shown.
Binary file removed assets/icons/Infrared/hourglass4_24x24.png
Binary file not shown.
Binary file removed assets/icons/Infrared/hourglass5_24x24.png
Binary file not shown.
Binary file removed assets/icons/Infrared/hourglass6_24x24.png
Binary file not shown.
Binary file removed assets/icons/PIN/Pin_cell_13x13.png
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/subghz/protocols/nice_flor_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ void subghz_protocol_decoder_nice_flor_s_get_string(void* context, FuriString* o
furi_string_cat_printf(
output,
"%s %dbit\r\n"
"Key:0x%013llX%llX\r\n"
"Key:%013llX%llX\r\n"
"Sn:%05lX\r\n"
"Cnt:%04lX Btn:%02X\r\n",
NICE_ONE_NAME,
Expand Down
92 changes: 57 additions & 35 deletions scripts/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@

ICONS_TEMPLATE_H_HEADER = """#pragma once
#include <furi.h>
#include <stddef.h>
#include <gui/icon.h>
"""
ICONS_TEMPLATE_H_ICON_NAME = "extern const Icon {name};\n"
ICONS_TEMPLATE_H_ICON_PATHS = """
typedef struct {
const Icon* icon;
const char* path;
} IconPath;
extern const IconPath ICON_PATHS[];
extern const size_t ICON_PATHS_COUNT;
"""

ICONS_TEMPLATE_C_HEADER = """#include "{assets_filename}.h"
Expand All @@ -25,6 +34,15 @@
ICONS_TEMPLATE_C_FRAME = "const uint8_t {name}[] = {data};\n"
ICONS_TEMPLATE_C_DATA = "const uint8_t* const {name}[] = {data};\n"
ICONS_TEMPLATE_C_ICONS = "const Icon {name} = {{.width={width},.height={height},.frame_count={frame_count},.frame_rate={frame_rate},.frames=_{name}}};\n"
ICONS_TEMPLATE_C_ICON_PATH = ' {{&{name}, "{path}"}},\n'
ICONS_TEMPLATE_C_ICON_PATHS = """
const IconPath ICON_PATHS[] = {{
#ifndef FURI_RAM_EXEC
{icon_paths}
#endif
}};
const size_t ICON_PATHS_COUNT = COUNT_OF(ICON_PATHS);
"""

MAX_IMAGE_WIDTH = 2**16 - 1
MAX_IMAGE_HEIGHT = 2**16 - 1
Expand All @@ -45,6 +63,22 @@ def init(self):
required=False,
default="assets_icons",
)
self.parser_icons.add_argument(
"--fw-bundle",
dest="fw_bundle",
help="Bundle all icons and path info, only for use in firmware blob",
default=0,
type=int,
required=False,
)
self.parser_icons.add_argument(
"--add-include",
dest="add_include",
help="Add assets_icons.h include drop-in for apps",
default=0,
type=int,
required=False,
)

self.parser_icons.set_defaults(func=self.icons)

Expand Down Expand Up @@ -138,7 +172,6 @@ def icons(self):
)
icons = []
paths = []
is_main_assets = self.args.filename == "assets_icons"
symbols = pathlib.Path(__file__).parent.parent
if "UFBT_HOME" in os.environ:
symbols /= "sdk_headers/f7_sdk"
Expand All @@ -154,7 +187,8 @@ def icons(self):
if "frame_rate" in filenames:
self.logger.debug("Folder contains animation")
icon_name = "A_" + os.path.split(dirpath)[1].replace("-", "_")
if not is_main_assets and api_has_icon(icon_name):
icon_in_api = api_has_icon(icon_name)
if not self.args.fw_bundle and icon_in_api:
self.logger.info(
f"{self.args.filename}: ignoring duplicate icon {icon_name}"
)
Expand Down Expand Up @@ -193,8 +227,9 @@ def icons(self):
)
icons_c.write("\n")
icons.append((icon_name, width, height, frame_rate, frame_count))
p = dirpath.removeprefix(self.args.input_directory)[1:]
paths.append((icon_name, p.replace("\\", "/")))
if self.args.fw_bundle and icon_in_api:
path = dirpath.removeprefix(self.args.input_directory)[1:]
paths.append((icon_name, path.replace("\\", "/")))
else:
# process icons
for filename in filenames:
Expand All @@ -204,7 +239,8 @@ def icons(self):
icon_name = "I_" + "_".join(filename.split(".")[:-1]).replace(
"-", "_"
)
if not is_main_assets and api_has_icon(icon_name):
icon_in_api = api_has_icon(icon_name)
if not self.args.fw_bundle and icon_in_api:
self.logger.info(
f"{self.args.filename}: ignoring duplicate icon {icon_name}"
)
Expand All @@ -222,8 +258,11 @@ def icons(self):
)
icons_c.write("\n")
icons.append((icon_name, width, height, 0, 1))
p = fullfilename.removeprefix(self.args.input_directory)[1:]
paths.append((icon_name, p.replace("\\", "/").rsplit(".", 1)[0]))
if self.args.fw_bundle and icon_in_api:
path = fullfilename.removeprefix(self.args.input_directory)[1:]
paths.append(
(icon_name, path.replace("\\", "/").rsplit(".", 1)[0])
)
# Create array of images:
self.logger.debug("Finalizing source file")
for name, width, height, frame_rate, frame_count in icons:
Expand All @@ -236,21 +275,14 @@ def icons(self):
frame_count=frame_count,
)
)
if is_main_assets:
icons_c.write(
"""
const IconPath ICON_PATHS[] = {
#ifndef FURI_RAM_EXEC
"""
)
for name, path in paths:
icons_c.write(f' {{&{name}, "{path}"}},\n')
icons_c.write(
"""#endif
};
const size_t ICON_PATHS_COUNT = COUNT_OF(ICON_PATHS);
"""
if not self.args.fw_bundle:
icons_c.write("\n")
else:
icon_paths = "\n".join(
ICONS_TEMPLATE_C_ICON_PATH.format(name=name, path=path)
for name, path in paths
)
icons_c.write(ICONS_TEMPLATE_C_ICON_PATHS.format(icon_paths=icon_paths))
icons_c.close()

# Create Public Header
Expand All @@ -263,19 +295,9 @@ def icons(self):
icons_h.write(ICONS_TEMPLATE_H_HEADER)
for name, width, height, frame_rate, frame_count in icons:
icons_h.write(ICONS_TEMPLATE_H_ICON_NAME.format(name=name))
if is_main_assets:
icons_h.write(
"""
typedef struct {
const Icon* icon;
const char* path;
} IconPath;
extern const IconPath ICON_PATHS[];
extern const size_t ICON_PATHS_COUNT;
"""
)
else:
if self.args.fw_bundle:
icons_h.write(ICONS_TEMPLATE_H_ICON_PATHS)
if self.args.add_include:
icons_h.write("#include <assets_icons.h>\n")
icons_h.close()
self.logger.debug("Done")
Expand Down
39 changes: 39 additions & 0 deletions scripts/check_unused_icons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
import pathlib

root = pathlib.Path(__file__).parent / ".."
icons = root / "assets/icons"


def count_icon_usages(name: str):
count = 0
name = name.encode()
# EXTREMELY wasteful, but who cares
for dir in ("applications", "furi", "lib", "targets"):
for filetype in (".c", ".cpp", ".h", ".fam"):
for file in (root / dir).glob(f"**/*{filetype}"):
try:
if name in file.read_bytes():
count += 1
except Exception:
print(f"Failed to read {file}")
return count


if __name__ == "__main__":
counts = {}

for category in icons.iterdir():
if not category.is_dir():
continue
for icon in category.iterdir():
if icon.is_dir() and (icon / "frame_rate").is_file():
name = "A_" + icon.name.replace("-", "_")
elif icon.is_file() and icon.suffix == ".png":
name = "I_" + "_".join(icon.name.split(".")[:-1]).replace("-", "_")
else:
continue
counts[name[2:]] = count_icon_usages(name)

for name, count in sorted(counts.items(), key=lambda x: x[1], reverse=True):
print(f"{name} used {count} times")
Loading

0 comments on commit e63c0ab

Please sign in to comment.