Skip to content

Commit eed344e

Browse files
committed
code cleanup
made it compile and look nicer
1 parent a9d5382 commit eed344e

12 files changed

+331
-286
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
Software/PC control/.vs/
3+
Software/PC control/bin/Debug/
4+
Software/PC control/bin/Release/
5+
6+
Software/ASCOM driver/.vs/
7+
Software/ASCOM driver/bin/Debug/
8+
Software/ASCOM driver/bin/Release/
Binary file not shown.

Software/PC control/Form1.Designer.cs

Lines changed: 243 additions & 221 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Software/PC control/Form1.cs

Lines changed: 71 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Data;
5-
using System.Drawing;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
92
using System.Windows.Forms;
103
using System.IO.Ports;
114

@@ -16,7 +9,6 @@ public partial class Form1 : Form
169
bool isConnected = false;
1710
String[] ports;
1811
SerialPort port;
19-
int asdf;
2012

2113
public Form1()
2214
{
@@ -26,11 +18,11 @@ public Form1()
2618

2719
foreach (string port in ports)
2820
{
29-
comboBox1.Items.Add(port);
21+
cbPorts.Items.Add(port);
3022
Console.WriteLine(port);
3123
if (ports[0] != null)
3224
{
33-
comboBox1.SelectedItem = ports[0];
25+
cbPorts.SelectedItem = ports[0];
3426
}
3527
}
3628
}
@@ -51,10 +43,11 @@ void getAvailableComPorts()
5143
{
5244
ports = SerialPort.GetPortNames();
5345
}
46+
5447
private void connectToArduino()
5548
{
5649
isConnected = true;
57-
string selectedPort = comboBox1.GetItemText(comboBox1.SelectedItem);
50+
string selectedPort = cbPorts.GetItemText(cbPorts.SelectedItem);
5851
port = new SerialPort(selectedPort, 57600, Parity.None, 8, StopBits.One);
5952
port.Open();
6053
port.Write("START#");
@@ -73,84 +66,97 @@ private void disconnectFromArduino()
7366

7467
private void enableControls()
7568
{
76-
button2.Enabled = true;
77-
button3.Enabled = true;
78-
button4.Enabled = true;
79-
button5.Enabled = true;
80-
button6.Enabled = true;
81-
button7.Enabled = true;
82-
numericUpDown1.Enabled = true;
83-
numericUpDown2.Enabled = true;
84-
numericUpDown3.Enabled = true;
85-
numericUpDown4.Enabled = true;
86-
numericUpDown5.Enabled = true;
87-
numericUpDown6.Enabled = true;
88-
numericUpDown7.Enabled = true;
69+
btnManualUp.Enabled = true;
70+
btnManualDown.Enabled = true;
71+
btnManualLeft.Enabled = true;
72+
btnManualRight.Enabled = true;
73+
74+
btnRAMove.Enabled = true;
75+
btnDecMove.Enabled = true;
76+
77+
udManualSteps.Enabled = true;
78+
79+
udRAHours.Enabled = true;
80+
udRAMinutes.Enabled = true;
81+
udRASeconds.Enabled = true;
82+
83+
udDecSeconds.Enabled = true;
84+
udDecMinutes.Enabled = true;
85+
udDecDegrees.Enabled = true;
8986
}
9087

9188
private void disableControls()
9289
{
93-
button2.Enabled = false;
94-
button3.Enabled = false;
95-
button4.Enabled = false;
96-
button5.Enabled = false;
97-
button6.Enabled = false;
98-
button7.Enabled = false;
99-
numericUpDown1.Enabled = false;
100-
numericUpDown2.Enabled = false;
101-
numericUpDown3.Enabled = false;
102-
numericUpDown4.Enabled = false;
103-
numericUpDown5.Enabled = false;
104-
numericUpDown6.Enabled = false;
105-
numericUpDown7.Enabled = false;
90+
btnManualUp.Enabled = false;
91+
btnManualDown.Enabled = false;
92+
btnManualLeft.Enabled = false;
93+
btnManualRight.Enabled = false;
94+
95+
btnRAMove.Enabled = false;
96+
btnDecMove.Enabled = false;
97+
98+
udManualSteps.Enabled = false;
99+
100+
udRAHours.Enabled = false;
101+
udRAMinutes.Enabled = false;
102+
udRASeconds.Enabled = false;
103+
104+
udDecSeconds.Enabled = false;
105+
udDecMinutes.Enabled = false;
106+
udDecDegrees.Enabled = false;
106107
}
107108

108109
private void Form1_Load(object sender, EventArgs e)
109110
{
110111

111112
}
112113

113-
private void button5_Click(object sender, EventArgs e)
114-
{
115-
if (isConnected)
116-
{
117-
port.Write(numericUpDown1.Value + "\a" + "R#");
118-
}
114+
private void btnRAMove_Click(object sender, EventArgs e)
115+
{
116+
if (!isConnected)
117+
return;
118+
119+
port.Write(udRAHours.Value + "\a" + udRAMinutes.Value + "\b" + udRASeconds.Value + "\f" + "S");
119120
}
120121

121-
private void button4_Click(object sender, EventArgs e)
122+
private void btnDecMove_Click(object sender, EventArgs e)
122123
{
123-
if (isConnected)
124-
{
125-
port.Write(numericUpDown1.Value + "\a" + "L#");
126-
}
124+
if (!isConnected)
125+
return;
126+
127+
// move command missing here
127128
}
128129

129-
private void button2_Click(object sender, EventArgs e)
130+
private void btnManualUp_Click(object sender, EventArgs e)
130131
{
131-
if (isConnected)
132-
{
133-
port.Write(numericUpDown1.Value + "\a" + "UP#");
134-
}
132+
if (!isConnected)
133+
return;
134+
135+
port.Write(udManualSteps.Value + "\a" + "UP#");
135136
}
136137

137-
private void button3_Click(object sender, EventArgs e)
138+
private void btnManualLeft_Click(object sender, EventArgs e)
138139
{
139-
if (isConnected)
140-
{
141-
port.Write(numericUpDown1.Value + "\a" + "DOWN#");
142-
}
140+
if (!isConnected)
141+
return;
142+
143+
port.Write(udManualSteps.Value + "\a" + "L#");
143144
}
144145

145-
private void button6_Click(object sender, EventArgs e)
146+
private void btnManualRight_Click(object sender, EventArgs e)
146147
{
147-
if (isConnected)
148-
{
149-
port.Write(numericUpDown2.Value + "\a" + numericUpDown3.Value + "\b" + numericUpDown4.Value + "\f" + "S");
150-
}
148+
if (!isConnected)
149+
return;
150+
151+
port.Write(udManualSteps.Value + "\a" + "R#");
151152
}
152153

153-
154+
private void btnManualDown_Click(object sender, EventArgs e)
155+
{
156+
if (!isConnected)
157+
return;
158+
159+
port.Write(udManualSteps.Value + "\a" + "DOWN#");
160+
}
154161
}
155-
156162
}
Binary file not shown.
Binary file not shown.

Software/PC control/obj/Debug/OpenAstroTracker Control.csproj.FileListAbsolute.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ C:\Users\Fabian\source\repos\OpenAstroTracker Control\bin\Debug\OpenAstroTracker
77
C:\Users\Fabian\source\repos\OpenAstroTracker Control\obj\Debug\OpenAstroTracker Control.exe
88
C:\Users\Fabian\source\repos\OpenAstroTracker Control\obj\Debug\OpenAstroTracker Control.pdb
99
C:\Users\Fabian\source\repos\OpenAstroTracker Control\obj\Debug\OpenAstroTracker Control.csprojAssemblyReference.cache
10+
I:\OpenAstroTracker\Software\PC control\bin\Debug\OpenAstroTracker Control.exe.config
11+
I:\OpenAstroTracker\Software\PC control\bin\Debug\OpenAstroTracker Control.exe
12+
I:\OpenAstroTracker\Software\PC control\bin\Debug\OpenAstroTracker Control.pdb
13+
I:\OpenAstroTracker\Software\PC control\obj\Debug\OpenAstroTracker Control.csprojAssemblyReference.cache
14+
I:\OpenAstroTracker\Software\PC control\obj\Debug\OpenAstroTracker_Control.Form1.resources
15+
I:\OpenAstroTracker\Software\PC control\obj\Debug\OpenAstroTracker_Control.Properties.Resources.resources
16+
I:\OpenAstroTracker\Software\PC control\obj\Debug\OpenAstroTracker Control.csproj.GenerateResource.cache
17+
I:\OpenAstroTracker\Software\PC control\obj\Debug\OpenAstroTracker Control.exe
18+
I:\OpenAstroTracker\Software\PC control\obj\Debug\OpenAstroTracker Control.pdb

0 commit comments

Comments
 (0)