Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen 3 SkullOS #70

Merged
merged 3 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions Source/skullOS.HardwareServices/CameraService.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -13,7 +11,7 @@
int yResolution;


public CameraService(int x = 2592, int y = 1944)

Check warning on line 14 in Source/skullOS.HardwareServices/CameraService.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_processSettings' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
xResolution = x;
yResolution = y;
Expand All @@ -24,35 +22,28 @@
//TODO: Still needs quality setting
public async Task<string> 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!";
Expand Down
2 changes: 1 addition & 1 deletion Source/skullOS.Modules/Data/CameraSettings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
UseMic=False
UseBuzzer=False
UseBuzzer=True
CameraLight=6
2 changes: 1 addition & 1 deletion Source/skullOS.Modules/Data/PropSettings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Sounds=False
Lights=False
Lights=True
Servos=False
4 changes: 2 additions & 2 deletions Source/skullOS/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading