Skip to content

Commit

Permalink
Alpha 0.001 release
Browse files Browse the repository at this point in the history
Not fully fleshed out yet, but by seeing demand, i'm going to put it under releases.
  • Loading branch information
BrianLima committed Jan 22, 2018
1 parent 6fa0e44 commit f791b9b
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 174 deletions.
53 changes: 0 additions & 53 deletions HueHue/Helpers/Effects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,59 +309,6 @@ public static void ResetStep()
/// </summary>
public static void ColorCycle()
{
//if (step == 1) //Started with Red, transition to Yellow
//{
// Colors[0].G++;

// if (Colors[0].G == 255)
// {
// step++;
// }
//}
//else if (step == 2) //From Yellow to Green
//{
// Colors[0].R--;

// if (Colors[0].R == 0)
// {
// step++;
// }
//}
//else if (step == 3) //From Green to Alice Blue
//{
// Colors[0].B++;

// if (Colors[0].B == 255)
// {
// step++;
// }
//}
//else if (step == 4) //From Alice Blue to Blue
//{
// Colors[0].G--;

// if (Colors[0].G == 0)
// {
// step++;
// }
//}
//else if (step == 5) // From Blue to Pink/Purple
//{
// Colors[0].R++;
// if (Colors[0].R == 255)
// {
// step++;
// }
//}
//else if (step == 6) //From Pink/Purple to Red
//{
// Colors[0].B--;
// if (Colors[0].B == 0)
// {
// ResetStep(); //We Cycled all the basic colors, reset and start again
// }
//}

Colors[0] = Colors[0].AddHue(1);

//Fill the strip with the color
Expand Down
225 changes: 112 additions & 113 deletions HueHue/Helpers/RazerChroma.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace HueHue.Helpers
{
class RazerChroma : Device, IDisposable
{
//private Thread _workerThread;
//private CancellationTokenSource _cancellationTokenSource;
//private bool running = false;
private Thread _workerThread;
private CancellationTokenSource _cancellationTokenSource;
private bool running = false;

RazerDeviceProvider provider;

Expand All @@ -24,9 +24,9 @@ public RazerChroma(string _type, SubType _subType, string _Name)

public static void GetRazerDevices()
{
RGBSurface.Instance.LoadDevices(RazerDeviceProvider.Instance, RGBDeviceType.All, true, false );
RGBSurface.Instance.LoadDevices(RazerDeviceProvider.Instance, RGBDeviceType.All, true, false);
}

public override void Start()
{
provider = new RazerDeviceProvider();
Expand All @@ -35,127 +35,126 @@ public override void Start()
provider.Initialize();
}

// if (_workerThread != null) return;
// _cancellationTokenSource = new CancellationTokenSource();
// _workerThread = new Thread(BackgroundWorker_DoWork)
// {
// Name = "Serial sending",
// IsBackground = true
// };
// _workerThread.Start(_cancellationTokenSource.Token);
// running = true;

// if (!RazerDeviceProvider.Instance.IsInitialized)
// {
// RazerDeviceProvider.Instance.Initialize();
// }
if (_workerThread != null) return;

_cancellationTokenSource = new CancellationTokenSource();
_workerThread = new Thread(BackgroundWorker_DoWork)
{
Name = "Serial sending",
IsBackground = true
};
_workerThread.Start(_cancellationTokenSource.Token);
running = true;

if (!RazerDeviceProvider.Instance.IsInitialized)
{
RazerDeviceProvider.Instance.Initialize();
}
}

//private async void BackgroundWorker_DoWork(object tokenObject)
//{

// //TODO: Implement device/effect specific color handling
// var cancellationToken = (CancellationToken)tokenObject;
// while (!cancellationToken.IsCancellationRequested)
// {
// try
// {
// switch (subType)
// {
// case SubType.Keyboard:
// RazerKeyboardRGBDevice d = new RazerKeyboardRGBDevice();


// var keyboardGrid = Corale.Colore.Razer.Keyboard.Effects.Custom.Create();
// //Loop through all Rows
// for (var r = 0; r < Corale.Colore.Razer.Keyboard.Constants.MaxRows; r++)
// {
// //Loop through all Columns
// for (var c = 0; c < Corale.Colore.Razer.Keyboard.Constants.MaxColumns; c++)
// {
// // Set the current row and column to the random color
// keyboardGrid[r, c] = (new Color(Effects.LEDs[c].R, Effects.LEDs[c].G, Effects.LEDs[c].B));
// }
// }

// await Task.Run(() => Chroma.Instance.Keyboard.SetCustom(keyboardGrid));
// break;
// case SubType.Mouse:
// var mouseCustom = Corale.Colore.Razer.Mouse.Effects.Custom.Create();
// for (int i = 0; i < Corale.Colore.Razer.Mouse.Constants.MaxLeds; i++)
// {
// mouseCustom[i] = (new Color(Effects.LEDs[i].R, Effects.LEDs[i].G, Effects.LEDs[i].B));
// }
// await Task.Run(() => Chroma.Instance.Mouse.SetCustom(mouseCustom));
// break;
// case SubType.Headset: //LEDs on a headset for some reason doesn't seem to be adressable
// //var headCustom = Corale.Colore.Razer.Headset.Effects.Static;

// await Task.Run(() => Chroma.Instance.Headset.SetAll(new Color(Effects.LEDs[0].R, Effects.LEDs[0].G, Effects.LEDs[0].B)));
// break;
// case SubType.Mousepad:
// var padCustom = Corale.Colore.Razer.Mousepad.Effects.Custom.Create();
// for (int i = 0; i < Corale.Colore.Razer.Mousepad.Constants.MaxLeds; i++)
// {
// padCustom[i] = (new Color(Effects.LEDs[i].R, Effects.LEDs[i].G, Effects.LEDs[i].B));
// }
// await Task.Run(() => Chroma.Instance.Mousepad.SetCustom(padCustom));
// break;
// case SubType.Keypad:
// var keypadGrid = Corale.Colore.Razer.Keypad.Effects.Custom.Create();
// // Loop through all Rows
// for (var r = 0; r < Corale.Colore.Razer.Keypad.Constants.MaxRows; r++)
// {
// //Loop through all Columns
// for (var c = 0; c < Corale.Colore.Razer.Keypad.Constants.MaxColumns; c++)
// {
// // Set the current row and column to the random color
// keypadGrid[r, c] = (new Color(Effects.LEDs[c].R, Effects.LEDs[c].G, Effects.LEDs[c].B));
// }
// }
// await Task.Run(() => Chroma.Instance.Keypad.SetCustom(keypadGrid)); break;
// case SubType.All:
// await Task.Run(() => Chroma.Instance.SetAll(new Color(Effects.LEDs[0].R, Effects.LEDs[0].G, Effects.LEDs[0].B)));
// break;
// default:
// break;
// }

// //15 so we aproach 60~70 fps
// Task.Delay(15, cancellationToken).Wait(cancellationToken);
// }
// catch (Exception ex)
// {

// }
// }
//}
private async void BackgroundWorker_DoWork(object tokenObject)
{

//TODO: Implement device/effect specific color handling
var cancellationToken = (CancellationToken)tokenObject;
while (!cancellationToken.IsCancellationRequested)
{
try
{
var x = RazerDeviceProvider.Instance.Devices;
//switch (subType)
//{
// case SubType.Keyboard:
// RazerRGBDevice<RazerKeyboardRGBDeviceInfo>()
// var keyboardGrid = Corale.Colore.Razer.Keyboard.Effects.Custom.Create();
// //Loop through all Rows
// for (var r = 0; r < Corale.Colore.Razer.Keyboard.Constants.MaxRows; r++)
// {
// //Loop through all Columns
// for (var c = 0; c < Corale.Colore.Razer.Keyboard.Constants.MaxColumns; c++)
// {
// // Set the current row and column to the random color
// keyboardGrid[r, c] = (new Color(Effects.LEDs[c].R, Effects.LEDs[c].G, Effects.LEDs[c].B));
// }
// }

// await Task.Run(() => Chroma.Instance.Keyboard.SetCustom(keyboardGrid));
// break;
// case SubType.Mouse:
// var mouseCustom = Corale.Colore.Razer.Mouse.Effects.Custom.Create();
// for (int i = 0; i < Corale.Colore.Razer.Mouse.Constants.MaxLeds; i++)
// {
// mouseCustom[i] = (new Color(Effects.LEDs[i].R, Effects.LEDs[i].G, Effects.LEDs[i].B));
// }
// await Task.Run(() => Chroma.Instance.Mouse.SetCustom(mouseCustom));
// break;
// case SubType.Headset: //LEDs on a headset for some reason doesn't seem to be adressable
// //var headCustom = Corale.Colore.Razer.Headset.Effects.Static;

// await Task.Run(() => Chroma.Instance.Headset.SetAll(new Color(Effects.LEDs[0].R, Effects.LEDs[0].G, Effects.LEDs[0].B)));
// break;
// case SubType.Mousepad:
// var padCustom = Corale.Colore.Razer.Mousepad.Effects.Custom.Create();
// for (int i = 0; i < Corale.Colore.Razer.Mousepad.Constants.MaxLeds; i++)
// {
// padCustom[i] = (new Color(Effects.LEDs[i].R, Effects.LEDs[i].G, Effects.LEDs[i].B));
// }
// await Task.Run(() => Chroma.Instance.Mousepad.SetCustom(padCustom));
// break;
// case SubType.Keypad:
// var keypadGrid = Corale.Colore.Razer.Keypad.Effects.Custom.Create();
// // Loop through all Rows
// for (var r = 0; r < Corale.Colore.Razer.Keypad.Constants.MaxRows; r++)
// {
// //Loop through all Columns
// for (var c = 0; c < Corale.Colore.Razer.Keypad.Constants.MaxColumns; c++)
// {
// // Set the current row and column to the random color
// keypadGrid[r, c] = (new Color(Effects.LEDs[c].R, Effects.LEDs[c].G, Effects.LEDs[c].B));
// }
// }
// await Task.Run(() => Chroma.Instance.Keypad.SetCustom(keypadGrid)); break;
// case SubType.All:
// await Task.Run(() => Chroma.Instance.SetAll(new Color(Effects.LEDs[0].R, Effects.LEDs[0].G, Effects.LEDs[0].B)));
// break;
// default:
// break;
//}

//15 so we aproach 60~70 fps
Task.Delay(15, cancellationToken).Wait(cancellationToken);
}
catch (Exception ex)
{

}
}
}

public override void Stop()
{
// if (_workerThread == null) return;

// _cancellationTokenSource.Cancel();
// _cancellationTokenSource = null;
// _workerThread.Join();
// _workerThread = null;
// running = false;
// //RazerDeviceProvider.Instance.();
// if (_workerThread == null) return;

// _cancellationTokenSource.Cancel();
// _cancellationTokenSource = null;
// _workerThread.Join();
// _workerThread = null;
// running = false;
// //RazerDeviceProvider.Instance.();
}

public void Dispose()
{
// Dispose(true);
// GC.SuppressFinalize(this);
// Dispose(true);
// GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
// if (disposing)
// {
// Stop();
// }
// if (disposing)
// {
// Stop();
// }
}
}
}
7 changes: 7 additions & 0 deletions HueHue/HueHue.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@
<Compile Include="Views\Devices\AddArduinoView.xaml.cs">
<DependentUpon>AddArduinoView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Devices\AddAsusAuraView.xaml.cs">
<DependentUpon>AddAsusAuraView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Devices\AddDeviceView.xaml.cs">
<DependentUpon>AddDeviceView.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -235,6 +238,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Devices\AddAsusAuraView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Devices\AddDeviceView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
37 changes: 37 additions & 0 deletions HueHue/Views/Devices/AddAsusAuraView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<UserControl x:Class="HueHue.Views.Devices.AddAsusAuraView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HueHue.Views.Devices"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="68"/>
<RowDefinition/>
<RowDefinition Height="100"/>
</Grid.RowDefinitions>
<Button Content="Add" Margin="0,0,10,10" Height="32" HorizontalAlignment="Right" Width="75" VerticalAlignment="Bottom" Click="Button_Click" Grid.Row="2"/>
<Image HorizontalAlignment="Left" Height="50" Margin="10,10,0,0" VerticalAlignment="Top" Width="50" Source="/HueHue;component/Icons/Devices/AURA-sync.png" Stretch="UniformToFill" RenderOptions.BitmapScalingMode="HighQuality"/>
<Label Content="Setup a new Asus Aura Device" HorizontalAlignment="Left" Margin="65,20,0,0" VerticalAlignment="Top" Height="26" Width="190"/>
<ComboBox Margin="80,27,0,0" VerticalAlignment="Top" x:Name="ComboBox_SubType" Grid.Row="2" HorizontalAlignment="Left" Width="120" Height="29" SelectionChanged="ComboBox_SubType_SelectionChanged">
</ComboBox>
<Label Content="Type:" HorizontalAlignment="Left" Margin="18,30,0,0" VerticalAlignment="Top" Grid.Row="2" Height="26" Width="37"/>
<Label Content="Name:" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Grid.Row="2" Height="26" Width="45"/>
<Grid Margin="10,7,10,22" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="7*"/>
<ColumnDefinition Width="204.8"/>
<ColumnDefinition Width="8*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="First, download and install the Asus Aura SDK on your PC:" TextWrapping="Wrap" Height="33" VerticalAlignment="Top" Grid.ColumnSpan="3"/>
<Button Content="Download Asus Aura SDK" Margin="1.8,33,4,0" VerticalAlignment="Top" Grid.Column="1" Click="Button_Click_1"/>
<TextBlock Text="Now, make sure that the Asus SDK service is running, and just complete the setup below." Margin="0,70,0,0" TextWrapping="Wrap" Height="33" VerticalAlignment="Top" Grid.ColumnSpan="3"/>

</Grid>
<TextBox Height="23" Margin="80,4,100,0" TextWrapping="WrapWithOverflow" VerticalAlignment="Top" Grid.Row="2" Text="Chroma" x:Name="TextBoxName"/>

</Grid>
</UserControl>
Loading

0 comments on commit f791b9b

Please sign in to comment.