-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathunit2.pas
369 lines (338 loc) · 10.8 KB
/
unit2.pas
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
(******************************************************************************)
(* *)
(* Author : Uwe Schächterle (Corpsman) *)
(* *)
(* This file is part of KLab *)
(* *)
(* See the file license.md, located under: *)
(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *)
(* for details about the license. *)
(* *)
(* It is not allowed to change or remove this text from any *)
(* source file of the project. *)
(* *)
(******************************************************************************)
Unit Unit2;
{$MODE objfpc}{$H+}
Interface
Uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
StdCtrls, Spin, Buttons, types;
Type
{ TForm2 }
TForm2 = Class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
CheckBox1: TCheckBox;
CheckBox10: TCheckBox;
CheckBox11: TCheckBox;
CheckBox12: TCheckBox;
CheckBox13: TCheckBox;
CheckBox14: TCheckBox;
CheckBox15: TCheckBox;
CheckBox16: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
CheckBox9: TCheckBox;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
Edit1: TEdit;
Edit10: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
FloatSpinEdit1: TFloatSpinEdit;
GroupBox1: TGroupBox;
Label1: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label2: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel;
Label25: TLabel;
Label26: TLabel;
Label27: TLabel;
Label28: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
PageControl1: TPageControl;
SpeedButton1: TSpeedButton;
SpinEdit1: TSpinEdit;
SpinEdit2: TSpinEdit;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
Tabsheet4: TTabSheet;
Procedure Button1Click(Sender: TObject);
Procedure Button2Click(Sender: TObject);
Procedure Button3Click(Sender: TObject);
Procedure Button5Click(Sender: TObject);
Procedure Button6Click(Sender: TObject);
Procedure CheckBox10Click(Sender: TObject);
Procedure CheckBox14Click(Sender: TObject);
Procedure CheckBox6Click(Sender: TObject);
Procedure CheckBox7Click(Sender: TObject);
Procedure CheckBox8Click(Sender: TObject);
Procedure CheckBox9Click(Sender: TObject);
Procedure ComboBox1Change(Sender: TObject);
Procedure FormCreate(Sender: TObject);
Procedure FormShow(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
Procedure Load_all_Konfigs();
Procedure Read_all_Konfigs();
End;
Var
Form2: TForm2;
Implementation
{$R *.lfm}
Uses
uklab,
lazutf8,
unit1, // Für Global changed
unit7;
Var
searchpath: String;
libsearchpath: String;
{ TForm2 }
Procedure TForm2.Load_all_Konfigs;
Begin
// Common
ComboBox1.Items.Text := KlabConfig.Aviable_CPUS.Text;
ComboBox1.Text := KlabConfig.CPU;
SpinEdit1.Value := KlabConfig.Clock;
edit4.text := KlabConfig.HexFile;
edit5.text := KlabConfig.MapFile;
edit6.text := KlabConfig.Logfile;
edit7.text := KlabConfig.OutFile;
ComboBox1Change(Nil);
// Compiler
Edit1.text := KlabConfig.CompilerCommand;
CheckBox1.Checked := KlabConfig.MCall;
CheckBox2.Checked := KlabConfig.Wstrict;
CheckBox3.Checked := KlabConfig.Wall;
CheckBox4.Checked := KlabConfig.g;
CheckBox5.Checked := KlabConfig.definecpu;
CheckBox15.Checked := KlabConfig.usesearchpath;
searchpath := KlabConfig.searchpaths.Text;
CheckBox16.Checked := KlabConfig.uselibsearchpath;
libsearchpath := KlabConfig.libsearchpaths.Text;
Case KlabConfig.optimization Of
'0': ComboBox2.ItemIndex := 0;
'1': ComboBox2.ItemIndex := 1;
'2': ComboBox2.ItemIndex := 2;
'3': ComboBox2.ItemIndex := 3;
's': ComboBox2.ItemIndex := 4;
End;
// Linker
edit2.text := KlabConfig.LinkerCommand;
edit3.text := KlabConfig.ObjectCopyCommand;
// Programmer
CheckBox6.Checked := KlabConfig.OverrideBaud;
CheckBox7.Checked := KlabConfig.SpecifyJTAGPeriod;
CheckBox8.Checked := KlabConfig.SpecifyProgrammerType;
CheckBox9.Checked := KlabConfig.SpecifyConnectionPort;
CheckBox10.Checked := KlabConfig.SpecifyExternalConfigFile;
CheckBox11.Checked := KlabConfig.DisableAutoErase;
CheckBox12.Checked := KlabConfig.DoNotWrite;
CheckBox13.Checked := KlabConfig.OverrideInvalidSignature;
CheckBox14.Checked := KlabConfig.CountErases;
ComboBox3.Text := inttostr(KlabConfig.RS232BaudRate);
FloatSpinEdit1.Value := KlabConfig.JTAGPeriod / 10;
edit8.text := KlabConfig.ProgrammerType;
edit9.text := KlabConfig.ConnectionPort;
Edit10.text := KlabConfig.ExternalFile;
SpinEdit2.Value := KlabConfig.EraseCount;
CheckBox6Click(Nil);
CheckBox7Click(Nil);
CheckBox8Click(Nil);
CheckBox9Click(Nil);
CheckBox10Click(Nil);
CheckBox14Click(Nil);
End;
Procedure TForm2.Read_all_Konfigs;
Begin
// Liest Unit2 aus und Speichert es in KlabConfig
// Common
KlabConfig.CPU := ComboBox1.Text;
KlabConfig.Clock := SpinEdit1.Value;
KlabConfig.HexFile := edit4.text;
KlabConfig.MapFile := edit5.text;
KlabConfig.Logfile := edit6.text;
KlabConfig.OutFile := edit7.text;
cpu := LoadCPU(KlabConfig.CPU);
// Compiler
KlabConfig.CompilerCommand := Edit1.text;
KlabConfig.MCall := CheckBox1.Checked;
KlabConfig.Wstrict := CheckBox2.Checked;
KlabConfig.Wall := CheckBox3.Checked;
KlabConfig.g := CheckBox4.Checked;
KlabConfig.definecpu := CheckBox5.Checked;
KlabConfig.usesearchpath := CheckBox15.Checked;
KlabConfig.searchpaths.Text := searchpath;
KlabConfig.uselibsearchpath := CheckBox16.Checked;
KlabConfig.libsearchpaths.Text := libsearchpath;
Case ComboBox2.ItemIndex Of
0: KlabConfig.optimization := '0';
1: KlabConfig.optimization := '1';
2: KlabConfig.optimization := '2';
3: KlabConfig.optimization := '3';
4: KlabConfig.optimization := 's';
End;
// Linker
KlabConfig.LinkerCommand := edit2.text;
KlabConfig.ObjectCopyCommand := edit3.text;
// Programmer
KlabConfig.OverrideBaud := CheckBox6.Checked;
KlabConfig.SpecifyJTAGPeriod := CheckBox7.Checked;
KlabConfig.SpecifyProgrammerType := CheckBox8.Checked;
KlabConfig.SpecifyConnectionPort := CheckBox9.Checked;
KlabConfig.SpecifyExternalConfigFile := CheckBox10.Checked;
KlabConfig.DisableAutoErase := CheckBox11.Checked;
KlabConfig.DoNotWrite := CheckBox12.Checked;
KlabConfig.OverrideInvalidSignature := CheckBox13.Checked;
KlabConfig.CountErases := CheckBox14.Checked;
KlabConfig.RS232BaudRate := strtointdef(ComboBox3.Text, 19200);
KlabConfig.JTAGPeriod := round(FloatSpinEdit1.Value * 10);
KlabConfig.ProgrammerType := edit8.text;
KlabConfig.ConnectionPort := edit9.text;
KlabConfig.ExternalFile := Edit10.text;
KlabConfig.EraseCount := SpinEdit2.Value;
End;
Procedure TForm2.Button3Click(Sender: TObject);
Begin
close;
End;
Procedure TForm2.Button5Click(Sender: TObject);
Begin
form7.SelectDirectoryDialog1.InitialDir := ExtractFilePath(ParamStrUTF8(0));
form7.Caption := 'Search Path Properties';
form7.ListBox1.Items.Text := searchpath;
form7result := false;
form7.ShowModal;
If form7result Then Begin
searchpath := form7.ListBox1.Items.Text;
End;
End;
Procedure TForm2.Button6Click(Sender: TObject);
Begin
form7.SelectDirectoryDialog1.InitialDir := ExtractFilePath(ParamStrUTF8(0));
form7.Caption := 'LibSearch Path Properties';
form7.ListBox1.Items.Text := libsearchpath;
form7result := false;
form7.ShowModal;
If form7result Then Begin
libsearchpath := form7.ListBox1.Items.Text;
End;
End;
Procedure TForm2.CheckBox6Click(Sender: TObject);
Begin
ComboBox3.Enabled := CheckBox6.Checked;
label26.Enabled := CheckBox6.Checked;
End;
Procedure TForm2.CheckBox7Click(Sender: TObject);
Begin
FloatSpinEdit1.Enabled := CheckBox7.Checked;
label27.Enabled := CheckBox7.Checked;
End;
Procedure TForm2.CheckBox8Click(Sender: TObject);
Begin
edit8.Enabled := CheckBox8.Checked;
End;
Procedure TForm2.CheckBox9Click(Sender: TObject);
Begin
edit9.Enabled := CheckBox9.Checked;
End;
Procedure TForm2.CheckBox10Click(Sender: TObject);
Begin
edit10.Enabled := CheckBox10.Checked;
End;
Procedure TForm2.CheckBox14Click(Sender: TObject);
Begin
label28.Enabled := CheckBox14.Checked;
button4.Enabled := CheckBox14.Checked;
SpinEdit2.Enabled := CheckBox14.Checked;
End;
Procedure TForm2.ComboBox1Change(Sender: TObject);
Var
cp: TCPU;
Begin
cp := LoadCPU(ComboBox1.Text);
SpinEdit1.MaxValue := cp.maxcpu;
label15.Caption := inttostr(cp.flash);
label16.Caption := inttostr(cp.ram);
label17.Caption := inttostr(cp.maxcpu);
label18.Caption := inttostr(cp.eeprom);
label15.Left := label19.Left - label15.Width - 10;
label16.Left := label19.Left - label16.Width - 10;
label17.Left := label19.Left - label17.Width - 10;
label18.Left := label19.Left - label18.Width - 10;
TabSheet1.Repaint;
End;
Procedure TForm2.FormCreate(Sender: TObject);
Begin
Tform(self).Constraints.MaxHeight := Tform(self).Height;
Tform(self).Constraints.MinHeight := Tform(self).Height;
Tform(self).Constraints.Maxwidth := Tform(self).width;
Tform(self).Constraints.Minwidth := Tform(self).width;
PageControl1.PageIndex := 0;
{$IFDEF WINDOWS}
label10.Visible := false;
edit6.Visible := false;
{$ENDIF}
End;
Procedure TForm2.FormShow(Sender: TObject);
Begin
label15.Left := label19.Left - label15.Width - 10;
label16.Left := label19.Left - label16.Width - 10;
label17.Left := label19.Left - label17.Width - 10;
label18.Left := label19.Left - label18.Width - 10;
End;
Procedure TForm2.Button1Click(Sender: TObject);
Begin
If Not GlobalChanged Then Begin
form1.caption := form1.caption + '*';
End;
GlobalChanged := true;
Read_all_Konfigs;
close;
End;
Procedure TForm2.Button2Click(Sender: TObject);
Begin
Read_all_Konfigs;
SaveEditorProperties();
End;
End.