Exemplo n.º 1
0
    def hackBuffer(self, index, buffer):
        data_0x10 = {
            1: [0x20, 0x00, 0x6e, 0xea, 0x00, 0x00, 0x01, 0xbc],
            2: [0x20, 0x00, 0x6d, 0xea, 0x00, 0x00, 0x81, 0x77],
            3: [0x20, 0x00, 0x6a, 0xea, 0x00, 0x00, 0xb1, 0xf3],
            4: [0x20, 0x00, 0x69, 0xea, 0x00, 0x00, 0x74, 0xfa],
            5: [0x20, 0x00, 0x6b, 0xea, 0x00, 0x00, 0x7c, 0x3e],
            6: [0x20, 0x00, 0x6f, 0xea, 0x00, 0x00, 0x14, 0xde],
            7: [0x20, 0x00, 0x70, 0xea, 0x00, 0x00, 0x35, 0xa1],
            8: [0x20, 0x00, 0x6c, 0xea, 0x00, 0x00, 0x3f, 0x2c],
            40: [0x2e, 0x00, 0xaa, 0xeb, 0x00, 0x00, 0x68,
                 0xf1],  #gts 0xaa, 0x68, 0xf1 may vary
            47: [0x28, 0x00, 0x8c, 0xea, 0x00, 0x00, 0x01, 0xbc],  # gtr 47
            42: [0x2a, 0x00, 0x72, 0xeb, 0x00, 0x00, 0x5c, 0xd3],  # gtr 42
        }

        if Config.isGtrMode():
            index = Config.isGtrMode()
        if Config.isGtsMode():
            index = Config.isGtsMode()
        p_0x10 = data_0x10[index]
        for i in range(len(p_0x10)):
            buffer[0x10 + i] = p_0x10[i]
        # hard coding?
        buffer[60:60 + 4] = int(64).to_bytes(4, byteorder='little')
Exemplo n.º 2
0
    def generatePreviews(parameters, images, outputDirectory, baseName):
        assert(type(parameters) == list)
        assert(type(images) == list)
        assert(type(outputDirectory) == str)
        assert(type(baseName) == str)

        logging.debug("Generating previews...")

        states = Parser.getPreviewStates(outputDirectory)
        logging.debug("Generating states done...")
        staticPreview = PreviewGenerator.createImage(parameters, images, WatchState())
        logging.debug("Generating static preview gen done...")
        staticPreview.save(os.path.join(outputDirectory, f"{baseName}_static.png"))

        # generate small preview image for Preview section.
        from PIL import Image
        new_w, new_h = Config.getPreviewWidth(), Config.getPreviewHeight()
        im_resized = staticPreview.resize((new_w, new_h), resample = Image.LANCZOS)
        im_resized.save(os.path.join(outputDirectory, f"{baseName}_static_{Config.getPreviewWidth()}.png"))
        logging.debug("Generating static preview save done...")

        previewImages = PreviewGenerator.createAnimation(parameters, images, states)
        logging.debug("Generating anim preview gen done...")

        images = []
        for previewImage in previewImages:
            images.append(previewImage)
        images[0].save(os.path.join(outputDirectory, f"{baseName}_animated.gif"),
            save_all=True,
            append_images=images[1:],
            duration=1000,
            loop=0)
Exemplo n.º 3
0
    def createFrame(watchFace, resources, state):
        from PIL import Image, ImageDraw

        # graphics = Image.new('RGBA', (360, 360))
        graphics = Image.new('RGBA',
                             (Config.getImageWidth(), Config.getImageHeight()))
        watchFace.draw3(graphics, resources, state)
        return graphics
Exemplo n.º 4
0
 def draw2x(self, drawer, images, angle, center):
     x = self._x
     y = self._y
     if angle is None:
         temp = images[self._imageIndex].getBitmap()
         drawer.paste(temp, (center.getX() + x, center.getY() + y), temp)
     else:
         bitmap = images[self._imageIndex].getBitmap()
         from PIL import Image
         # temp = Image.new('RGBA', (360, 360))
         # temp.paste(bitmap, (180 - x, 180 - y), bitmap)
         temp = Image.new('RGBA',
                          (Config.getImageWidth(), Config.getImageHeight()))
         temp.paste(bitmap, (Config.getImageWidthHalf() - x,
                             Config.getImageHeightHalf() - y), bitmap)
         temp = temp.rotate(angle)
         drawer.paste(temp, (center.getX() + 0, center.getY() + 0), temp)
Exemplo n.º 5
0
 def draw2(self, drawer, images, angle):
     x = self._x
     y = self._y
     if angle is None:
         temp = images[self._imageIndex].getBitmap()
         drawer.paste(temp, (x, y), temp)
     else:
         bitmap = images[self._imageIndex].getBitmap()
         from PIL import Image
         # temp = Image.new('RGBA', (360, 360))
         # temp.paste(bitmap, (180 - x, 180 - y), bitmap)
         temp = Image.new('RGBA',
                          (Config.getImageSize(), Config.getImageSize()))
         temp.paste(
             bitmap,
             (Config.getImageSizeHalf() - x, Config.getImageSizeHalf() - y),
             bitmap)
         temp = temp.rotate(angle)
         drawer.paste(temp, (0, 0), temp)
    def draw2(self, drawer, images, angle, center=None):
        x = self._x
        y = self._y
        if angle is None:
            temp = images[self._imageIndex].getBitmap()
            drawer.paste(temp, (x, y), temp)
        else:
            bitmap = images[self._imageIndex].getBitmap()
            from PIL import Image

            temp = Image.new('RGBA', Config.getImageSize())
            temp.paste(bitmap, (Config.getImageSizeHalf()[0] - x,
                                Config.getImageSizeHalf()[1] - y), bitmap)
            temp = temp.rotate(angle)

            if center is None:
                drawer.paste(temp, (0, 0), temp)
            else:
                drawer.paste(temp, (center.getX(), center.getY()), temp)
Exemplo n.º 7
0
 def hackBuffer(self, index, buffer):
     data_0x10 = {
         1 : [0x20, 0x00, 0x6e, 0xea, 0x00, 0x00, 0x01, 0xbc],
         2 : [0x20, 0x00, 0x6d, 0xea, 0x00, 0x00, 0x81, 0x77],
         3 : [0x20, 0x00, 0x6a, 0xea, 0x00, 0x00, 0xb1, 0xf3],
         4 : [0x20, 0x00, 0x69, 0xea, 0x00, 0x00, 0x74, 0xfa],
         5 : [0x20, 0x00, 0x6b, 0xea, 0x00, 0x00, 0x7c, 0x3e],
         6 : [0x20, 0x00, 0x6f, 0xea, 0x00, 0x00, 0x14, 0xde],
         7 : [0x20, 0x00, 0x70, 0xea, 0x00, 0x00, 0x35, 0xa1],
         8 : [0x20, 0x00, 0x6c, 0xea, 0x00, 0x00, 0x3f, 0x2c],
         9 : [0x28, 0x00, 0x8c, 0xea, 0x00, 0x00, 0x01, 0xbc], # gtr only (by manelto)
         # from https://github.com/amazfitbip/py_amazfit_tools
         40 : [0x2e, 0x00, 0xaa, 0xeb, 0x00, 0x00, 0x68, 0xf1], #gts 0xaa, 0x68, 0xf1 may vary
     }
     if Config.isGtrMode():
         index = 9
     if Config.isGtsMode():
         index = 40
     p_0x10 = data_0x10[index]
     for i in range(len(p_0x10)):
         buffer[0x10 + i] = p_0x10[i]
     # hard coding?
     buffer[60:60+4] = int(64).to_bytes(4, byteorder='little')
Exemplo n.º 8
0
 def hackBuffer(self, index, buffer):
     data_0x10 = {
         1: [0x20, 0x00, 0x6e, 0xea, 0x00, 0x00, 0x01, 0xbc],
         2: [0x20, 0x00, 0x6d, 0xea, 0x00, 0x00, 0x81, 0x77],
         3: [0x20, 0x00, 0x6a, 0xea, 0x00, 0x00, 0xb1, 0xf3],
         4: [0x20, 0x00, 0x69, 0xea, 0x00, 0x00, 0x74, 0xfa],
         5: [0x20, 0x00, 0x6b, 0xea, 0x00, 0x00, 0x7c, 0x3e],
         6: [0x20, 0x00, 0x6f, 0xea, 0x00, 0x00, 0x14, 0xde],
         7: [0x20, 0x00, 0x70, 0xea, 0x00, 0x00, 0x35, 0xa1],
         8: [0x20, 0x00, 0x6c, 0xea, 0x00, 0x00, 0x3f, 0x2c],
         9: [0x28, 0x00, 0x8c, 0xea, 0x00, 0x00, 0x01,
             0xbc],  # gtr only (by manelto)
     }
     if Config.isGtrMode():
         index = 9
     p_0x10 = data_0x10[index]
     for i in range(len(p_0x10)):
         buffer[0x10 + i] = p_0x10[i]
     # hard coding?
     buffer[60:60 + 4] = int(64).to_bytes(4, byteorder='little')
Exemplo n.º 9
0
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--gts',
                        action='store_true',
                        help='force GTS watchface')
    parser.add_argument('--gtr',
                        action='store_true',
                        help='force GTR watchface')
    parser.add_argument(
        'filename',
        nargs='+',
        help='''watchface.bin - unpacks watchface images and config
    watchface.json - packs config and referenced images to bin file''')
    args = parser.parse_args()

    Config.setGtrMode(args.gtr)
    Config.setGtsMode(args.gts)

    for inputFileName in args.filename:
        isDirectory = os.path.isdir(inputFileName)
        isFile = os.path.isfile(inputFileName)
        if not isDirectory and not isFile:
            print("File or direcotry %s doesn't exists." % (inputFileName, ))
            continue
        if isDirectory:
            print("Not supported yet.")
            sys.exit(1)
        _, inputFileExtension = os.path.splitext(inputFileName)
        try:
            import program
            if inputFileExtension == '.bin':