|
@@ -83,6 +83,7 @@ type
|
|
|
ADC2: TSpinEdit;
|
|
|
SaveDialog1: TSaveDialog;
|
|
|
SaveHexFile: TSaveDialog;
|
|
|
+ SaveBinFile: TSaveDialog;
|
|
|
SdpoSerial1: TSdpoSerial;
|
|
|
Servo1: TLabeledEdit;
|
|
|
Servo2: TLabeledEdit;
|
|
@@ -210,6 +211,7 @@ type
|
|
|
procedure setDirty(Value: boolean);
|
|
|
function checkDirty: boolean;
|
|
|
procedure checkPresets;
|
|
|
+ procedure makeBinFile(fileName: string);
|
|
|
procedure makeHexFile(fileName: string);
|
|
|
procedure setCaption;
|
|
|
procedure addHeaderText;
|
|
@@ -978,70 +980,85 @@ var
|
|
|
Lines: TStringList;
|
|
|
TimeOut: integer;
|
|
|
error: boolean;
|
|
|
+ filename: string;
|
|
|
|
|
|
begin
|
|
|
error := False;
|
|
|
- line := GetSerialPortNames;
|
|
|
- // if (line <> '') then
|
|
|
+ if cbTPSVersion.ItemIndex = 4 then
|
|
|
+ begin
|
|
|
+ // microbit code
|
|
|
+ SaveBinFile.FileName := 'mycobit';
|
|
|
+ if (SaveBinFile.Execute) then
|
|
|
+ begin
|
|
|
+ filename := SaveBinFile.FileName;
|
|
|
+ makeBinFile(filename);
|
|
|
+ end;
|
|
|
+ end
|
|
|
+ else
|
|
|
begin
|
|
|
- comServices := TStringList.Create;
|
|
|
- MCSStrings.DelimTextToStringlist(line, ',', comServices);
|
|
|
- return := mrOk;
|
|
|
- line := XMLPropStorage1.ReadString('ComPort', comServices[0]);
|
|
|
- frmSelectCom := TfrmSelectCom.Create(self);
|
|
|
- frmSelectCom.cbServices.Items.AddStrings(comServices);
|
|
|
- frmSelectCom.cbServices.Text := line;
|
|
|
+ line := GetSerialPortNames;
|
|
|
+ // if (line <> '') then
|
|
|
+ begin
|
|
|
+ comServices := TStringList.Create;
|
|
|
+ MCSStrings.DelimTextToStringlist(line, ',', comServices);
|
|
|
+ return := mrOk;
|
|
|
+ line := XMLPropStorage1.ReadString('ComPort', comServices[0]);
|
|
|
+ frmSelectCom := TfrmSelectCom.Create(self);
|
|
|
+ frmSelectCom.cbServices.Items.AddStrings(comServices);
|
|
|
+ frmSelectCom.cbServices.Text := line;
|
|
|
|
|
|
- return := frmSelectCom.ShowModal;
|
|
|
+ return := frmSelectCom.ShowModal;
|
|
|
|
|
|
- comService := frmSelectCom.cbServices.Text;
|
|
|
- XMLPropStorage1.WriteString('ComPort', comService);
|
|
|
- comServices.Free;
|
|
|
+ comService := frmSelectCom.cbServices.Text;
|
|
|
+ XMLPropStorage1.WriteString('ComPort', comService);
|
|
|
+ comServices.Free;
|
|
|
|
|
|
- if (return = mrOk) then
|
|
|
- begin
|
|
|
- hexFile := serialUpload;
|
|
|
+ if (return = mrOk) then
|
|
|
+ begin
|
|
|
+ hexFile := serialUpload;
|
|
|
|
|
|
- SdpoSerial1.Device := comService;
|
|
|
- SdpoSerial1.Active := True;
|
|
|
+ SdpoSerial1.Device := comService;
|
|
|
+ SdpoSerial1.Active := True;
|
|
|
|
|
|
- if (not readString(line)) then
|
|
|
- begin
|
|
|
- error := True;
|
|
|
- end;
|
|
|
- if (not error) then
|
|
|
- begin
|
|
|
- SdpoSerial1.WriteData('w');
|
|
|
- if (readString(line)) then
|
|
|
+ if (not readString(line)) then
|
|
|
begin
|
|
|
- if (pos('ready', line) > 0) then
|
|
|
+ error := True;
|
|
|
+ end;
|
|
|
+ if (not error) then
|
|
|
+ begin
|
|
|
+ SdpoSerial1.WriteData('w');
|
|
|
+ if (readString(line)) then
|
|
|
begin
|
|
|
- Lines := TStringList.Create;
|
|
|
- Lines.LoadFromFile(hexFile);
|
|
|
- for x := 0 to Lines.Count - 1 do
|
|
|
+ if (pos('ready', line) > 0) then
|
|
|
+ begin
|
|
|
+ Lines := TStringList.Create;
|
|
|
+ Lines.LoadFromFile(hexFile);
|
|
|
+ for x := 0 to Lines.Count - 1 do
|
|
|
+ begin
|
|
|
+ SdpoSerial1.WriteData(Lines.Strings[x]);
|
|
|
+ SdpoSerial1.WriteData(CRLF);
|
|
|
+ Sleep(250);
|
|
|
+ end;
|
|
|
+ SdpoSerial1.WriteData('e');
|
|
|
+ end
|
|
|
+ else
|
|
|
begin
|
|
|
- SdpoSerial1.WriteData(Lines.Strings[x]);
|
|
|
- SdpoSerial1.WriteData(CRLF);
|
|
|
- Sleep(250);
|
|
|
+ error := True;
|
|
|
end;
|
|
|
- SdpoSerial1.WriteData('e');
|
|
|
- end
|
|
|
- else
|
|
|
- begin
|
|
|
- error := True;
|
|
|
end;
|
|
|
end;
|
|
|
- end;
|
|
|
|
|
|
- if (error) then
|
|
|
- begin
|
|
|
- LSUAutoMsgBox('Messages', 'ID_NOT_READY', MB_OK + MB_ICONERROR);
|
|
|
- end else
|
|
|
- begin
|
|
|
- LSUAutoMsgBox('Messages', 'ID_UPLOAD_OK', MB_OK + MB_ICONINFORMATION);
|
|
|
+ if (error) then
|
|
|
+ begin
|
|
|
+ LSUAutoMsgBox('Messages', 'ID_NOT_READY', MB_OK + MB_ICONERROR);
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ LSUAutoMsgBox('Messages', 'ID_UPLOAD_OK', MB_OK + MB_ICONINFORMATION);
|
|
|
+ end;
|
|
|
+ SdpoSerial1.Active := False;
|
|
|
+ DeleteFile(hexFile);
|
|
|
end;
|
|
|
- SdpoSerial1.Active := False;
|
|
|
- DeleteFile(hexFile);
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
@@ -1185,6 +1202,36 @@ begin
|
|
|
SetLength(prgMem, 0);
|
|
|
end;
|
|
|
|
|
|
+procedure TForm1.makeBinFile(fileName: string);
|
|
|
+var
|
|
|
+ i, x: integer;
|
|
|
+ tmp: string;
|
|
|
+ hexFormat: TIntelHexFormat;
|
|
|
+ com, Data: byte;
|
|
|
+ f:file of byte;
|
|
|
+
|
|
|
+begin
|
|
|
+ i := StringGrid1.RowCount;
|
|
|
+ AssignFile(f, fileName);
|
|
|
+ Rewrite(f, 1);
|
|
|
+ for x := 1 to i - 1 do
|
|
|
+ begin
|
|
|
+ com := 0;
|
|
|
+ Data := 0;
|
|
|
+ tmp := StringGrid1.Cells[1, x];
|
|
|
+ if (tmp <> '') then
|
|
|
+ begin
|
|
|
+ com := HexToInt(tmp);
|
|
|
+ tmp := StringGrid1.Cells[2, x];
|
|
|
+ if (tmp <> '') then
|
|
|
+ Data := HexToInt(tmp);
|
|
|
+ Data := com * 16 + Data;
|
|
|
+ end;
|
|
|
+ Write(f, Data);
|
|
|
+ end;
|
|
|
+ CloseFile(f);
|
|
|
+end;
|
|
|
+
|
|
|
procedure TForm1.setCaption;
|
|
|
begin
|
|
|
if (activeFile = '') then
|