Beispiel #1
0
def read_pins():
    import json
    # return json.dumps(pytronics.readPins(DIGITAL_PINS))
    pins = pytronics.readPins(DIGITAL_PINS)
    analog = {}
    for chan in ['A0', 'A1', 'A2', 'A3']:
        analog[chan] = pytronics.analogRead(chan)
    return json.dumps({'pins': pins, 'analog': analog})
Beispiel #2
0
def read_pins():
    import json
    # return json.dumps(pytronics.readPins(DIGITAL_PINS))
    pins = pytronics.readPins(DIGITAL_PINS)
    analog = {}
    for chan in ['A0', 'A1', 'A2', 'A3']:
        analog[chan] = pytronics.analogRead(chan)
    return json.dumps({ 'pins': pins, 'analog': analog })
Beispiel #3
0
def analog():
    import json
    try:
        ad_ref = float(request.form['adref'])
    except KeyError:
        ad_ref = 3.3
    data = {
        "time" : float(time.time()),
        "A0" : float(pytronics.analogRead('A0')) * ad_ref / 1024.0
    }
    return json.dumps(data)
Beispiel #4
0
def analog():
    import json
    try:
        ad_ref = float(request.form['adref'])
    except KeyError:
        ad_ref = 3.3
    data = {
        "time" : float(time.time()),
        "A0" : float(pytronics.analogRead('A0')) * ad_ref / 1024.0
    }
    return json.dumps(data)
Beispiel #5
0
def analog_read(pin_name):
    if pin_name not in ANALOG_PINS:
        return "You seem to be trying to read from analog pin {0}, which does not exist. Try A0, A1, A2, or A3.".format(pin_name)
    else:
        return pytronics.analogRead(pin_name)
Beispiel #6
0
def analog_read(pin_name):
    if pin_name not in ANALOG_PINS:
        return "You seem to be trying to read from analog pin {0}, which does not exist. Try A0, A1, A2, or A3.".format(
            pin_name)
    else:
        return pytronics.analogRead(pin_name)
Beispiel #7
0
def index():
    pin = pytronics.digitalRead(2)
    (chan0, chan1, chan2, chan3) = [pytronics.analogRead(chan) for chan in ['A0', 'A1', 'A2', 'A3']]
    return render_template('/relay.html', chan0=chan0, chan1=chan1, chan2=chan2, chan3=chan3, pin=pin)