def test(): color = divoom_image.BMP_BLUE SYMBOL = "BTCUSDT" json_url = urllib.urlopen("https://www.binance.com/api/v3/ticker/24hr?symbol="+SYMBOL) data = json.loads(json_url.read()) if float(data["priceChange"]) < 0: arrow = u"\u2193" color = divoom_image.BMP_RED elif float(data["priceChange"]) == 0: arrow = u"\u2194" else: arrow = u"\u2191" color = divoom_image.BMP_GREEN TEXT = arrow+str(int(round(float(data["lastPrice"])))) img = divoom_image.draw_text_to_image(text=TEXT, color=color, size=(70, 10)) sliced_images = divoom_image.horizontal_slices(img) # create divoom packages raw_data_packages = [] # thing.create_off_package() #brightness for img in sliced_images: raw_data_packages.append(divoom_image.to_divoom_data(img)) # create BT divoom packages pkgs = thing.create_animation_packages(raw_data_packages, 1) for i in range(0, len(pkgs)): dev.send(pkgs[i])
def draw_text(self, text="HELLO WORLD"): img = divoom_image.draw_text_to_image(text=text, color=divoom_image.BMP_YELLOW, size=(70, 10)) sliced_images = divoom_image.horizontal_slices(img) # create divoom packages raw_data_packages = [] for img in sliced_images: raw_data_packages.append(divoom_image.to_divoom_data(img)) # create BT divoom packages pkgs = self.protocol.create_animation_packages(raw_data_packages, 1) for i in range(0, len(pkgs)): self.device.send(pkgs[i])
def hello_world(): img = divoom_image.draw_text_to_image(text="HELLO WORLD", color=divoom_image.BMP_YELLOW, size=(70, 10)) sliced_images = divoom_image.horizontal_slices(img) # create divoom packages raw_data_packages = [] for img in sliced_images: raw_data_packages.append(divoom_image.to_divoom_data(img)) # create BT divoom packages pkgs = thing.create_animation_packages(raw_data_packages, 1) for i in range(0, len(pkgs)): dev.send(pkgs[i])