|
@@ -38,6 +38,8 @@ type
|
|
|
cbIgnDly: TCheckBox;
|
|
|
cbTPSVersion: TComboBox;
|
|
|
cbAdrActual: TCheckBox;
|
|
|
+ cbHardwareEmu: TCheckBox;
|
|
|
+ cbSerialNames: TComboBox;
|
|
|
EditDelay: TLabeledEdit;
|
|
|
EditJump: TLabeledEdit;
|
|
|
EditPage: TLabeledEdit;
|
|
@@ -52,6 +54,7 @@ type
|
|
|
Label5: TLabel;
|
|
|
lbStack: TListBox;
|
|
|
MCSLabel: TLabel;
|
|
|
+ mmLogMessages: TMemo;
|
|
|
MenuItem1: TMenuItem;
|
|
|
pmExamples: TPopupMenu;
|
|
|
RC1: TSpinEdit;
|
|
@@ -165,7 +168,9 @@ type
|
|
|
procedure btnToneClick(Sender: TObject);
|
|
|
procedure cbCommandChange(Sender: TObject);
|
|
|
procedure cbDataChange(Sender: TObject);
|
|
|
+ procedure cbHardwareEmuChange(Sender: TObject);
|
|
|
procedure cbIgnDlyChange(Sender: TObject);
|
|
|
+ procedure cbSerialNamesChange(Sender: TObject);
|
|
|
procedure cbTPSVersionChange(Sender: TObject);
|
|
|
procedure FormActivate(Sender: TObject);
|
|
|
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
|
@@ -951,6 +956,9 @@ begin
|
|
|
outputSps();
|
|
|
selectAddress(0);
|
|
|
activateSps(False);
|
|
|
+ if SdpoSerial1.Active then begin
|
|
|
+ SdpoSerial1.Close;
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
procedure TForm1.acThisStepExecute(Sender: TObject);
|
|
@@ -1382,11 +1390,70 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+procedure TForm1.cbHardwareEmuChange(Sender: TObject);
|
|
|
+var line : String;
|
|
|
+ comServices : TStringList;
|
|
|
+begin
|
|
|
+ if cbHardwareEmu.Checked then
|
|
|
+ begin
|
|
|
+ cbSerialNames.Enabled:=true;
|
|
|
+ line := GetSerialPortNames;
|
|
|
+ comServices := TStringList.Create;
|
|
|
+ MCSStrings.DelimTextToStringlist(line, ',', comServices);
|
|
|
+ line := XMLPropStorage1.ReadString('ComPort', comServices[0]);
|
|
|
+ cbSerialNames.Items.AddStrings(comServices);
|
|
|
+ cbSerialNames.Text := line;
|
|
|
+ comServices.Free;
|
|
|
+ cbSerialNamesChange(sender);
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TForm1.cbIgnDlyChange(Sender: TObject);
|
|
|
begin
|
|
|
sps.SetIgnoreDelay(cbIgnDly.Checked);
|
|
|
end;
|
|
|
|
|
|
+procedure TForm1.cbSerialNamesChange(Sender: TObject);
|
|
|
+var retries : integer;
|
|
|
+ error : boolean;
|
|
|
+ line : string;
|
|
|
+begin
|
|
|
+ SdpoSerial1.Active := False;
|
|
|
+ SdpoSerial1.BaudRate := br__9600;
|
|
|
+ if cbTPSVersion.ItemIndex = 5 then
|
|
|
+ begin
|
|
|
+ // Micro:bit V2 auto programm
|
|
|
+ SdpoSerial1.BaudRate := br115200;
|
|
|
+ end;
|
|
|
+
|
|
|
+ SdpoSerial1.Device := cbSerialNames.Text;
|
|
|
+ SdpoSerial1.Active := True;
|
|
|
+ retries := 10;
|
|
|
+ error := True;
|
|
|
+ while retries > 0 do
|
|
|
+ begin
|
|
|
+ SdpoSerial1.WriteData('p');
|
|
|
+ if (readString(line, True)) then
|
|
|
+ begin
|
|
|
+ if (pos('command', line) > 0) then
|
|
|
+ begin
|
|
|
+ retries := 0;
|
|
|
+ error := False;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ if error then
|
|
|
+ begin
|
|
|
+ Form2.Memo1.Append('>h');
|
|
|
+ SdpoSerial1.WriteData('h');
|
|
|
+ end;
|
|
|
+ Dec(retries);
|
|
|
+ end;
|
|
|
+ if (error) then
|
|
|
+ begin
|
|
|
+ LSUAutoMsgBox('Messages', 'ID_NOT_READY', MB_OK + MB_ICONERROR);
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TForm1.cbTPSVersionChange(Sender: TObject);
|
|
|
begin
|
|
|
if (cbTPSVersion.ItemIndex = 0) then
|
|
@@ -1951,7 +2018,26 @@ begin
|
|
|
end;
|
|
|
|
|
|
procedure TForm1.inputSps;
|
|
|
+var line : string;
|
|
|
+ value : longint;
|
|
|
begin
|
|
|
+ if cbHardwareEmu.Checked then begin
|
|
|
+ while SdpoSerial1.DataAvailable do
|
|
|
+ begin
|
|
|
+ readString(line, false);
|
|
|
+ mmLogMessages.Lines.Insert(0, line);
|
|
|
+ end;
|
|
|
+ SdpoSerial1.WriteData('i');
|
|
|
+ readString(line, true);
|
|
|
+ line := RightstrPos(line, 3);
|
|
|
+ value := HexToInt(line);
|
|
|
+ mmLogMessages.Lines.Insert(0, line + ' ' + IntToHex(value, 2));
|
|
|
+
|
|
|
+ Din1.Checked:= (value and $01) > 0;
|
|
|
+ Din2.Checked:= (value and $02) > 0;
|
|
|
+ Din3.Checked:= (value and $04) > 0;
|
|
|
+ Din4.Checked:= (value and $08) > 0;
|
|
|
+ end;
|
|
|
sps.setDin1(Din1.Checked);
|
|
|
sps.setDin2(Din2.Checked);
|
|
|
sps.setDin3(Din3.Checked);
|