diff --git a/components/industrialstuff/Example/AdvLED/AdvLED_Demo.lpi b/components/industrialstuff/Example/AdvLED/AdvLED_Demo.lpi index 943cde908..1d8d7e20f 100644 --- a/components/industrialstuff/Example/AdvLED/AdvLED_Demo.lpi +++ b/components/industrialstuff/Example/AdvLED/AdvLED_Demo.lpi @@ -44,6 +44,7 @@ + diff --git a/components/industrialstuff/Example/AdvLED/main.pas b/components/industrialstuff/Example/AdvLED/main.pas index 13f313f21..0a0bb5934 100644 --- a/components/industrialstuff/Example/AdvLED/main.pas +++ b/components/industrialstuff/Example/AdvLED/main.pas @@ -35,6 +35,11 @@ implementation procedure TForm1.Button1Click(Sender: TObject); begin + case AdvLed1.State of + lsOFF: AdvLed1.FlashMode := fmFlashOffToOn; + lsON: AdvLed1.FlashMode := fmFlashOnToOff; + else exit; + end; AdvLed1.Flash(100); end; diff --git a/components/industrialstuff/source/AdvLed.pas b/components/industrialstuff/source/AdvLed.pas index 3a5dbbb30..c01735c0b 100644 --- a/components/industrialstuff/source/AdvLed.pas +++ b/components/industrialstuff/source/AdvLed.pas @@ -30,6 +30,7 @@ type TLedState = (lsDisabled, lsOff, lsOn); TAdvLedGlyphs = array[TLedState] of TLedBitmap; TLedStateEvent = procedure(Sender: TObject; AState: TLedState) of object; + TFlashMode = (fmFlashOffToOn, fmFlashOnToOff); // led control that shows the state of serial signals TAdvLed = class(TCustomImage) @@ -41,6 +42,7 @@ type FGlyphs: TAdvLedGlyphs; FBlinkTimer: TTimer; FFlashTimer: TTimer; + FFlashMode: TFlashMode; function GetGlyph(const Index: Integer): TLedBitmap; function GetBlinkDuration: Integer; procedure SetKind(const Value: TLedKind); @@ -80,6 +82,7 @@ type property State: TLedState read FState write SetState; property Blink: Boolean read FBlink write SetBlink; property BlinkDuration: Integer read GetBlinkDuration write SetBlinkDuration default 1000; + property FlashMode: TFlashMode read FFlashMode write FFlashMode default fmFlashOffToOn; property Align; property AutoSize default true; property Center; @@ -217,12 +220,20 @@ end; procedure TAdvLed.DoFlashTimer(Sender: TObject); begin FFlashTimer.Enabled:= False; - Toggle; + case FFlashMode of + fmFlashOffToOn: SetState(lsOff); + fmFlashOnToOff: SetState(lsOn); + end; end; procedure TAdvLed.Flash(ADuration: integer); begin - Toggle; + if FState = lsDisabled then + exit; + case FFlashMode of + fmFlashOffToOn: SetState(lsOn); + fmFlashOnToOff: SetState(lsOff); + end; FFlashTimer.Interval := ADuration; FFlashTimer.Enabled := true; end;