コード例 #1
0
    def __init__(self, car_name):
        self.car = Car(car_name)

        self.Detect_line_thread = threading.Thread(target=self.Detect_line)
        self.Detect_obstacle_thread = threading.Thread(
            target=self.Detect_obstacle)
        self.Measure_time_thread = threading.Thread(target=self.Measure_time)
        self.LED_module_thread = threading.Thread(target=self.LED_moudle)

        self.key_input_thread = threading.Thread(target=self.key_input)
        self.key_input2_thread = threading.Thread(target=self.key_input2)
        self.key_input3_thread = threading.Thread(target=self.key_input3)
        self.key_input4_thread = threading.Thread(target=self.key_input4)
        self.key_input5_thread = threading.Thread(target=self.key_input5)

        self.key_w = ""
        self.key_s = ""
        self.key_a = ""
        self.key_d = ""
        self.key_shift = ""

        self.button_pin = 33
        self.led_pin = 37

        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(self.button_pin, GPIO.IN)
        GPIO.setup(self.led_pin, GPIO.OUT)

        self.line = []
        self.distance = 0
        self.button_pressed_time = 0
        self.drive_start = False
        self.buzzer = buzzer.Buzzer()
        self.car_buzzer_start_count = 0
コード例 #2
0
ファイル: main.py プロジェクト: LaurenUnq/FAS
def main():
    d = 0
    lcd.ecrireMessage("Bonjour", 3)
    lcd.clearEcran()
    t = capteurTemperature.MesurerH()
    day = int(time.strftime("%d")) - 1
    while True:
        #demande prise de frequence cardiaque
        if d == 0:
            if bouton.etatBt2() == 1:
                d = 1
                t = time.time()
                l = lcd.Lcd(
                    "Placer le capteur de frequence cardiaque et appuyer de nouveau sur le bouton 2",
                    120)
                l.start()
                time.sleep(3)
        if d == 1:
            if bouton.etatBt2() == 1 and t + 120 > time.time():
                l.stop()
                l.join()
                prise(2, 4)
                d = 0
            if t + 120 <= time.time():
                l.stop()
                l.join()
                d = 0

    #demande de frequence cardiaque quotidienne
        if day != time.strftime("%d") and int(time.strftime("%H")) >= 8:
            lcd.ecrireMessage("Bonjour", 3)
            lcd.clearEcran()
            day = time.strftime("%d")
            freqQ = False
            while freqQ == False:
                ecran = lcd.Lcd(
                    "C est l heure de prendre votre frequence cardiaque! (appuyer sur le bouton 1)",
                    60)
                buzz = buzzer.Buzzer(10, 0)  #on modifiera le 0 plus tard
                ledr = led.Led(60, 0.5)
                bt1 = bouton.Button1(60)
                ecran.start()
                bt1.start()
                buzz.start()
                ledr.start()
                ret = bt1.join()
                if ret == True:
                    ecran.stop()
                    ledr.stop()
                    buzz.stop()
                    prise(2, 4)
                    freqQ = True
                ecran.join()
                ledr.join()
                buzz.join()
    t.join()
コード例 #3
0
ファイル: gas.py プロジェクト: ericlu5988/gas-module-pi
def init_system():
    # basic setup
    GPIO.setmode(GPIO.BCM)  # set the board numbering system to BCM
    # setup LED
    GPIO.setup(GREEN, GPIO.OUT)
    GPIO.setup(RED, GPIO.OUT)
    # setup sound
    buzz = buzzer.Buzzer()
    # setup LCD screen
    display = lcd.LCD_Display(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7)
    # setup buttons
    GPIO.setup(BUTTON_BACK, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    GPIO.setup(BUTTON_NEXT_ITEM, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    GPIO.setup(BUTTON_ENTER, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    return buzz, display
コード例 #4
0
	def run(self):
		buzz = buzzer.Buzzer(10,0) #on modifiera le 0 plus tard
		ecran = lcd.Lcd("Hydratez-vous et appuyer sur le bouton 1!",20)
		ledr = led.Led(20,0.5)
		bt1 = bouton.Button1(20)
		bt1.start()
		buzz.start()
		ecran.start()
		ledr.start()
		self.ret = bt1.join()
		if self.ret == True:
			ecran.stop()
			ledr.stop()
			buzz.stop()
		ecran.join()
		ledr.join()
		buzz.join()
コード例 #5
0
    def __init__(self, camera_data, display_data, led_data, buzzer_data,
                 random_data, version, port):
        log.info('starting APP version "{}"'.format(version))
        try:
            self.display = display.Display()
            self.cam = camera.Camera(camera_data)
            self._led_manager = leds.Leds(led_data)
            self._buzzer = buzzer.Buzzer(buzzer_data)
            self._stats = stats.Stats(random_data)
            self._software_version = version
            self._start_time = datetime.datetime.now()
            self._time_min_delta = datetime.timedelta(
                seconds=float(display_data['time_min_delta']))
            self._beam_position = list(
                int(val) for val in display_data['beam_position'].split(
                    ','))  # x1, y1, x2, y2
            self._beam_dead_zone = int(display_data['beam_dead_zone'])
            self._height = int(display_data['image_height'])
            self._width = int(display_data['image_width'])
            self._bag_select = float(display_data['bag_select'])
            self._image_template = display_data['image_template']
            self._image_bag = display_data['image_bag']
            self._port = port
            self._bag_datetime = datetime.datetime.now()
            self._mode_name = ['RUN', 'VIEW']
            self._mode_active = 0
            self._frame = None
            self._freeze = None
            self._alarm = False
            self._stats_active = False
            self._scanner = 0
            self._ack = False
            self.mark = False
        except ValueError as ex:
            msg = 'error reading camera_data {}. Aborting!'.format(ex)
            log.error(msg)
            sys.exit(msg)

        # start display
        self.display.window = 'ANACASE {}'.format(self._software_version)
        self.display.add_window_properties(cv2.WND_PROP_FULLSCREEN,
                                           cv2.WINDOW_FULLSCREEN)
        cv2.setMouseCallback(self.display.window, self._mouse_clicks)
コード例 #6
0
    GPIO.setup(yellow_pin, GPIO.OUT)

    GPIO.add_event_detect(clk_pin,
                          GPIO.FALLING,
                          callback=rotary_callback,
                          bouncetime=5)
    GPIO.add_event_detect(sw_pin,
                          GPIO.FALLING,
                          callback=sw_callback,
                          bouncetime=300)
    GPIO.add_event_detect(press_sw_pin,
                          GPIO.FALLING,
                          callback=press_sw_callback,
                          bouncetime=1000)

    buz = buzzer.Buzzer()

    # LED strip configuration:
    LED_COUNT = 1  # Number of LED pixels.
    LED_PIN = 12  # GPIO pin connected to the pixels (18 uses PWM!).
    LED_FREQ_HZ = 800000  # LED signal frequency in hertz (usually 800khz)
    LED_DMA = 10  # DMA channel to use for generating signal (try 10)
    LED_BRIGHTNESS = 255  # Set to 0 for darkest and 255 for brightest
    LED_INVERT = False  # True to invert the signal (when using NPN transistor level shift)
    LED_CHANNEL = 0  # set to '1' for GPIOs 13, 19, 41, 45 or 53

    # Create NeoPixel object with appropriate configuration.
    strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA,
                              LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
    # Intialize the library (must be called once before other functions).
    strip.begin()
コード例 #7
0
        # next state
        if self.button.was_pressed():
            self.state = self.co2
            self.buzzer.turn_off()
        if self.sensor_service.get_co2() < self.co2_threshold:
            self.alarm_muted = True
            self.state = self.co2
            self.buzzer.turn_off()


disp = grove_4_digit_display.Grove(
    16, 17, brightness=grove_4_digit_display.BRIGHT_HIGHEST)
button = button.Button(pin=5, double_press_threshold=0.4)
service = thingSpeakService.ThingSpeakService(channel=THING_SPEAK_CHANNEL,
                                              api_key=THING_SPEAK_API_KEY)
buzzer = buzzer.Buzzer(12)
servo = servo.Servo(pin=18, min=0, max=5000)
rot_sensor = rotation.RotationSensor(pin=4, min=0, max=5000)
led_actuator = led.Led(6)

SM = StateMachine(button=button,
                  display=disp,
                  sensor_service=service,
                  buzzer=buzzer,
                  rotation_sensor=rot_sensor,
                  servo=servo,
                  led=led_actuator)
try:
    while True:
        SM.run()
except KeyboardInterrupt:
コード例 #8
0
ファイル: airalarm.py プロジェクト: eggplant60/airalarm
# Initialize and Generate
# =========================================
if __name__ == '__main__':

    # Initialize GPIO and so on.
    gpio.setwarnings(False)
    gpio.setmode(gpio.BCM)  # Use BCM GPIO numbers
    conf = ac.Configuration()  # Load previous configurations
    ctrl = ac.Controller()
    bus = smbus.SMBus(1)  # I2C bus shared by devices

    # Sensor Initialization
    sensors = Sensors(bus)

    # Buzzer Initializatin
    buzzer = buzzer.Buzzer(buzzer.PIN)

    # LCD Initialization
    lcd = raspi_lcd.LCDController(bus, raspi_lcd.PIN_BACKLIGHT)
    lcd.initialize_display()
    lcd.display_messages(["RaspberryPi Zero", "   Air Alarm"])
    time.sleep(1)

    def start_thread(target):
        t = threading.Thread(target=target)
        t.setDaemon(True)
        t.start()
        return t

    # 以下の処理はデーモン化されており、エラーを吐いても全体の処理は止まらない
    # デーモンスレッドのみになったときは自動で終了する