preparing lid sensor and helo pins

This commit is contained in:
jpunkt 2022-01-18 21:35:05 +01:00
parent d713a5e2e9
commit 2670c3c714
3 changed files with 18 additions and 34 deletions

View file

@ -1,23 +1,6 @@
# GPIO pin definitions # GPIO pin definitions
BTN_START = 26 # "Start" button (begin the performance) TODO review LID_SWITCH = 22 # "Lid open" detector switch on front
BTN_BACK_GPIO = 14 # "Back" button (user input) HELO1 = 24 # Set this pin `HIGH`
BTN_FORWARD_GPIO = 18 # "Forward" button (user input) HELO2 = 23 # Set this pin `LOW`
LED_BACK_BTN = 15 # LED in back-button
LED_FWD_BTN = 23 # LED in forward-button
# LID_SWITCH = 18 # "Lid open" detector switch on front
LED_LAYER = 12 # LED-strip for top layer
LED_BACKLIGHT = 13 # LED-strip for backlight
MOTOR_CTRL_LR = (8, 7, 10) # Motor controller 1 (in1, in2, enable)
MOTOR_CTRL_UPDOWN = (9, 11, 25) # Motor controller 2 (in1, in2, enable)
SCROLL_UPDOWN_SENSORS = (22, 27) # Feed/Direction sensors
SCROLL_UPDOWN_ENDSTOP = 20 # End of Tape
SCROLL_LR_SENSORS = (6, 5) # Feed/Direction sensors
SCROLL_LR_ENDSTOP = 16 # End of Tape

View file

@ -12,13 +12,13 @@ import soundfile as sf
import pygame.mixer as mx import pygame.mixer as mx
from . import gpio_pins
from picamera import PiCamera from picamera import PiCamera
from gpiozero import Button from gpiozero import Button
import serial import serial
from .gpio_pins import *
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -84,7 +84,7 @@ class PizzaHAL:
def __init__(self, serialdev: str = SERIAL_DEV, baudrate: int = SERIAL_BAUDRATE, timeout: float = SERIAL_CONN_TIMEOUT): def __init__(self, serialdev: str = SERIAL_DEV, baudrate: int = SERIAL_BAUDRATE, timeout: float = SERIAL_CONN_TIMEOUT):
self.serialcon = serial.Serial(serialdev, baudrate=baudrate, timeout=timeout) self.serialcon = serial.Serial(serialdev, baudrate=baudrate, timeout=timeout)
self.btn_start = Button(gpio_pins.BTN_START) self.lid_switch = Button(LID_SWITCH)
self.camera = None self.camera = None
self.soundcache = {} self.soundcache = {}

View file

@ -1,18 +1,11 @@
import logging import logging
import os.path import os.path
from typing import Any
from time import sleep
from enum import Enum, auto from enum import Enum, auto
from subprocess import call
from pizzactrl import SOUNDS_PATH, fs_names from pizzactrl import fs_names
from pizzactrl.hal import ScrollSensor from .storyboard import Language, Storyboard
from .storyboard import Language, Activity, Select, Option, Storyboard
from .hal_serial import SerialCommunicationError, PizzaHAL, wait_for_input, play_sound, turn_off from .hal_serial import SerialCommunicationError, PizzaHAL, wait_for_input, play_sound, turn_off
from pizzactrl import storyboard
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -82,13 +75,21 @@ class Statemachine:
self._shutdown() self._shutdown()
def _lid_open(self):
# TODO implement
pass
def _lid_closed(self):
# TODO implement
pass
def _power_on(self): def _power_on(self):
""" """
Initialize hal callbacks, load sounds Initialize hal callbacks, load sounds
""" """
# TODO enable lid sensor # TODO enable lid sensor
# self.hal.lid_sensor.when_pressed = self._lid_open self.hal.lid_switch.when_pressed = self._lid_open
# self.hal.lid_sensor.when_released = self._lid_closed self.hal.lid_switch.when_released = self._lid_closed
self.hal.init_sounds() self.hal.init_sounds()
self.hal.init_camera() self.hal.init_camera()