Ejemplo n.º 1
0
    def load(self, host="localhost", port=6499):
        print "Tuner.load " + str(port)

        # Calibrate page
        self.calibrate = Calibrate(changefunc=self.onChange,
                                   host=host,
                                   port=port)
        self.tabs.addTab(self.calibrate.get_widget(), "Calibrate")

        # Preflight page
        self.preflight = Preflight(changefunc=self.onChange,
                                   host=host,
                                   port=port)
        self.tabs.addTab(self.preflight.get_widget(), "Preflight")

        # Launch page
        self.launch = Launch(changefunc=self.onChange, host=host, port=port)
        self.tabs.addTab(self.launch.get_widget(), "Launch")

        # Circle hold page
        self.circle = Circle(changefunc=self.onChange, host=host, port=port)
        self.tabs.addTab(self.circle.get_widget(), "Circle")

        # Chirp page
        self.chirp = Chirp(changefunc=self.onChange, host=host, port=port)
        self.tabs.addTab(self.chirp.get_widget(), "Chirp")

        # Land page
        self.land = Land(changefunc=self.onChange, host=host, port=port)
        self.tabs.addTab(self.land.get_widget(), "Land")
Ejemplo n.º 2
0
def get_output(mode, guide_tolerance, guide_delay):
    guide = None
    # guide_tolerance = 0.15
    # guide_delay = 0
    if mode == "speaker":
        guide = Speaker(tolerance=guide_tolerance, delay=guide_delay)
    elif mode == "beeper":
        guide = Beeper(tolerance=guide_tolerance, delay=guide_delay)
    elif mode == "chirp":
        guide = Chirp(tolerance=guide_tolerance, delay=guide_delay)

    return guide
Ejemplo n.º 3
0
        f.write('\n')
        f.close()
    except:
        print "Error: cannot write signal file"


if __name__ == "__main__":
    addr = 0x20
    if len(sys.argv) == 2:
        if sys.argv[1].startswith("0x"):
            addr = int(sys.argv[1], 16)
        else:
            addr = int(sys.argv[1])

    remove_signal()
    chirp = Chirp(2, addr)

    print chirp
    print "Send data to adafruit.io"
    sys.stdout.flush()
    while True:
        val = chirp.temp()
        time.sleep(0.2)
        hval = chirp.cap_sense()
        if hval < 415:
            water_plant_signal()
        time.sleep(0.2)
        lval = chirp.light()
        print "%d\t%d\t%d" % (hval, val, lval)
        valf = float(val) / 10
        aio.send('temp', valf)
def ReadAddressAndPOST(sensor):
    addr = sensor["sensorId"]
    print addr
    chirp = Chirp(1, int(addr, 16))

    # read moisture
    currentValMoisture = chirp.cap_sense()
    print currentValMoisture
    if ("moistureHistory" in sensor):
        historyM = sensor["moistureHistory"]
    else:
        historyM = []
    moisture = {}
    moisture["date"] = str(time.time()),
    moisture["value"] = str(currentValMoisture)
    historyM.append(moisture)
    print historyM

    #read light
    currentValLight = chirp.light()
    print currentValLight
    if ("lightHistory" in sensor):
        historyL = sensor["lightHistory"]
    else:
        historyL = []
    light = {
        "date": str(time.time()),
        "value": str(currentValLight)
    }
    historyL.append(light)
    print historyL

    #read temp
    currentValTemp = chirp.temp()
    print currentValTemp
    if ("tempHistory" in sensor):
        historyT = sensor["tempHistory"]
    else:
        historyT = []
    temp = {
        "date": str(time.time()),
        "value": str(currentValTemp)
    }
    historyT.append(temp)
    print historyT
    headers = {
        'content-type': 'application/json'
    }
    #update all data fields
    js = {
        "sensorId": addr,
        "sensorType": sensor["sensorType"],
        "pinId": sensor["pinId"],
        "turnOnTime": sensor["turnOnTime"],
        "turnOffTime": sensor["turnOffTime"],
        "turnOnMoisture": sensor["turnOnMoisture"],
        "turnOffMoisture": sensor["turnOffMoisture"],
        "moistureHistory": historyM,
        "turnOnLight": sensor["turnOnLight"],
        "turnOffLight": sensor["turnOffLight"],
        "lightHistory": historyL,
        "turnOnTemp": sensor["turnOnTemp"],
        "turnOffTemp": sensor["turnOffTemp"],
        "tempHistory": historyT
    }
    requests.post('http://localhost:3000/sensors/updatesensor',
                  data=json.dumps(js),
                  headers=headers)
Ejemplo n.º 5
0
VIDEO_FILE = None
if RECORD:
    filename = EXPERIMENT_ID + ".avi"
    VIDEO_FILE = os.path.join(EXPERIMENT_LOG, filename)

## Define output mode
guide = None
guide_tolerance = 0.15
guide_delay = 0
if OUTPUT_MODE == "speaker":
    guide = Speaker(tolerance=guide_tolerance, delay=guide_delay)
elif OUTPUT_MODE == "beeper":
    guide = Beeper(tolerance=guide_tolerance, delay=guide_delay)
elif OUTPUT_MODE == "chirp":
    guide = Chirp(tolerance=guide_tolerance, delay=guide_delay)

experiment_config = {
    "label_map": LABEL_MAP,
    "model_ckpt": PATH_TO_CKPT,
    "target_class": TARGET_CLASS,
    "output_mode": OUTPUT_MODE,
    "guide_tolerance": guide_tolerance,
    "guide_delay": guide_delay
}
log_to_file(experiment_config, LOG_FILE)

category_index = label_map_util.create_category_index_from_labelmap(
    LABEL_MAP, use_display_name=True)

## Load detection graph
Ejemplo n.º 6
0
args = parser.parse_args()

if args.server:
  server = args.server

if args.port:
  port = args.port

cargs = args.chirps[0]

print(server, port)

delay = 30

client = graphiteclient.GraphiteClient(server, port, delay)
client.verbose = True

chirps = []
for c in cargs:
    print(c)
    chirps.append({'chirp': Chirp(c['bus'], c['addr']), 'name': c['name']})

while True:
    for c in chirps:
        client.poke("chirp.%s.cap_sense" % (c['name']), c['chirp'].cap_sense())
        client.poke("chirp.%s.temp"      % (c['name']), c['chirp'].temp())
        client.poke("chirp.%s.light"     % (c['name']), c['chirp'].light())

    sys.stdout.flush()
    time.sleep(delay)
Ejemplo n.º 7
0
# Get old address (may be given in decimal or hex)
if sys.argv[1].startswith("0x"):
    old_addr = int(sys.argv[1], 16)
else:
    old_addr = int(sys.argv[1])

# Get new address (may be given in decimal or hex)
if sys.argv[2].startswith("0x"):
    new_addr = int(sys.argv[2], 16)
else:
    new_addr = int(sys.argv[2])

# Check that the new address is not occupied
try:
    chirp1 = Chirp(1, new_addr)
    chirp1.reset()
    print("The given new address %d is already in use. %s" %
          (new_addr, chirp1))
    sys.exit()
except IOError:
    pass

try:
    # If the following line throws an error, there is no Chirp on old_addr
    chirp = Chirp(1, old_addr)
except IOError:
    print("Cannot find a Chirp on address", old_addr)
    print("Use ''i2cdetect -y 1'' to see your current Chirp addresses.")

print("Renaming %s to address %d" % (chirp, new_addr))
#!/usr/bin/env python

from chirp import Chirp
import sys
from time import sleep

fromAddr = str(sys.argv[1])
toAddr = str(sys.argv[2])
print "Changing address from: " + fromAddr + ", to: " + toAddr

chirp = Chirp(1, int(fromAddr, 16))

# change address by writting to register 1 then writing new value follow by a reset.
# 1 = register 1, set address
# 6 = reset
# 7 = get version
print "writing to reg 1"
chirp.write(1)
sleep(0.5)
print "writing new address: " + toAddr
chirp.write(int(toAddr, 16))
sleep(0.5)
print "resetting unit"
chirp.write(6)
sleep(6)
print "testing new address..."
chirp = Chirp(1, int(toAddr, 16))
print "read version from new Address: " + str(chirp.get_reg(7))