Explorar o código

Merge branch 'develop'

Willie %!s(int64=4) %!d(string=hai) anos
pai
achega
c698939adb
Modificáronse 18 ficheiros con 548 adicións e 4799 borrados
  1. 12 9
      Beispiele/SimpleServo.tps
  2. 7 0
      Beispiele/blink.tps
  3. 16 0
      Beispiele/examples.json
  4. 12 0
      Beispiele/servo.tps
  5. 0 9
      Beispiele/simple_blink.tps
  6. 4 4
      SPS_EMU.000
  7. 19 6
      SPS_EMU.001
  8. 17 5
      SPS_EMU.044
  9. 18 5
      SPS_EMU.049
  10. 21 7
      SPS_Emu.lpi
  11. BIN=BIN
      SPS_Emu.lsu
  12. 7 0
      blink.tps
  13. 13 0
      tone.tps
  14. 115 4711
      ugui.lfm
  15. 250 35
      ugui.pas
  16. 19 6
      uselectcom.lfm
  17. 1 0
      uselectcom.pas
  18. 17 2
      usps.pas

+ 12 - 9
Beispiele/SimpleServo.tps

@@ -1,9 +1,12 @@
-#TPS:Willies SPS Arduino
-0x00,1,F,""
-0x01,2,8,""
-0x02,1,0,""
-0x03,2,7,""
-0x04,3,4,""
-0x05,0,0,""
-0x06,0,0,""
-0x07,0,0,""
+#TPS:Willies SPS Arduino 
+0x00,4,4,"" 
+0x01,5,1,"" 
+0x02,4,F,"" 
+0x03,7,C,"" 
+0x04,F,8,"" 
+0x05,4,0,"" 
+0x06,F,8,"" 
+0x07,2,0,"" 
+0x08,3,6,"" 
+0x09,F,F,"" 
+0x0A,0,,"" 

+ 7 - 0
Beispiele/blink.tps

@@ -0,0 +1,7 @@
+#TPS:Willies SPS Arduino
+0x00,1,5,""
+0x01,2,8,""
+0x02,1,A,""
+0x03,2,8,""
+0x04,3,4,""
+0x05,0,0,""

+ 16 - 0
Beispiele/examples.json

@@ -0,0 +1,16 @@
+{
+	"examples": [{
+			"name": "Blink",
+			"index": 1,
+			"file": "blink.tps"
+		}, {
+			"name": "Servo",
+			"index": 2,
+			"file": "servo.tps"
+		}, {
+			"name": "Tone",
+			"index": 3,
+			"file": "tone.tps"
+		}
+	]
+}

+ 12 - 0
Beispiele/servo.tps

@@ -0,0 +1,12 @@
+#TPS:Willies SPS Arduino 
+0x00,4,4,"" 
+0x01,5,1,"" 
+0x02,4,F,"" 
+0x03,7,C,"" 
+0x04,F,8,"" 
+0x05,4,0,"" 
+0x06,F,8,"" 
+0x07,2,0,"" 
+0x08,3,6,"" 
+0x09,F,F,"" 
+0x0A,0,,"" 

+ 0 - 9
Beispiele/simple_blink.tps

@@ -1,9 +0,0 @@
-#TPS:Willies SPS Arduino
-0x00,4,0,""
-0x01,1,5,""
-0x02,2,8,""
-0x03,1,A,""
-0x04,2,8,""
-0x05,3,4,""
-0x06,0,0,""
-0x07,0,0,""

+ 4 - 4
SPS_EMU.000

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

+ 19 - 6
SPS_EMU.001

@@ -6,6 +6,7 @@ ID_EXIT=&Exit
 ID_NEW=&New
 ID_OPEN=&Open
 ID_SAVE=&Save
+ID_SAVE_AS=S&ave as
 ID_NEWLINE=New &Line
 ID_DELLINE=Delete Line
 ID_PRGFILE=Prog. File
@@ -26,6 +27,7 @@ ID_EXIT=Exit the program
 ID_NEW=Create a new file
 ID_OPEN=open a file
 ID_SAVE=save the actual file
+ID_SAVE_AS=save as
 ID_NEWLINE=Add a new line to the program
 ID_DELLINE=Delete the actual line
 ID_PRGFILE=Show the programming file
@@ -40,10 +42,11 @@ ID_RESETPRESETS=reset all presets
 ID_SAVEPRESETS=save presets to file
 ID_LOADPRESETS=load presets from file
 ID_NEXT_INSERT=goto next row, add row if necessary
+ID_EXAMPLE=Load example from web
 
 [infobox]
 ID_APPTITLE=TPS/PLC Emulator
-ID_COPYRIGHT=MCS (C) 2018 Wilfried Klaas #13#10 EMail: w.klaas@gmx.de
+ID_COPYRIGHT=MCS (C) 2020 Wilfried Klaas #13#10 EMail: w.klaas@gmx.de
 
 [form1Captions]
 ID_TPS_VERSION=PLC target: 
@@ -55,10 +58,10 @@ ID_OUTPUT_1=Output 1
 ID_OUTPUT_2=Output 2
 ID_OUTPUT_3=Output 3
 ID_OUTPUT_4=Output 4
-ID_INPUT_4=Input 4
-ID_INPUT_3=Input 3
-ID_INPUT_2=Input 2
-ID_INPUT_1=Input 1
+ID_INPUT_4=Input &4
+ID_INPUT_3=Input &3
+ID_INPUT_2=Input &2
+ID_INPUT_1=Input &1
 ID_REFRESH_ADDR=Refresh address
 ID_MNEMONIC=Instruction
 ID_MNE_DATA=Data
@@ -72,6 +75,7 @@ ID_SAVE_TPS=File save as
 ID_SAVE_HEX=File save as
 ID_OPEN=Open program
 ID_SAVE=Save program
+ID_SAVE_AS=Save program as
 ID_CLICK_HERE= or click here.
  
 [form1Hints]
@@ -97,6 +101,11 @@ ID_GRID_MNEMONIC=Instruction
 ID_GRID_DATA=Data
 ID_GRID_DESCRIPTION=Description
 ID_GRID_COMMENT=Notes / Comment
+ID_BTN_PRG_SEL=PRG selected
+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
@@ -111,7 +120,7 @@ ID_CLOSE=&Close
 ID_CLOSE=Close window
 
 [form1Filter]
-ID_SAVE_TPS=TPS/PLC files (*.tps)|*.tps|all files (*.*)|*.*
+ID_SAVE_TPS=TPS/SPS 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 (*.*)|*.*
@@ -162,12 +171,16 @@ ID_START_LINE=Addr   BD   Inst.    Data      Comment
 [MessagesMSG]
 ID_MB_WARNINGT=Warning
 ID_MB_QUESTIONT=Question
+ID_MB_INFOT=Information
 SAVE_CHANGESM=The program has been changed. Do you want to save the changes?
+ID_UPLOAD_OKM=Pogram uploaded.
+ID_NOT_READYM=Arduino not responding. Maybe not connected, SEL not pressed oder wrong firmware version^?
 
 [frmSelectComCaptions]
 ID_COMPORT=Port
 ID_ARDUINO_INST=Arduino installation
 ID_COMMENT=Please select the port of the arduino.
+ID_COMMAND_HINT=To upload, please hold the SEL button down until a message appears.
 
 [frmSelectComHints]
 ID_COMPORT=Com Port

+ 17 - 5
SPS_EMU.044

@@ -6,6 +6,7 @@ ID_EXIT=&Exit
 ID_NEW=&New
 ID_OPEN=&Open
 ID_SAVE=&Save
+ID_SAVE_AS=&Save as
 ID_NEWLINE=New &Line
 ID_DELLINE=Delete Line
 ID_PRGFILE=Prog. File
@@ -26,6 +27,7 @@ ID_EXIT=Exit the program
 ID_NEW=Create a new file
 ID_OPEN=open a file
 ID_SAVE=save the actual file
+ID_SAVE_AS=save as
 ID_NEWLINE=Add a new line to the program
 ID_DELLINE=Delete the actual line
 ID_PRGFILE=Show the programming file
@@ -40,10 +42,11 @@ ID_RESETPRESETS=reset all presets
 ID_SAVEPRESETS=save presets to file
 ID_LOADPRESETS=load presets from file
 ID_NEXT_INSERT=goto next row, add row if necessary
+ID_EXAMPLE=Load example from web
 
 [infobox]
 ID_APPTITLE=TPS/PLC Emulator
-ID_COPYRIGHT=MCS (C) 2018 Wilfried Klaas #13#10 EMail: w.klaas@gmx.de
+ID_COPYRIGHT=MCS (C) 2020 Wilfried Klaas #13#10 EMail: w.klaas@gmx.de
 
 [form1Captions]
 ID_TPS_VERSION=PLC target: 
@@ -55,10 +58,10 @@ ID_OUTPUT_1=Output 1
 ID_OUTPUT_2=Output 2
 ID_OUTPUT_3=Output 3
 ID_OUTPUT_4=Output 4
-ID_INPUT_4=Input 4
-ID_INPUT_3=Input 3
-ID_INPUT_2=Input 2
-ID_INPUT_1=Input 1
+ID_INPUT_4=Input &4
+ID_INPUT_3=Input &3
+ID_INPUT_2=Input &2
+ID_INPUT_1=Input &1
 ID_REFRESH_ADDR=Refresh address
 ID_MNEMONIC=Instruction
 ID_MNE_DATA=Data
@@ -72,6 +75,7 @@ ID_SAVE_TPS=File save as
 ID_SAVE_HEX=File save as
 ID_OPEN=Open program
 ID_SAVE=Save program
+ID_SAVE_AS=Save program as
 ID_CLICK_HERE= or click here.
  
 [form1Hints]
@@ -97,6 +101,10 @@ ID_GRID_MNEMONIC=Instruction
 ID_GRID_DATA=Data
 ID_GRID_DESCRIPTION=Description
 ID_GRID_COMMENT=Notes / Comment
+ID_BTN_PRG_SEL=PRG selected
+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
@@ -162,12 +170,16 @@ ID_START_LINE=Addr   BD   Inst.    Data      Comment
 [MessagesMSG]
 ID_MB_WARNINGT=Warning
 ID_MB_QUESTIONT=Question
+ID_MB_INFOT=Information
 SAVE_CHANGESM=The program has been changed. Do you want to save the changes?
+ID_UPLOAD_OKM=Pogram uploaded.
+ID_NOT_READYM=Arduino not responding. Maybe not connected, SEL not pressed oder wrong firmware version^?
 
 [frmSelectComCaptions]
 ID_COMPORT=Port
 ID_ARDUINO_INST=Arduino installation
 ID_COMMENT=Please select the port of the arduino.
+ID_COMMAND_HINT=To upload, please hold the SEL button down until a message appears.
 
 [frmSelectComHints]
 ID_COMPORT=Com Port

+ 18 - 5
SPS_EMU.049

@@ -6,6 +6,7 @@ ID_EXIT=B&eenden
 ID_NEW=&Neu
 ID_OPEN=Ö&ffnen
 ID_SAVE=&Speichern
+ID_SAVE_AS=&Speichern als
 ID_NEWLINE=Neue &Zeile
 ID_DELLINE=Zeile löschen
 ID_PRGFILE=Programmierdatei
@@ -26,6 +27,7 @@ ID_EXIT=Beenden
 ID_NEW=Neue Datei erzeugen
 ID_OPEN=Datei öffnen
 ID_SAVE=Aktuelle Datei speichern
+ID_SAVE_AS=Datei speichern unter
 ID_NEWLINE=Neue Zeile hinzufügen
 ID_DELLINE=Aktuelle Zeile löschen
 ID_PRGFILE=Programmierdatei anzeigen
@@ -40,10 +42,11 @@ ID_RESETPRESETS=Einstellungen zurücksetzen
 ID_LOADPRESETS=Presets aus Datei laden
 ID_SAVEPRESETS=Presets in Datei speichern
 ID_NEXT_INSERT=nächste Zeile, wenn nötig, lege neue Zeile an
+ID_EXAMPLE=Beispiele aus dem Internet laden
 
 [infobox]
 ID_APPTITLE=TPS/SPS Emulator
-ID_COPYRIGHT=MCS (C) 2018 Wilfried Klaas #13#10 EMail: w.klaas@gmx.de
+ID_COPYRIGHT=MCS (C) 2020 Wilfried Klaas #13#10 EMail: w.klaas@gmx.de
 
 [form1Captions]
 ID_TPS_VERSION=TPS Zielsystem: 
@@ -55,10 +58,10 @@ ID_OUTPUT_1=Ausgang 1
 ID_OUTPUT_2=Ausgang 2
 ID_OUTPUT_3=Ausgang 3
 ID_OUTPUT_4=Ausgang 4
-ID_INPUT_4=Eingang 4
-ID_INPUT_3=Eingang 3
-ID_INPUT_2=Eingang 2
-ID_INPUT_1=Eingang 1
+ID_INPUT_4=Eingang &4
+ID_INPUT_3=Eingang &3
+ID_INPUT_2=Eingang &2
+ID_INPUT_1=Eingang &1
 ID_REFRESH_ADDR=Adresse aktualisieren
 ID_MNEMONIC=Befehle
 ID_MNE_DATA=Daten
@@ -72,6 +75,7 @@ ID_SAVE_TPS=Datei sichern als
 ID_SAVE_HEX=Datei sichern als
 ID_OPEN=Programm öffnen
 ID_SAVE=Programm speichern
+ID_SAVE_AS=Programm speichern untern
 ID_CLICK_HERE= oder clicken sie hier.
  
 [form1Hints]
@@ -97,6 +101,11 @@ ID_GRID_MNEMONIC=
 ID_GRID_DATA=
 ID_GRID_DESCRIPTION=
 ID_GRID_COMMENT=
+ID_BTN_PRG_SEL=PRG selektiert
+ID_BTN_PRG_NON=PRG nicht selektiert
+ID_BTN_SEL_SEL=SEL selektiert
+ID_BTN_SEL_NON=SEL nicht selektiert
+
 
 [form2Captions]
 ID_CAPTION=Programmdatei
@@ -162,12 +171,16 @@ ID_START_LINE=Addr   BD   Befehl   Daten     Kommentar
 [MessagesMSG]
 ID_MB_WARNINGT=Warnung
 ID_MB_QUESTIONT=Frage
+ID_MB_INFOT=Information
 SAVE_CHANGESM=Die Datei wurde geändert. Wollen Sie die Änderungen speichern?
+ID_UPLOAD_OKM=Pogramm übertragen.
+ID_NOT_READYM=Arduino antwortet nicht. Evtl. Arduino nicht angeschlossen, SEL nicht gedrückt oder falsche Firmware?
 
 [frmSelectComCaptions]
 ID_COMPORT=Schnittstelle
 ID_ARDUINO_INST=Arduinoinstallation
 ID_COMMENT=Bitte wählen Sie die Schnittstelle des Arduino.
+ID_COMMAND_HINT=Zum Upload halten Sie bitte die SEL Taste gedrückt bis eine Meldung erscheint.
 
 [frmSelectComHints]
 ID_COMPORT=

+ 21 - 7
SPS_Emu.lpi

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
-    <Version Value="10"/>
+    <Version Value="11"/>
     <PathDelim Value="\"/>
     <General>
       <SessionStorage Value="InProjectDir"/>
@@ -10,7 +10,8 @@
       <ResourceType Value="res"/>
       <UseXPManifest Value="True"/>
       <XPManifest>
-        <DpiAware Value="True"/>
+        <DpiAware Value="Per-monitor"/>
+        <ExecutionLevel Value="highestAvailable"/>
       </XPManifest>
       <Icon Value="0"/>
     </General>
@@ -22,7 +23,7 @@
       <AutoIncrementBuild Value="True"/>
       <MinorVersionNr Value="2"/>
       <RevisionNr Value="1"/>
-      <BuildNr Value="57"/>
+      <BuildNr Value="72"/>
       <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>
@@ -32,12 +33,9 @@
     <PublishOptions>
       <Version Value="2"/>
       <DestinationDirectory Value="$(ProjPath)\published\"/>
-      <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
-      <ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
     </PublishOptions>
     <RunParams>
       <local>
-        <FormatVersion Value="1"/>
         <CommandLineParams Value="beispiele/tone.tps"/>
       </local>
       <environment>
@@ -45,6 +43,19 @@
           <Variable0 Name="lazarus_debuglog" Value="c:\temp\debug.txt"/>
         </UserOverrides>
       </environment>
+      <FormatVersion Value="2"/>
+      <Modes Count="1">
+        <Mode0 Name="default">
+          <local>
+            <CommandLineParams Value="beispiele/tone.tps"/>
+          </local>
+          <environment>
+            <UserOverrides Count="1">
+              <Variable0 Name="lazarus_debuglog" Value="c:\temp\debug.txt"/>
+            </UserOverrides>
+          </environment>
+        </Mode0>
+      </Modes>
     </RunParams>
     <RequiredPackages Count="2">
       <Item1>
@@ -136,7 +147,7 @@
     </Linking>
   </CompilerOptions>
   <Debugging>
-    <Exceptions Count="4">
+    <Exceptions Count="5">
       <Item1>
         <Name Value="EAbort"/>
       </Item1>
@@ -149,6 +160,9 @@
       <Item4>
         <Name Value="Exception"/>
       </Item4>
+      <Item5>
+        <Name Value="EScannerError"/>
+      </Item5>
     </Exceptions>
   </Debugging>
 </CONFIG>

BIN=BIN
SPS_Emu.lsu


+ 7 - 0
blink.tps

@@ -0,0 +1,7 @@
+#TPS:Willies SPS Arduino
+0x00,1,5,""
+0x01,2,8,""
+0x02,1,A,""
+0x03,2,8,""
+0x04,3,4,""
+0x05,0,0,""

+ 13 - 0
tone.tps

@@ -0,0 +1,13 @@
+#TPS:Willies SPS Arduino
+0x00,4,4,""
+0x01,5,1,""
+0x02,4,F,""
+0x03,7,C,""
+0x04,F,8,""
+0x05,2,8,""
+0x06,4,0,""
+0x07,F,8,""
+0x08,2,8,""
+0x09,3,6,""
+0x0A,F,F,""
+0x0B,0,0,""

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 115 - 4711
ugui.lfm


+ 250 - 35
ugui.pas

@@ -9,7 +9,8 @@ interface
 uses
   Windows, Classes, SysUtils, FileUtil, SdpoSerial, Forms, Controls, Graphics, Dialogs,
   Grids, ExtCtrls, Menus, ComCtrls, ActnList, StdActns, LCLProc, StdCtrls, Spin,
-  XMLPropStorage, uSPS, LCLType, Buttons, types, MCSWINAPI, Math, fpjson, jsonparser, Midi;
+  XMLPropStorage, uSPS, LCLType, Buttons, types, MCSWINAPI, Math,
+  fpjson, jsonparser, Midi;
 
 type
 
@@ -29,10 +30,10 @@ type
     acHelpAbout: TAction;
     acHexFile: TAction;
     acNextInsert: TAction;
+    acSaveAs: TAction;
     acUpload: TAction;
     ActionList1: TActionList;
     acFileOpen: TFileOpen;
-    acFileSaveAs: TFileSaveAs;
     btnTone: TBitBtn;
     cbTPSVersion: TComboBox;
     cbAdrActual: TCheckBox;
@@ -44,11 +45,14 @@ type
     acPresetSave: TFileSaveAs;
     GBControl: TGroupBox;
     ImageList2: TImageList;
+    ImageList3: TImageList;
     Label3: TLabel;
     Label4: TLabel;
     Label5: TLabel;
     lbStack: TListBox;
     MCSLabel: TLabel;
+    MenuItem1: TMenuItem;
+    pmExamples: TPopupMenu;
     RC1: TSpinEdit;
     RC2: TSpinEdit;
     cbCommand: TComboBox;
@@ -60,7 +64,6 @@ type
     GBOutput: TGroupBox;
     GBInput: TGroupBox;
     GBInternal: TGroupBox;
-    ImageList1: TImageList;
     Label1: TLabel;
     Label10: TLabel;
     Label11: TLabel;
@@ -127,6 +130,8 @@ type
     tbPreset6: TToolButton;
     tbPreset7: TToolButton;
     tbPreset8: TToolButton;
+    ToolButton20: TToolButton;
+    ToolButton21: TToolButton;
     ToolButton3: TToolButton;
     ToolButton4: TToolButton;
     ToolButton5: TToolButton;
@@ -140,7 +145,6 @@ type
     procedure acDeleteRowExecute(Sender: TObject);
     procedure acExitExecute(Sender: TObject);
     procedure acFileOpenAccept(Sender: TObject);
-    procedure acFileSaveAsAccept(Sender: TObject);
     procedure acDebugExecute(Sender: TObject);
     procedure acHelpAboutExecute(Sender: TObject);
     procedure acHexFileExecute(Sender: TObject);
@@ -150,6 +154,7 @@ type
     procedure acNextStepExecute(Sender: TObject);
     procedure acPresetLoadAccept(Sender: TObject);
     procedure acPresetSaveAccept(Sender: TObject);
+    procedure acSaveAsExecute(Sender: TObject);
     procedure acShowHexFileExecute(Sender: TObject);
     procedure acStopExecute(Sender: TObject);
     procedure acThisStepExecute(Sender: TObject);
@@ -163,14 +168,19 @@ type
     procedure FormCreate(Sender: TObject);
     procedure FormDropFiles(Sender: TObject; const FileNames: array of string);
     procedure MCSLabelClick(Sender: TObject);
+    procedure MenuItem1Click(Sender: TObject);
     procedure mnSaveClick(Sender: TObject);
+    procedure pmExamplesPopup(Sender: TObject);
     procedure Shape1Paint(Sender: TObject);
     procedure Shape2Paint(Sender: TObject);
     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);
   private
     { private declarations }
@@ -179,8 +189,10 @@ type
     activeFile: string;
     dirty: boolean;
     lastNote: byte;
+    Examples: TStringList;
     procedure initMidi;
     procedure playNote(note: byte);
+    procedure loadFromList(Lines: TStringList; filename: string);
     function readString(var line: string): boolean;
     procedure saveSection(filename: string; key: string);
     procedure loadSection(filename: string; key: string);
@@ -214,7 +226,7 @@ var
 implementation
 
 uses MCSAbout, uTextUi, uSelectCom, MCSTools, MCSStrings, synaser,
-  MCSIO, mcsintelhex, MCSLSU, MCSIniFiles;
+  MCSIO, mcsintelhex, MCSLSU, MCSIniFiles, MCSWinHttp, luijsonutils;
 
 {$R *.lfm}
 
@@ -238,11 +250,12 @@ begin
   Infobox.Build := MCSGetVersion(Application.ExeName);
   Infobox.AppID := 31;
   Infobox.AppURL :=
-    'http://www.wk-music.de/pages/mcs/microcontroller/tps-sps-emulator.php';
+    'http://www.wk-music.de/willie/pages/mcs/microcontroller/tps-sps-emulator.php';
   sps := TSPS.Create();
   sps.setDelayCallback(@delayCallback);
   addHeaderText;
   renumberGrid();
+  cbTPSVersion.ItemIndex := 0;
   cbTPSVersionChange(Sender);
   acStop.Enabled := False;
   ToolButton18.Align := alRight;
@@ -259,6 +272,7 @@ begin
   Timer1.Enabled := True;
   MCSLSU.MakeForm('form1', 'ID_', form1);
   initMidi;
+  Examples := TStringList.Create;
 end;
 
 procedure TForm1.initMidi;
@@ -290,6 +304,55 @@ begin
   lastNote := note;
 end;
 
+procedure TForm1.loadFromList(Lines: TStringList; filename: string);
+var
+  i, x: integer;
+  line: string;
+  list: TStringList;
+begin
+  acNew.Execute;
+  list := TStringList.Create;
+  i := 1;
+  for x := 0 to Lines.Count - 1 do
+  begin
+    if (i + 1 > StringGrid1.RowCount) then
+    begin
+      StringGrid1.RowCount := StringGrid1.RowCount + 1;
+    end;
+    line := Lines[x];
+    if (Pos('#', line) = 1) then
+    begin
+      line := RightstrPos(line, 2);
+      if (Pos('TPS:', line) = 1) then
+      begin
+        line := RightstrPos(line, 5);
+        cbTPSVersion.Text := line;
+        cbTPSVersionChange(nil);
+      end;
+    end
+    else
+    begin
+      MCSStrings.DelimSepTextToStringlist(line, '"', ',', list);
+      if list.Count > 0 then
+        Stringgrid1.Cells[0, i] := list[0];
+      if list.Count > 1 then
+        Stringgrid1.Cells[1, i] := list[1];
+      if list.Count > 2 then
+        Stringgrid1.Cells[2, i] := list[2];
+      if list.Count > 3 then
+        Stringgrid1.Cells[4, i] := list[3];
+      list.Clear;
+      Inc(i);
+    end;
+  end;
+  list.Free;
+  activeFile := filename;
+  renumberGrid();
+  addHeaderText;
+  setCaption();
+  setDirty(False);
+end;
+
 procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of string);
 var
   line: string;
@@ -306,11 +369,105 @@ begin
   ShExec2(self.Handle, InfoBox.AppURL);
 end;
 
+procedure TForm1.MenuItem1Click(Sender: TObject);
+var
+  i: integer;
+  fileName, Data: string;
+  Lines: TStringList;
+begin
+  if (Sender is TMenuItem) then
+  begin
+    if (checkDirty()) then
+    begin
+      i := TMenuItem(Sender).Tag;
+      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;
+
 procedure TForm1.mnSaveClick(Sender: TObject);
 begin
   Statusbar1.SimpleText := Sender.ClassName;
 end;
 
+procedure TForm1.pmExamplesPopup(Sender: TObject);
+var
+  x, i, j, pos, index: integer;
+  myName: string;
+  myMenu, my2Menu: TMenuItem;
+  jsonString: string;
+  JsonObject: TJsonObject;
+  Data, JArray: TJSONData;
+  JItem: TJSONData;
+  subMenuName: string;
+  subMenu: TMenuItem;
+begin
+  for i := pmExamples.Items.Count - 1 downto 0 do
+  begin
+    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;
+  end;
+  pmExamples.Items.Clear;
+  Examples.Clear;
+
+  try
+    jsonString := DownloadFile('http://wkla.no-ip.biz/down/tps_examples/examples.json');
+    Data := StringToJSONData(jsonString);
+    JsonObject := TJSONObject(Data);
+
+    i := JsonObject.Count;
+    for x := 0 to JsonObject.Count - 1 do
+    begin
+      subMenuName := JsonObject.Names[x];
+      JArray := GetJSONProp(TJSONObject(Data), subMenuName);
+      if (JArray <> nil) then
+      begin
+        subMenu := TMenuItem.Create(pmExamples);
+        subMenu.Caption := subMenuName;
+        pmExamples.Items.Add(subMenu);
+        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('%.2d - %s', [index, myName]);
+          end;
+          myMenu := TMenuItem.Create(subMenu);
+          myMenu.Caption := myName;
+          myMenu.Tag := pos;
+          if (index > -1) then
+          begin
+            myMenu.OnClick := @MenuItem1Click;
+          end;
+          subMenu.Add(myMenu);
+        end;
+      end;
+    end;
+  except
+  end;
+end;
+
 procedure TForm1.Shape1Paint(Sender: TObject);
 var
   radius: integer;
@@ -419,12 +576,15 @@ begin
   end;
 end;
 
-procedure TForm1.acFileSaveAsAccept(Sender: TObject);
+procedure TForm1.acSaveAsExecute(Sender: TObject);
 var
   filename: string;
 begin
-  filename := (Sender as TFileSaveAs).Dialog.FileName;
-  saveFile(filename);
+  if SaveDialog1.Execute() then
+  begin
+    filename := SaveDialog1.FileName;
+    saveFile(filename);
+  end;
 end;
 
 procedure TForm1.saveFile(filename: string);
@@ -451,8 +611,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;
@@ -473,7 +633,7 @@ begin
   begin
     activateSps(True);
     acDebug.Enabled := True;
-    acDebug.ImageIndex := 10;
+    acDebug.ImageIndex := 57;
     cbAdrActual.Enabled := True;
     acNextStep.Enabled := False;
     // sps programmieren
@@ -720,7 +880,8 @@ 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;
@@ -736,7 +897,7 @@ begin
   begin
     stopit := True;
     sps.break();
-    acDebug.ImageIndex := 18;
+    acDebug.ImageIndex := 40;
     //   repeat
     //     Application.ProcessMessages;
     //   until (not sps.isDelayActive());
@@ -785,6 +946,7 @@ end;
 procedure TForm1.btnToneClick(Sender: TObject);
 begin
   MidiOutput.SendAllSoundOff(0, 0);
+  ImageList2.GetBitmap(22, btnTone.Glyph);
 end;
 
 function TForm1.serialUpload: string;
@@ -873,9 +1035,10 @@ begin
 
       if (error) then
       begin
-        Application.MessageBox('Arduino antwortet nicht. Evtl. Arduino nicht angeschlossen oder falsche Firmware?',
-          'Keine Antwort',
-          MB_OK + MB_ICONEXCLAMATION);
+        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);
@@ -929,7 +1092,8 @@ 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);
@@ -1029,7 +1193,8 @@ begin
   end
   else
   begin
-    Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) + ':' + ExtractFileName(activeFile);
+    Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) +
+      ':' + ExtractFileName(activeFile);
   end;
 
 end;
@@ -1044,7 +1209,8 @@ 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;
 
@@ -1096,6 +1262,10 @@ begin
     acUpload.Enabled := False;
     Label5.Visible := False;
     btnTone.Visible := False;
+    ADC1.Value := 0;
+    ADC1.MaxValue := 15;
+    ADC2.Value := 0;
+    ADC2.MaxValue := 15;
   end;
   if (cbTPSVersion.ItemIndex = 1) then
   begin
@@ -1118,6 +1288,10 @@ begin
     acUpload.Enabled := False;
     Label5.Visible := False;
     btnTone.Visible := False;
+    ADC1.Value := 0;
+    ADC1.MaxValue := 15;
+    ADC2.Value := 0;
+    ADC2.MaxValue := 15;
   end;
   if ((cbTPSVersion.ItemIndex = 2) or (cbTPSVersion.ItemIndex = 3)) then
   begin
@@ -1152,6 +1326,10 @@ begin
 
     EditE.Visible := True;
     EditF.Visible := True;
+    ADC1.Value := 0;
+    ADC1.MaxValue := 255;
+    ADC2.Value := 0;
+    ADC2.MaxValue := 255;
   end;
   cbCommand.Items.Clear;
   sps.getCommands(cbCommand.Items);
@@ -1184,7 +1362,8 @@ 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;
@@ -1237,10 +1416,14 @@ begin
   WriteIniBool(key, 'set', XMLPropStorage1.ReadBoolean(key + '.set', False), filename);
   WriteIniBool(key, 'prg', XMLPropStorage1.ReadBoolean(key + '.prg', False), filename);
   WriteIniBool(key, 'sel', XMLPropStorage1.ReadBoolean(key + '.sel', False), filename);
-  WriteIniBool(key, 'input1', XMLPropStorage1.ReadBoolean(key + '.input1', False), filename);
-  WriteIniBool(key, 'input2', XMLPropStorage1.ReadBoolean(key + '.input2', False), filename);
-  WriteIniBool(key, 'input3', XMLPropStorage1.ReadBoolean(key + '.input3', False), filename);
-  WriteIniBool(key, 'input4', XMLPropStorage1.ReadBoolean(key + '.input4', False), filename);
+  WriteIniBool(key, 'input1', XMLPropStorage1.ReadBoolean(key + '.input1', False),
+    filename);
+  WriteIniBool(key, 'input2', XMLPropStorage1.ReadBoolean(key + '.input2', False),
+    filename);
+  WriteIniBool(key, 'input3', XMLPropStorage1.ReadBoolean(key + '.input3', False),
+    filename);
+  WriteIniBool(key, 'input4', XMLPropStorage1.ReadBoolean(key + '.input4', False),
+    filename);
   WriteIniInteger(key, 'adc1', XMLPropStorage1.ReadInteger(key + '.adc1', 0), filename);
   WriteIniInteger(key, 'adc2', XMLPropStorage1.ReadInteger(key + '.adc2', 0), filename);
   WriteIniInteger(key, 'rc1', XMLPropStorage1.ReadInteger(key + '.rc1', 0), filename);
@@ -1252,10 +1435,14 @@ 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));
@@ -1302,7 +1489,8 @@ begin
   RC2.Value := XMLPropStorage1.ReadInteger(key + '.rc2', RC2.Value);
 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
@@ -1344,10 +1532,24 @@ begin
   checkPresets();
 end;
 
+procedure TForm1.tbPrgChange(Sender: TObject);
+begin
+  if tbPrg.Checked then
+  begin
+    tbPrg.Hint := MCSLSU.GetLSUText('form1Hints', 'ID_BTN_PRG_SEL', lsuCode);
+  end
+  else
+  begin
+    tbPrg.Hint := MCSLSU.GetLSUText('form1Hints', 'ID_BTN_PRG_NON', lsuCode);
+  end;
+end;
+
 procedure TForm1.tbResetClick(Sender: TObject);
 begin
   tbPrg.Checked := False;
+  tbPrg.Hint := MCSLSU.GetLSUText('form1Hints', 'ID_BTN_PRG_NON', lsuCode);
   tbSel.Checked := False;
+  tbSel.Hint := MCSLSU.GetLSUText('form1Hints', 'ID_BTN_SEL_NON', lsuCode);
   Din1.Checked := False;
   Din2.Checked := False;
   Din3.Checked := False;
@@ -1358,6 +1560,18 @@ begin
   RC2.Value := 8;
 end;
 
+procedure TForm1.tbSelChange(Sender: TObject);
+begin
+  if tbSel.Checked then
+  begin
+    tbSel.Hint := MCSLSU.GetLSUText('form1Hints', 'ID_BTN_SEL_SEL', lsuCode);
+  end
+  else
+  begin
+    tbSel.Hint := MCSLSU.GetLSUText('form1Hints', 'ID_BTN_SEL_NON', lsuCode);
+  end;
+end;
+
 procedure TForm1.Timer1Timer(Sender: TObject);
 var
   jsonString: string;
@@ -1372,8 +1586,8 @@ 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;
@@ -1392,7 +1606,8 @@ 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;
 
@@ -1476,7 +1691,7 @@ begin
     begin
       playNote(0);
     end;
-    btntone.Enabled := False;
+    btntone.Enabled := True;
   end;
   List := TStringList.Create;
   try

+ 19 - 6
uselectcom.lfm

@@ -9,7 +9,7 @@ object frmSelectCom: TfrmSelectCom
   OnCreate = FormCreate
   OnShow = FormShow
   Position = poMainFormCenter
-  LCLVersion = '1.8.4.0'
+  LCLVersion = '2.0.10.0'
   object ButtonPanel1: TButtonPanel
     Left = 6
     Height = 34
@@ -30,10 +30,10 @@ object frmSelectCom: TfrmSelectCom
     AnchorSideTop.Control = cbServices
     AnchorSideTop.Side = asrCenter
     AnchorSideRight.Side = asrBottom
-    Left = 78
+    Left = 79
     Height = 15
     Top = 52
-    Width = 73
+    Width = 72
     Anchors = [akTop, akRight]
     Caption = 'ID_COMPORT'
     ParentColor = False
@@ -49,13 +49,26 @@ object frmSelectCom: TfrmSelectCom
   end
   object Label2: TLabel
     AnchorSideRight.Side = asrBottom
-    Left = 0
+    Left = 4
     Height = 15
-    Top = 0
-    Width = 401
+    Top = 4
+    Width = 393
     Align = alTop
+    BorderSpacing.Around = 4
     Caption = 'ID_COMMENT'
     ParentColor = False
     WordWrap = True
   end
+  object Label3: TLabel
+    Left = 4
+    Height = 39
+    Top = 87
+    Width = 393
+    Align = alBottom
+    AutoSize = False
+    BorderSpacing.Around = 4
+    Caption = 'ID_COMMAND_HINT'
+    ParentColor = False
+    WordWrap = True
+  end
 end

+ 1 - 0
uselectcom.pas

@@ -17,6 +17,7 @@ type
     cbServices: TComboBox;
     Label1: TLabel;
     Label2: TLabel;
+    Label3: TLabel;
     procedure FormCreate(Sender: TObject);
     procedure FormShow(Sender: TObject);
   private

+ 17 - 2
usps.pas

@@ -84,7 +84,7 @@ const
   A_CALC_LIST_AT: array[0..15] of string = ('', 'A=A+1',
     'A=A-1', 'A=A+B', 'A=A-B', 'A=A*B', 'A=A/B',
     'A=A And B', 'A=A Or B', 'A=A Xor B', 'A=Not A', 'A=A % B',
-    'A=A+16*B', 'A = B - A', '', '');
+    'A=A+16*B', 'A = B - A', 'A=A SHR 1', 'A=A SHL 1');
   PAGE_LIST_H: array[0..15] of string = ('Page 0', 'Page 1',
     'Page 2', 'Page 3', 'Page 4', 'Page 5', 'Page 6',
     'Page 7', '', '', '', '', '', '', '', '');
@@ -903,7 +903,16 @@ begin
     6: dout2 := (a and $01) > 0;
     7: dout3 := (a and $01) > 0;
     8: dout4 := (a and $01) > 0;
-    9: pwm1 := a * 16;
+    9:
+    begin
+      pwm1 := a * 16;
+      case version of
+        Holtek:
+        begin
+          pwm1 := a;
+        end;
+      end;
+    end;
     10: pwm2 := a * 16;
     11:
     begin
@@ -944,6 +953,12 @@ begin
     13: case version of
         ATTiny84, Arduino: a := b - a;
       end;
+    14: case version of
+        ATTiny84, Arduino: a := a SHR 1;
+      end;
+    15: case version of
+        ATTiny84, Arduino: a := a SHL 1;
+      end;
   end;
   case version of
     Holtek, ATMega8: a := a and 15;

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio