Skip to content

Commit

Permalink
More options in the parameter file
Browse files Browse the repository at this point in the history
  • Loading branch information
Synless committed Oct 21, 2023
1 parent b79470b commit f8a7ee8
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 60 deletions.
9 changes: 6 additions & 3 deletions Arduino/SynLight_Serial/SynLight_Serial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ void loop()
Serial.readBytes(buffer, sizeof(buffer));
Serial.read();

if(!serial_found && buffer[0] == 'p' && buffer[1] == 'i' && buffer[2] == 'n' && buffer[3] == 'g')
if(buffer[0] == 'p' && buffer[1] == 'i' && buffer[2] == 'n' && buffer[3] == 'g')
{
Serial.println("pong");
return;
}

found = false;

Expand Down Expand Up @@ -67,8 +70,8 @@ void loop()
t3 = millis();
if(found)
{
br = max(0,min(maxBrightness,br+12));
setBrightness(br);
//br = max(0,min(maxBrightness,br+12));
setBrightness(maxBrightness);
}
else if(start_fade)
{
Expand Down
2 changes: 1 addition & 1 deletion SynLight/Model/Arduino/Arduino_Serial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public int BaudRate
}
public bool isTurboEnabled = true;

public Arduino_Serial() { }
public Arduino_Serial() { Arduino.BaudRate = 115200; }

~Arduino_Serial()
{
Expand Down
2 changes: 1 addition & 1 deletion SynLight/Model/Arduino/Arduino_UDP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Arduino_UDP()
const int ipRange = 8;

static UdpClient udpClient = new UdpClient(UDPPort);
static int waitTime = 1;
int waitTime = 1;
public override bool Setup()
{
byte[] ping = Encoding.ASCII.GetBytes(querry);
Expand Down
79 changes: 46 additions & 33 deletions SynLight/Model/Param_SynLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public bool Ratio
{
get
{
return ratio;
return ratio;
}
set
{
Expand All @@ -266,8 +266,9 @@ public bool Ratio
}
if(!ratio)
{
double tmp = Height / A;
Shifting = (int)(((double)Height / 2) - (tmp / 2) + B);
double tmp = Height / AShift;
double tmp_Height = (double)Height / 2;
Shifting = (int)(tmp_Height - (tmp / 2) + BShift);
}
else
{
Expand Down Expand Up @@ -343,21 +344,7 @@ public bool PlayPause
System.Threading.Thread.Sleep(1);
if(playPause && !processMainLoop.IsAlive && !processFindArduino.IsAlive)
{
if(useComPort)
{
processMainLoop.Start();
}
else
{
StaticConnected = false;
try
{
processFindArduino.Start();
}
catch
{
}
}
processMainLoop.Start();
debug = true;
}

Expand All @@ -375,7 +362,7 @@ public bool CanPlayPause
}
}

private bool lpf = true;
private bool lpf = false;
public bool LPF
{
get
Expand All @@ -389,7 +376,7 @@ public bool LPF
}
}

private bool bgf = true;
private bool bgf = false;
public bool BGF
{
get
Expand Down Expand Up @@ -444,7 +431,7 @@ public byte Blue
OnPropertyChanged(nameof(Blue));
}
}
private int contrast = 7;
private int contrast = 0;
public int Contrast
{
get
Expand All @@ -457,7 +444,7 @@ public int Contrast
OnPropertyChanged(nameof(Contrast));
}
}
private bool usingFlux = true;
private bool usingFlux = false;
public bool UsingFlux
{
get { return usingFlux; }
Expand All @@ -467,7 +454,7 @@ public bool UsingFlux
OnPropertyChanged(nameof(UsingFlux));
}
}
private bool turbo = true;
private bool turbo = false;
public bool Turbo
{
get { return turbo; }
Expand All @@ -494,7 +481,7 @@ public int Mix
get { return mix; }
set
{
mix = value;
mix = Math.Max(0,Math.Min(100,value));
staticColorChanged = true;
OnPropertyChanged(nameof(Mix));
}
Expand All @@ -514,8 +501,8 @@ public bool StaticConnected
}
#endregion

protected double A = 1.32;
protected double B = 1;
protected double AShift = 1.32;
protected double BShift = 1;
protected bool staticColorChanged = false;
protected const int packetSize = 1200;

Expand Down Expand Up @@ -559,7 +546,7 @@ public bool StaticConnected

protected static Arduino_Serial arduinoSerial = new Arduino_Serial();
protected static Arduino_UDP arduinoUDP = new Arduino_UDP();
protected static bool useComPort = false;
protected static bool useComPort = true;
#endregion

public Param_SynLight()
Expand Down Expand Up @@ -635,9 +622,19 @@ public Param_SynLight()
}
else if (subLine[0].StartsWith("COM"))
{
arduinoSerial.PortName = subLine[0];
useComPort = true;
staticConnected = true;
try
{
if(int.TryParse(subLine[0].Replace("COM",String.Empty), out int tmp))
{
arduinoSerial.PortName = subLine[0];
useComPort = true;
StaticConnected = true;
}
}
catch
{

}
}
else if(subLine[0] == "X")
{
Expand All @@ -647,10 +644,26 @@ public Param_SynLight()
{
Height = int.Parse(subLine[1]);
}
else if(subLine[0] == "S")
else if (subLine[0] == "S")
{
Shifting = int.Parse(subLine[1]);
}
else if (subLine[0] == "MIX")
{
Mix = int.Parse(subLine[1]);
}
else if (subLine[0] == "RED")
{
Red = byte.Parse(Math.Max(0,Math.Min(255,(int.Parse(subLine[1])))).ToString());
}
else if (subLine[0] == "GREEN")
{
Green = byte.Parse(Math.Max(0, Math.Min(255, (int.Parse(subLine[1])))).ToString());
}
else if (subLine[0] == "BLUE")
{
Blue = byte.Parse(Math.Max(0, Math.Min(255, (int.Parse(subLine[1])))).ToString());
}
else if(subLine[0] == "TL")
{
TopLeft = true;
Expand Down Expand Up @@ -689,11 +702,11 @@ public Param_SynLight()
}
else if(subLine[0] == "A")
{
A = Convert.ToDouble(subLine[1]);
AShift = Convert.ToDouble(subLine[1].Replace(",", "."));
}
else if(subLine[0] == "B")
{
B = Convert.ToDouble(subLine[1]);
BShift = Convert.ToDouble(subLine[1].Replace(",","."));
}
else if(subLine[0] == "LPF")
{
Expand Down
35 changes: 17 additions & 18 deletions SynLight/Model/Process_SynLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ public Process_SynLight()
processMainLoop = new Thread(CheckMethodProcess);
processFindArduino.Start();
}
~Process_SynLight()
{
//Immediately turns of the LEDS after pressing the Stop button
for (int i = 0; i < newByteToSend.Count; i++)
newByteToSend[i] = 0;

const int numberOfTries = 10;
SendPayload(PayloadType.terminalPayload, newByteToSend);
}

const int numberOfTries = 2;
private void FindArduinoProcess()
{
while (!StaticConnected)
Expand Down Expand Up @@ -101,10 +109,14 @@ private void CheckMethodProcess()
}

//Immediately turns of the LEDS after pressing the Stop button
SendPayload(PayloadType.fixedColor, 0);
processMainLoop = new Thread(CheckMethodProcess);
for (int i = 0; i < newByteToSend.Count; i++)
newByteToSend[i] = 0;

SendPayload(PayloadType.terminalPayload, newByteToSend);

Tittle = "Synlight - Paused";

processMainLoop = new Thread(CheckMethodProcess);
Tittle = "Synlight - " + (useComPort ? arduinoSerial.PortName : arduinoUDP.IPAddress.ToString()) + " - Paused";
}

private int _Height;
Expand Down Expand Up @@ -481,7 +493,7 @@ private void ProcessScreenShot()
}
private void Send()
{
newByteToSend = new List<byte>(0);
newByteToSend = new List<byte>(0);

if (LPF) //Low-pass filtering
{
Expand Down Expand Up @@ -591,18 +603,5 @@ protected static void SendPayload(PayloadType plt, List<byte> payload)
arduinoUDP.Send(plt, payload);
}
}
protected static void SendPayload(PayloadType plt, byte r = 0)
{
List<byte> payload = new List<byte> { r };

if (useComPort)
{
arduinoSerial.Send(plt, payload);
}
else
{
arduinoUDP.Send(plt, payload);
}
}
}
}
Binary file added SynLight/SY.ico
Binary file not shown.
8 changes: 5 additions & 3 deletions SynLight/SynLight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -30,7 +31,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand All @@ -56,8 +56,7 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>
</ApplicationIcon>
<ApplicationIcon>SY.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>SynLight.App</StartupObject>
Expand Down Expand Up @@ -327,6 +326,9 @@
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Resource Include="SY.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion SynLight/SynLight.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory />
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
Expand Down
40 changes: 40 additions & 0 deletions SynLight/bin/Debug/param.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-------------------------[SCREENS SETUP - ONLY RELEVENT FOR MULTI-SCREEN SETUP. SINGLE SCREEN : IGNORED]
//MAINSCREEN=2
//SCREEN1=1920,1080
//SCREEN2=1920,1080
//SCREEN3=1920,1080
-------------------------[LAN SETTINGS - NOT NEEDED SINCE IT CAN SCAN THE NETWORK]
//UDPPort=8787
//IP=192.168.137.175
-------------------------[COM SETTINGS - NOT NEEDED SINCE IT CAN SCAN THE NETWORK]
COM1
-------------------------[LED SETTINGS AT STARTUP]
X=35
Y=22
CORNERS=0
S=0
UPDOWN=0
CONTRAST=8
-------------------------[1ST LED AND DIRECTION SETTINGS AT STARTUP]
BL
CCW
-------------------------[COLOR MIX AT STARTUP]
MIX=0
RED=255
GREEN=255
BLUE=255
-------------------------[FILTERS AT STARTUP]
LPF
BGF
KBL
TURBO
-------------------------[21:9 TWEAKING VARIABLES]
A=1,33
B=1,0
-------------------------[WILL RUN IN BACKGROUND, KILL VIA TASK MANNAGER]
HIDE
//SHOW
-------------------------[OTHER]
//MOBILESHARING
//CLEANFILES
//FLUX

0 comments on commit f8a7ee8

Please sign in to comment.