You've already forked lazarus-ccr
IndustrialStuff: Fix functionality of Flash method of TAdvLED in case of too frequent calls.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8209 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -44,6 +44,7 @@
|
|||||||
<Filename Value="main.pas"/>
|
<Filename Value="main.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="Form1"/>
|
<ComponentName Value="Form1"/>
|
||||||
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="Main"/>
|
<UnitName Value="Main"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
|
@ -35,6 +35,11 @@ implementation
|
|||||||
|
|
||||||
procedure TForm1.Button1Click(Sender: TObject);
|
procedure TForm1.Button1Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
case AdvLed1.State of
|
||||||
|
lsOFF: AdvLed1.FlashMode := fmFlashOffToOn;
|
||||||
|
lsON: AdvLed1.FlashMode := fmFlashOnToOff;
|
||||||
|
else exit;
|
||||||
|
end;
|
||||||
AdvLed1.Flash(100);
|
AdvLed1.Flash(100);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ type
|
|||||||
TLedState = (lsDisabled, lsOff, lsOn);
|
TLedState = (lsDisabled, lsOff, lsOn);
|
||||||
TAdvLedGlyphs = array[TLedState] of TLedBitmap;
|
TAdvLedGlyphs = array[TLedState] of TLedBitmap;
|
||||||
TLedStateEvent = procedure(Sender: TObject; AState: TLedState) of object;
|
TLedStateEvent = procedure(Sender: TObject; AState: TLedState) of object;
|
||||||
|
TFlashMode = (fmFlashOffToOn, fmFlashOnToOff);
|
||||||
|
|
||||||
// led control that shows the state of serial signals
|
// led control that shows the state of serial signals
|
||||||
TAdvLed = class(TCustomImage)
|
TAdvLed = class(TCustomImage)
|
||||||
@ -41,6 +42,7 @@ type
|
|||||||
FGlyphs: TAdvLedGlyphs;
|
FGlyphs: TAdvLedGlyphs;
|
||||||
FBlinkTimer: TTimer;
|
FBlinkTimer: TTimer;
|
||||||
FFlashTimer: TTimer;
|
FFlashTimer: TTimer;
|
||||||
|
FFlashMode: TFlashMode;
|
||||||
function GetGlyph(const Index: Integer): TLedBitmap;
|
function GetGlyph(const Index: Integer): TLedBitmap;
|
||||||
function GetBlinkDuration: Integer;
|
function GetBlinkDuration: Integer;
|
||||||
procedure SetKind(const Value: TLedKind);
|
procedure SetKind(const Value: TLedKind);
|
||||||
@ -80,6 +82,7 @@ type
|
|||||||
property State: TLedState read FState write SetState;
|
property State: TLedState read FState write SetState;
|
||||||
property Blink: Boolean read FBlink write SetBlink;
|
property Blink: Boolean read FBlink write SetBlink;
|
||||||
property BlinkDuration: Integer read GetBlinkDuration write SetBlinkDuration default 1000;
|
property BlinkDuration: Integer read GetBlinkDuration write SetBlinkDuration default 1000;
|
||||||
|
property FlashMode: TFlashMode read FFlashMode write FFlashMode default fmFlashOffToOn;
|
||||||
property Align;
|
property Align;
|
||||||
property AutoSize default true;
|
property AutoSize default true;
|
||||||
property Center;
|
property Center;
|
||||||
@ -217,12 +220,20 @@ end;
|
|||||||
procedure TAdvLed.DoFlashTimer(Sender: TObject);
|
procedure TAdvLed.DoFlashTimer(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FFlashTimer.Enabled:= False;
|
FFlashTimer.Enabled:= False;
|
||||||
Toggle;
|
case FFlashMode of
|
||||||
|
fmFlashOffToOn: SetState(lsOff);
|
||||||
|
fmFlashOnToOff: SetState(lsOn);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAdvLed.Flash(ADuration: integer);
|
procedure TAdvLed.Flash(ADuration: integer);
|
||||||
begin
|
begin
|
||||||
Toggle;
|
if FState = lsDisabled then
|
||||||
|
exit;
|
||||||
|
case FFlashMode of
|
||||||
|
fmFlashOffToOn: SetState(lsOn);
|
||||||
|
fmFlashOnToOff: SetState(lsOff);
|
||||||
|
end;
|
||||||
FFlashTimer.Interval := ADuration;
|
FFlashTimer.Interval := ADuration;
|
||||||
FFlashTimer.Enabled := true;
|
FFlashTimer.Enabled := true;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user