PIs have no way to get any input if not through a connected keyboard - and even then, a screen would probably be required. A cheap workaround would be to add a physical button so that some input could still be sent through pressing the button for different lengths of time. Something like that could be achieved by shorting pins 5 and 6 on the GPIO and detecting their status through software daemons.
The following toy Python code listens to GPIO status and executes two commands depending on the amount of time the button has been pressed
#!/bin/env python
import threading
import time
#<https://pypi.org/project/RPi.GPIO/>
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
class Button(threading.Thread):
def __init__(self, channel, longpress=5):
threading.Thread.__init__(self)
self._pressed = False
self._listen = True
self.last_pressed = time.time()
self.longpress= longpress #amount of seconds triggering a long press
self.channel = channel
GPIO.setup(self.channel, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Button pin set as input
self.deamon = True
self.start()
def shortpress_action(self):
print("[%s] short press" % self.channel)
def longpress_action(self, delta):
print("[%s] pressed for %02d seconds" % (self.channel, delta))
def stop(self):
self._listen = False
def run(self):
while self._listen:
if GPIO.input(self.channel): #button released
if self._pressed == True:
self._pressed = False
pt = time.time() - self.last_pressed
if pt > self.longpress: self.longpress_action(pt)
else: self.shortpress_action()
else: #button pressed
if self._pressed == False:
self._pressed = True
self.last_pressed = time.time()
def printout(self, message):
print ("[%s] btn %s\\r" % (self.channel, message), end='')
#our PCB is connected on PINs 13,26 (BCM) or 33, 37 (BOARD)
BTN = [Button(n) for n in [33,37]]
print("Listening. Press CTRL+C to exit")
try:
pass
except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
GPIO.cleanup() # cleanup all GPIO
for B in BTN: B.stop()
Conveniently, pins 5 and 6 are both connected to the lightbox socket so there are two options to use those:
See also [GPIO-utils](https://github.com/rust-embedded/gpio-utils#:~:text=GPIO Utils provides convenient access,required for most embedded systems.)