Esempio n. 1
0
    def write(self, text=None, line=1, cursor=0, truncate=True, center=False):
        """
        Function to write text to the LCD Screen.

        Parameters
        ----------
        text : str
            String to be written to the screen.
        line : int, optional
            Line number to write to (default: 1)
        cursor : int, optional
            The cursor position to start at (default: 0)
        truncate : bool, optional
            Boolean flag to indicate whether to truncate the line or not
            (default: True)
        center : bool, optional
            Boolean flag to indicate whether to center the line or not
            (default: False)
        """
        # Force the text to be a string
        # [X] I couldn't find a way to test this variable without making it
        # a variable of the class, look into a way to not have to do
        # this as it's not necessary
        self.text = str(text)

        # If the truncate flag is set and the length of the text is
        # longer than 16 characters then cut it down to size
        if len(self.text) > 16 and truncate:
            self.text = self.text[:16]

        if center:
            self.text = self.text.center(16)

        lcd.set_cursor_position(cursor, line)
        lcd.write(self.text)
Esempio n. 2
0
def showNodeMetrics():
  # Get usage metrics from raw API call to /apis/metrics.k8s.io/v1beta1/nodes
  api_client = client.ApiClient()
  raw_resp = api_client.call_api('/apis/metrics.k8s.io/v1beta1/nodes/', 'GET', _preload_content=False)
  # Crazy conversion required, dunno why this is so hard
  response_metrics = json.loads(raw_resp[0].data.decode('utf-8'))  

  # Call list Nodes
  nodes = v1.list_node()
  count = 0
  for node in nodes.items:
    if count > 2: break
    # Get name and cpu/mem capacity 
    name = node.metadata.name
    mem_capacity = utils.parse_quantity(node.status.allocatable["memory"])
    cpu_capacity = utils.parse_quantity(node.status.allocatable["cpu"])

    # Search node metrics we grabbed before keyed on node name
    node_metrics = next(n for n in response_metrics["items"] if n["metadata"]["name"] == name)
    mem_usage = utils.parse_quantity(node_metrics["usage"]["memory"])
    cpu_usage = utils.parse_quantity(node_metrics["usage"]["cpu"])

    cpu_perc = round((cpu_usage/cpu_capacity)*100)
    mem_perc = round((mem_usage/mem_capacity)*100) 

    lcd.set_cursor_position(7, count)
    lcd.write(f"{cpu_perc: 3}%")
    lcd.set_cursor_position(12, count)
    lcd.write(f"{mem_perc: 3}%")    
    count = count + 1
def showWelcomeMessage():
    lcd.clear()
    lcd.set_cursor_position(0,0)
    lcd.write("Welcome!")
    lcd.set_cursor_position(0,1)
    lcd.write("FruityWiFi " +  __FRUITYWIFI__)
    time.sleep(2)
def temperatures():
#--------------------------------
    #TEMPERATURE AMBIANTE
    lcd.clear()                             #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(0,0)            #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Temp Ambiante:")             #Affichage du String entre guillemet

    
    lcd.set_cursor_position(0,1)            #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(str(climat_now))              #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable
#--------------------------------
    time.sleep(5)
#--------------------------------
    #TEMPERATURE MIN & MAX

    lcd.clear()                         #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(0,0)        #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Temp MIN/MAX:")          #Affichage du String entre guillemet

    
    lcd.set_cursor_position(0,1)    #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(str(climat_min))      #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable

    lcd.set_cursor_position(0,2)    #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(str(climat_max))      #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable
Esempio n. 5
0
	def redraw(self, menu):
		lcd.clear()
		lcd.set_cursor_position(3,1)
		lcd.write("Bye (^_^)/")
		for x in reversed(range(127)):
			backlight.rgb(0, x * 2, 0)
		lcd.clear()
		sys.exit(0)
Esempio n. 6
0
def lcdInfo(lcdMessage, line, rgb=""):

    lcd.set_cursor_position(0, line)
    lcd.write(lcdMessage)
    if rgb == "red":
        backlight.rgb(200, 0, 0)
    if rgb == "green":
        backlight.rgb(0, 200, 0)
 def redraw(self, menu):
     print "Bye ;)"
     lcd.clear()
     lcd.set_cursor_position(4, 1)
     lcd.write("Bye Bye!")
     time.sleep(2)
     lcd.clear()
     backlight.rgb(0, 0, 0)
     sys.exit()
Esempio n. 8
0
def printNodes():
  nodes = v1.list_node()
  count = 0
  for node in nodes.items:
    if count > 2: break
    name = node.metadata.name
    lcd.set_cursor_position(0, count)
    lcd.write(name+":")
    count = count + 1
    def redraw(self, menu):
        print "Bye ;)"
	lcd.clear()
	lcd.set_cursor_position(4,1)
	lcd.write("Bye Bye!")
	time.sleep(2)
	lcd.clear()
	backlight.rgb(0,0,0)
	sys.exit()
def Taux_Humidite():
    #Taux d'Humidité présent dans l'Environnement actuel
    #--------------------------------
    lcd.clear()                                 #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(0,0)                #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Taux d'Humidite")                #Affichage du String entre guillemet

    lcd.set_cursor_position(0,1)                #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(str(pourcentage_humidite))        #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable  
def Vitesse_du_vent():
    #Vitesse du Vent
    #--------------------------------
    lcd.clear()                                 #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(0,0)                #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Vitesse Vent m/s")               #Affichage du String entre guillemet

    lcd.set_cursor_position(0,1)                #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(str(vitesse_du_vent))             #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable    
def Taux_de_Nuage():
    #Taux de Nuages présent dans le ciel
    #--------------------------------
    lcd.clear()                                 #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(0,0)                #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Taux Nuage")                     #Affichage du String entre guillemet

    lcd.set_cursor_position(0,1)                #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(str(couverture_de_nuage))         #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable  
Esempio n. 13
0
 def redraw(self, menu):
     lcd.clear()
     menu.write_option(row=0, text="About this App")
     menu.write_option(
         row=1,
         text=
         "Site: https://github.com/Floppynator/FruityDisplay_DisplayOTron3000",
         scroll=True)
     lcd.set_cursor_position(0, 2)
     lcd.write("Twitter: @HA1pe")
Esempio n. 14
0
def handle_down(pin):
    global loopcount
    loopcount = 0
    lcd.clear()
    backlight.rgb(255, 0, 0)
    lcd.write("Shutting Down!")
    time.sleep(1)
    os.system('systemctl poweroff')
    sys.exit()
    time.sleep(2)
Esempio n. 15
0
 def JobIsDone(self, localLcd):
     lcd.clear()
     backlight.rgb(255, 255, 255)
     localLcd.write('Job is Done!')
     for i in range(0, 100):
         backlight.set_graph((100 - i) / 100.0)
         time.sleep(0.05)
     backlight.update()
     lcd.clear()
     lcd.write('Ready for the   next job')
Esempio n. 16
0
def show_follower_count(pin):
    try:
        followers = twitter.follower_count()
        msg = "You have %-6i followers" % followers
    except:
        msg = "Twitter API     limit reached"

    backlight.sweep(random())
    lcd.clear()
    lcd.write(msg)
Esempio n. 17
0
def handle_down(pin):
    print("Down pressed!")    
    global image_num
    global reset_initiated

    if reset_initiated == False:
        reset_initiated = True
        print("first time")
    else:
        lcd.set_cursor_position(0, 0)
        lcd.write("SHUTTING DOWN   ")
        os.system("sudo shutdown now");
Esempio n. 18
0
def handle_down(pin):
    print("Down pressed!")
    global image_num
    global reset_initiated

    if reset_initiated == False:
        reset_initiated = True
        print("first time")
    else:
        lcd.set_cursor_position(0, 0)
        lcd.write("SHUTTING DOWN   ")
        os.system("sudo shutdown now")
def temps_systeme():
    system_time = temps_actuel()

    #Affichage DOT3K
    lcd.clear()  #Nettoyage de la Zone Affichable

    lcd.set_cursor_position(
        0, 0)  #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Temps/Time:")  #Affichage du String entre guillemet

    lcd.set_cursor_position(
        0, 1)  #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(system_time)
Esempio n. 20
0
    def on_print_progress(self, storage, path, progress):
        lcd.clear()
        start = path.rfind('/')
        end = path.rfind('.')
        # Just want the file name, no path or extension.
        # The rfind gets us the deepest directory so we can truncate that off the string
        # It also gets us the index of the file extension
        # The code below will substring any directories off the path, and remove the extention
        if (start == -1):
            start = 0
        if (end == -1):
            end = path.len() - 1
        lcd.write(path[start:end])
        backlight.set_graph(progress / 100.0)
        backlight.rgb(0, 0, 255)
        backlight.update()
        lcd.set_cursor_position(0, 1)
        lcd.write('Completed: ' + str(progress) + '%')

        if progress == 1:
            self.start_date = time.time()

        if progress > 10 and progress < 100:
            now = time.time()
            elapsed = now - self.start_date
            average = elapsed / (progress - 1)
            remaining = int((100 - progress) * average)
            remaining = str(datetime.timedelta(seconds=remaining))
            lcd.set_cursor_position(0, 2)
            lcd.write('ETC: ')
            lcd.write(remaining)

        if progress == 100:
            self.JobIsDone(lcd)
def affichage_numero():
    #--------------------------------
    #NUMEROS D'URGENCES INTERNATIONAUX
    lcd.clear()  #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(
        0, 0)  #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Numero Urgence:")  #Affichage du String entre guillemet

    lcd.set_cursor_position(
        0, 1)  #Positionnement du Curseur à la colonne 0 et ligne 1
    print(tel_urgence)
    lcd.write(
        str(tel_urgence)
    )  #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable
Esempio n. 22
0
def _message(code, credit_balance=None):
    message_lock.acquire()
    _message_output(code)
    lcd.clear()
    lcd.write(message_code[code])
    if credit_balance is not None:
        lcd.set_cursor_position(0,2)
        lcd.write(" ")
        lcd.write(balance)
        credit_balance_string = locale.format('%.2f', credit_balance, monetary=True)
        lcd.set_cursor_position(lcd.COLS-len(credit_balance_string)-1,2)
        lcd.write(credit_balance_string)
        lcd.write(" ")
    time.sleep(2.5)
    message_lock.release()
Esempio n. 23
0
	def animate(self):	
		self.get_messages()
		
		message_portion = self.message[self.message_position : self.message_position + self.display_width]
		message_portion = message_portion + " " * (self.display_width - len(message_portion))
		lcd.set_cursor_position(0, self.line)
		lcd.write(message_portion)
	
		if self.progress:
			self.message_position = self.message_position + 1
		
		self.progress = not self.progress
	
		if self.message_position >= len(self.message):
			self.message_position = 0
def loadingScreen():
    lcd.clear()
    
    # set brigthness 
    backlight.set_bar(0, 20)
    
    # write loading message to lcd
    lcd.set_cursor_position(3,1)
    lcd.write("Loading...")
    
    # fire up bargraph leds! Wohoo
    for i in range(100):
        backlight.set_graph(i / 70.0)
        time.sleep(0.005)
        
    # disable leds =(
    backlight.set_graph(0)
Esempio n. 25
0
	def handle_press (pin):
		global camera_running

		lcd.clear()
		lcd.write("Stopping camera...")
		backlight.rgb(0, 0, 0)
		sleep(0.5)
		print "Stopping camera..."
		camera_running = False

		camera.terminate()
		camera.join()

		lcd.clear()
		lcd.write("Camera stopped...")
		sleep(0.5)
		print "Camera stopped..."
Esempio n. 26
0
def handle_button(pin):
    print("Button pressed!")
    global image_num
    global reset_initiated
    global picture_waiting

    if picture_waiting!=True:
        picture_waiting = True
        image_num = image_num + 1
        camera.capture('image' + format(image_num,'03') + '.jpg')
        print 'image file: image' + format(image_num,'03') + '.jpg'

        lcd.set_cursor_position(13, 2)
        lcd.write(format(image_num,'03'))
        reset_initiated = False
        picture_waiting = False
    else:
        print 'waiting on image to return'
Esempio n. 27
0
def handle_button(pin):
    print("Button pressed!")
    global image_num
    global reset_initiated
    global picture_waiting

    if picture_waiting != True:
        picture_waiting = True
        image_num = image_num + 1
        camera.capture('image' + format(image_num, '03') + '.jpg')
        print 'image file: image' + format(image_num, '03') + '.jpg'

        lcd.set_cursor_position(13, 2)
        lcd.write(format(image_num, '03'))
        reset_initiated = False
        picture_waiting = False
    else:
        print 'waiting on image to return'
Esempio n. 28
0
def display_tweet(lcd, tweet, scroll_speed):
    """Displays a tweet as a scrolling marquee with its author's name
       written underneath."""

    # Remove '\n' characters because dot3k displays them wierdly!
    s = tweet.text.replace("\n", " ")

    # Append 16 spaces to the tweet for scrolling. This stops the
    # author's handle from spilling into the tweet.
    s += " " * 16
    lcd.clear()

    for i in range(0, len(s) - 16):
        lcd.write(s[i:i + 16])  # 16 = Width of Dot3k display in chars.

        # Add the author's handle below the tweet
        lcd.write("@" + tweet.author.screen_name)

        time.sleep(scroll_speed)
        lcd.clear()
def determination_dot3k():

    recup_affichage(
    )  #Demarrage du fichier python Recuperation_Determination.py
    global ville  #Déclaration de la variable GLOBAL 'ville'
    ville = determine_less(
    )  #L'information dtermine par un autre fichier python est stocker dans la variable pour être utiliser apès

    #Using the 'lcd.write' way
    lcd.clear()  #Nettoyage de la Zone Affichable

    lcd.set_cursor_position(
        0, 0)  #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Nous sommes ici:")  #Affichage du String entre guillemet

    lcd.set_cursor_position(
        0, 1)  #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(
        ville
    )  #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable
    def right(self):
	# fire cmd
	self.last_update = 1

        cmd = self.config.get('commands', self.cmds[self.selected_cmd])
        time.sleep(1)
	cmd = cmd.split(",")

	lcd.clear()
	lcd.set_cursor_position(0,0)
	lcd.write("Execute CMD")	
	lcd.set_cursor_position(0,1)
	lcd.write(cmd[0])
	time.sleep(1)
        
	# EXECUTE THIS COMMAND
        out = str(self.execCommand(cmd[1]))
        print(out)

	lcd.clear()
	lcd.set_cursor_position(6,1)
	lcd.write("Done.")
	time.sleep(1)
	lcd.clear()
	self.last_update = 0

	return True
    def right(self):
        # fire cmd
        self.last_update = 1

        cmd = self.config.get('commands', self.cmds[self.selected_cmd])
        time.sleep(1)
        cmd = cmd.split(",")

        lcd.clear()
        lcd.set_cursor_position(0, 0)
        lcd.write("Execute CMD")
        lcd.set_cursor_position(0, 1)
        lcd.write(cmd[0])
        time.sleep(1)

        # EXECUTE THIS COMMAND
        out = str(self.execCommand(cmd[1]))
        print(out)

        lcd.clear()
        lcd.set_cursor_position(6, 1)
        lcd.write("Done.")
        time.sleep(1)
        lcd.clear()
        self.last_update = 0

        return True
Esempio n. 32
0
def init_animation():
	hourglass = [
		[0x1F,0x11,0x11,0x11,0x11,0x11,0x11,0x1F],[0x1F,0x1F,0x11,0x11,0x11,0x11,0x11,0x1F],
		[0x1F,0x1F,0x1F,0x11,0x11,0x11,0x11,0x1F],[0x1F,0x1F,0x1F,0x1F,0x11,0x11,0x11,0x1F],
		[0x1F,0x11,0x1F,0x1F,0x1F,0x11,0x11,0x1F],[0x1F,0x11,0x11,0x1F,0x1F,0x1F,0x11,0x1F],
		[0x1F,0x11,0x11,0x11,0x1F,0x1F,0x1F,0x1F],[0x1F,0x11,0x11,0x11,0x11,0x1F,0x1F,0x1F],
		[0x1F,0x11,0x11,0x11,0x11,0x11,0x1F,0x1F],[0x1F,0x11,0x11,0x11,0x11,0x11,0x11,0x1F]
	]
	greetingtext = [
	#	"- - - - - - - - ",
		"     Welcome    ",
		"       To       ",
		"    Yuki-Chan   "
	]
	
	dotc = 0
	texti = 0
	for x in range(127):
		backlight.rgb(x / 2, x * 2, x / 2)
		"""
		lcd.create_char(0, getAnimFrame(hourglass, 5))
		lcd.clear()
		lcd.set_cursor_position(15,2)
		lcd.write(chr(0))
		"""
		lcd.set_cursor_position(0,1)
		lcd.write(greetingtext[texti])
		
		if dotc > 30:
			texti = (texti + 1) % len(greetingtext)
			dotc = 0
		else:
			dotc += 1
		
		lcd.set_cursor_position(6,2)
		for i in range(dotc / 10):
			lcd.write(".")

	lcd.clear()
Esempio n. 33
0
def idle():
    #if debug: print "Start idle function." 
    backlight.off()
    lcd.set_cursor_position(0,0)
    lcd.write(txt_security)
    lcd.set_cursor_position(4,1)
    t = datetime.now().strftime("%H:%M:%S")
    lcd.write(t)
    lcd.set_cursor_position(0,2)
    lcd.write(txt_pressme)
    time.sleep(0.5)
def display():
    forecast = darksky.Forecast(api_key, latitude, longitude, units=units)
    current = forecast.currently
    temp = current.temperature
    temp = str(temp)
    humidity = current.humidity * 100
    humidity = str(humidity)
    rain = current.precipProbability * 100
    rain = str(rain)
    uvIndex = current.uvIndex
    uv = str(uvIndex)
    if uvIndex <= 2.9:
        backlight.rgb(90, 148, 35)  # Green (low)
    elif (uvIndex >= 3) and (uvIndex <= 5.9):
        backlight.rgb(241, 227, 54)  # Yellow (moderate)
    elif (uvIndex >= 6) and (uvIndex <= 7.9):
        backlight.rgb(217, 90, 18)  # Orange (high)
    elif (uvIndex >= 8) and (uvIndex <= 10.9):
        backlight.rgb(185, 2, 34)  # Red (very high)
    else:
        backlight.rgb(99, 74, 195)  # Violet (extreme)
    try:
        lcd.clear()
        lcd.set_cursor_position(0, 0)
        print("Temperture: " + temp + " C")
        lcd.write("Temp: " + temp + "\xf2C")
        lcd.set_cursor_position(0, 1)
        print("Humidity: " + humidity + "%")
        lcd.write("Humidity: " + humidity + "%")
        lcd.set_cursor_position(0, 2)
        print("Rain: " + rain + "%")
        lcd.write("Rain: " + rain + "%")
        print("UV Index: " + uv + "")
    except:
        lcd.write("Connection Error")

    # Press the button on the joystick to exit
    @nav.on(nav.BUTTON)
    def handle_button(pin):
        lcd.clear()
        backlight.rgb(0, 0, 0)
        backlight.set_graph(0)
        os._exit(1)
def Volumes():
    #Volume de Neige (en m² ?)
    #--------------------------------
    lcd.clear()                                     #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(0,0)                    #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Volumes Neige/Pluie")                #Affichage du String entre guillemet

    lcd.set_cursor_position(0,1)            #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(volume_de_neige)              #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable

    lcd.set_cursor_position(0,2)         #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(str(volume_de_pluie))      #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable    
def condition_climatique():
    #Status de la Météo Actuel
    #--------------------------------
    lcd.clear()                                 #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(0,0)                #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Condition Meteo")                #Affichage du String entre guillemet

    lcd.set_cursor_position(0,1)            #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write("Actuel:")                    #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable

    lcd.set_cursor_position(0,2)            #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(status_climat)                #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable    
Esempio n. 37
0
    def printIt(self, message1="", message2="", message3=""):
        lcd.clear()
        message1 = self.validateMessage(message1)
        message2 = self.validateMessage(message2)
        message3 = self.validateMessage(message3)
        print "+".ljust(columns+1,"-")+"+"
        print "|"+message1+"|"
        print "|"+message2+"|"
        print "|"+message3+"|"
        print "+".ljust(columns+1,"-")+"+"
	lcd.write(message1)
	lcd.write(message2)
	lcd.write(message3)
def update_weather():
    payload = {
        'id': CITY_ID,
        'units': 'metric',
        'appid': API_KEY
    }
    global temp
    try:
        r = requests.get(url=url, params=payload)
        location = r.json().get('name')
        temp = r.json().get('main').get('temp')
        humidity = r.json().get('main').get('humidity')
        lcd.set_cursor_position(0, 0)
        print("City: "+str(location)+" ")
        lcd.write("City: "+str(location)+" ")
        lcd.set_cursor_position(0, 1)
        print("Temperture: "+str(temp)+"°C")
        lcd.write("Temp: "+str(temp)+"\xf2C")
        lcd.set_cursor_position(0, 2)
        print("Humidity: "+str(humidity)+" %")
        lcd.write("Humidity: "+str(humidity)+" %")
    except:
        lcd.write("Connection Error")
Esempio n. 39
0
    def redraw(self):
        volume = subprocess.check_output("mpc status | grep volume", shell=True, stderr=subprocess.STDOUT)
        volume = volume[7:volume.find("%")]

        lcd.clear()
        lcd.set_cursor_position(0, 0)
        lcd.write(self.channelName[self.selectedStation])

        lcd.set_cursor_position(0, 1)
        lcd.write(time.strftime("%d.%m. %H:%M:%S"))

        lcd.set_cursor_position(0, 2)
        lcd.write('Volume:' + volume + ' %')

        cpu = psutil.cpu_percent()
        backlight.set_graph(float(cpu) / 100.0)
Esempio n. 40
0
def showKubeDeploys():
  global deploy_index, deploy_max
  all_deploys = v1Apps.list_deployment_for_all_namespaces()

  deploy_max = 0
  deploys = []
  for deploy in all_deploys.items:
    if deploy.metadata.namespace != "kube-system": 
      deploys.append(deploy)

  deploy_max = len(deploys)
  lcd.set_cursor_position(0, 0)
  lcd.write(deploys[deploy_index].metadata.name[:16])
  lcd.set_cursor_position(0, 1)
  lcd.write(deploys[deploy_index].spec.template.spec.containers[0].image[:16])
  lcd.set_cursor_position(0, 2)
  lcd.write(f"replicas: {deploys[deploy_index].status.replicas}/{deploys[deploy_index].status.ready_replicas}")  
Esempio n. 41
0
def queries_thread():
    """Print pihole stats to the lcd"""

    lcd.clear()
    t = threading.currentThread()
    while getattr(t, "running", True):
        pihole = ph.PiHole("192.168.1.32")

        lcd.set_cursor_position(0, 0)
        lcd.write('{} queries'.format(pihole.queries))

        lcd.set_cursor_position(0, 1)
        lcd.write('{}% blocked'.format(pihole.ads_percentage))

        lcd.set_cursor_position(0, 2)
        lcd.write('{} total'.format(pihole.blocked))

        time.sleep(5)
Esempio n. 42
0
def neige_3h():
    #Prochainement de la Neige ?

    #--------------------------------
    lcd.clear()  #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(
        0, 0)  #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("Neige dans 3H?")  #Affichage du String entre guillemet

    if will_snow == True:  #Si il y a de la pluie alors...
        lcd.set_cursor_position(0, 1)
        lcd.write("Neige prevue")  #On affirme cela par un message

    elif will_snow == False:  #Sinon...
        lcd.set_cursor_position(
            0, 1)  #Positionnement du Curseur à la colonne 0 et ligne 1
        lcd.write(
            "Aucune Neige prevue"
        )  #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable
Esempio n. 43
0
def affichage_de_la_boussole_dot3k_2():
    #--------------------------------
    #BOUSSOLE 2/2
    lcd.clear()  #Nettoyage de la Zone Affichable
    lcd.set_cursor_position(
        0, 0)  #Positionnement du Curseur à la colonne 0 et ligne 0
    lcd.write("BOUSSOLE 2/2")  #Affichage du String entre guillemet

    lcd.set_cursor_position(
        0, 1)  #Positionnement du Curseur à la colonne 0 et ligne 1
    lcd.write(
        str(round_retourne_longitude)
    )  #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable

    lcd.set_cursor_position(
        0, 2)  #Positionnement du Curseur à la colonne 0 et ligne 2
    lcd.write(
        dir_Longitude_Hemisphere
    )  #Affichage de la valeur convertis de FLOAT à STRING via une valeur retourné qui a stocker dans une variable
Esempio n. 44
0
def handle_left(pin):
  print("Left pressed!")
  l.clear()
  b.rgb(0,0,255)
  l.write("Leftie left left!")
Esempio n. 45
0
#!/usr/bin/env python
print("""Testing DOT3K Interface...""")

import dot3k.lcd as lcd
import dot3k.backlight as backlight
import time
lcd.clear()
lcd.write("=DOT3K==========                ========loading=")
backlight.left_rgb(255, 0, 0)
time.sleep(0.3)
backlight.mid_rgb(255, 0, 0)
time.sleep(0.3)
backlight.right_rgb(255, 0, 0)
time.sleep(0.3)
backlight.left_rgb(255, 255, 0)
time.sleep(0.3)
backlight.mid_rgb(255, 255, 0)
time.sleep(0.3)
backlight.right_rgb(255, 255, 0)
time.sleep(0.3)
backlight.left_rgb(255, 255, 255)
time.sleep(0.3)
backlight.mid_rgb(255, 255, 255)
time.sleep(0.3)
backlight.right_rgb(255, 255, 255)
time.sleep(0.3)
lcd.clear()
lcd.write("=DOT3K==========                ==========ready=")
backlight.rgb(0, 0, 255)
time.sleep(0.1)
backlight.rgb(255, 255, 255)
Esempio n. 46
0
 def display_message(message):
     lcd.clear()
     lcd.write(message)
Esempio n. 47
0
#!/usr/bin/env python
import dot3k.lcd as lcd
import dot3k.backlight as backlight
import time, datetime, copy, math, psutil
import time
from datetime import datetime, timedelta


lcd.write(chr(0) + 'Yay LGBT Pride!')# + chr(0))
lcd.set_cursor_position(0,2)
lcd.write(' Party hrs left ')# + chr(3) + chr(2) + chr(5))

eqlchar = [
	[0x0,0x1f,0x1f,0x0,0x0,0x1f,0x1f,0x0], #=
	[0x0,0x0,0x1f,0x1f,0x0,0x0,0x1f,0x1f], #= move
	[0x0,0x1f,0x1f,0x0,0x0,0x1f,0x1f,0x0], #= move
	[0x1f,0x1f,0x0,0x0,0x1f,0x1f,0x0,0x0], #= move
	[0x1f,0x1f,0x1b,0x1b,0x1f,0x1f,0x18,0x18], #P
	[0x1f,0x1f,0x1b,0x1b,0x1f,0x1f,0x1a,0x19], #R
	[0x1f,0x1f,0xe,0xe,0xe,0xe,0x1f,0x1f], #I
	[0x1e,0x1f,0x1b,0x1b,0x1b,0x1b,0x1f,0x1e], #D
	[0x1f,0x1f,0x18,0x1e,0x1e,0x18,0x1f,0x1f] #E
] #WHADDOESTHATSPELL??  Pride!

def getAnimFrame(char,fps):
	return char[ int(round(time.time()*fps) % len(char)) ]

cpu_sample_count = 200
cpu_samples = [0] * cpu_sample_count
hue = 0.0
while True:
             backlight.set_graph(0.0)
         
         sys.exit()
     elif command == 'reset':
         lcd.clear()
         backlight.off()
         backlight.set_graph(0.0)
 elif component == 'LCD':
     if command == 'clear':
         lcd.clear()
     elif command == 'setContrast':
         lcd.set_contrast(parameters['contrast'])
     elif command == 'setCursorPosition':
         lcd.set_cursor_position(parameters['column'], parameters['row'])
     elif command == 'write':
         lcd.write(parameters['value'])
     elif command == 'createCharacter':
         lcd.create_char(parameters['memoryPosition'], parameters['map'])
     elif command == 'writeCharacter':
         lcd.write(chr(parameters['memoryPosition']))
 elif component == 'Backlight':
     if command == 'turnOff':
         backlight.off()
     elif command == 'useRBGMode':
         backlight.use_rbg()
     elif command == 'setBrightnessOfLed':
         backlight.set(parameters['ledIndex'], parameters['brightness'])
     elif command == 'setToHue':
         backlight.hue(parameters['hue'])
     elif command == 'setLeftToHue':
         backlight.left_hue(parameters['hue'])
    def redraw(self, menu):
        lcd.clear()
	menu.write_option(row=0, text="About this App")
        menu.write_option(row=1, text="Site: https://github.com/Floppynator/FruityDisplay_DisplayOTron3000", scroll=True)
	lcd.set_cursor_position(0,2)	
	lcd.write("Twitter: @HA1pe")
Esempio n. 50
0
def shutdown_animation():
	lcd.set_cursor_position(3,1)
	lcd.write("Bye (^_^)/")
	for x in reversed(range(127)):
		backlight.rgb(x, x * 2, x)
	lcd.clear()
Esempio n. 51
0
print datetime.datetime.now().strftime('%b %d, %G %I:%M%p--'), "Started proc_animation"


print datetime.datetime.now().strftime('%b %d, %G %I:%M%p--'), "Init control, running..."

try:
	@joystick.on(joystick.BUTTON)
	def handle_press (pin):
		global camera_running

		lcd.clear()
		lcd.write("Stopping camera...")
		backlight.rgb(0, 0, 0)
		sleep(0.5)
		print "Stopping camera..."
		camera_running = False

		camera.terminate()
		camera.join()

		lcd.clear()
		lcd.write("Camera stopped...")
		sleep(0.5)
		print "Camera stopped..."

	lcd.write('Running!')
except:
	pass

thread_control(d)
Esempio n. 52
0
import dot3k.backlight as backlight 
import time
from threading import Thread

pirate = [
        [0x00,0x1f,0x0b,0x03,0x00,0x04,0x11,0x1f],
        [0x00,0x1f,0x16,0x06,0x00,0x08,0x03,0x1e],
        [0x00,0x1f,0x0b,0x03,0x00,0x04,0x11,0x1f],
        [0x00,0x1f,0x05,0x01,0x00,0x02,0x08,0x07]
]

def get_anim_frame(anim, fps):
  return anim[ int(round(time.time()*fps) % len(anim)) ]

lcd.set_cursor_position(1,0)
lcd.write('Display-o-tron')
lcd.write('      ' + chr(0) + '3000  ')
lcd.create_char(0,get_anim_frame(pirate,4))



while 1:
  backlight.rgb(255,0,0)
  time.sleep(1)
  backlight.rgb(0,255,0)
  time.sleep(1)
  backlight.rgb(0,0,255)
  time.sleep(1)
  backlight.rgb(255,255,255)
  time.sleep(1)
  for i in range(0,360):
Esempio n. 53
0
#!/usr/bin/env python
print("""
This example shows you how to create animations on Display-o-Tron!
You should see a collection of animated icons on your display.

Press CTRL+C to exit.
""")

import dot3k.lcd as lcd
import dot3k.backlight as backlight
import time, datetime, copy, math, psutil

lcd.write(chr(0) + 'Ooo! Such time' + chr(0))
lcd.set_cursor_position(0, 2)
lcd.write(chr(1) + chr(4) + ' Very Wow! ' + chr(3) + chr(2) + chr(5))

pirate = [
    [0x00, 0x1f, 0x0b, 0x03, 0x00, 0x04, 0x11, 0x1f],
    [0x00, 0x1f, 0x16, 0x06, 0x00, 0x08, 0x03, 0x1e],
    [0x00, 0x1f, 0x0b, 0x03, 0x00, 0x04, 0x11, 0x1f],
    [0x00, 0x1f, 0x05, 0x01, 0x00, 0x02, 0x08, 0x07]
]

heart = [
    [0x00, 0x0a, 0x1f, 0x1f, 0x1f, 0x0e, 0x04, 0x00],
    [0x00, 0x00, 0x0a, 0x0e, 0x0e, 0x04, 0x00, 0x00],
    [0x00, 0x00, 0x00, 0x0e, 0x04, 0x00, 0x00, 0x00],
    [0x00, 0x00, 0x0a, 0x0e, 0x0e, 0x04, 0x00, 0x00]
]

raa = [
Esempio n. 54
0
def handle_down(pin):
  print("Down pressed!")
  l.clear()
  b.rgb(0,255,0)
  l.write("Down down doobie down!")
Esempio n. 55
0
def handle_button(pin):
  print("Button pressed!")
  l.clear()
  b.rgb(255,255,255)
  l.write("Ouch!")
Esempio n. 56
0
def handle_up(pin):
  print("Up pressed!")
  l.clear()
  b.rgb(255,0,0)
  l.write("Up up and away!")
Esempio n. 57
0
def handle_right(pin):
  print("Right pressed!")
  l.clear()
  b.rgb(0,255,255)
  l.write("Rightie tighty!")
Esempio n. 58
0
#!/usr/bin/env python

import dot3k.lcd as lcd
import dot3k.backlight as backlight
import time

# Clear the LCD and display Hello World
lcd.clear()
lcd.write("Hello World")

# Turn off the backlight
backlight.rgb(0,0,0)

"""
set_graph accepts a float between 0.0 and 1.0
and lights up the LEDs accordingly
"""
for i in range(100):
    backlight.set_graph(i/100.0)
    time.sleep(0.05)

"""
set_bar will set a specific bargraph LED to
a brightness between 0 and 255
"""
for i in range(256):
    backlight.set_bar(0,[255-i]*9)
    time.sleep(0.01)

backlight.set_graph(0)
Esempio n. 59
0
def temp_light(temperature):
    scale = set_temp - 20
    if temperature < 20:
        return [0,0,255]
    else:
        temp_difference = set_temp - temperature
        backlight_colour = int((scale - temp_difference)*(255/scale))
        return [(0 + backlight_colour), 0 , (255 - backlight_colour)]

@joystick.on(joystick.UP)
def handle_up(pin):
    global set_temp
    set_temp += 1

@joystick.on(joystick.DOWN)
def handle_down(pin):
    global set_temp
    set_temp -= 1
    
while True:
    temperature = read_temp()
    lcd_text = "Water temp: " + str(round(temperature, 1)) + "Set temp: " + str(set_temp)
    lcd.clear()
    lcd.write(lcd_text)
    rgb_colours = temp_light(temperature)
    backlight.rgb(rgb_colours[0], rgb_colours[1], rgb_colours[2])
    if temperature >= set_temp:
        bz.on()
    time.sleep(0.5)