1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| unit LEDmessUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CPortCtl, CPort, Menus, ComCtrls, StrUtils;
type
TForm1 = class(TForm)
ComPort1: TComPort;
btnSend: TButton;
ComLed1: TComLed;
StatusBar1: TStatusBar;
StaticText1: TStaticText;
lblTime: TLabel;
chkDimmer: TCheckBox;
btnAll: TButton;
btnExit: TButton;
procedure btnAllClick(Sender: TObject);
procedure btnSendClick(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
CurrentTime: string;
implementation
{$R *.dfm}
procedure GetCurrentTime;
var HourTens,
HourOnes,
MinuteTens,
MinuteOnes: char;
begin
CurrentTime := DateTimeToStr(Now());
CurrentTime := MidStr(CurrentTime,12,5);
Form1.lblTime.Caption := CurrentTime;
end;
procedure SendCommand(Command: String;Param: String);
var CheckSum: integer;
begin
CheckSum := 256-(13+1+StrToIntDef(Command,68)+StrToInt(Param)) mod 256;
Form1.ComPort1.WriteStr(#13);
Form1.ComPort1.WriteStr('1');
Form1.ComPort1.WriteStr(Command);
Form1.ComPort1.WriteStr(Param);
Form1.ComPort1.WriteStr(IntToStr(CheckSum));
end;
procedure StrobeDisplay;
var CommandByte: String;
Param: String;
begin
CommandByte := 'S';
Param := IntToStr(255);
SendCommand(CommandByte,Param);
end;
procedure DisplayAllDigits;
var CommandByte: String;
Param: String;
begin
CommandByte := 'D';
Param := IntToStr(255);
SendCommand(CommandByte,Param);
end;
procedure TForm1.btnSendClick(Sender: TObject);
begin
GetCurrentTime;
end;
procedure TForm1.btnAllClick(Sender: TObject);
begin
DisplayAllDigits;
StrobeDisplay;
end;
end. |
Partager