Skip to content

Commit

Permalink
Or maybe this was the version I used?
Browse files Browse the repository at this point in the history
  • Loading branch information
David032 committed Oct 30, 2023
1 parent bb13b1f commit 6d9818d
Show file tree
Hide file tree
Showing 12 changed files with 396 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,5 @@ FodyWeavers.xsd

ServoSkullDemo/Builds
skullOS/skullOs/

skullOS/skullOSselfContained/
20 changes: 20 additions & 0 deletions Pinout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|Env Sensor|Grey|x|x| | |
|Env Sensor|Green|x|x|White|RGB Array|
|Env Sensor|Blue|x|x|Grey|RGB Array|
| | |x|x| | |
|Env Sensor|Purple|x|x| | |
| | |x|x| | |
| | |x|x|Brown|Power LED|
| | |x|x|Red|Power LED|
| | |x|x| | |
|RGB Array|Black|x|x|Yellow|Button|
| | |x|x|Yellow|Button|
| | |x|x| | |
|Buzzer|Black|x|x| | |
| | |x|x| | |
| | |x|x|Orange|Notification LED|
| | |x|x|Yellow|Notification LED|
|Buzzer|White|x|x|Green|Warning LED|
| | |x|x|Dark Blue|Warning LED|
|White LED|Red|x|x| | |
|White LED|Brown|x|x| | |
7 changes: 6 additions & 1 deletion ServoSkull.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Output", "skullOS.O
{464B162B-62FC-49CC-A6AB-72DBE959DD8C} = {464B162B-62FC-49CC-A6AB-72DBE959DD8C}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skullOS.Interlink", "skullOS.Interlink\skullOS.Interlink.csproj", "{E6CD1206-E775-44B6-93C1-CB2DEFB3C89B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Interlink", "skullOS.Interlink\skullOS.Interlink.csproj", "{E6CD1206-E775-44B6-93C1-CB2DEFB3C89B}"
ProjectSection(ProjectDependencies) = postProject
{464B162B-62FC-49CC-A6AB-72DBE959DD8C} = {464B162B-62FC-49CC-A6AB-72DBE959DD8C}
{9AC8960C-539A-4B2C-9D24-5169AF4337FA} = {9AC8960C-539A-4B2C-9D24-5169AF4337FA}
{D4E9CB35-2264-4717-BDB6-7797E84B5DFE} = {D4E9CB35-2264-4717-BDB6-7797E84B5DFE}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EE38A10C-F0BB-40B5-B1E6-8CB16C6E452C}"
ProjectSection(SolutionItems) = preProject
Pinout.md = Pinout.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
7 changes: 5 additions & 2 deletions skullOS.Camera/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using Iot.Device.Media;
using skullOS.Core;
using System.Device.Gpio;
using System.Device.I2c;

namespace skullOS.Camera
{
public class Camera : Controller
{
//capture size is set to QHD, which is supported by the zero cam
VideoDevice device;
VideoConnectionSettings deviceSettings = new(busId: 0, captureSize: (2560, 1440), pixelFormat: VideoPixelFormat.JPEG);
VideoConnectionSettings deviceSettings = new(busId: 0, captureSize: (2592, 1944), pixelFormat: VideoPixelFormat.JPEG);

GpioButton actionButton;

Expand All @@ -22,7 +23,7 @@ public override void Run(GpioController controller)
{
}

public override bool Setup(GpioController controller)
public override bool Setup(GpioController controller, I2cDevice i2CDevice)
{
var settings = SettingsLoader.LoadConfig(@"Data/Settings.txt");
var defaultValue = new KeyValuePair<string, string>("", "");
Expand All @@ -44,6 +45,8 @@ public override bool Setup(GpioController controller)
{
case "Image":
device = VideoDevice.Create(deviceSettings);
device.Settings.HorizontalFlip = true;
device.Settings.VerticalFlip = true;
actionButton = new(int.Parse(pinToActOn.Value));
actionButton.Press += TakePicture;

Expand Down
3 changes: 2 additions & 1 deletion skullOS.Core/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using skullOS.Core.Interfaces;
using System.Device.Gpio;
using System.Device.I2c;

namespace skullOS.Core
{
public abstract class Controller : ISubSystem
{
public abstract void Run(GpioController controller);

public abstract bool Setup(GpioController controller);
public abstract bool Setup(GpioController controller, I2cDevice i2CDevice);

public abstract void Stop();
}
Expand Down
3 changes: 2 additions & 1 deletion skullOS.Core/Interfaces/ISubSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Device.Gpio;
using System.Device.I2c;

namespace skullOS.Core.Interfaces
{
public interface ISubSystem
{
bool Setup(GpioController controller);
bool Setup(GpioController controller, I2cDevice i2CDevice);

void Run(GpioController controller);

Expand Down
6 changes: 4 additions & 2 deletions skullOS.Input/Input.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using skullOS.Core;
using System.Device.Gpio;
using System.Device.I2c;

namespace skullOS.Input
{
Expand All @@ -21,12 +22,13 @@ public override void Run(GpioController controller)
throw new NotImplementedException();
}

public override bool Setup(GpioController controller, System.Device.I2c.I2cBus i2cDevice)

public override void Stop()
{
throw new NotImplementedException();
}

public override void Stop()
public override bool Setup(GpioController controller, I2cDevice i2CDevice)
{
throw new NotImplementedException();
}
Expand Down
55 changes: 46 additions & 9 deletions skullOS.Interlink/Interlink.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using Iot.Device.Buzzer;
using Iot.Device.Bmp180;
using Iot.Device.Buzzer;
using skullOS.Core;
using skullOS.Core.Interfaces;
using skullOS.Output;
using System.Device.Gpio;
using System.Device.I2c;
using System.Net.NetworkInformation;

namespace skullOS.Interlink
{
Expand All @@ -17,7 +21,7 @@ public override void Run(GpioController controller)
Console.WriteLine("Interlink ran successfully!");
}

public override bool Setup(GpioController controller)
public override bool Setup(GpioController controller, I2cDevice i2CDevice)
{
Link();
return true;
Expand All @@ -39,10 +43,12 @@ public void Link()
cameraModule = (Camera.Camera)subSystems.Select(x => x).Where(x => x.ToString() == "skullOS.Camera.Camera").FirstOrDefault();
outputModule = (Output.Output)subSystems.Select(x => x).Where(x => x.ToString() == "skullOS.Output.Output").FirstOrDefault();

cameraModule.GetButton().Press += PlayBuzzerWhenActivated;
cameraModule.GetButton().Press += FlashLightWhenActivatedAsync;
cameraModule.GetButton().Press += PlayBuzzerWhenActivated;

Console.WriteLine(cameraModule.GetCamera().Settings);
var autoEvent = new AutoResetEvent(false);
//var temperatureCheck = new Timer(CheckTemperature, autoEvent, 0, 300000);
var connectionCheck = new Timer(CheckForNetwork, autoEvent, 0, 30000);
}


Expand All @@ -52,15 +58,46 @@ public void Link()
public void PlayBuzzerWhenActivated(object? sender, EventArgs e)
{
var buzzer = (Buzzer)outputModule.outputDevices.Select(x => x).FirstOrDefault(x => x.Name == "Buzzer").Device;
buzzer.PlayTone(1500, 1500);
buzzer.PlayTone(1500, 750);
}

private async void FlashLightWhenActivatedAsync(object? sender, EventArgs e)
{
//Output.SkullLed? led = (Output.SkullLed)outputModule.outputDevices.Select(x => x).FirstOrDefault(x => x.Name == "Camera Light");
//led.TurnOn();
//await Task.Delay(15000);
//led.TurnOff();
var cameraLED = (OutputLED)outputModule.outputDevices.Select(x => x).FirstOrDefault(x => x.Name == "Camera Light");
cameraLED.TurnOn();
await Task.Delay(750);
cameraLED.TurnOff();
}

public void CheckTemperature(object? state)
{
var warningLight = (OutputLED)outputModule.outputDevices.Select(x => x).FirstOrDefault(x => x.Name == "Danger Light");
var temperatureDevice = (Bmp180)outputModule.outputDevices.Select(x => x).FirstOrDefault(x => x.Name == "Env Sensor").Device;

var temp = temperatureDevice.ReadTemperature();
if (temp.DegreesCelsius >= 30)
{
warningLight.TurnOn();
}
else
{
warningLight.TurnOff();
}
}

public void CheckForNetwork(object? state)
{
var connectionLed = (OutputLED)outputModule.outputDevices.Select(x => x).FirstOrDefault(x => x.Name == "Alert Light");

if (NetworkInterface.GetIsNetworkAvailable())
{
connectionLed.TurnOn();
}
else
{
connectionLed.TurnOff();
}

}

#endregion
Expand Down
Loading

0 comments on commit 6d9818d

Please sign in to comment.