|
@@ -165,6 +165,7 @@ type
|
|
|
procedure cbCommandChange(Sender: TObject);
|
|
|
procedure cbDataChange(Sender: TObject);
|
|
|
procedure cbTPSVersionChange(Sender: TObject);
|
|
|
+ procedure FormActivate(Sender: TObject);
|
|
|
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
procedure FormDropFiles(Sender: TObject; const FileNames: array of string);
|
|
@@ -177,12 +178,13 @@ type
|
|
|
procedure StringGrid1EditingDone(Sender: TObject);
|
|
|
procedure StringGrid1Selection(Sender: TObject; aCol, aRow: integer);
|
|
|
procedure tbPreset1Click(Sender: TObject);
|
|
|
- procedure tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint;
|
|
|
- var Handled: boolean);
|
|
|
+ procedure tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: boolean);
|
|
|
procedure tbPrgChange(Sender: TObject);
|
|
|
procedure tbResetClick(Sender: TObject);
|
|
|
procedure tbSelChange(Sender: TObject);
|
|
|
procedure Timer1Timer(Sender: TObject);
|
|
|
+ procedure XMLPropStorage1RestoringProperties(Sender: TObject);
|
|
|
+ procedure XMLPropStorage1SavingProperties(Sender: TObject);
|
|
|
private
|
|
|
{ private declarations }
|
|
|
sps: TSPS;
|
|
@@ -218,6 +220,9 @@ type
|
|
|
procedure loadPreset(filename: string);
|
|
|
procedure savePreset(filename: string);
|
|
|
procedure activateSps(enable: boolean);
|
|
|
+ procedure enableMicrobit(enable: boolean);
|
|
|
+ procedure outputMicrobit();
|
|
|
+ procedure inputMicrobit();
|
|
|
public
|
|
|
{ public declarations }
|
|
|
end;
|
|
@@ -228,7 +233,8 @@ var
|
|
|
implementation
|
|
|
|
|
|
uses MCSAbout, uTextUi, uSelectCom, MCSTools, MCSStrings, synaser,
|
|
|
- MCSIO, mcsintelhex, MCSLSU, MCSIniFiles, MCSWinHttp, luijsonutils;
|
|
|
+ MCSIO, mcsintelhex, MCSLSU, MCSIniFiles, MCSWinHttp, luijsonutils,
|
|
|
+ uiMicrobit, uMicrobit;
|
|
|
|
|
|
{$R *.lfm}
|
|
|
|
|
@@ -613,8 +619,8 @@ begin
|
|
|
begin
|
|
|
if (StringGrid1.Cells[1, x] <> '') then
|
|
|
begin
|
|
|
- line := StringGrid1.Cells[0, x] + ',' + StringGrid1.Cells[1, x] +
|
|
|
- ',' + StringGrid1.Cells[2, x] + ',"' + StringGrid1.Cells[4, x] + '"';
|
|
|
+ line := StringGrid1.Cells[0, x] + ',' + StringGrid1.Cells[1, x] + ',' +
|
|
|
+ StringGrid1.Cells[2, x] + ',"' + StringGrid1.Cells[4, x] + '"';
|
|
|
Writeln(f, line);
|
|
|
end;
|
|
|
end;
|
|
@@ -795,9 +801,11 @@ begin
|
|
|
begin
|
|
|
acNextStep.Enabled := False;
|
|
|
acStop.Enabled := False;
|
|
|
+ inputMicrobit();
|
|
|
inputSps();
|
|
|
sps.nextStep();
|
|
|
outputSps();
|
|
|
+ outputMicrobit();
|
|
|
acNextStep.Enabled := True;
|
|
|
acStop.Enabled := True;
|
|
|
end;
|
|
@@ -882,8 +890,7 @@ begin
|
|
|
tmp := tmp + '0';
|
|
|
line := line + tmp;
|
|
|
|
|
|
- line := line + ' ' + StringGrid1.Cells[3, x] + ' ,"' +
|
|
|
- StringGrid1.Cells[4, x] + '"';
|
|
|
+ line := line + ' ' + StringGrid1.Cells[3, x] + ' ,"' + StringGrid1.Cells[4, x] + '"';
|
|
|
list.add(line);
|
|
|
end;
|
|
|
end;
|
|
@@ -1016,10 +1023,18 @@ begin
|
|
|
if (return = mrOk) then
|
|
|
begin
|
|
|
hexFile := serialUpload;
|
|
|
+ SdpoSerial1.BaudRate:= br__9600;
|
|
|
+
|
|
|
+ if cbTPSVersion.ItemIndex = 5 then
|
|
|
+ begin
|
|
|
+ // Micro:bit V2 auto programm
|
|
|
+ SdpoSerial1.BaudRate:= br115200;
|
|
|
+ end;
|
|
|
|
|
|
SdpoSerial1.Device := comService;
|
|
|
SdpoSerial1.Active := True;
|
|
|
|
|
|
+ SdpoSerial1.WriteData('p');
|
|
|
if (not readString(line)) then
|
|
|
begin
|
|
|
error := True;
|
|
@@ -1109,8 +1124,7 @@ var
|
|
|
begin
|
|
|
if (dirty) then
|
|
|
begin
|
|
|
- i := MCSLSU.LSUAutoMsgBox('Messages', 'SAVE_CHANGES', MB_ICONQUESTION or
|
|
|
- MB_YESNOCANCEL);
|
|
|
+ i := MCSLSU.LSUAutoMsgBox('Messages', 'SAVE_CHANGES', MB_ICONQUESTION or MB_YESNOCANCEL);
|
|
|
if (i = mrYes) then
|
|
|
begin
|
|
|
saveFile(activeFile);
|
|
@@ -1208,7 +1222,7 @@ var
|
|
|
tmp: string;
|
|
|
hexFormat: TIntelHexFormat;
|
|
|
com, Data: byte;
|
|
|
- f:file of byte;
|
|
|
+ f: file of byte;
|
|
|
|
|
|
begin
|
|
|
i := StringGrid1.RowCount;
|
|
@@ -1240,8 +1254,7 @@ begin
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
- Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) +
|
|
|
- ':' + ExtractFileName(activeFile);
|
|
|
+ Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) + ':' + ExtractFileName(activeFile);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
@@ -1256,8 +1269,7 @@ begin
|
|
|
StringGrid1.Columns[i].Title.Caption :=
|
|
|
MCSLSU.GetLSUText('form1Captions', StringGrid1.Columns[i].Title.Caption, lsuCode);
|
|
|
end;
|
|
|
- StringGrid1.Cells[0, 0] := MCSLSU.GetLSUText('form1Captions',
|
|
|
- 'ID_GRID_STORAGE', lsuCode);
|
|
|
+ StringGrid1.Cells[0, 0] := MCSLSU.GetLSUText('form1Captions', 'ID_GRID_STORAGE', lsuCode);
|
|
|
StringGrid1.Repaint;
|
|
|
end;
|
|
|
|
|
@@ -1313,6 +1325,7 @@ begin
|
|
|
ADC1.MaxValue := 15;
|
|
|
ADC2.Value := 0;
|
|
|
ADC2.MaxValue := 15;
|
|
|
+ enableMicrobit(False);
|
|
|
end;
|
|
|
if (cbTPSVersion.ItemIndex = 1) then
|
|
|
begin
|
|
@@ -1339,6 +1352,7 @@ begin
|
|
|
ADC1.MaxValue := 15;
|
|
|
ADC2.Value := 0;
|
|
|
ADC2.MaxValue := 15;
|
|
|
+ enableMicrobit(False);
|
|
|
end;
|
|
|
if ((cbTPSVersion.ItemIndex = 2) or (cbTPSVersion.ItemIndex = 3)) then
|
|
|
begin
|
|
@@ -1377,6 +1391,7 @@ begin
|
|
|
ADC1.MaxValue := 255;
|
|
|
ADC2.Value := 0;
|
|
|
ADC2.MaxValue := 255;
|
|
|
+ enableMicrobit(False);
|
|
|
end;
|
|
|
|
|
|
if (cbTPSVersion.ItemIndex = 4) then
|
|
@@ -1404,12 +1419,46 @@ begin
|
|
|
ADC1.MaxValue := 15;
|
|
|
ADC2.Value := 0;
|
|
|
ADC2.MaxValue := 15;
|
|
|
+ enableMicrobit(False);
|
|
|
+ end;
|
|
|
+
|
|
|
+ if (cbTPSVersion.ItemIndex = 5) then
|
|
|
+ begin
|
|
|
+ // micro:bit v2
|
|
|
+ sps.setTPSVersion(MicroBitV2);
|
|
|
+
|
|
|
+ Label2.Visible := True;
|
|
|
+ ADC2.Visible := True;
|
|
|
+ PWM2.Visible := True;
|
|
|
+ Label16.Visible := True;
|
|
|
+ RC1.Visible := True;
|
|
|
+ Label17.Visible := True;
|
|
|
+ RC2.Visible := True;
|
|
|
+ Servo1.Visible := True;
|
|
|
+ Servo2.Visible := True;
|
|
|
+ Shape1.Visible := True;
|
|
|
+ Shape2.Visible := True;
|
|
|
+ EditE.Visible := True;
|
|
|
+ EditF.Visible := True;
|
|
|
+ acUpload.Enabled := True;
|
|
|
+ Label5.Visible := True;
|
|
|
+ btnTone.Visible := True;
|
|
|
+ ADC1.Value := 0;
|
|
|
+ ADC1.MaxValue := 15;
|
|
|
+ ADC2.Value := 0;
|
|
|
+ ADC2.MaxValue := 15;
|
|
|
+ enableMicrobit(True);
|
|
|
end;
|
|
|
|
|
|
cbCommand.Items.Clear;
|
|
|
sps.getCommands(cbCommand.Items);
|
|
|
end;
|
|
|
|
|
|
+procedure TForm1.FormActivate(Sender: TObject);
|
|
|
+begin
|
|
|
+ enableMicrobit(cbTPSVersion.ItemIndex = 5);
|
|
|
+end;
|
|
|
+
|
|
|
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
|
|
begin
|
|
|
canClose := checkDirty();
|
|
@@ -1437,8 +1486,7 @@ begin
|
|
|
begin
|
|
|
x := StringGrid1.Row;
|
|
|
StringGrid1.Cells[3, x] :=
|
|
|
- sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]),
|
|
|
- HexToInt(StringGrid1.Cells[2, x]));
|
|
|
+ sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]), HexToInt(StringGrid1.Cells[2, x]));
|
|
|
setDirty(True);
|
|
|
end;
|
|
|
end;
|
|
@@ -1483,7 +1531,45 @@ begin
|
|
|
GBControl.Enabled := enable;
|
|
|
GBInternal.Enabled := enable;
|
|
|
GBOutput.Enabled := enable;
|
|
|
- ;
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TForm1.enableMicrobit(enable: boolean);
|
|
|
+begin
|
|
|
+ if fMicrobit <> nil then
|
|
|
+ begin
|
|
|
+ if enable and not fMicrobit.Visible then
|
|
|
+ begin
|
|
|
+ fMicrobit.Show();
|
|
|
+ fMicrobit.Left := Left + Width + 8;
|
|
|
+ fMicrobit.Top := Top;
|
|
|
+ end;
|
|
|
+ if not enable and fMicrobit.Visible then
|
|
|
+ fMicrobit.Hide();
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TForm1.inputMicrobit();
|
|
|
+begin
|
|
|
+ if (fMicrobit <> nil) and fMicrobit.Visible then
|
|
|
+ begin
|
|
|
+ sps.setACC(fMicrobit.accx.Value, fMicrobit.accz.Value, fMicrobit.accz.Value);
|
|
|
+ sps.setComp(fMicrobit.compass.Value);
|
|
|
+ sps.setLight(fMicrobit.light.Value);
|
|
|
+ sps.setSnd(fMicrobit.snd.Value);
|
|
|
+ sps.setGesture(fMicrobit.cbGesture.ItemIndex);
|
|
|
+ sps.setLogo(fMicrobit.tbLogo.Checked);
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TForm1.outputMicrobit();
|
|
|
+var
|
|
|
+ image: TMBImage;
|
|
|
+begin
|
|
|
+ if (fMicrobit <> nil) and fMicrobit.Visible then
|
|
|
+ begin
|
|
|
+ image := sps.getDisplay();
|
|
|
+ fMicrobit.setImage(image);
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
procedure TForm1.saveSection(filename: string; key: string);
|
|
@@ -1503,6 +1589,14 @@ begin
|
|
|
WriteIniInteger(key, 'adc2', XMLPropStorage1.ReadInteger(key + '.adc2', 0), filename);
|
|
|
WriteIniInteger(key, 'rc1', XMLPropStorage1.ReadInteger(key + '.rc1', 0), filename);
|
|
|
WriteIniInteger(key, 'rc2', XMLPropStorage1.ReadInteger(key + '.rc2', 0), filename);
|
|
|
+ WriteIniBool(key, 'logo', XMLPropStorage1.ReadBoolean(key + '.logo', False), filename);
|
|
|
+ WriteIniInteger(key, 'accx', XMLPropStorage1.ReadInteger(key + '.accx', 0), filename);
|
|
|
+ WriteIniInteger(key, 'accy', XMLPropStorage1.ReadInteger(key + '.accy', 0), filename);
|
|
|
+ WriteIniInteger(key, 'accz', XMLPropStorage1.ReadInteger(key + '.accz', 0), filename);
|
|
|
+ WriteIniInteger(key, 'sound', XMLPropStorage1.ReadInteger(key + '.sound', 0), filename);
|
|
|
+ WriteIniInteger(key, 'light', XMLPropStorage1.ReadInteger(key + '.light', 0), filename);
|
|
|
+ WriteIniInteger(key, 'comp', XMLPropStorage1.ReadInteger(key + '.comp', 0), filename);
|
|
|
+ WriteIniInteger(key, 'gesture', XMLPropStorage1.ReadInteger(key + '.gesture', 0), filename);
|
|
|
end;
|
|
|
|
|
|
procedure TForm1.loadSection(filename: string; key: string);
|
|
@@ -1510,18 +1604,23 @@ begin
|
|
|
XMLPropStorage1.WriteBoolean(key + '.set', ReadIniBool(key, 'set', False, filename));
|
|
|
XMLPropStorage1.WriteBoolean(key + '.prg', ReadIniBool(key, 'prg', False, filename));
|
|
|
XMLPropStorage1.WriteBoolean(key + '.sel', ReadIniBool(key, 'sel', False, filename));
|
|
|
- XMLPropStorage1.WriteBoolean(key + '.input1', ReadIniBool(key,
|
|
|
- 'input1', False, filename));
|
|
|
- XMLPropStorage1.WriteBoolean(key + '.input2', ReadIniBool(key,
|
|
|
- 'input2', False, filename));
|
|
|
- XMLPropStorage1.WriteBoolean(key + '.input3', ReadIniBool(key,
|
|
|
- 'input3', False, filename));
|
|
|
- XMLPropStorage1.WriteBoolean(key + '.input4', ReadIniBool(key,
|
|
|
- 'input4', False, filename));
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.input1', ReadIniBool(key, 'input1', False, filename));
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.input2', ReadIniBool(key, 'input2', False, filename));
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.input3', ReadIniBool(key, 'input3', False, filename));
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.input4', ReadIniBool(key, 'input4', False, filename));
|
|
|
XMLPropStorage1.WriteInteger(key + '.adc1', ReadIniInteger(key, 'adc1', 0, filename));
|
|
|
XMLPropStorage1.WriteInteger(key + '.adc2', ReadIniInteger(key, 'adc2', 0, filename));
|
|
|
XMLPropStorage1.WriteInteger(key + '.rc1', ReadIniInteger(key, 'rc1', 0, filename));
|
|
|
XMLPropStorage1.WriteInteger(key + '.rc2', ReadIniInteger(key, 'rc2', 0, filename));
|
|
|
+
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.logo', ReadIniBool(key, 'logo', False, filename));
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.accx', ReadIniInteger(key, 'accx', 0, filename));
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.accy', ReadIniInteger(key, 'accy', 0, filename));
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.accz', ReadIniInteger(key, 'accz', 0, filename));
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.sound', ReadIniInteger(key, 'sound', 0, filename));
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.light', ReadIniInteger(key, 'light', 0, filename));
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.comp', ReadIniInteger(key, 'comp', 0, filename));
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.gesture', ReadIniInteger(key, 'gesture', 0, filename));
|
|
|
end;
|
|
|
|
|
|
procedure TForm1.tbPreset1Click(Sender: TObject);
|
|
@@ -1562,10 +1661,17 @@ begin
|
|
|
ADC2.Value := XMLPropStorage1.ReadInteger(key + '.adc2', ADC2.Value);
|
|
|
RC1.Value := XMLPropStorage1.ReadInteger(key + '.rc1', RC1.Value);
|
|
|
RC2.Value := XMLPropStorage1.ReadInteger(key + '.rc2', RC2.Value);
|
|
|
+ fMicrobit.tbLogo.Checked := XMLPropStorage1.ReadBoolean(key + '.logo', fMicrobit.tbLogo.Checked);
|
|
|
+ fMicrobit.accx.Value := XMLPropStorage1.ReadInteger(key + '.accx', fMicrobit.accx.Value);
|
|
|
+ fMicrobit.accy.Value := XMLPropStorage1.ReadInteger(key + '.accy', fMicrobit.accy.Value);
|
|
|
+ fMicrobit.accz.Value := XMLPropStorage1.ReadInteger(key + '.accz', fMicrobit.accz.Value);
|
|
|
+ fMicrobit.snd.Value := XMLPropStorage1.ReadInteger(key + '.sound', fMicrobit.snd.Value);
|
|
|
+ fMicrobit.light.Value := XMLPropStorage1.ReadInteger(key + '.light', fMicrobit.light.Value);
|
|
|
+ fMicrobit.compass.Value := XMLPropStorage1.ReadInteger(key + '.comp', fMicrobit.compass.Value);
|
|
|
+ fMicrobit.cbGesture.ItemIndex := XMLPropStorage1.ReadInteger(key + '.gesture', fMicrobit.cbGesture.ItemIndex);
|
|
|
end;
|
|
|
|
|
|
-procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint;
|
|
|
- var Handled: boolean);
|
|
|
+procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: boolean);
|
|
|
var
|
|
|
key: string;
|
|
|
begin
|
|
@@ -1604,6 +1710,14 @@ begin
|
|
|
XMLPropStorage1.WriteInteger(key + '.adc2', ADC2.Value);
|
|
|
XMLPropStorage1.WriteInteger(key + '.rc1', RC1.Value);
|
|
|
XMLPropStorage1.WriteInteger(key + '.rc2', RC2.Value);
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.logo', fMicrobit.tbLogo.Checked);
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.accx', fMicrobit.accx.Value);
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.accy', fMicrobit.accy.Value);
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.accz', fMicrobit.accz.Value);
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.sound', fMicrobit.snd.Value);
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.light', fMicrobit.light.Value);
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.comp', fMicrobit.compass.Value);
|
|
|
+ XMLPropStorage1.WriteInteger(key + '.gesture', fMicrobit.cbGesture.ItemIndex);
|
|
|
checkPresets();
|
|
|
end;
|
|
|
|
|
@@ -1661,12 +1775,37 @@ begin
|
|
|
if (InfoBox.newVersion) then
|
|
|
begin
|
|
|
MCSLabel.Font.Color := clred;
|
|
|
- MCSLabel.Hint := InfoBox.versionHint + chr($0a) + chr($0d) +
|
|
|
- MCSLSU.GetLSUText('form1Captions', 'ID_CLICK_HERE', lsuCode);
|
|
|
+ MCSLabel.Hint := InfoBox.versionHint + chr($0a) + chr($0d) + MCSLSU.GetLSUText(
|
|
|
+ 'form1Captions', 'ID_CLICK_HERE', lsuCode);
|
|
|
end;
|
|
|
MCSLabel.Caption := InfoBox.versionText;
|
|
|
end;
|
|
|
|
|
|
+procedure TForm1.XMLPropStorage1RestoringProperties(Sender: TObject);
|
|
|
+var
|
|
|
+ Uid: TGuid;
|
|
|
+ Result: HResult;
|
|
|
+ uuid: string;
|
|
|
+
|
|
|
+begin
|
|
|
+ uuid := XMLPropStorage1.ReadString('AppUUID', '');
|
|
|
+ if uuid = '' then
|
|
|
+ begin
|
|
|
+ Result := CreateGuid(Uid);
|
|
|
+ if Result = S_OK then
|
|
|
+ begin
|
|
|
+ uuid := GuidToString(Uid);
|
|
|
+ XMLPropStorage1.WriteString('AppUUID', uuid);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ Infobox.AppUUID := uuid;
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TForm1.XMLPropStorage1SavingProperties(Sender: TObject);
|
|
|
+begin
|
|
|
+
|
|
|
+end;
|
|
|
+
|
|
|
|
|
|
procedure TForm1.renumberGrid;
|
|
|
var
|
|
@@ -1681,8 +1820,7 @@ begin
|
|
|
if (StringGrid1.Cells[2, x] = '') then
|
|
|
StringGrid1.Cells[2, x] := '0';
|
|
|
StringGrid1.Cells[3, x] :=
|
|
|
- sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]),
|
|
|
- HexToInt(StringGrid1.Cells[2, x]));
|
|
|
+ sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]), HexToInt(StringGrid1.Cells[2, x]));
|
|
|
end;
|
|
|
end;
|
|
|
|