|
@@ -187,10 +187,10 @@ type
|
|
activeFile: string;
|
|
activeFile: string;
|
|
dirty: boolean;
|
|
dirty: boolean;
|
|
lastNote: byte;
|
|
lastNote: byte;
|
|
- Examples : TStringList;
|
|
|
|
|
|
+ Examples: TStringList;
|
|
procedure initMidi;
|
|
procedure initMidi;
|
|
procedure playNote(note: byte);
|
|
procedure playNote(note: byte);
|
|
- procedure loadFromList(lines : TStringlist; filename : String);
|
|
|
|
|
|
+ procedure loadFromList(Lines: TStringList; filename: string);
|
|
function readString(var line: string): boolean;
|
|
function readString(var line: string): boolean;
|
|
procedure saveSection(filename: string; key: string);
|
|
procedure saveSection(filename: string; key: string);
|
|
procedure loadSection(filename: string; key: string);
|
|
procedure loadSection(filename: string; key: string);
|
|
@@ -253,7 +253,7 @@ begin
|
|
sps.setDelayCallback(@delayCallback);
|
|
sps.setDelayCallback(@delayCallback);
|
|
addHeaderText;
|
|
addHeaderText;
|
|
renumberGrid();
|
|
renumberGrid();
|
|
- cbTPSVersion.ItemIndex:=0;
|
|
|
|
|
|
+ cbTPSVersion.ItemIndex := 0;
|
|
cbTPSVersionChange(Sender);
|
|
cbTPSVersionChange(Sender);
|
|
acStop.Enabled := False;
|
|
acStop.Enabled := False;
|
|
ToolButton18.Align := alRight;
|
|
ToolButton18.Align := alRight;
|
|
@@ -302,21 +302,22 @@ begin
|
|
lastNote := note;
|
|
lastNote := note;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TForm1.loadFromList(lines: TStringlist; filename : String);
|
|
|
|
|
|
+procedure TForm1.loadFromList(Lines: TStringList; filename: string);
|
|
var
|
|
var
|
|
- i,x: integer;
|
|
|
|
|
|
+ i, x: integer;
|
|
line: string;
|
|
line: string;
|
|
list: TStringList;
|
|
list: TStringList;
|
|
begin
|
|
begin
|
|
acNew.Execute;
|
|
acNew.Execute;
|
|
list := TStringList.Create;
|
|
list := TStringList.Create;
|
|
i := 1;
|
|
i := 1;
|
|
- for x := 0 to lines.count-1 do begin
|
|
|
|
|
|
+ for x := 0 to Lines.Count - 1 do
|
|
|
|
+ begin
|
|
if (i + 1 > StringGrid1.RowCount) then
|
|
if (i + 1 > StringGrid1.RowCount) then
|
|
begin
|
|
begin
|
|
StringGrid1.RowCount := StringGrid1.RowCount + 1;
|
|
StringGrid1.RowCount := StringGrid1.RowCount + 1;
|
|
end;
|
|
end;
|
|
- line := lines[x];
|
|
|
|
|
|
+ line := Lines[x];
|
|
if (Pos('#', line) = 1) then
|
|
if (Pos('#', line) = 1) then
|
|
begin
|
|
begin
|
|
line := RightstrPos(line, 2);
|
|
line := RightstrPos(line, 2);
|
|
@@ -326,7 +327,8 @@ begin
|
|
cbTPSVersion.Text := line;
|
|
cbTPSVersion.Text := line;
|
|
cbTPSVersionChange(nil);
|
|
cbTPSVersionChange(nil);
|
|
end;
|
|
end;
|
|
- end else
|
|
|
|
|
|
+ end
|
|
|
|
+ else
|
|
begin
|
|
begin
|
|
MCSStrings.DelimSepTextToStringlist(line, '"', ',', list);
|
|
MCSStrings.DelimSepTextToStringlist(line, '"', ',', list);
|
|
if list.Count > 0 then
|
|
if list.Count > 0 then
|
|
@@ -338,7 +340,7 @@ begin
|
|
if list.Count > 3 then
|
|
if list.Count > 3 then
|
|
Stringgrid1.Cells[4, i] := list[3];
|
|
Stringgrid1.Cells[4, i] := list[3];
|
|
list.Clear;
|
|
list.Clear;
|
|
- inc(i);
|
|
|
|
|
|
+ Inc(i);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
list.Free;
|
|
list.Free;
|
|
@@ -366,19 +368,25 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TForm1.MenuItem1Click(Sender: TObject);
|
|
procedure TForm1.MenuItem1Click(Sender: TObject);
|
|
-var i : integer;
|
|
|
|
- fileName, data : String;
|
|
|
|
- lines : TStringList;
|
|
|
|
|
|
+var
|
|
|
|
+ i: integer;
|
|
|
|
+ fileName, Data: string;
|
|
|
|
+ Lines: TStringList;
|
|
begin
|
|
begin
|
|
- if (Sender is TMenuItem) then begin
|
|
|
|
- if (checkDirty()) then begin
|
|
|
|
|
|
+ if (Sender is TMenuItem) then
|
|
|
|
+ begin
|
|
|
|
+ if (checkDirty()) then
|
|
|
|
+ begin
|
|
i := TMenuItem(Sender).Tag;
|
|
i := TMenuItem(Sender).Tag;
|
|
- filename := examples[i-1];
|
|
|
|
- data := DownloadFile('http://wkla.no-ip.biz/down/tps_examples/' + filename);
|
|
|
|
- lines := TStringList.Create;
|
|
|
|
- lines.Text:= data;
|
|
|
|
- loadFromList(lines, filename);
|
|
|
|
- lines.Free;
|
|
|
|
|
|
+ if (i >= 0) then
|
|
|
|
+ begin
|
|
|
|
+ filename := examples[i];
|
|
|
|
+ Data := DownloadFile('http://wkla.no-ip.biz/down/tps_examples/' + filename);
|
|
|
|
+ Lines := TStringList.Create;
|
|
|
|
+ Lines.Text := Data;
|
|
|
|
+ loadFromList(Lines, filename);
|
|
|
|
+ Lines.Free;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -390,9 +398,9 @@ end;
|
|
|
|
|
|
procedure TForm1.pmExamplesPopup(Sender: TObject);
|
|
procedure TForm1.pmExamplesPopup(Sender: TObject);
|
|
var
|
|
var
|
|
- i: integer;
|
|
|
|
|
|
+ i, j, pos, index: integer;
|
|
myName: string;
|
|
myName: string;
|
|
- myMenu: TMenuItem;
|
|
|
|
|
|
+ myMenu, my2Menu: TMenuItem;
|
|
jsonString: string;
|
|
jsonString: string;
|
|
Data, JArray: TJSONData;
|
|
Data, JArray: TJSONData;
|
|
JItem: TJSONData;
|
|
JItem: TJSONData;
|
|
@@ -400,6 +408,15 @@ begin
|
|
for i := pmExamples.Items.Count - 1 downto 0 do
|
|
for i := pmExamples.Items.Count - 1 downto 0 do
|
|
begin
|
|
begin
|
|
myMenu := pmExamples.Items[i];
|
|
myMenu := pmExamples.Items[i];
|
|
|
|
+ if (myMenu.Count > 0) then
|
|
|
|
+ begin
|
|
|
|
+ for j := myMenu.Count - 1 downto 0 do
|
|
|
|
+ begin
|
|
|
|
+ my2Menu := myMenu.Items[j];
|
|
|
|
+ my2Menu.Free;
|
|
|
|
+ end;
|
|
|
|
+ myMenu.Clear;
|
|
|
|
+ end;
|
|
myMenu.Free;
|
|
myMenu.Free;
|
|
end;
|
|
end;
|
|
pmExamples.Items.Clear;
|
|
pmExamples.Items.Clear;
|
|
@@ -411,15 +428,48 @@ begin
|
|
JArray := GetJSONProp(TJSONObject(Data), 'examples');
|
|
JArray := GetJSONProp(TJSONObject(Data), 'examples');
|
|
for i := 1 to TJSONArray(JArray).Count do
|
|
for i := 1 to TJSONArray(JArray).Count do
|
|
begin
|
|
begin
|
|
- JItem := TJSONArray(JArray).Items[i-1];
|
|
|
|
|
|
+ JItem := TJSONArray(JArray).Items[i - 1];
|
|
myName := GetJsonProp(TJSONObject(JItem), 'name', '');
|
|
myName := GetJsonProp(TJSONObject(JItem), 'name', '');
|
|
- myName := format('%.2d - %s', [i, myName]);
|
|
|
|
|
|
+ pos := -1;
|
|
|
|
+ index := GetJsonProp(TJSONObject(JItem), 'index', -1);
|
|
|
|
+ if (index > -1) then
|
|
|
|
+ begin
|
|
|
|
+ pos := Examples.Add(GetJsonProp(TJSONObject(JItem), 'file', ''));
|
|
|
|
+ myName := format('%.2d - %s', [index, myName]);
|
|
|
|
+ end;
|
|
myMenu := TMenuItem.Create(pmExamples);
|
|
myMenu := TMenuItem.Create(pmExamples);
|
|
myMenu.Caption := myName;
|
|
myMenu.Caption := myName;
|
|
- myMenu.Tag := i;
|
|
|
|
- myMenu.OnClick := @MenuItem1Click;
|
|
|
|
|
|
+ myMenu.Tag := pos;
|
|
|
|
+ if (index > -1) then
|
|
|
|
+ begin
|
|
|
|
+ myMenu.OnClick := @MenuItem1Click;
|
|
|
|
+ end;
|
|
pmExamples.Items.Add(myMenu);
|
|
pmExamples.Items.Add(myMenu);
|
|
- Examples.Add(GetJsonProp(TJSONObject(JItem), 'file', ''));
|
|
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ JArray := GetJSONProp(TJSONObject(Data), 'demo');
|
|
|
|
+ if (JArray <> nil) then
|
|
|
|
+ begin
|
|
|
|
+ for i := 1 to TJSONArray(JArray).Count do
|
|
|
|
+ begin
|
|
|
|
+ JItem := TJSONArray(JArray).Items[i - 1];
|
|
|
|
+ myName := GetJsonProp(TJSONObject(JItem), 'name', '');
|
|
|
|
+ pos := -1;
|
|
|
|
+ index := GetJsonProp(TJSONObject(JItem), 'index', -1);
|
|
|
|
+ if (index > -1) then
|
|
|
|
+ begin
|
|
|
|
+ pos := Examples.Add(GetJsonProp(TJSONObject(JItem), 'file', ''));
|
|
|
|
+ myName := format('%s: %.2d - %s', ['demo', index, myName]);
|
|
|
|
+ end;
|
|
|
|
+ myMenu := TMenuItem.Create(pmExamples);
|
|
|
|
+ myMenu.Caption := myName;
|
|
|
|
+ myMenu.Tag := pos;
|
|
|
|
+ if (index > -1) then
|
|
|
|
+ begin
|
|
|
|
+ myMenu.OnClick := @MenuItem1Click;
|
|
|
|
+ end;
|
|
|
|
+ pmExamples.Items.Add(myMenu);
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
except
|
|
except
|
|
end;
|
|
end;
|
|
@@ -1218,10 +1268,10 @@ begin
|
|
acUpload.Enabled := False;
|
|
acUpload.Enabled := False;
|
|
Label5.Visible := False;
|
|
Label5.Visible := False;
|
|
btnTone.Visible := False;
|
|
btnTone.Visible := False;
|
|
- ADC1.Value:=0;
|
|
|
|
- ADC1.MaxValue:=15;
|
|
|
|
- ADC2.Value:=0;
|
|
|
|
- ADC2.MaxValue:=15;
|
|
|
|
|
|
+ ADC1.Value := 0;
|
|
|
|
+ ADC1.MaxValue := 15;
|
|
|
|
+ ADC2.Value := 0;
|
|
|
|
+ ADC2.MaxValue := 15;
|
|
end;
|
|
end;
|
|
if (cbTPSVersion.ItemIndex = 1) then
|
|
if (cbTPSVersion.ItemIndex = 1) then
|
|
begin
|
|
begin
|
|
@@ -1244,10 +1294,10 @@ begin
|
|
acUpload.Enabled := False;
|
|
acUpload.Enabled := False;
|
|
Label5.Visible := False;
|
|
Label5.Visible := False;
|
|
btnTone.Visible := False;
|
|
btnTone.Visible := False;
|
|
- ADC1.Value:=0;
|
|
|
|
- ADC1.MaxValue:=15;
|
|
|
|
- ADC2.Value:=0;
|
|
|
|
- ADC2.MaxValue:=15;
|
|
|
|
|
|
+ ADC1.Value := 0;
|
|
|
|
+ ADC1.MaxValue := 15;
|
|
|
|
+ ADC2.Value := 0;
|
|
|
|
+ ADC2.MaxValue := 15;
|
|
end;
|
|
end;
|
|
if ((cbTPSVersion.ItemIndex = 2) or (cbTPSVersion.ItemIndex = 3)) then
|
|
if ((cbTPSVersion.ItemIndex = 2) or (cbTPSVersion.ItemIndex = 3)) then
|
|
begin
|
|
begin
|
|
@@ -1282,10 +1332,10 @@ begin
|
|
|
|
|
|
EditE.Visible := True;
|
|
EditE.Visible := True;
|
|
EditF.Visible := True;
|
|
EditF.Visible := True;
|
|
- ADC1.Value:=0;
|
|
|
|
- ADC1.MaxValue:=255;
|
|
|
|
- ADC2.Value:=0;
|
|
|
|
- ADC2.MaxValue:=255;
|
|
|
|
|
|
+ ADC1.Value := 0;
|
|
|
|
+ ADC1.MaxValue := 255;
|
|
|
|
+ ADC2.Value := 0;
|
|
|
|
+ ADC2.MaxValue := 255;
|
|
end;
|
|
end;
|
|
cbCommand.Items.Clear;
|
|
cbCommand.Items.Clear;
|
|
sps.getCommands(cbCommand.Items);
|
|
sps.getCommands(cbCommand.Items);
|