[FL-2556] Update complete screen (#1332)
* Desktop: slideshow implementation * Updater: handling splashscreen installation; added format version field to slideshow binary * Desktop: added bidirectional slideshow navigation + instant cancel by "back" button; Updater: rebalanced update stages weights * Updater: fixed missing field init; fixed potential loop when baking slideshows * Assets: fixed "update complete" image to match original * Desktop: added check for slideshow file version * Scripts: slideshow.py cleanup * Desktop: removed first start intro sequence * Desktop: removed first start remnants
This commit is contained in:
@@ -38,9 +38,9 @@ class Main(App):
|
||||
return 1
|
||||
|
||||
with open(self.args.input, mode="rb") as file:
|
||||
bin = file.read()
|
||||
bindata = file.read()
|
||||
|
||||
data = struct.pack("<II", self.args.address, len(bin)) + bin
|
||||
data = struct.pack("<II", self.args.address, len(bindata)) + bindata
|
||||
|
||||
# Target prefix
|
||||
szTargetName = self.args.label.encode("ascii")
|
||||
|
61
scripts/slideshow.py
Normal file
61
scripts/slideshow.py
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import struct
|
||||
|
||||
from flipper.app import App
|
||||
from flipper.assets.icon import file2image
|
||||
|
||||
|
||||
class Main(App):
|
||||
MAGIC = 0x72676468
|
||||
VERSION = 1
|
||||
|
||||
def init(self):
|
||||
self.parser.add_argument("-i", "--input", help="input folder", required=True)
|
||||
self.parser.add_argument("-o", "--output", help="output file", required=True)
|
||||
|
||||
self.parser.set_defaults(func=self.pack)
|
||||
|
||||
def pack(self):
|
||||
if not os.path.exists(self.args.input):
|
||||
self.logger.error(f'"{self.args.input}" does not exist')
|
||||
return 1
|
||||
|
||||
file_idx = 0
|
||||
images = []
|
||||
while True:
|
||||
frame_filename = os.path.join(self.args.input, f"frame_{file_idx:02}.png")
|
||||
if not os.path.exists(frame_filename):
|
||||
break
|
||||
|
||||
self.logger.debug(f"working on {frame_filename}")
|
||||
try:
|
||||
images.append(file2image(frame_filename))
|
||||
self.logger.debug(f"Processed frame #{file_idx}")
|
||||
file_idx += 1
|
||||
except Exception as e:
|
||||
self.logger.error(e)
|
||||
break
|
||||
|
||||
widths = set(img.width for img in images)
|
||||
heights = set(img.height for img in images)
|
||||
if len(widths) != 1 or len(heights) != 1:
|
||||
self.logger.error("All images must have same dimensions!")
|
||||
return 2
|
||||
|
||||
data = struct.pack(
|
||||
"<IBBBB", self.MAGIC, self.VERSION, widths.pop(), heights.pop(), len(images)
|
||||
)
|
||||
for image in images:
|
||||
data += struct.pack("<H", len(image.data))
|
||||
data += image.data
|
||||
|
||||
with open(self.args.output, mode="wb") as file:
|
||||
file.write(data)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Main()()
|
@@ -11,6 +11,8 @@ import zlib
|
||||
import tarfile
|
||||
import math
|
||||
|
||||
from slideshow import Main as SlideshowMain
|
||||
|
||||
|
||||
class Main(App):
|
||||
UPDATE_MANIFEST_VERSION = 2
|
||||
@@ -31,6 +33,9 @@ class Main(App):
|
||||
FLASH_BASE = 0x8000000
|
||||
MIN_LFS_PAGES = 6
|
||||
|
||||
# Post-update slideshow
|
||||
SPLASH_BIN_NAME = "splash.bin"
|
||||
|
||||
def init(self):
|
||||
self.subparsers = self.parser.add_subparsers(help="sub-command help")
|
||||
|
||||
@@ -63,6 +68,7 @@ class Main(App):
|
||||
)
|
||||
|
||||
self.parser_generate.add_argument("--obdata", dest="obdata", required=False)
|
||||
self.parser_generate.add_argument("--splash", dest="splash", required=False)
|
||||
self.parser_generate.add_argument(
|
||||
"--I-understand-what-I-am-doing", dest="disclaimer", required=False
|
||||
)
|
||||
@@ -124,6 +130,19 @@ class Main(App):
|
||||
self.disclaimer()
|
||||
return 2
|
||||
|
||||
if self.args.splash:
|
||||
splash_args = [
|
||||
"-i",
|
||||
self.args.splash,
|
||||
"-o",
|
||||
join(self.args.directory, self.SPLASH_BIN_NAME),
|
||||
]
|
||||
if splash_code := SlideshowMain(no_exit=True)(splash_args):
|
||||
self.logger.error(
|
||||
f"Failed to convert splash screen data: {splash_code}"
|
||||
)
|
||||
return splash_code
|
||||
|
||||
file = FlipperFormatFile()
|
||||
file.setHeader(
|
||||
"Flipper firmware upgrade configuration", self.UPDATE_MANIFEST_VERSION
|
||||
@@ -152,6 +171,7 @@ class Main(App):
|
||||
file.writeKey("OB reference", self.bytes2ffhex(obvalues.reference))
|
||||
file.writeKey("OB mask", self.bytes2ffhex(obvalues.compare_mask))
|
||||
file.writeKey("OB write mask", self.bytes2ffhex(obvalues.write_mask))
|
||||
file.writeKey("Splashscreen", self.SPLASH_BIN_NAME if self.args.splash else "")
|
||||
file.save(join(self.args.directory, self.UPDATE_MANIFEST_NAME))
|
||||
|
||||
return 0
|
||||
|
Reference in New Issue
Block a user