Skip to content
Snippets Groups Projects
Commit e1195df7 authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Initial tests

parent c73f8155
Branches
No related tags found
No related merge requests found
......@@ -40,6 +40,9 @@ A stechuhr client consists of:
| LED module 5V | Raspi GPIO 5V | 5V WS2812 Module (if more than 1 LED is used consider connecting this to the external PSU 5V) | Jumpercable with female pinheader on one side, soldered on the other |
| LED module GND | Raspi GPIO GND | 5V WS2812 Module | Jumpercable with female pinheader on one side, soldered on the other |
| LED module PWM | Raspi GPIO 10 | D2 WS2812 Module | Jumpercable with female pinheader on one side, soldered on the other |
| Buzzer + | Raspi GPIO 18 | Buzzer + | Jumpercable with female pinheader on one side, soldered on the other |
| Buzzer - | GND | Buzzer + | Jumpercable with female pinheader on one side, soldered on the other |
![](images/gpio.png)
......
......@@ -19,11 +19,13 @@ import fcntl
import ctypes
import struct
import logging
import RPi.GPIO as GPIO
from config import initialize_config
from keycode import KEYCODE
APPLICATION_NAME = "stechuhr-client"
DEFAULT_CONFIG = """
......@@ -82,6 +84,11 @@ verify_cert = true
LEDS = neopixel_spi.NeoPixel_SPI(board.SPI(), 10)
buzzer_pin = 12
GPIO.setmode(GPIO.BOARD)
GPIO.setup(buzzer_pin, GPIO.OUT)
# from input-event-codes.h
# type can be EV_SYN, EV_KEY or EV_MSC
EV_KEY = 1
......@@ -105,8 +112,11 @@ def dispatch_led(ledstate, config):
"""
Dispatch a LED thread with a given LED state
"""
thread = threading.Thread(target = set_led, args = (ledstate, config, ))
thread.start()
led_thread = threading.Thread(target = set_led, args = (ledstate, config, ))
led_thread.start()
buzzer_thread = threading.Thread(target = set_buzzer, args = (ledstate, config, ))
buzzer_thread.start()
def set_led(ledstate, config):
"""
......@@ -140,6 +150,22 @@ def set_led(ledstate, config):
LEDS.fill(config["led"]["standby_color"][0])
def set_buzzer(ledstate, config):
global buzzer_pin
buzzer = GPIO.PWM(buzzer_pin, 1000) # Set frequency to 1 Khz
buzzer.start(10) # Set dutycycle to 10
time.sleep(0.5)
buzzer = GPIO.PWM(buzzer_pin, 2000) # Set frequency to 1 Khz
buzzer.start(50) # Set dutycycle to 10
time.sleep(0.5)
buzzer = GPIO.PWM(buzzer_pin, 1000) # Set frequency to 1 Khz
buzzer.start(10) # Set dutycycle to 10
time.sleep(0.5)
buzzer = GPIO.PWM(buzzer_pin, 2000) # Set frequency to 1 Khz
buzzer.start(50) # Set dutycycle to 10
time.sleep(0.5)
buzzer.stop()
def process_request(output_queue, config=None, logger=None):
"""
Process a event from the output queue.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment