Example #1
0
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])
Example #3
0
 def show_text(self, txt, speed=20, font=None):
     """
       Display text & scroll, call is blocking
     """
     if (type(txt) is not list) or (len(txt)==0) or (type(txt[0]) is not tuple):
         raise Exception("a list of tuple is expected")
     im = draw_multiple_to_image(txt, font)
     slices = horizontal_slices(im)
     for i, s in enumerate(slices):
         #s.save("./debug/%s.bmp"%i)
         self.set_static_image(build_img(s))
         time.sleep(1.0/speed)
Example #4
0
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])
Example #5
0
 def show_text2(self, txt, font=None):
     """
     Use dynamic_image_message to display scolling text
     Cannot go faster than 1fps
     """
     if (type(txt) is not list) or (len(txt)==0) or (type(txt[0]) is not tuple):
         raise Exception("a list of tuple is expected")
     imgs = []
     im = divoom_image.draw_multiple_to_image(txt, font)
     slices = horizontal_slices(im)
     for i, s in enumerate(slices):
         # s.save("./debug/%s.bmp"%i)
         imgs.append(build_img(s))
     print len(imgs)
     self.set_dynamic_images(imgs)