-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBreathingControl.cs
128 lines (115 loc) · 3.77 KB
/
BreathingControl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SerialKiller3000
{
public partial class BreathingControl : UserControl
{
public static bool breathingMode = false;
bool rising;
int pwm = 0;
public BreathingControl()
{
InitializeComponent();
}
private void BreathingControl_Load(object sender, EventArgs e)
{
breathRed.Select();
}
public void BreathingStart(object sender, EventArgs e)
{
if (stuff.Mode == (int)stuff.ModeStatus.breathingModeActive)
timer1.Enabled = true;
timer1.Start();
timer1.Interval = 20;
{
if (pwm < 10) //this looks better than turning the led completely off
rising = true;
else if (pwm > 199)
rising = false;
if (pwm < 200 && rising)
if (trackBar1.Value == 1)
{
pwm++;
}
else if (trackBar1.Value == 2)
{
pwm += 2;
}
else if (trackBar1.Value == 3)
{
pwm += 3;
}
else if (trackBar1.Value == 4)
{
pwm += 4;
}
else
{
pwm += 5;
}
else
if (trackBar1.Value == 1)
pwm--;
else if (trackBar1.Value == 2)
pwm -= 2;
else if (trackBar1.Value == 3)
pwm -= 3;
else if (trackBar1.Value == 4)
pwm -= 4;
else
pwm -= 5;
if (breathRed.Checked)
stuff.Serial.uart.Write("rgb " + pwm + "," + 0 + "," + 0 + ";");
else if (breathGreen.Checked)
stuff.Serial.uart.Write("rgb " + 0 + "," + pwm + "," + 0 + ";");
else if (breathBlue.Checked)
stuff.Serial.uart.Write("rgb " + 0 + "," + 0 + "," + pwm + ";");
else if (breathRG.Checked)
stuff.Serial.uart.Write("rgb " + pwm + "," + pwm + "," + 0 + ";");
else if (breathRB.Checked)
stuff.Serial.uart.Write("rgb " + pwm + "," + 0 + "," + pwm + ";");
else if (breathGB.Checked)
stuff.Serial.uart.Write("rgb " + 0 + "," + pwm + "," + pwm + ";");
else
stuff.Serial.uart.Write("rgb " + pwm + "," + pwm + "," + pwm + ";");
}
}
public void BreathingStop()
{
timer1.Stop();
timer1.Enabled = false;
stuff.Serial.RgbledOFF();
pwm = 0;
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
if (trackBar1.Value == 1)
{
label2.Text = "Very slow";
}
else if (trackBar1.Value == 2)
{
label2.Text = "Slow";
}
else if (trackBar1.Value == 3)
{
label2.Text = "Normal";
}
else if (trackBar1.Value == 4)
{
label2.Text = "Fast";
}
else
{
label2.Text = "Very fast";
}
}
}
}