소스 검색

Merge branch 'develop'

Klaas, Wilfried 4 년 전
부모
커밋
07f632dc26
9개의 변경된 파일135개의 추가작업 그리고 82개의 파일을 삭제
  1. 4 4
      SPS_EMU.000
  2. 6 5
      SPS_EMU.001
  3. 2 0
      SPS_EMU.044
  4. 2 0
      SPS_EMU.049
  5. 2 11
      SPS_Emu.lpi
  6. BIN
      SPS_Emu.lsu
  7. 13 3
      ugui.lfm
  8. 94 47
      ugui.pas
  9. 12 12
      usps.pas

+ 4 - 4
SPS_EMU.000

@@ -2,9 +2,9 @@
 LSUTextFile=1
 Copyrigth=MCS Media Computer Software
 [LSUInfo]
-CompileDate=30.12.2020
-CompileTime=18:00:02
+CompileDate=31.03.2021
+CompileTime=10:09:34
 Name=Wilfried Klaas
-LSUBinFile=E:\DATEN\Git-box\SPS_Emulator\SPS_Emu.lsu
-LSUTextFile=E:\DATEN\Git-box\SPS_Emulator\SPS_Emu.
+LSUBinFile=H:\privat\git-sourcen\SPS_Emulator\SPS_Emu.lsu
+LSUTextFile=H:\privat\git-sourcen\SPS_Emulator\SPS_Emu.
 RegString=

+ 6 - 5
SPS_EMU.001

@@ -6,7 +6,7 @@ ID_EXIT=&Exit
 ID_NEW=&New
 ID_OPEN=&Open
 ID_SAVE=&Save
-ID_SAVE_AS=S&ave as
+ID_SAVE_AS=&Save as
 ID_NEWLINE=New &Line
 ID_DELLINE=Delete Line
 ID_PRGFILE=Prog. File
@@ -14,8 +14,8 @@ ID_PRGULOAD=Upload
 ID_HEXFILE=Create HEX file
 ID_EXEC_STATEMENT=Execute Instruction
 ID_EXEC_NEXT=Next step
-ID_EXEC_STOP=Stop execution
-ID_EXEC_DEBUG=Debug program
+ID_EXEC_STOP=Stop debug execution
+ID_EXEC_DEBUG=Start/stop the program
 ID_ABOUT=&About
 ID_RESETPRESETS=R
 ID_SAVEPRESETS=S
@@ -73,6 +73,7 @@ ID_GRID_DESCRIPTION=Descr.
 ID_GRID_COMMENT=Comment
 ID_SAVE_TPS=File save as
 ID_SAVE_HEX=File save as
+ID_SAVE_BIN=File save as
 ID_OPEN=Open program
 ID_SAVE=Save program
 ID_SAVE_AS=Save program as
@@ -106,7 +107,6 @@ ID_BTN_PRG_NON=PRG not selected
 ID_BTN_SEL_SEL=SEL selected
 ID_BTN_SEL_NON=SEL not selected
 
-
 [form2Captions]
 ID_CAPTION=Program file
 
@@ -120,10 +120,11 @@ ID_CLOSE=&Close
 ID_CLOSE=Close window
 
 [form1Filter]
-ID_SAVE_TPS=TPS/SPS files (*.tps)|*.tps|all files (*.*)|*.*
+ID_SAVE_TPS=TPS/PLC files (*.tps)|*.tps|all files (*.*)|*.*
 ID_SAVE_HEX=Intel Hex file (*.hex)|*.hex|all files (*.*)|*.*
 ID_OPEN=TPS/SPS file (*.tps)|*.tps|all files (*.*)|*.*
 ID_SAVE=TPS/SPS file (*.tps)|*.tps|all files (*.*)|*.*
+ID_SAVE_BIN=binary file (*)|*|all files (*.*)|*.*
 
 [form1Action]
 ID_EXIT=&Exit

+ 2 - 0
SPS_EMU.044

@@ -73,6 +73,7 @@ ID_GRID_DESCRIPTION=Descr.
 ID_GRID_COMMENT=Comment
 ID_SAVE_TPS=File save as
 ID_SAVE_HEX=File save as
+ID_SAVE_BIN=File save as
 ID_OPEN=Open program
 ID_SAVE=Save program
 ID_SAVE_AS=Save program as
@@ -123,6 +124,7 @@ ID_SAVE_TPS=TPS/PLC files (*.tps)|*.tps|all files (*.*)|*.*
 ID_SAVE_HEX=Intel Hex file (*.hex)|*.hex|all files (*.*)|*.*
 ID_OPEN=TPS/SPS file (*.tps)|*.tps|all files (*.*)|*.*
 ID_SAVE=TPS/SPS file (*.tps)|*.tps|all files (*.*)|*.*
+ID_SAVE_BIN=binary file (*)|*|all files (*.*)|*.*
 
 [form1Action]
 ID_EXIT=&Exit

+ 2 - 0
SPS_EMU.049

@@ -73,6 +73,7 @@ ID_GRID_DESCRIPTION=Beschr.
 ID_GRID_COMMENT=Notizen
 ID_SAVE_TPS=Datei sichern als
 ID_SAVE_HEX=Datei sichern als
+ID_SAVE_BIN=Datei sichern als
 ID_OPEN=Programm öffnen
 ID_SAVE=Programm speichern
 ID_SAVE_AS=Programm speichern untern
@@ -124,6 +125,7 @@ ID_SAVE_TPS=TPS/SPS Dateien (*.tps)|*.tps|alle Dateien (*.*)|*.*
 ID_SAVE_HEX=Intel Hex File (*.hex)|*.hex|alle Dateien (*.*)|*.*
 ID_OPEN=TPS/SPS Dateien (*.tps)|*.tps|alle Dateien (*.*)|*.*
 ID_SAVE=TPS/SPS Dateien (*.tps)|*.tps|alle Dateien (*.*)|*.*
+ID_SAVE_BIN=Binärdatei (*)|*|alle Dateien (*.*)|*.*
 
 [form1Action]
 ID_EXIT=B&eenden

+ 2 - 11
SPS_Emu.lpi

@@ -10,8 +10,7 @@
       <ResourceType Value="res"/>
       <UseXPManifest Value="True"/>
       <XPManifest>
-        <DpiAware Value="Per-monitor"/>
-        <ExecutionLevel Value="highestAvailable"/>
+        <DpiAware Value="True"/>
       </XPManifest>
       <Icon Value="0"/>
     </General>
@@ -23,7 +22,7 @@
       <AutoIncrementBuild Value="True"/>
       <MinorVersionNr Value="2"/>
       <RevisionNr Value="1"/>
-      <BuildNr Value="72"/>
+      <BuildNr Value="76"/>
       <Language Value="0407"/>
       <StringTable CompanyName="MCS" FileDescription="TPS/SPS Emulator" InternalName="SPS_EMU" LegalCopyright="MCS (C) Wilfried Klaas" OriginalFilename="SPS_EMU.exe" ProductName="TPS/SPS Emulator" ProductVersion="0.2"/>
     </VersionInfo>
@@ -126,14 +125,6 @@
       <OtherUnitFiles Value="..\Lazarus_Libraries"/>
       <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
     </SearchPaths>
-    <CodeGeneration>
-      <Checks>
-        <IOChecks Value="True"/>
-      </Checks>
-      <Optimizations>
-        <OptimizationLevel Value="2"/>
-      </Optimizations>
-    </CodeGeneration>
     <Linking>
       <Debugging>
         <StripSymbols Value="True"/>

BIN
SPS_Emu.lsu


+ 13 - 3
ugui.lfm

@@ -1,7 +1,7 @@
 object Form1: TForm1
-  Left = 234
+  Left = 241
   Height = 584
-  Top = 113
+  Top = 118
   Width = 751
   AllowDropFiles = True
   Caption = 'SPS Emulator'
@@ -14,7 +14,7 @@ object Form1: TForm1
   OnDropFiles = FormDropFiles
   SessionProperties = 'cbAdrActual.Checked;Height;Left;StringGrid1.Columns;Top;Width'
   ShowHint = True
-  LCLVersion = '2.0.10.0'
+  LCLVersion = '2.0.12.0'
   object Panel1: TPanel
     Left = 427
     Height = 531
@@ -665,6 +665,7 @@ object Form1: TForm1
         'TPS ATMega8'
         'Willies SPS ATTiny84'
         'Willies SPS Arduino'
+        'BBC micro:bit'
       )
       OnChange = cbTPSVersionChange
       Style = csDropDownList
@@ -47318,6 +47319,7 @@ object Form1: TForm1
   object SdpoSerial1: TSdpoSerial
     Active = False
     BaudRate = br__9600
+    AltBaudRate = 0
     DataBits = db8bits
     Parity = pNone
     FlowControl = fcNone
@@ -65394,4 +65396,12 @@ object Form1: TForm1
       C635232323D6161616E4AAAAAA4F
     }
   end
+  object SaveBinFile: TSaveDialog
+    Title = 'ID_SAVE_BIN'
+    FileName = 'mycobit'
+    Filter = 'Default|*'
+    Options = [ofNoTestFileCreate, ofEnableSizing, ofViewDetail]
+    Left = 616
+    Top = 496
+  end
 end

+ 94 - 47
ugui.pas

@@ -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

+ 12 - 12
usps.pas

@@ -135,7 +135,7 @@ const
 type
   {TPSVersion}
 
-  TTPSVersion = (Holtek, ATMega8, ATTiny84, Arduino);
+  TTPSVersion = (Holtek, ATMega8, ATTiny84, Arduino, MicroBit);
 
   { TServo }
 
@@ -548,7 +548,7 @@ begin
       case Data of
         0: if (a = 0) then
             case version of
-              ATTiny84, Arduino: skip := True;
+              ATTiny84, Arduino, MicroBit: skip := True;
             end;
         1: if (a > b) then
             skip := True;
@@ -676,7 +676,7 @@ begin
   if (cmd = 0) then
   begin
     case version of
-      Holtek, ATMega8: MCSStrings.copyArray2List(O_LIST_H, list);
+      Holtek, ATMega8, MicroBit: MCSStrings.copyArray2List(O_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(O_LIST_AT, list);
     end;
   end;
@@ -693,7 +693,7 @@ begin
   if (cmd = 5) then
   begin
     case version of
-      Holtek: MCSStrings.copyArray2List(IS_A_LIST_H, list);
+      Holtek, MicroBit: MCSStrings.copyArray2List(IS_A_LIST_H, list);
       ATMega8: MCSStrings.copyArray2List(IS_A_LIST_A8, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(IS_A_LIST_AT, list);
     end;
@@ -701,7 +701,7 @@ begin
   if (cmd = 6) then
   begin
     case version of
-      Holtek: MCSStrings.copyArray2List(A_IS_LIST_H, list);
+      Holtek, MicroBit: MCSStrings.copyArray2List(A_IS_LIST_H, list);
       ATMega8: MCSStrings.copyArray2List(A_IS_LIST_A8, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(A_IS_LIST_AT, list);
     end;
@@ -709,14 +709,14 @@ begin
   if (cmd = 7) then
   begin
     case version of
-      Holtek, ATMega8: MCSStrings.copyArray2List(A_CALC_LIST_H, list);
+      Holtek, ATMega8, MicroBit: MCSStrings.copyArray2List(A_CALC_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(A_CALC_LIST_AT, list);
     end;
   end;
   if (cmd = 8) then
   begin
     case version of
-      Holtek, ATMega8: MCSStrings.copyArray2List(PAGE_LIST_H, list);
+      Holtek, ATMega8, MicroBit: MCSStrings.copyArray2List(PAGE_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(PAGE_LIST_AT, list);
     end;
   end;
@@ -729,7 +729,7 @@ begin
   if (cmd = 12) then
   begin
     case version of
-      Holtek: MCSStrings.copyArray2List(SKIP_LIST_H, list);
+      Holtek, MicroBit: MCSStrings.copyArray2List(SKIP_LIST_H, list);
       ATMega8: MCSStrings.copyArray2List(SKIP_LIST_A8, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(SKIP_LIST_AT, list);
     end;
@@ -739,14 +739,14 @@ begin
   if (cmd = 14) then
   begin
     case version of
-      Holtek, ATMega8: MCSStrings.copyArray2List(RET_LIST_H, list);
+      Holtek, ATMega8, MicroBit: MCSStrings.copyArray2List(RET_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(RET_LIST_AT, list);
     end;
   end;
   if (cmd = 15) then
   begin
     case version of
-      Holtek, ATMega8: MCSStrings.copyArray2List(F_LIST_H, list);
+      Holtek, ATMega8, MicroBit: MCSStrings.copyArray2List(F_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(F_LIST_AT, list);
     end;
   end;
@@ -961,7 +961,7 @@ begin
       end;
   end;
   case version of
-    Holtek, ATMega8: a := a and 15;
+    Holtek, ATMega8, MicroBit: a := a and 15;
   end;
 end;
 
@@ -1005,7 +1005,7 @@ begin
   case (Data) of
     0: if (a = 0) then
         case version of
-          ATTiny84, Arduino: addr := addr + 1;
+          ATTiny84, Arduino, MicroBit: addr := addr + 1;
         end;
     1: if (a > b) then
         addr := addr + 1;