diff --git a/.gitignore b/.gitignore index 1d2217f..9495d37 100644 --- a/.gitignore +++ b/.gitignore @@ -170,4 +170,4 @@ cython_debug/ # PyPI configuration file .pypirc - +Sauvegarde-wav/ diff --git a/README.md b/README.md index 3789766..93a06cb 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,4 @@ To keep acces to the system, the RPI4 is set in AP mode. ## Author [Ange-Marie MAURIN](mailto://a-m.maurin@a2msystemes.fr) +[Biscuit production](https://biscuit-production.fr) diff --git a/RayPonder/Events/EventTypes.py b/RayPonder/Events/EventTypes.py index 8257837..b6528c4 100644 --- a/RayPonder/Events/EventTypes.py +++ b/RayPonder/Events/EventTypes.py @@ -1,27 +1,45 @@ +import sys from enum import Enum -from evdev import ecodes - - -class EventTypes(Enum): - - """Keyboad event types""" - PickUp = ecodes.KEY_F12 - Recording = ecodes.KEY_F11 - Playing = ecodes.KEY_F10 - FileSyn = ecodes.KEY_F9 - RecordTimeout = ecodes.KEY_F8 +if sys.platform != "win32": + from evdev import ecodes + class EventTypes(Enum): + """Keyboad event types""" + PickUp = ecodes.KEY_F12 + Recording = ecodes.KEY_F11 + Playing = ecodes.KEY_F10 + FileSyn = ecodes.KEY_F9 + RecordTimeout = ecodes.KEY_F8 + + class EventProducerType(Enum): + Keyboard = ecodes.EV_KEY + Timer = ecodes.EV_MAX + Unknown = -1 + Player = 300 + Recorder = 301 +else: + class EventTypes(Enum): + + """Keyboad event types""" + PickUp = 12 + Recording = 11 + Playing = 10 + FileSyn = 9 + RecordTimeout = 8 + + class EventProducerType(Enum): + Keyboard = 1 + Timer = 2 + Unknown = -1 + Player = 300 + Recorder = 301 + class EventVal(Enum): Pressed = 1 Released = 0 -class EventProducerType(Enum): - Keyboard = ecodes.EV_KEY - Timer = ecodes.EV_MAX - Unknown = -1 - Player = 300 - Recorder = 301 + class RayEventType(Enum): diff --git a/RayPonder/Events/PhyEventLoop.py b/RayPonder/Events/PhyEventLoopEvdev.py similarity index 98% rename from RayPonder/Events/PhyEventLoop.py rename to RayPonder/Events/PhyEventLoopEvdev.py index 56d97a7..1f401e0 100644 --- a/RayPonder/Events/PhyEventLoop.py +++ b/RayPonder/Events/PhyEventLoopEvdev.py @@ -9,7 +9,7 @@ from RayPonder import Events -class PhyEventLoop: +class PhyEventLoopEvDev: def __init__(self, queue, config): self.device_path = config['phy-event']['gpio-dev-input'] self.pickup_state = int(config["phy-event"]["pickup-state"]) diff --git a/RayPonder/Events/PhyEventLoopKeyboard.py b/RayPonder/Events/PhyEventLoopKeyboard.py new file mode 100644 index 0000000..b8440b1 --- /dev/null +++ b/RayPonder/Events/PhyEventLoopKeyboard.py @@ -0,0 +1,51 @@ +# PhyEvents.py +import keyboard +import threading +import queue +# from RayPonder.Events import EventProducerType, RayEventType +from RayPonder import Events + + + + + +class PhyEventLoopKeyboard: + def __init__(self, queue, config): + self.device_path = config['phy-event']['gpio-dev-input'] + self.pickup_state = int(config["phy-event"]["pickup-state"]) + # print(f"PhyEventLoop() : current state {self.pickup_state}") + self.event_queue = queue + self.running = False + + def start(self): + self.running = True + self.thread = threading.Thread(target=self.read_events) + self.thread.start() + + def read_events(self): + while self.running: + try: + event = keyboard.read_event() + if event: + print(event) + if (event.event_type == keyboard.KEY_DOWN and event.name == "f12"): + # print(f"PhyEventLoop() : Event received -> {event}") + key_ev = Events.RayEvent(producer=self, producer_type=Events.EventProducerType.Keyboard, ray_event=Events.RayEventType.HangUp) + if (event.event_type == self.pickup_state): + key_ev.ray_event = Events.RayEventType.PickUp + print(f"ending value {key_ev.ray_event.name}") + # print(f"PhyEventLoop() : sending -> {key_ev.ray_event.name}") + self.event_queue.put(key_ev) + except queue.Empty: + pass + + def stop(self): + self.running = False + self.thread.join() + + def get_event(self): + try: + return self.event_queue.get(timeout=1) + except queue.Empty: + return None + diff --git a/RayPonder/Events/__init__.py b/RayPonder/Events/__init__.py index 97f4d11..a904baf 100644 --- a/RayPonder/Events/__init__.py +++ b/RayPonder/Events/__init__.py @@ -1,4 +1,9 @@ # RayPonder/__init__.py -from .PhyEventLoop import PhyEventLoop +import sys +if sys.platform == "win32": + from .PhyEventLoopKeyboard import PhyEventLoopKeyboard as PhyEventLoop +else: + from .PhyEventLoopEvdev import PhyEventLoopEvDev as PhyEventLoop +# from .PhyEventLoop import PhyEventLoop from .EventTypes import EventTypes, EventVal, EventProducerType, RayEventType from .RayEvent import RayEvent \ No newline at end of file diff --git a/n999.py b/n999.py new file mode 100644 index 0000000..b92c939 --- /dev/null +++ b/n999.py @@ -0,0 +1,20 @@ +from paramiko import SSHClient, WarningPolicy +import argparse + +parser = argparse.ArgumentParser(prog="N999", description="Download files in selected ssh directory", epilog="made with love, used with care") +parser.add_argument("--host", type=str, default="coope-birthday2.local", help="The host to connect to") +parser.add_argument("--user", type=str, default="coope", help="The user to connect as") +parser.add_argument("--record-folder", type=str, default="/coope/", help="path to record folder") +args = parser.parse_args() + + +client = SSHClient() +client.set_missing_host_key_policy(WarningPolicy()) +password = "C0op3r@tive" + +if __name__ == "__main__": + print(f"{args.host}, {args.user}, {args.record_folder}") + client.connect(args.host, username=args.user, password=password) + stdin, stdout, stderr = client.exec_command(f"cd {args.record_folder}; ls -la") + print(stdout.readlines()) + client.close() \ No newline at end of file diff --git a/ray-ponder.conf b/ray-ponder.conf index 9b689b9..b024ffc 100644 --- a/ray-ponder.conf +++ b/ray-ponder.conf @@ -1,5 +1,5 @@ [general] -root= /mnt/coope_drive/ +root= ./ [recorder] add-uuid = yes dest-dir = records/ @@ -15,7 +15,7 @@ format = 32 recode-timeout = 10 [player] message-path = messages/ -start-message = message01.wav +start-message = Cabine6.wav [phy-event] gpio-dev-input = /dev/input/event0 pickup-state = 0 diff --git a/requirements.txt b/requirements.txt index 9c1f636..3aa3a71 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ -evdev==1.9.1 +evdev==1.9.1; sys.platform == 'linux' +keyboard==0.13.5; sys.platform == 'win32' PyAudio==0.2.14 uuid==1.30