Exemplo n.º 1
0
 def __init__(self, brickConfiguration, usedSensors=None):
     self.cfg = brickConfiguration
     dir = os.path.dirname(__file__)
     self.font_s = ImageFont.load(os.path.join(dir, 'ter-u12n_unicode.pil'))
     self.font_x = ImageFont.load(os.path.join(dir, 'ter-u18n_unicode.pil'))
     self.lcd = ev3dev.Screen()
     self.led = ev3dev.Leds
     self.keys = ev3dev.Button()
     self.sound = ev3dev.Sound
     (self.font_w, self.font_h) = self.lcd.draw.textsize('X',
                                                         font=self.font_s)
     self.timers = {}
     self.sys_bus = None
     self.bt_server = None
     self.bt_connections = []
Exemplo n.º 2
0
    def __init__(self):
        """
        Performs Alexa Gadget initialization routines and ev3dev resource allocation.
        """
        super().__init__()

        # the default I2C address of the sensor
        self.I2C_ADDRESS = 0x21

        # setup the buses
        self.airqualitybus = SMBus(3)
        self.temperaturebus = SMBus(4)

        #setup the moisbus and relaybus
        self.airqualitybus.write_byte_data(self.I2C_ADDRESS, 0x42, 0x01)
        self.temperaturebus.write_byte_data(self.I2C_ADDRESS, 0x42, 0x01)

        #setup the lastmois so we can track it well
        self.lastairquality = 0
        self.lasttemperature = 0
        self.count = 0
        self.speed = 0

        # Robot state
        self.auto_mode = False
        self.filterwarning = False

        self.sound = Sound()
        self.leds = Leds()
        self.color = ColorSensor()
        self.touch = TouchSensor()

        #Motor
        self.fan = MediumMotor(OUTPUT_A)

        #screen
        self.screen = ev3.Screen()

        # Start threads
        threading.Thread(target=self._autofan_thread, daemon=True).start()
        threading.Thread(target=self._manual_button_thread,
                         daemon=True).start()
Exemplo n.º 3
0
 def __init__(self, brickConfiguration, usedSensors=None):
     self.cfg = brickConfiguration
     dir = os.path.dirname(__file__)
     # char size: 6 x 12 -> num-chars: 29.666667 x 10.666667
     self.font_s = ImageFont.load(os.path.join(dir, 'ter-u12n_unicode.pil'))
     # char size: 10 x 18 -> num-chars: 17.800000 x 7.111111
     # self.font_s = ImageFont.load(os.path.join(dir, 'ter-u18n_unicode.pil'))
     self.lcd = ev3dev.Screen()
     self.led = ev3dev.Leds
     self.keys = ev3dev.Button()
     self.sound = ev3dev.Sound
     (self.font_w, self.font_h) = self.lcd.draw.textsize('X',
                                                         font=self.font_s)
     # logger.info('char size: %d x %d -> num-chars: %f x %f',
     #     self.font_w, self.font_h, 178 / self.font_w, 128 / self.font_h)
     self.timers = {}
     self.sys_bus = None
     self.bt_server = None
     self.bt_connections = []
     self.lang = 'de'
Exemplo n.º 4
0
#!/usr/bin/env python3
# run me in ssh via:
#   brickrun ./draw-grayscale.py
# or
#   sudo openvt -s -w -- sudo --user robot -- ./draw-grayscale.py

from time import sleep

import ev3dev.auto as ev3

screen = ev3.Screen()

smile = True

while True:
    screen.clear()

    screen.draw.ellipse((20, 20, 60, 60))
    screen.draw.ellipse((30, 30, 50, 50), fill=128)
    screen.draw.ellipse((118, 20, 158, 60))
    screen.draw.ellipse((128, 30, 148, 50), fill=128)

    # print(smile)

    if smile:
        screen.draw.arc((20, 80, 158, 100), 0, 180)
    else:
        screen.draw.arc((20, 80, 158, 100), 180, 360)

    smile = not smile
Exemplo n.º 5
0
    if len(sys.argv
           ) > 1:  # Whatever argument is enough the lower log levels...
        log_level = logging.DEBUG
    else:
        log_level = logging.CRITICAL

    access_log = logging.getLogger("tornado.access")
    app_log = logging.getLogger("tornado.application")
    gen_log = logging.getLogger("tornado.general")
    access_log.setLevel(log_level)
    app_log.setLevel(log_level)
    gen_log.setLevel(log_level)
    plotter_log.setLevel(logging.INFO)

    # Prepare the screen
    lcd = ev.Screen()
    logo = Image.open('static/logo.jpg')
    img = Image.new("1", (128, 178), color=255)
    img.paste(logo.resize((100, 127)), (14, 0))
    draw = ImageDraw.Draw(img)
    draw.text((2, 127), 'Point your browser to:')
    draw.text((2, 137), '{0}:9093'.format(get_ip_address()))
    draw.text((2, 150), 'press back to exit')
    del draw
    lcd.image.paste(img.rotate(-90), box=(0, 0))

    # Set up web server
    application.listen(9093)  # starts the web sockets connection
    logging.info("Started web server at {0}:9093".format(get_ip_address()))

    # Display ip number on screen for easy connection