From 90b2e2c31158051853b2ba6bca17450464fa95f3 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 14 Feb 2022 22:17:48 +1100 Subject: [PATCH] Refactor more --- .github/workflows/push.yml | 2 +- Bootup Logos/README.md | 18 ++++++++++++++---- Bootup Logos/img2logo.py | 18 +++++++----------- Bootup Logos/run.sh | 4 ++++ 4 files changed, 26 insertions(+), 16 deletions(-) create mode 100755 Bootup Logos/run.sh diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9a61efb..45588e3 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -28,7 +28,7 @@ jobs: run: mkdir -p /tmp/${{ matrix.model }} - name: build test - run: cd Bootup\ Logos && python3 img2logo.py ${{matrix.args}} Images/IronOS.gif /tmp/${{ matrix.model }}/IronOS.gif + run: cd Bootup\ Logos && ./run.sh /tmp/${{ matrix.model }}/ ${{matrix.args}} - name: Archive artifacts uses: actions/upload-artifact@v2 diff --git a/Bootup Logos/README.md b/Bootup Logos/README.md index 40687a8..95dd36f 100644 --- a/Bootup Logos/README.md +++ b/Bootup Logos/README.md @@ -1,12 +1,22 @@ - ## Boot up logo's are logos or animations shown on boot of IronOS -These are programmed into the device just like the normal firmware. +These are programmed into the device just like the normal firmware. They can be (re)programmed as many times as desired after flashing the normal firmware. - ### Data storage format The data is stored into the second last page of flash, this gives 1024 bytes of space for the entire payload of bootup logo data. -The first byte is marked purely to \ No newline at end of file +The first byte is marked purely to indicate that the page is programmed and which revision of the boot logo logic it is +The next byte indicates the frame timing in milliseconds, or `0` to indicate only show first frame for whole bootloader duration (still image mode) +Then the OLED buffer is cleared to black, then every frame is encoded as either: + +### Full frame updates + +`[0xFF][Full framebuffer of data]` + +### Delta frame update + +`[count of updates][[index,data][index,data][index,data][index,data]]` +Where index is byte location into screen buffer, and data is the new byte to plonk down there +This just overwrites individual bytes in the output buffer diff --git a/Bootup Logos/img2logo.py b/Bootup Logos/img2logo.py index ebed819..fd21e87 100755 --- a/Bootup Logos/img2logo.py +++ b/Bootup Logos/img2logo.py @@ -131,7 +131,6 @@ def animated_image_to_bytes(imageIn: Image, negative: bool, dither: bool, thresh frameData = [] frameTiming = None for framenum in range(0, imageIn.n_frames): - print(f"Frame {framenum}") imageIn.seek(framenum) image = imageIn @@ -206,8 +205,9 @@ def img2hex( data = animated_image_to_bytes(image, negative, dither, threshold) else: # magic/required header - data = [DATA_PROGRAMMED_MARKER, 0xBB] - data.extend(still_image_to_bytes(image, negative, dither, threshold, preview_filename)) + data = [DATA_PROGRAMMED_MARKER, 0x00] # Timing value of 0 + image_bytes = still_image_to_bytes(image, negative, dither, threshold, preview_filename) + data.extend(get_screen_blob([0] * LCD_NUM_BYTES, image_bytes)) # Pad up to the full page size if len(data) < LCD_PAGE_SIZE: @@ -217,8 +217,9 @@ def img2hex( if isPinecil: deviceSettings = PinecilSettings # Generate both possible outputs + output_name = output_filename_base + os.path.basename(input_filename) DFUOutput.writeFile( - output_filename_base + ".dfu", + output_name + ".dfu", data, deviceSettings.IMAGE_ADDRESS, deviceSettings.DFU_TARGET_NAME, @@ -226,7 +227,7 @@ def img2hex( deviceSettings.DFU_PINECIL_PRODUCT, deviceSettings.DFU_PINECIL_VENDOR, ) - HexOutput.writeFile(output_filename_base + ".hex", data, deviceSettings.IMAGE_ADDRESS) + HexOutput.writeFile(output_name + ".hex", data, deviceSettings.IMAGE_ADDRESS) def parse_commandline(): @@ -273,7 +274,6 @@ def parse_commandline(): help="use dithering (speckling) to convert gray or " "color to black and white", ) - parser.add_argument("-f", "--force", action="store_true", help="force overwriting of existing files") parser.add_argument( "-E", "--erase", @@ -297,21 +297,17 @@ if __name__ == "__main__": args = parse_commandline() - if os.path.exists(args.output_filename) and not args.force: - sys.stderr.write('Won\'t overwrite existing file "{}" (use --force ' "option to override)\n".format(args.output_filename)) - sys.exit(1) - if args.preview and os.path.exists(args.preview) and not args.force: sys.stderr.write('Won\'t overwrite existing file "{}" (use --force ' "option to override)\n".format(args.preview)) sys.exit(1) img2hex( input_filename=args.input_filename, + output_filename_base=args.output_filename, preview_filename=args.preview, threshold=args.threshold, dither=args.dither, negative=args.negative, make_erase_image=args.erase, - output_filename_base=args.output_filename, isPinecil=args.pinecil, ) diff --git a/Bootup Logos/run.sh b/Bootup Logos/run.sh new file mode 100755 index 0000000..0f08031 --- /dev/null +++ b/Bootup Logos/run.sh @@ -0,0 +1,4 @@ +#! /bin/sh +echo $1 +echo $2 +find Images/ -type f -exec python img2logo.py {} "$1" "$2" \;