From 2670c3c714b6b2be8f0dc6657ac6432b9784c1e2 Mon Sep 17 00:00:00 2001 From: jpunkt Date: Tue, 18 Jan 2022 21:35:05 +0100 Subject: [PATCH] preparing lid sensor and helo pins --- pizzactrl/gpio_pins.py | 23 +++-------------------- pizzactrl/hal_serial.py | 6 +++--- pizzactrl/statemachine.py | 23 ++++++++++++----------- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/pizzactrl/gpio_pins.py b/pizzactrl/gpio_pins.py index 1415b33..3251437 100644 --- a/pizzactrl/gpio_pins.py +++ b/pizzactrl/gpio_pins.py @@ -1,23 +1,6 @@ # 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) -BTN_FORWARD_GPIO = 18 # "Forward" button (user input) - -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 +HELO1 = 24 # Set this pin `HIGH` +HELO2 = 23 # Set this pin `LOW` \ No newline at end of file diff --git a/pizzactrl/hal_serial.py b/pizzactrl/hal_serial.py index a1cdc94..73ca870 100644 --- a/pizzactrl/hal_serial.py +++ b/pizzactrl/hal_serial.py @@ -12,13 +12,13 @@ import soundfile as sf import pygame.mixer as mx -from . import gpio_pins - from picamera import PiCamera from gpiozero import Button import serial +from .gpio_pins import * + 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): 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.soundcache = {} diff --git a/pizzactrl/statemachine.py b/pizzactrl/statemachine.py index 4fc4746..562c39d 100644 --- a/pizzactrl/statemachine.py +++ b/pizzactrl/statemachine.py @@ -1,18 +1,11 @@ import logging import os.path -from typing import Any - -from time import sleep - from enum import Enum, auto -from subprocess import call -from pizzactrl import SOUNDS_PATH, fs_names -from pizzactrl.hal import ScrollSensor -from .storyboard import Language, Activity, Select, Option, Storyboard +from pizzactrl import fs_names +from .storyboard import Language, Storyboard from .hal_serial import SerialCommunicationError, PizzaHAL, wait_for_input, play_sound, turn_off -from pizzactrl import storyboard logger = logging.getLogger(__name__) @@ -82,13 +75,21 @@ class Statemachine: self._shutdown() + def _lid_open(self): + # TODO implement + pass + + def _lid_closed(self): + # TODO implement + pass + def _power_on(self): """ Initialize hal callbacks, load sounds """ # TODO enable lid sensor - # self.hal.lid_sensor.when_pressed = self._lid_open - # self.hal.lid_sensor.when_released = self._lid_closed + self.hal.lid_switch.when_pressed = self._lid_open + self.hal.lid_switch.when_released = self._lid_closed self.hal.init_sounds() self.hal.init_camera()