Exemple #1
0
    if delta < 0.0:
        tau = 3.0
    else:
        tau = 20.0

    nv = delta / tau + old

    if nv < 0.01:
        nv = 0.01
    elif nv > 0.99:
        nv = 0.99

    #if (nv > off_threshold/10.) and (nv < on_threshold):
    #    print("{:0.2f}".format(nv))

    graph.value = nv

    last_st = st
    if nv < old and nv < off_threshold:
        st = 0
    elif nv > old and nv > on_threshold:
        st = 1
    if last_st != st:
        print("[" + str(datetime.datetime.now()) + "] UTC. Input = " +
              "{:0.2f}".format(nv) + "% Generator is " + ["ON", "OFF"][st])
        body = "generator is " + ["ON", "OFF"][st]
        send_sms(os.environ['DFM_CELL'], body)
        send_sms(os.environ['LRM_CELL'], body)

    sleep(0.2)
    old = nv
Exemple #2
0
# This import needs to be first
from __future__ import division  # required for python 2 import
from gpiozero import LEDBarGraph
from time import sleep

# Create a graph object
graph = LEDBarGraph(5, 6, 13, 19, 26, 21)
# graph = LEDBarGraph(5, 6, 13, 19, 26, 21, pwm=True)
# Allows for more precise values for LED's
graph.value = 1  # (1, 1, 1, 1, 1, 1) all are ones or on
sleep(1)
graph.value = 1 / 2  # (1, 1, 1, 0, 0, 0)
sleep(1)
graph.value = -1 / 2  # ( 0, 0, 0, 1, 1, 1)
sleep(1)
graph.value = 1 / 4  # (1, 0, 0, 0, 0, 0)
sleep(1)
graph.value = -1  # (1, 1, 1, 1, 1, 1) all are ones or LEDs are on
from gpiozero import LEDBarGraph
from time import sleep
import requests


# Connect 30mA LEDs with 47 ohm resistors
# Connect anodes to all of the GPIOs listed below
leds = LEDBarGraph(17, 18, 27, 22, 23, 24, 10, 25, 9, 11)
url = "http://api.open-notify.org/astros.json"

while True:
    r = requests.get(url)
    data = r.json()
    people = data['number']
    print(people)
    leds.value = people/10
    sleep(1)


Exemple #4
0
from gpiozero import LEDBarGraph
from time import sleep
from __future__ import division  # required for python 2

graph = LEDBarGraph(5, 6, 13, 19, 26, pwm=True)

graph.value = 1 / 10  # (0.5, 0, 0, 0, 0)
sleep(1)
graph.value = 3 / 10  # (1, 0.5, 0, 0, 0)
sleep(1)
graph.value = -3 / 10  # (0, 0, 0, 0.5, 1)
sleep(1)
graph.value = 9 / 10  # (1, 1, 1, 1, 0.5)
sleep(1)
graph.value = 95 / 100  # (1, 1, 1, 1, 0.75)
sleep(1)
Exemple #5
0
from gpiozero import LEDBarGraph
from time import sleep

graph = LEDBarGraph(17, 27, 22, 5, 6, pwm=True)
while (True):
    graph.value = 0
    sleep(.1)
    graph.value = 2 / 10  # (0.5, 0, 0, 0, 0)
    sleep(.1)
    graph.value = 4 / 10  # (1, 0.5, 0, 0, 0)
    sleep(.1)
    graph.value = 6 / 10  # (0, 0, 0, 0.5, 1)
    sleep(.1)
    graph.value = 8 / 10  # (1, 1, 1, 1, 0.5)
    sleep(.1)
    graph.value = 1  # (1, 1, 1, 1, 0.75)
    sleep(.1)
from gpiozero import LEDBarGraph
from time import sleep
from __future__ import division  # required for python 2

graph = LEDBarGraph(5, 6, 13, 19, 26, pwm=True)

graph.value = 1/10  # (0.5, 0, 0, 0, 0)
sleep(1)
graph.value = 3/10  # (1, 0.5, 0, 0, 0)
sleep(1)
graph.value = -3/10  # (0, 0, 0, 0.5, 1)
sleep(1)
graph.value = 9/10  # (1, 1, 1, 1, 0.5)
sleep(1)
graph.value = 95/100  # (1, 1, 1, 1, 0.75)
sleep(1)
Exemple #7
0
from gpiozero import LEDBarGraph
from time import sleep

graph = LEDBarGraph(26, 19, 13, 6, 5, pwm=True)

graph.value = 1 / 10
sleep(1)
graph.value = 3 / 10
sleep(1)
graph.value = -3 / 10
sleep(1)
graph.value = 9 / 10
sleep(1)
graph.value = 95 / 100
sleep(1)
graph.value = 0
Exemple #8
0
        while 'STORAGE' not in j.text:
            print(j.text)
            print('no data')
            wait = 30
            while wait > 0:
                print(wait)
                time.sleep(1)
                wait -= 1
            j = r.get(u, timeout=10)
        t = j.json()['siteCurrentPowerFlow']['STORAGE']

        c = int(t['chargeLevel'])

        # output selection control structure, tuple addressing

        graph.value = c / 100

        wait = 900
        while wait > 0:
            try:
                print(wait)
                time.sleep(1)
                wait -= 1
            except KeyboardInterrupt:
                graph.close()
                sys.exit()
    except requests.packages.urllib3.exceptions.NewConnectionError:
        print('urk')
    except requests.exceptions.ConnectionError:
        print('-e-r-r-o-r-')
    except requests.exceptions.ReadTimeout:
Exemple #9
0
from gpiozero import LEDBarGraph
from time import sleep

graph = LEDBarGraph(5, 6, 13, 19, 26, 20)
''' in LEDBarGraph, we can give values like 1/2 and half the LEDs glow.
That is not possible in LED board. In LED Board, we need to give individual values'''

while True:
    graph.value = 1  #(1,1,1,1,1,1)
    sleep(1)
    graph.value = 1 / 2  #(1,1,1,0,0,0)
    sleep(1)
    graph.value = -1 / 2  #(0,0,0,1,1,1)
    sleep(1)
    graph.value = 1 / 4  #(1,0,0,0,0,0)
    sleep(1)
    graph.value = -1 / 4  #(0,0,0,0,0,1)
    sleep(1)
    graph.value = -1  #(1,1,1,1,1,1)
    sleep(1)
    graph.value = 0  #(0,0,0,0,0,0,0)
    sleep(1)
Exemple #10
0
from gpiozero import MCP3008, LEDBarGraph
from time import sleep

def convert_temp(gen):
    for value in gen:
        yield (value * 3.3 - 0.5) * 100

adc = MCP3008(channel=7)
graph = LEDBarGraph (26, 19, 13, 6, 5, pwm=True)

for temp in convert_temp(adc.values):
    bars = temp / 35
    graph.value = bars
    sleep(1)


Exemple #11
0
#!/usr/bin/python3

#import gpiozero
from gpiozero import LEDBarGraph, LED, Button
from time import sleep

GPIO_led_R = 14
GPIO_led_Y = 15
GPIO_led_G = 4
GPIO_led_B = 17
GPIO_btn_B = 18

graph = LEDBarGraph(GPIO_led_R, GPIO_led_Y, GPIO_led_G, pwm=True)

mtrSts = LED(GPIO_led_B)

mtrSts.on()

graph.value = 0
print("Graph off.  Waiting 5 seconds...")
sleep(5)
print("Graphing")

for i in range(0, 100, 5):
    graph.value = i / 100
    print("i=", i)
    mtrSts.toggle()
    sleep(1)
Exemple #12
0
#!/usr/bin/python3

from gpiozero import LEDBarGraph
from time import sleep

graph = LEDBarGraph(4, 17, 22, 5, 13, 26)

graph.value = 1
sleep(1)
graph.value = 1 / 2
sleep(1)
graph.value = -1 / 2
sleep(1)
graph.value = 1 / 4
sleep(1)
graph.value = -1
sleep(1)