forked from MakeMagazinDE/GRBLize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_Defaults.pas
140 lines (119 loc) · 3.59 KB
/
app_Defaults.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
// AppDefaults StringGrid Handler
unit app_defaults;
interface
uses Classes, Grids;
type
T_machine_options = record // Ausstattungsdetails
NewGrblVersion: boolean;
SPI: Boolean;
Display: Boolean;
Panel: Boolean;
Caxis: Boolean;
VariableSpindle: Boolean;
MistCoolant: Boolean;
HomingLock: Boolean;
DeviceAddressed: Boolean;
DeviceAddress: Integer;
SingleAxisHoming: Boolean;
HomingOrigin: Boolean; // HOMING_FORCE_SET_ORIGIN set
PositiveSpace: Boolean; // derived from AppDefaults Table
end;
var
MachineOptions: T_machine_options; // Ausstattungsdetails
procedure InitMachineOptions;
procedure LoadStringGrid(aGrid: TStringGrid; const my_fileName: string);
function get_AppDefaults_float(sg_row: Integer): double;
function get_AppDefaults_bool(sg_row: Integer): boolean;
function get_AppDefaults_int(sg_row: Integer): Integer;
function get_AppDefaults_str(sg_row: Integer): String;
procedure set_AppDefaults_int(sg_row, new_val: Integer);
procedure set_AppDefaults_bool(sg_row: Integer; new_val: boolean);
implementation
uses
grbl_com, grbl_player_main, SysUtils, StrUtils;
procedure InitMachineOptions;
begin
with MachineOptions do begin
SPI:= false;
Display:= false;
Panel:= false;
Caxis:= false;
VariableSpindle:= false;
MistCoolant:= false;
HomingLock:= false;
DeviceAddressed:= false;
DeviceAddress:= 0;
HomingOrigin:= false; // HOMING_FORCE_SET_ORIGIN
SingleAxisHoming:= false;
NewGrblVersion:= false;
MachineOptions.PositiveSpace:= get_AppDefaults_bool(45);
end;
end;
// AppDefaults StringGrid
procedure LoadStringGrid(aGrid: TStringGrid; const my_fileName: string);
var
my_StringList, my_Line: TStringList;
aCol, aRow: Integer;
begin
aGrid.RowCount := 2; //clear any previous data
my_StringList := TStringList.Create;
try
my_Line := TStringList.Create;
try
my_StringList.LoadFromFile(my_fileName);
aGrid.RowCount := my_StringList.Count;
for aRow := 0 to my_StringList.Count-1 do
begin
my_Line.CommaText := my_StringList[aRow];
for aCol := 0 to aGrid.ColCount-1 do
if aCol < my_Line.Count then
aGrid.Cells[aCol, aRow] := my_Line[aCol]
else
aGrid.Cells[aCol, aRow] := '0';
end;
finally
my_Line.Free;
end;
finally
my_StringList.Free;
end;
MachineOptions.PositiveSpace:= get_AppDefaults_bool(45);
end;
function get_AppDefaults_float(sg_row: Integer): double;
begin
result:= 0;
if sg_row < Form1.SgAppDefaults.RowCount then
result:= StrToFloatDef(Form1.SgAppDefaults.Cells[1,sg_row],0);
end;
function get_AppDefaults_bool(sg_row: Integer): boolean;
begin
result:= false;
if sg_row < Form1.SgAppDefaults.RowCount then
result:= Form1.SgAppDefaults.Cells[1,sg_row] = 'ON';
end;
function get_AppDefaults_int(sg_row: Integer): Integer;
begin
result:= 0;
if sg_row < Form1.SgAppDefaults.RowCount then
result:= StrToIntDef(Form1.SgAppDefaults.Cells[1,sg_row],0);
end;
function get_AppDefaults_str(sg_row: Integer): String;
begin
result:= '';
if sg_row < Form1.SgAppDefaults.RowCount then
result:= Form1.SgAppDefaults.Cells[1,sg_row];
end;
procedure set_AppDefaults_int(sg_row, new_val: Integer);
begin
if sg_row < Form1.SgAppDefaults.RowCount then
Form1.SgAppDefaults.Cells[1,sg_row]:= IntToStr(new_val);
end;
procedure set_AppDefaults_bool(sg_row: Integer; new_val: boolean);
begin
if sg_row < Form1.SgAppDefaults.RowCount then
if new_val then
Form1.SgAppDefaults.Cells[1,sg_row]:= 'ON'
else
Form1.SgAppDefaults.Cells[1,sg_row]:= 'OFF';
end;
end.