Skip to content

Commit

Permalink
MCM Birmingham 2023 Version
Browse files Browse the repository at this point in the history
Made an OS upgrade the night before which required rebuilding the camera system, and tried to get the app to switch between urls based on the version
  • Loading branch information
David032 committed Dec 5, 2023
1 parent 4af49a5 commit 8a7fe25
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 54 deletions.
14 changes: 0 additions & 14 deletions ServoSkull.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.HardwareServices",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServoSkullDemo", "MiscFiles\ServoSkullDemo\ServoSkullDemo.csproj", "{0B0F89D7-32B6-4E20-B676-44F70E7B5352}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Tests", "Tests\skullOS.Tests\skullOS.Tests.csproj", "{1D19D4D0-6BB7-42B8-A631-D141F651845F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Core.Tests", "Tests\skullOS.Core.Tests\skullOS.Core.Tests.csproj", "{23A5D116-8359-4E36-B64C-E6E4CAFF7140}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -69,22 +65,12 @@ Global
{0B0F89D7-32B6-4E20-B676-44F70E7B5352}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B0F89D7-32B6-4E20-B676-44F70E7B5352}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B0F89D7-32B6-4E20-B676-44F70E7B5352}.Release|Any CPU.Build.0 = Release|Any CPU
{1D19D4D0-6BB7-42B8-A631-D141F651845F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D19D4D0-6BB7-42B8-A631-D141F651845F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D19D4D0-6BB7-42B8-A631-D141F651845F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D19D4D0-6BB7-42B8-A631-D141F651845F}.Release|Any CPU.Build.0 = Release|Any CPU
{23A5D116-8359-4E36-B64C-E6E4CAFF7140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23A5D116-8359-4E36-B64C-E6E4CAFF7140}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23A5D116-8359-4E36-B64C-E6E4CAFF7140}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23A5D116-8359-4E36-B64C-E6E4CAFF7140}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0B0F89D7-32B6-4E20-B676-44F70E7B5352} = {EE38A10C-F0BB-40B5-B1E6-8CB16C6E452C}
{1D19D4D0-6BB7-42B8-A631-D141F651845F} = {B50B951E-DF9B-49DD-9CAC-ED8B01C6B1E7}
{23A5D116-8359-4E36-B64C-E6E4CAFF7140} = {B50B951E-DF9B-49DD-9CAC-ED8B01C6B1E7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FA7BE016-5699-47F3-A654-08A907CE1F11}
Expand Down
1 change: 1 addition & 0 deletions SkulliumLite/Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Compile Include="Assets\Scripts\FooterController.cs" />
<Compile Include="Assets\Scripts\BuzzerController.cs" />
<Compile Include="Assets\Scripts\MainMenuDriver.cs" />
<Compile Include="Assets\Scripts\URLS.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Assets\TextMesh Pro\Shaders\TMPro.cginc" />
Expand Down
2 changes: 1 addition & 1 deletion SkulliumLite/Assets/Scripts/BuzzerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void PlayTune()

IEnumerator SendTuneRequest()
{
using (UnityWebRequest webRequest = UnityWebRequest.Get("http://servoskull.local:5000/Buzzer/PlayTune?tune=" + tuneInt))
using (UnityWebRequest webRequest = UnityWebRequest.Get(URLS.BaseUrl() + "Buzzer/PlayTune?tune=" + tuneInt))
{
yield return webRequest.SendWebRequest();
}
Expand Down
2 changes: 1 addition & 1 deletion SkulliumLite/Assets/Scripts/Deleter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void Delete()

IEnumerator DeleteElement()
{
using (UnityWebRequest webRequest = UnityWebRequest.Delete("http://servoskull.local:5000/Captures/Delete?filePath=" + idToDelete))
using (UnityWebRequest webRequest = UnityWebRequest.Delete(URLS.BaseUrl() + "Captures/Delete?filePath=" + idToDelete))
{
yield return webRequest.SendWebRequest();
}
Expand Down
4 changes: 2 additions & 2 deletions SkulliumLite/Assets/Scripts/GalleryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ IEnumerator PopulateDisplay()

IEnumerator GetCaptures()
{
using (UnityWebRequest webRequest = UnityWebRequest.Get("http://servoskull.local:5000/Captures/AllCaptures"))
using (UnityWebRequest webRequest = UnityWebRequest.Get(URLS.BaseUrl() + "Captures/AllCaptures"))
{
yield return webRequest.SendWebRequest();
var result = webRequest.downloadHandler.text;
Expand All @@ -75,7 +75,7 @@ IEnumerator GetCaptures()
//id is filename+extension
IEnumerator SetupElement(string id)
{
using (UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture("http://servoskull.local:5000/Captures/Image/?fileId=" + id))
using (UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(URLS.BaseUrl() + "/ Captures/Image/?fileId=" + id))
{
yield return webRequest.SendWebRequest();
var texture = DownloadHandlerTexture.GetContent(webRequest);
Expand Down
4 changes: 2 additions & 2 deletions SkulliumLite/Assets/Scripts/MainMenuDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void DeleteMostRecent()

IEnumerator GetLatestImage()
{
using (UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture("http://servoskull.local:5000/Captures/MostRecent"))
using (UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(URLS.BaseUrl() + "Captures/MostRecent"))
{
yield return webRequest.SendWebRequest();
print(webRequest.url);
Expand All @@ -43,7 +43,7 @@ IEnumerator GetLatestImage()

IEnumerator DeleteLatestImage()
{
using (UnityWebRequest webRequest = UnityWebRequest.Delete("http://servoskull.local:5000/Captures/DeleteMostRecent"))
using (UnityWebRequest webRequest = UnityWebRequest.Delete(URLS.BaseUrl() + "Captures/DeleteMostRecent"))
{
yield return webRequest.SendWebRequest();
}
Expand Down
12 changes: 12 additions & 0 deletions SkulliumLite/Assets/Scripts/URLS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public static class URLS
{
public static string BaseUrl()
{
#if DEBUG
return "http://servoskull.local:5000/";
#endif
#if !DEBUG
return "https://servoskull.local:5001/";
#endif
}
}
36 changes: 18 additions & 18 deletions SkulliumLite/UserSettings/Layouts/default-2022.dwlt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
width: 1920
height: 997
m_ShowMode: 4
m_Title: Inspector
m_Title: Scene
m_RootView: {fileID: 2}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
Expand Down Expand Up @@ -119,7 +119,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 100}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 38
controlID: 92
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
Expand Down Expand Up @@ -233,7 +233,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 1
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: ProjectBrowser
m_Name: ConsoleWindow
m_EditorClassIdentifier:
m_Children: []
m_Position:
Expand All @@ -242,14 +242,14 @@ MonoBehaviour:
y: 561
width: 1466
height: 386
m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021}
m_ActualView: {fileID: 13}
m_MinSize: {x: 101, y: 121}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 16}
m_Panes:
- {fileID: 13}
- {fileID: 16}
m_Selected: 0
m_LastSelected: 1
m_Selected: 1
m_LastSelected: 0
--- !u!114 &11
MonoBehaviour:
m_ObjectHideFlags: 52
Expand Down Expand Up @@ -389,23 +389,23 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets
- Assets/Scripts
m_Globs: []
m_OriginalText:
m_ImportLogFlags: 0
m_ViewMode: 1
m_StartGridSize: 64
m_LastFolders:
- Assets
- Assets/Scripts
m_LastFoldersGridSize: -1
m_LastProjectPath: I:\ServoSkull\SkulliumLite
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 66610000
m_LastClickedID: 24934
m_ExpandedIDs: 000000006661000000ca9a3b
m_SelectedIDs: 20620000
m_LastClickedID: 25120
m_ExpandedIDs: 000000000e62000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand Down Expand Up @@ -433,7 +433,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 0000000066610000
m_ExpandedIDs: 000000000e620000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand All @@ -458,8 +458,8 @@ MonoBehaviour:
m_Icon: {fileID: 0}
m_ResourceFile:
m_ListAreaState:
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_SelectedInstanceIDs: 30620000
m_LastClickedInstanceID: 25136
m_HadKeyboardFocusLastEvent: 1
m_ExpandedInstanceIDs: c6230000a6bf0000
m_RenameOverlay:
Expand Down Expand Up @@ -526,9 +526,9 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_SelectedIDs: 30620000
m_LastClickedID: 0
m_ExpandedIDs: eed4ffff3ad5ffffb8d6ffff3adbffff8adbffff20ddffff0efbffff1c6000005e600000706000008a600000a4600000be600000fa60000000610000
m_ExpandedIDs: 0efbffff
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand Down
12 changes: 0 additions & 12 deletions Tests/skullOS.Tests/MockGpioController.cs

This file was deleted.

38 changes: 37 additions & 1 deletion skullOS.HardwareServices/CameraService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Iot.Device.Media;
using Iot.Device.Camera.Settings;
using Iot.Device.Common;
using Iot.Device.Media;
using skullOS.HardwareServices.Interfaces;
using System.Diagnostics;

Expand All @@ -10,12 +12,46 @@ public class CameraService : ICameraService
private Process? cameraCommand;
private TaskCompletionSource<bool> eventHandled;

private readonly ProcessSettings _processSettings;


public CameraService(VideoConnectionSettings cameraSettings = null)

Check warning on line 18 in skullOS.HardwareServices/CameraService.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 18 in skullOS.HardwareServices/CameraService.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Non-nullable field 'eventHandled' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 18 in skullOS.HardwareServices/CameraService.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 18 in skullOS.HardwareServices/CameraService.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Non-nullable field 'eventHandled' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
cameraSettings ??= new(busId: 0, captureSize: (2592, 1944), pixelFormat: VideoPixelFormat.JPEG);
Camera = VideoDevice.Create(cameraSettings);
Camera.Settings.HorizontalFlip = true;
Camera.Settings.VerticalFlip = true;

_processSettings = ProcessSettingsFactory.CreateForLibcamerastill();
}

public async Task<string> TakePictureAsync(string fileLocation)
{
var builder = new CommandOptionsBuilder()
.WithTimeout(1)
.WithVflip()
.WithHflip()
.WithResolution(2592, 1944);
var args = builder.GetArguments();

using var proc = new ProcessRunner(_processSettings);
Console.WriteLine("Using the following command line:");
Console.WriteLine(proc.GetFullCommandLine(args));
Console.WriteLine();

//string? filename = $"{fileLocation} {DateTime.Now:yyyyMMddHHmmss}.jpg";
string? filename = $"{DateTime.Now:yyyyMMddHHmmss}.jpg"; //Fakename
try
{
using var file = File.OpenWrite(filename);
await proc.ExecuteAsync(args, file);
}
catch (Exception)
{
await Console.Out.WriteLineAsync("Cam errored!");
}

return filename;
}

#region SharpCamera code(https://github.com/David032/sharpCamera) for recording video
Expand Down
12 changes: 9 additions & 3 deletions skullOS.Modules/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Camera : Module, ICameraModule
public MicrophoneService MicrophoneService;
public LedService LedService;
public CameraMode CameraMode = CameraMode.Image;
public BuzzerService BuzzerService;

bool useMic = false;

Expand Down Expand Up @@ -51,16 +52,21 @@ public Camera()
LedService = new LedService(pins);
}
}

BuzzerService = new BuzzerService(13);
}

public void TakePicture()
public async void TakePicture()
{
LogMessage($"({DateTime.Now}) Picture taken!");
if (LedService != null && LedService.LEDs.ContainsKey("CameraLight"))
{
LedService.BlinkLight("CameraLight");
}
CameraService.Camera.Capture($"{FileManager.GetSkullDirectory()}/Captures/{DateTime.Now:yyyyMMddHHmmss}.jpg");
BuzzerService.Buzzer.PlayTone(1500, 500);
await CameraService.TakePictureAsync($"{FileManager.GetSkullDirectory()}/Captures/");
LogMessage($"({DateTime.Now}) Picture taken!");

//CameraService.Camera.Capture($"{FileManager.GetSkullDirectory()}/Captures/{DateTime.Now:yyyyMMddHHmmss}.jpg");
}

public void RecordShortVideo()
Expand Down

0 comments on commit 8a7fe25

Please sign in to comment.