Skip to content

Commit

Permalink
Gen 3 SkullOS (#70)
Browse files Browse the repository at this point in the history
* Gen 3 Skull

Action Button = GPIO 4,
Change mode button = GPIO 14
Heartbeat light = GPIO 26
Activity Light = GPIO 13
Buzzer = GPIO 12

Now uses the new camera system for videos, but it doesn't appear to be very good
  • Loading branch information
David032 authored Nov 17, 2024
1 parent 96854b9 commit 90fff1a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 31 deletions.
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 @@ -24,35 +22,28 @@ public CameraService(int x = 2592, int y = 1944)
//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

0 comments on commit 90fff1a

Please sign in to comment.