-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
282 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Pin=25 | ||
Mode=Image | ||
Mode=Image | ||
LedPin=26 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Device.Gpio; | ||
|
||
namespace skullOS.Core.LED_Elements | ||
{ | ||
public enum LedBehaviour | ||
{ | ||
On, | ||
Off, | ||
OnEvent | ||
} | ||
|
||
public class SkullLed | ||
{ | ||
public string name = ""; | ||
public int pin = 0; | ||
public LedBehaviour state = LedBehaviour.Off; | ||
|
||
private GpioController gpioController; | ||
bool ledOn = false; | ||
|
||
public SkullLed(string LedName, int ledPin, GpioController controller) | ||
{ | ||
name = LedName; | ||
pin = ledPin; | ||
gpioController = controller; | ||
} | ||
|
||
public void ToggleState() | ||
{ | ||
gpioController.Write(pin, ((ledOn) ? PinValue.High : PinValue.Low)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
BuzzerPin = 17 | ||
NeoPixel = True | ||
NeoPixelCount = 8 | ||
LedPin = 23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using skullOS.Core; | ||
using System.Device.Gpio; | ||
using System.Drawing; | ||
|
||
namespace skullOS.Output | ||
{ | ||
public class Output : Controller | ||
{ | ||
public List<SkullOutputDevice> outputDevices = new(); | ||
|
||
public override void Run(GpioController controller) | ||
{ | ||
var pixelDisplay = (SkullNeoPixel)outputDevices.Select(x => x).Where(x => x.Name == "NeoPixel").FirstOrDefault(); | ||
pixelDisplay.device.Image.SetPixel(0, 0, Color.AliceBlue); | ||
} | ||
|
||
public override bool Setup(GpioController controller) | ||
{ | ||
var settings = SettingsLoader.LoadConfig(@"Data/Settings.txt"); | ||
var defaultValue = new KeyValuePair<string, string>("", ""); | ||
|
||
if (settings.ContainsKey("Buzzer")) | ||
{ | ||
settings.TryGetValue("Buzzer", out string BuzzerPin); | ||
var deviceBuzzer = new SkullBuzzer("Buzzer", int.Parse(BuzzerPin)); | ||
outputDevices.Add(deviceBuzzer); | ||
} | ||
if (settings.ContainsKey("NeoPixel")) | ||
{ | ||
settings.TryGetValue("NeoPixelCount", out string count); | ||
var deviceNeoPixel = new SkullNeoPixel("NeoPixel", int.Parse(count)); | ||
outputDevices.Add(deviceNeoPixel); | ||
} | ||
|
||
if (settings.ContainsKey("LedPin")) | ||
{ | ||
settings.TryGetValue("LedPin", out string pin); | ||
var deviceLed = new skullOS.Output.SkullLed("Life Light", int.Parse(pin), controller); | ||
outputDevices.Add(deviceLed); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public override void Stop() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Iot.Device.Buzzer; | ||
|
||
namespace skullOS.Output | ||
{ | ||
internal class SkullBuzzer : SkullOutputDevice | ||
{ | ||
int Pin = 0; | ||
public Buzzer device | ||
{ | ||
get { return buzzer; } | ||
} | ||
Buzzer buzzer; | ||
|
||
|
||
public SkullBuzzer(string name, int pin) | ||
{ | ||
this.Name = name; | ||
this.Pin = pin; | ||
buzzer = new Buzzer(pin); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using skullOS.Core.LED_Elements; | ||
using System.Device.Gpio; | ||
|
||
namespace skullOS.Output | ||
{ | ||
public class SkullLed : SkullOutputDevice | ||
{ | ||
public string name = ""; | ||
public int pin = 0; | ||
public LedBehaviour state = LedBehaviour.Off; | ||
|
||
private GpioController gpioController; | ||
bool ledOn = false; | ||
|
||
public SkullLed(string LedName, int ledPin, GpioController controller) | ||
{ | ||
name = LedName; | ||
pin = ledPin; | ||
gpioController = controller; | ||
} | ||
|
||
public void ToggleState() | ||
{ | ||
gpioController.Write(pin, ((ledOn) ? PinValue.High : PinValue.Low)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Iot.Device.Ws28xx; | ||
using System.Device.Spi; | ||
|
||
namespace skullOS.Output | ||
{ | ||
internal class SkullNeoPixel : SkullOutputDevice | ||
{ | ||
public Ws2812b device | ||
{ | ||
get { return neoPixel; } | ||
} | ||
Ws2812b neoPixel; | ||
|
||
public SkullNeoPixel(string name, int count) | ||
{ | ||
this.Name = name; | ||
|
||
SpiConnectionSettings spiSettings = new(0, 0) | ||
{ | ||
ClockFrequency = 2_400_000, | ||
Mode = SpiMode.Mode0, | ||
DataBitLength = 8 | ||
}; | ||
using SpiDevice spi = SpiDevice.Create(spiSettings); | ||
|
||
Ws2812b neopixel = new(spi, count); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace skullOS.Output | ||
{ | ||
public abstract class SkullOutputDevice | ||
{ | ||
public string Name = ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\skullOS.Core\skullOS.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Data\Output.txt"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Device.Gpio; | ||
|
||
namespace skullOS.Tests | ||
{ | ||
internal class MockGpioController : GpioController | ||
{ | ||
public MockGpioController() | ||
{ | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.