Ejemplo n.º 1
0
        Display.setFontSize(display_name, FontSize.MEDIUM)
        Display.setTextColor(display_name, DisplayBackground.RED)
        logger.info("Set font size to MEDIUM, text color to RED")
        Display.showText(display_name, DisplayLine.TWO, TextAlignment.CENTER,
                         "RED!")
        time.sleep(5)
        # Set display background color
        logger.info("Painting background color to BLUE")
        Display.paintBackgroundColor(display_name, DisplayBackground.BLUE)
        time.sleep(5)
    except Exception as e:
        logger.error("Failed to run display commands {}, ex {}".format(
            display_name, e))
        #traceback.print_exc()
    finally:
        # Program completed, disconnect elements and quit
        plezmoApi.disconnect(display_name)
        time.sleep(1)
        plezmoApi.close()


# Program starts here
if __name__ == "__main__":
    display_name = utils.extract_element_name()
    if display_name == None:
        logger.error(
            "Display element name is mandatory, e.g. # python display_example.py Display"
        )
    else:
        main(display_name)
    quit()
Ejemplo n.º 2
0
@PlezmoEventHandler
def r_tilt_handler():
    logger.info("Right tilt event handler:: Got right tilt event")

@PlezmoEventHandler
def f_tilt_handler():
    logger.info("Front tilt event handler:: Got front tilt event")

@PlezmoEventHandler
def b_tilt_handler():
    logger.info("Back tilt event handler:: Got back tilt event")

@PlezmoEventHandler
def flat_handler():
    logger.info("Flat event handler:: Got flat event")

@PlezmoEventHandler
def move_handler():
    logger.info("Move event handler:: Got move event")

@PlezmoEventHandler
def stop_handler():
    logger.info("Stop event handler:: Got stop event")

# Program starts here
if __name__ == "__main__":
    motion_name = utils.extract_element_name()
    if motion_name == None:
        logger.error("Motion element name is mandatory, e.g. # python motion_example.py Motion")
    else:
        main(motion_name)
Ejemplo n.º 3
0
        logger.info("Got NEAR event after wait for")
    except Exception as e:
        logger.error("Failed to run distance commands {}, ex {}".format(
            distance_name, e))
        #traceback.print_exc()
    finally:
        # Program completed, disconnect elements and quit
        plezmoApi.disconnect(distance_name)
        time.sleep(1)
        plezmoApi.close()


@PlezmoEventHandler
def near_handler():
    logger.info("Got near event")


@PlezmoEventHandler
def far_handler():
    logger.info("Got far event")


# Program starts here
if __name__ == "__main__":
    distance_name = utils.extract_element_name()
    if distance_name == None:
        logger.error(
            "Distance element name is mandatory, e.g. # python distance_example.py Distance"
        )
    else:
        main(distance_name)
Ejemplo n.º 4
0
        Music.setVolume(music_name, Volume.HIGH)
        logger.info("Set instrument to FLUTE, tempo to MEDIUM, volume to HIGH")
        i = Music.getInstrument(music_name)
        logger.info("Got instrument {}".format(i))
        t = Music.getTempo(music_name)
        logger.info("Got tempo {}".format(t))
        v = Music.getVolume(music_name)
        logger.info("Got volume {}".format(v))
        logger.info("Playing note 66 with beats = 3")
        Music.playNote(music_name, Note(66), 3)
        time.sleep(5)
    except Exception as e:
        logger.error("Failed to run music commands {}, ex {}".format(
            music_name, e))
        #traceback.print_exc()
    finally:
        # Program completed, disconnect elements and quit
        plezmoApi.disconnect(music_name)
        time.sleep(1)
        plezmoApi.close()


# Program starts here
if __name__ == "__main__":
    music_name = utils.extract_element_name()
    if music_name == None:
        logger.error(
            "Music element name is mandatory, e.g. # python music_example.py Music"
        )
    else:
        main(music_name)
Ejemplo n.º 5
0
        Light.fadeIn(light_name, Percentage(100), LightColor("#FF0000"), LightFadeSpeed.FAST)
        time.sleep(2)
        # Fade out
        logger.info("Fading out the light slowly")
        Light.fadeOut(light_name, LightFadeSpeed.SLOW)
        time.sleep(2)
        # Get brightness detected
        b = Light.getBrightness(light_name)
        logger.info("Brightness {}".format(b))
        # Get color detected
        c = Light.getColor(light_name)
        logger.info("Color {}".format(c))
        # Get state (ON/OFF)
        s = Light.getState(light_name)
        logger.info("State {}".format(s))
    except Exception as e:
        logger.error("Failed to run Light commands {}, ex {}".format(light_name, e))
        #traceback.print_exc()
    finally:
        # Program completed, disconnect elements and quit
        plezmoApi.disconnect(light_name)
        time.sleep(1)
        plezmoApi.close()

# Program starts here
if __name__ == "__main__":
    light_name = utils.extract_element_name()
    if light_name == None:
        logger.error("Light element name is mandatory, e.g. # python light_example.py Light")
    else:
        main(light_name)
Ejemplo n.º 6
0
def green_handler():
    logger.info("Got green color change event")


# Event handler whenever color sensor detects RED color
@PlezmoEventHandler
def red_handler():
    logger.info("Got red color change event")


# Event handler whenever color sensor detects darkness
@PlezmoEventHandler
def darkness_handler():
    logger.info("Got darkness event")


# Event handler whenever color sensor detects brightness
@PlezmoEventHandler
def brightness_handler():
    logger.info("Got brightness event")


# Program starts here
if __name__ == "__main__":
    color_name = utils.extract_element_name()
    if color_name == None:
        logger.error(
            "Color element name is mandatory, e.g. # python color_example.py Color"
        )
    else:
        main(color_name)