Skip to content

Commit c2b78c0

Browse files
committed
Merge branch 'develop'
2 parents 84ec864 + 1e96c30 commit c2b78c0

File tree

61 files changed

+1461
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1461
-338
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using TTController.Common;
5+
6+
namespace TTController.Plugin.BlinkEffect
7+
{
8+
public class BlinkEffectConfig : EffectConfigBase
9+
{
10+
public int On { get; set; } = 1000;
11+
public int Off { get; set; } = 1000;
12+
public List<LedColor> Colors { get; set; }
13+
}
14+
15+
public class BlinkEffect : EffectBase<BlinkEffectConfig>
16+
{
17+
private int _ticks;
18+
private bool _state;
19+
20+
public BlinkEffect(BlinkEffectConfig config) : base(config) { }
21+
22+
public override string EffectType => "ByLed";
23+
24+
public override IDictionary<PortIdentifier, List<LedColor>> GenerateColors(List<PortIdentifier> ports, ICacheProvider cache)
25+
{
26+
var current = Environment.TickCount;
27+
var diff = current - _ticks;
28+
29+
if ((_state && diff > Config.On) || (!_state && diff > Config.Off))
30+
{
31+
_ticks = current;
32+
_state = !_state;
33+
}
34+
35+
var result = new Dictionary<PortIdentifier, List<LedColor>>();
36+
foreach (var port in ports)
37+
{
38+
var config = cache.GetPortConfig(port);
39+
if (config == null)
40+
continue;
41+
42+
if (_state)
43+
{
44+
result.Add(port, Config.Colors.ToList());
45+
}
46+
else
47+
{
48+
var offColor = new LedColor(0, 0, 0);
49+
result.Add(port, Enumerable.Range(0, config.LedCount).Select(x => offColor).ToList());
50+
}
51+
}
52+
53+
return result;
54+
}
55+
}
56+
}

Plugins/Effects/TTController.Plugin.DefaultEffect/Properties/AssemblyInfo.cs renamed to Plugins/Effects/TTController.Plugin.BlinkEffect/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
8-
[assembly: AssemblyTitle("TTController.Plugin.DefaultEffect")]
8+
[assembly: AssemblyTitle("TTController.Plugin.BlinkEffect")]
99
[assembly: AssemblyDescription("")]
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("TTController.Plugin.DefaultEffect")]
12+
[assembly: AssemblyProduct("TTController.Plugin.BlinkEffect")]
1313
[assembly: AssemblyCopyright("Copyright © 2019")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
@@ -20,7 +20,7 @@
2020
[assembly: ComVisible(false)]
2121

2222
// The following GUID is for the ID of the typelib if this project is exposed to COM
23-
[assembly: Guid("371d0801-022d-4ff8-b26b-62477b51ec8c")]
23+
[assembly: Guid("cef4bbe4-a710-4160-b673-b0fcd3b1ccae")]
2424

2525
// Version information for an assembly consists of the following four values:
2626
//

Plugins/Effects/TTController.Plugin.DefaultEffect/TTController.Plugin.DefaultEffect.csproj renamed to Plugins/Effects/TTController.Plugin.BlinkEffect/TTController.Plugin.BlinkEffect.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{371D0801-022D-4FF8-B26B-62477B51EC8C}</ProjectGuid>
7+
<ProjectGuid>{CEF4BBE4-A710-4160-B673-B0FCD3B1CCAE}</ProjectGuid>
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>TTController.Plugin.DefaultEffect</RootNamespace>
11-
<AssemblyName>TTController.Plugin.DefaultEffect</AssemblyName>
10+
<RootNamespace>TTController.Plugin.BlinkEffect</RootNamespace>
11+
<AssemblyName>TTController.Plugin.BlinkEffect</AssemblyName>
1212
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<Deterministic>true</Deterministic>
@@ -41,12 +41,12 @@
4141
<Reference Include="System.Xml" />
4242
</ItemGroup>
4343
<ItemGroup>
44-
<Compile Include="DefaultEffect.cs" />
44+
<Compile Include="BlinkEffect.cs" />
4545
<Compile Include="Properties\AssemblyInfo.cs" />
4646
</ItemGroup>
4747
<ItemGroup>
4848
<ProjectReference Include="..\..\..\Source\TTController.Common\TTController.Common.csproj">
49-
<Project>{c1e69ff7-20f6-425c-b8ba-9a1116a35e52}</Project>
49+
<Project>{C1E69FF7-20F6-425C-B8BA-9A1116A35E52}</Project>
5050
<Name>TTController.Common</Name>
5151
</ProjectReference>
5252
</ItemGroup>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using TTController.Common;
4+
5+
namespace TTController.Plugin.ByLedColorEffect
6+
{
7+
public class ByLedColorEffectConfig : EffectConfigBase
8+
{
9+
public List<LedColor> Colors { get; set; }
10+
}
11+
12+
public class ByLedColorEffect : EffectBase<ByLedColorEffectConfig>
13+
{
14+
public ByLedColorEffect(ByLedColorEffectConfig config) : base(config) { }
15+
16+
public override string EffectType => "ByLed";
17+
18+
public override IDictionary<PortIdentifier, List<LedColor>> GenerateColors(List<PortIdentifier> ports, ICacheProvider cache) =>
19+
ports.ToDictionary(p => p, p => Config.Colors.ToList());
20+
}
21+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("TTController.Plugin.ByLedColorEffect")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("TTController.Plugin.ByLedColorEffect")]
13+
[assembly: AssemblyCopyright("Copyright © 2019")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("17b4553b-99ef-49e8-8270-3153b9b12e57")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{17B4553B-99EF-49E8-8270-3153B9B12E57}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>TTController.Plugin.ByLedColorEffect</RootNamespace>
11+
<AssemblyName>TTController.Plugin.ByLedColorEffect</AssemblyName>
12+
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="System" />
35+
<Reference Include="System.Core" />
36+
<Reference Include="System.Xml.Linq" />
37+
<Reference Include="System.Data.DataSetExtensions" />
38+
<Reference Include="Microsoft.CSharp" />
39+
<Reference Include="System.Data" />
40+
<Reference Include="System.Net.Http" />
41+
<Reference Include="System.Xml" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="ByLedColorEffect.cs" />
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<ProjectReference Include="..\..\..\Source\TTController.Common\TTController.Common.csproj">
49+
<Project>{C1E69FF7-20F6-425C-B8BA-9A1116A35E52}</Project>
50+
<Name>TTController.Common</Name>
51+
</ProjectReference>
52+
</ItemGroup>
53+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
54+
</Project>

Plugins/Effects/TTController.Plugin.DefaultEffect/DefaultEffect.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using TTController.Common;
5+
6+
namespace TTController.Plugin.FlowEffect
7+
{
8+
public class FlowEffectConfig : EffectConfigBase
9+
{
10+
public float FillStep { get; set; }
11+
public float HueStep { get; set; }
12+
public float Saturation { get; set; }
13+
public float Brightness { get; set; }
14+
}
15+
16+
public class FlowEffect : EffectBase<FlowEffectConfig>
17+
{
18+
private float _currentHue;
19+
private float _lastHue;
20+
private float _fill;
21+
22+
23+
public FlowEffect(FlowEffectConfig config) : base(config)
24+
{
25+
_lastHue = 0;
26+
_currentHue = Config.HueStep;
27+
}
28+
29+
public override string EffectType => "ByLed";
30+
31+
public override IDictionary<PortIdentifier, List<LedColor>> GenerateColors(List<PortIdentifier> ports, ICacheProvider cache)
32+
{
33+
_fill += Config.FillStep;
34+
if (_fill >= 1)
35+
{
36+
_fill = 0;
37+
_lastHue = _currentHue;
38+
_currentHue = (_currentHue + Config.HueStep) % 360;
39+
}
40+
41+
var result = new Dictionary<PortIdentifier, List<LedColor>>();
42+
foreach (var port in ports)
43+
{
44+
var config = cache.GetPortConfig(port);
45+
if(config == null)
46+
continue;
47+
48+
var lastColor = LedColor.FromHsv(_lastHue, Config.Saturation, Config.Brightness);
49+
var currentColor = LedColor.FromHsv(_currentHue, Config.Saturation, Config.Brightness);
50+
51+
var colors = Enumerable.Range(0, config.LedCount).Select(x => lastColor).ToList();
52+
for (var i = 0; i < (int) Math.Round(config.LedCount * _fill); i++)
53+
{
54+
colors[i] = currentColor;
55+
}
56+
57+
result.Add(port, colors);
58+
}
59+
60+
return result;
61+
}
62+
}
63+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("TTController.Plugin.FlowEffect")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("TTController.Plugin.FlowEffect")]
13+
[assembly: AssemblyCopyright("Copyright © 2019")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("fd3e1660-41d2-450a-bc75-751af1056a3a")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)