import argparse import os import struct import glob import hashlib # Define the TagSettings format tag_settings_format = ' 5000): file_type = 0x21 else: file_type = 0x20 eeprom_header = EepromImageHeader( md5_checksum, 0x474d4721, 0x3000-14, file_type, file_id, 0x79) output_file.seek(offset) output_file.write(eeprom_header.pack()) offset += 22 # The size of the EepromImageHeader struct input_data = input_file.read() output_file.seek(offset) output_file.write(input_data) def addsplash(output_file): with open('splashscreen.raw', 'rb') as input_file: offset = 0x1000 md5_checksum = calculate_md5_checksum('splashscreen.raw') # determine if we have a color image or not if (os.path.getsize('splashscreen.raw') > 5000): file_type = 0x21 else: file_type = 0x20 eeprom_header = EepromImageHeader( md5_checksum, 0x474d4721, 0x3000-14, file_type, 0, 0x09) output_file.seek(offset) output_file.write(eeprom_header.pack()) offset += 22 # The size of the EepromImageHeader struct input_data = input_file.read() output_file.seek(offset) output_file.write(input_data) # Main function def main(): parser = argparse.ArgumentParser( description="Creates a slideshow for 2.9\" OpenEPaperLink tags") parser.add_argument("output_file", help="Output binary file for eeprom") parser.add_argument("input_files", nargs='+', help="Input image files to be included in the output") parser.add_argument("--splash", "-s", action="store_true", help="Adds a splash-screen to the slideshow that will be shown first (must be named 'splashscreen.raw')") parser.add_argument("--waitrfwake", "-w", action="store_true", help="Forces the tag to wait for RF wake signal to start the slideshow. Tag will display the first slideshow image while waiting for this signal") args = parser.parse_args() input_files = [] for input_file in args.input_files: input_files.extend(glob.glob(input_file)) with open(args.output_file, 'wb') as output_file: if (args.waitrfwake): write_tagsettings(output_file, 0x20) # wait for wake first else: write_tagsettings(output_file, 0x08) # slow slideshow write_input_files(input_files, output_file) if (args.splash): addsplash(output_file) if __name__ == '__main__': main()