From aefeb42ade36855a13d239a633279e3d1abfd130 Mon Sep 17 00:00:00 2001 From: David K Date: Tue, 22 Oct 2024 18:59:15 +0100 Subject: [PATCH 1/3] Required config changes Action Button = GPIO 4, Change mode button = GPIO 14 Heartbeat light = GPIO 26 Activity Light = GPIO 13 Buzzer = GPIO 12 --- Source/skullOS.Modules/Camera.cs | 4 ++-- Source/skullOS.Modules/Data/CameraSettings.txt | 2 +- Source/skullOS/InputManager.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/skullOS.Modules/Camera.cs b/Source/skullOS.Modules/Camera.cs index 394107e..d6d2cec 100644 --- a/Source/skullOS.Modules/Camera.cs +++ b/Source/skullOS.Modules/Camera.cs @@ -97,12 +97,12 @@ public Camera(ICameraService camService = null, IMicrophoneService micService = //This should be reading from the file! if (buzService == null) { - BuzzerService = new BuzzerService(13); + BuzzerService = new BuzzerService(12); } else { BuzzerService = buzService; - BuzzerService.SetBuzzer(13); + BuzzerService.SetBuzzer(12); } useBuzzer = true; } diff --git a/Source/skullOS.Modules/Data/CameraSettings.txt b/Source/skullOS.Modules/Data/CameraSettings.txt index 1c90400..fc89f0c 100644 --- a/Source/skullOS.Modules/Data/CameraSettings.txt +++ b/Source/skullOS.Modules/Data/CameraSettings.txt @@ -1,3 +1,3 @@ UseMic=False -UseBuzzer=False +UseBuzzer=True CameraLight=6 \ No newline at end of file diff --git a/Source/skullOS/InputManager.cs b/Source/skullOS/InputManager.cs index bc9704a..3200cee 100644 --- a/Source/skullOS/InputManager.cs +++ b/Source/skullOS/InputManager.cs @@ -9,8 +9,8 @@ internal class InputManager { GpioButton ActionButton; GpioButton ToggleButton; - int actionButtonPin = 24; //25 - int toggleButtonPin = 23; //26 + int actionButtonPin = 4; //25 + int toggleButtonPin = 14; //26 private Module? activeModule; List<(int, Module, string)> inputModules = []; int index = 0; From 415a55a11347b2a9af80a93d025c9e81a35fac97 Mon Sep 17 00:00:00 2001 From: David K Date: Tue, 22 Oct 2024 20:49:59 +0100 Subject: [PATCH 2/3] More fixes Validated core functionality is now working - still need to deal with the awful video resolution --- Source/skullOS.Modules/Camera.cs | 4 ++-- Source/skullOS.Modules/Data/PropSettings.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/skullOS.Modules/Camera.cs b/Source/skullOS.Modules/Camera.cs index d6d2cec..394107e 100644 --- a/Source/skullOS.Modules/Camera.cs +++ b/Source/skullOS.Modules/Camera.cs @@ -97,12 +97,12 @@ public Camera(ICameraService camService = null, IMicrophoneService micService = //This should be reading from the file! if (buzService == null) { - BuzzerService = new BuzzerService(12); + BuzzerService = new BuzzerService(13); } else { BuzzerService = buzService; - BuzzerService.SetBuzzer(12); + BuzzerService.SetBuzzer(13); } useBuzzer = true; } diff --git a/Source/skullOS.Modules/Data/PropSettings.txt b/Source/skullOS.Modules/Data/PropSettings.txt index 10600e6..518c531 100644 --- a/Source/skullOS.Modules/Data/PropSettings.txt +++ b/Source/skullOS.Modules/Data/PropSettings.txt @@ -1,3 +1,3 @@ Sounds=False -Lights=False +Lights=True Servos=False \ No newline at end of file From 99d9ae21fa68f572af8c2fdafb73a2d7e1ea696e Mon Sep 17 00:00:00 2001 From: David K Date: Sun, 17 Nov 2024 18:09:33 +0000 Subject: [PATCH 3/3] Using the new camera system for videos But it doesn't appear to be very good --- .../skullOS.HardwareServices/CameraService.cs | 45 ++++++++----------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/Source/skullOS.HardwareServices/CameraService.cs b/Source/skullOS.HardwareServices/CameraService.cs index 7f6e70f..ce032e1 100644 --- a/Source/skullOS.HardwareServices/CameraService.cs +++ b/Source/skullOS.HardwareServices/CameraService.cs @@ -1,8 +1,6 @@ using Iot.Device.Camera.Settings; using Iot.Device.Common; -using skullOS.HardwareServices.Exceptions; using skullOS.HardwareServices.Interfaces; -using System.Diagnostics; namespace skullOS.HardwareServices { @@ -24,35 +22,28 @@ public CameraService(int x = 2592, int y = 1944) //TODO: Still needs quality setting public async Task RecordShortVideoAsync(string fileLocation, bool useMic) { + var processSettings = ProcessSettingsFactory.CreateForLibcameravid(); + var builder = new CommandOptionsBuilder() + .WithContinuousStreaming() + .WithVflip() + .WithHflip() + .WithResolution(1920, 1080); + var args = builder.GetArguments(); + using var proc = new ProcessRunner(processSettings); + + var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss"); + string? filename = fileLocation + timestamp + ".h264"; + using var file = File.OpenWrite(filename); + + var task = await proc.ContinuousRunAsync(args, file); + await Task.Delay(30000); + proc.Dispose(); try { - using Process videoRecording = new(); - string args = string.Empty; - if (useMic) - { - args = " --codec libav --hflip --vflip --libav-audio --width 1920 --height 1080 -t 30000 -o " + $"{fileLocation}" - + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mp4"; - } - else - { - args = " --codec libav --hflip --vflip --width 1920 --height 1080 -t 30000 -o " + $"{fileLocation}" - + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mp4"; - } - videoRecording.StartInfo.UseShellExecute = false; - videoRecording.StartInfo.FileName = "libcamera-vid"; - videoRecording.StartInfo.Arguments = args; - videoRecording.EnableRaisingEvents = true; -#if DEBUG - await Console.Out.WriteLineAsync("Running:"); - await Console.Out.WriteLineAsync(videoRecording.StartInfo.FileName + videoRecording.StartInfo.Arguments); -#endif - videoRecording.Start(); - await Task.WhenAny(Task.Delay(30000)); + await task; } - catch (CameraErrorException e) + catch (Exception) { - await Console.Out.WriteLineAsync(e.Message); - return "Camera errored when recording video!"; } return $"({DateTime.Now}) Short video recorded!";