Beispiel #1
0
def lcd():
    form = LcdForm()
    if form.validate_on_submit():
        my_gpio = mygpio.MyGPIO()
        result = my_gpio.lcd_display_text(form.lcd_text.data)
        if result:
            message = "Sent text '%s' to display" % (form.lcd_text.data, )
            return render_template('lcd.html',
                                   title='LCD Display',
                                   info_message=message,
                                   form=form)
        else:
            error = "Error when sending text to LCD, make sure that is properly connected"
            return render_template('lcd.html',
                                   title='LCD Display',
                                   error_message=error,
                                   form=form)

    my_gpio = mygpio.MyGPIO()
    error = None
    if not my_gpio.is_lcd_connected():
        error = "There is no LCD connected!"
    return render_template('lcd.html',
                           title='LCD Display',
                           error_message=error,
                           form=form)
Beispiel #2
0
def gpio():
    form = GenericCPIOForm()
    my_gpio = mygpio.MyGPIO()
    pins = my_gpio.get_pins()
    if form.validate_on_submit():
        pin_info = my_gpio.get_pin_info(form.pin.data)
        if pin_info is not None:
            my_gpio.configure()
            if form.value.data == 'high':
                my_gpio.turn_on(pin_info['bcm'])
            else:
                my_gpio.turn_off(pin_info['bcm'])
            error_message = None
            info_message = 'Pin %s (# %s) setted as %s' % (
                pin_info['title'], form.pin.data, form.value.data)
        else:
            info_message = None
            error_message = 'You cannot send outputs to VCC or GND pins'
        return render_template('gpio_board.html',
                               title='GPIO',
                               form=form,
                               pins=pins,
                               info_message=info_message,
                               error_message=error_message)
    return render_template('gpio_board.html',
                           title='GPIO',
                           form=form,
                           pins=pins)
Beispiel #3
0
def lcd_rows():
    form = LcdRowForm()
    if form.validate_on_submit():
        my_gpio = mygpio.MyGPIO()
        result = my_gpio.lcd_display_rowtext(form.lcd_text.data,
                                             form.lcd_row.data)
        if result:
            message = "Sent text '%s' for row '%s' to display" % (
                form.lcd_text.data, form.lcd_row.data)
            return render_template('lcd.html',
                                   title='LCD Display',
                                   info_message=message,
                                   form=form)
        else:
            error = "Error when sending text to LCD, make sure that is properly connected"
            return render_template('lcd.html',
                                   title='LCD Display',
                                   error_message=error,
                                   form=form)

    form = LcdForm()
    return render_template('lcd.html',
                           title='LCD Display',
                           error_message=None,
                           form=form)
Beispiel #4
0
def gpio_blink_pin(pin, repetitions, pause_time):
    my_gpio = mygpio.MyGPIO()
    my_gpio.configure()

    for i in range(repetitions):
        my_gpio.turn_on(pin)
        time.sleep(pause_time)
        my_gpio.turn_off(pin)
        time.sleep(pause_time / 2)
Beispiel #5
0
def lcd_clear():
    my_gpio = mygpio.MyGPIO()
    result = my_gpio.lcd_clear()
    error = None
    if not result:
        error = "Error when sending clear command to LCD, make sure that is properly connected"
    form = LcdForm()
    return render_template('lcd.html',
                           title='LCD Display',
                           error_message=error,
                           form=form)