Browse Source

BUG: ADC could take values from 0.255, but holtek only supports 0..15

Klaas, Wilfried 4 years ago
parent
commit
7b50cb7db8
4 changed files with 44 additions and 29 deletions
  1. 1 9
      SPS_Emu.lpi
  2. 19 19
      ugui.lfm
  3. 14 0
      ugui.pas
  4. 10 1
      usps.pas

+ 1 - 9
SPS_Emu.lpi

@@ -22,7 +22,7 @@
       <AutoIncrementBuild Value="True"/>
       <MinorVersionNr Value="2"/>
       <RevisionNr Value="1"/>
-      <BuildNr Value="62"/>
+      <BuildNr Value="64"/>
       <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>
@@ -34,14 +34,6 @@
       <DestinationDirectory Value="$(ProjPath)\published\"/>
     </PublishOptions>
     <RunParams>
-      <local>
-        <CommandLineParams Value="beispiele/tone.tps"/>
-      </local>
-      <environment>
-        <UserOverrides Count="1">
-          <Variable0 Name="lazarus_debuglog" Value="c:\temp\debug.txt"/>
-        </UserOverrides>
-      </environment>
       <FormatVersion Value="2"/>
       <Modes Count="1">
         <Mode0 Name="default">

+ 19 - 19
ugui.lfm

@@ -1,12 +1,12 @@
 object Form1: TForm1
   Left = 266
-  Height = 582
+  Height = 584
   Top = 104
-  Width = 699
+  Width = 707
   AllowDropFiles = True
   Caption = 'SPS Emulator'
-  ClientHeight = 582
-  ClientWidth = 699
+  ClientHeight = 584
+  ClientWidth = 707
   Constraints.MinHeight = 582
   Constraints.MinWidth = 684
   OnCloseQuery = FormCloseQuery
@@ -16,14 +16,14 @@ object Form1: TForm1
   ShowHint = True
   LCLVersion = '2.0.2.0'
   object Panel1: TPanel
-    Left = 375
-    Height = 533
+    Left = 383
+    Height = 535
     Top = 26
     Width = 324
     Align = alRight
     BevelOuter = bvNone
     BorderStyle = bsSingle
-    ClientHeight = 529
+    ClientHeight = 531
     ClientWidth = 320
     TabOrder = 0
     object GBOutput: TGroupBox
@@ -598,7 +598,7 @@ object Form1: TForm1
     Left = 0
     Height = 26
     Top = 0
-    Width = 699
+    Width = 707
     ButtonHeight = 22
     ButtonWidth = 22
     Caption = 'ToolBar1'
@@ -777,26 +777,26 @@ object Form1: TForm1
   object StatusBar1: TStatusBar
     Left = 0
     Height = 23
-    Top = 559
-    Width = 699
+    Top = 561
+    Width = 707
     Panels = <>
   end
   object Panel2: TPanel
     Left = 0
-    Height = 533
+    Height = 535
     Top = 26
-    Width = 375
+    Width = 383
     Align = alClient
     BevelOuter = bvNone
     Caption = 'Panel2'
-    ClientHeight = 533
-    ClientWidth = 375
+    ClientHeight = 535
+    ClientWidth = 383
     TabOrder = 3
     object StringGrid1: TStringGrid
       Left = 0
-      Height = 499
+      Height = 501
       Top = 0
-      Width = 375
+      Width = 383
       Align = alClient
       Columns = <      
         item
@@ -835,13 +835,13 @@ object Form1: TForm1
     object Panel3: TPanel
       Left = 0
       Height = 34
-      Top = 499
-      Width = 375
+      Top = 501
+      Width = 383
       Align = alBottom
       BevelInner = bvLowered
       BevelOuter = bvNone
       ClientHeight = 34
-      ClientWidth = 375
+      ClientWidth = 383
       TabOrder = 1
       object cbCommand: TComboBox
         Left = 64

+ 14 - 0
ugui.pas

@@ -253,6 +253,7 @@ begin
   sps.setDelayCallback(@delayCallback);
   addHeaderText;
   renumberGrid();
+  cbTPSVersion.ItemIndex:=0;
   cbTPSVersionChange(Sender);
   acStop.Enabled := False;
   ToolButton18.Align := alRight;
@@ -1217,6 +1218,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
@@ -1239,6 +1244,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
@@ -1273,6 +1282,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);
@@ -1509,6 +1522,7 @@ begin
   MCSLabel.Caption := InfoBox.versionText;
 end;
 
+
 procedure TForm1.renumberGrid;
 var
   x, i: integer;

+ 10 - 1
usps.pas

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