📄 unit_global_variant.~pas
字号:
Inc(j);
sbufLED[j] := 32;
Inc(j);
sbufLength := 2 * LEDStyle + 10 + f; // 整帧长度(不包括校验位)
for p := j to (sbufLength - 1) do
sbufLED[p] := 0;
sbufLED[6] := k;//字符个数
sum := 0; //校验位
for p := 3 to (j - 1) do
if sbufLED[p] = $FF then
Continue
else
Inc(sum, sbufLED[p]);
sbufLED[sbufLength] := sum mod 256;
if sbufLED[sbufLength] = $FA then // 校验位为$FA,做相应处理
begin
Inc(sbufLength);
sbufLED[sbufLength] := $FF;
Inc(sbufLength);
end
else
Inc(sbufLength);
comm1.WriteCommData(@sbufLED, sbufLength); // 写串口
sleep(delayTime);
n := 0;
k := 0;
j := 10;
f := 0;
Continue;
end; // 汉字高位遇到屏末字节
Inc(k);
sbufLED[j] := 96;
Inc(j);
sbufLED[j] := ord(s[i]);
Inc(j);
flag := False;
Inc(i);
end
else // 是汉字低位
begin
sbufLED[j] := ord(s[i]);
flag := True;
Inc(n);
Inc(i);
if sbufLED[j] = $FA then // 如果值为$FA,则在后面加$FF
begin
Inc(j);
sbufLED[j] := $FF;
Inc(j);
Inc(f);
end
else
Inc(j);
if (i > length(s)) then //最后一个
begin
sbufLED[8] := sbufLED[7]; // 引出方式
// sbufLED[7] := sty_in;
// sBufLED[8] := sty_out;
Inc(m);
sbufLED[4] := m;
for p := n + 1 to LEDStyle do //不够一幕加空格
begin
Inc(k);
sbufLED[j] := 97;
Inc(j);
sbufLED[j] := 32;
Inc(j);
end;
sbufLength := 2 * LEDStyle + 10 + f;
for p := j to (sbufLength - 1) do
sbufLED[p] := 0;
sbufLED[6] := k;//字符个数
sum := 0; //校验位
for p := 3 to (j - 1) do
begin
if sbufLED[p] = $FF then
Continue
else
Inc(sum, sbufLED[p]);
end;
sbufLED[sbufLength] := sum mod 256;
if sbufLED[sbufLength] = $FA then // 校验位为$FA,做相应处理
begin
Inc(sbufLength);
sbufLED[sbufLength] := $FF;
Inc(sbufLength);
end
else
Inc(sbufLength);
comm1.WriteCommData(@sbufLED, sbufLength); // 写串口
sleep(delayTime);
// 显示命令
LEDShowCommand[8] := m;
sum := 0;
for p := 3 to 23 do
Inc(sum, LEDShowCommand[p]);
LEDShowCommand[24] := sum mod 256;
if LEDShowCommand[24] = $FA then
begin
LEDShowCommand[25] := $FF;
sbufLength := 26;
end
else
sbufLength := 25;
Comm1.WriteCommData(@LEDShowCommand,sbufLength);
Sleep(delayTime);
Break;
end; // 字符串最后一个
if n = LEDStyle then // 如果是一屏最后一个字符,则输出
begin
Inc(m);
sbufLED[4] := m;
sbufLength := 2 * LEDStyle + 10 + f;
for p := j to (sbufLength - 1) do
sbufLED[p] := 0;
sbufLED[6] := k;//字符个数
sum := 0; //校验位
for p := 3 to (j - 1) do
begin
if sbufLED[p] = $FF then
Continue
else
Inc(sum, sbufLED[p]);
end;
sbufLED[sbufLength] := sum mod 256;
if sbufLED[sbufLength] = $FA then // 校验位为$FA,做相应处理
begin
Inc(sbufLength);
sbufLED[sbufLength] := $FF;
Inc(sbufLength);
end
else
Inc(sbufLength);
comm1.WriteCommData(@sbufLED, sbufLength); // 写串口
sleep(delayTime);
n := 0;
k := 0;
j := 10;
f := 0;
Continue;
end; // 汉字低位遇到屏末字节
end; // 汉字低位
end
else//是字符
begin
Inc(k);
sbufLED[j] := 97;
Inc(j);
sbufLED[j] := ord(s[i]);
Inc(j);
Inc(n);
Inc(i);
if (i > length(s)) then //最后一个
begin
sbufLED[8] := sbufLED[7];
// sbufLED[7] := sty_in;
// sbufLED[8] := sty_out;
Inc(m);
sbufLED[4] := m;
for p := n + 1 to LEDStyle do //不够一幕加空格
begin
Inc(k);
sbufLED[j] := 97;
Inc(j);
sbufLED[j] := 32;
Inc(j);
end;
sbufLength := 2 * LEDStyle + 10 + f;
for p := j to (sbufLength - 1) do
sbufLED[p] := 0;
sbufLED[6] := k;//字符个数
sum:=0; //校验位
for p := 3 to (j - 1) do
begin
if sbufLED[p] = $FF then
Continue
else
Inc(sum, sbufLED[p]);
end;
sbufLED[sbufLength]:= sum mod 256;
if sbufLED[sbufLength] = $FA then
begin
Inc(sbufLength);
sbufLED[sbufLength] := $FF;
Inc(sbufLength);
end
else
Inc(sbufLength);
Comm1.WriteCommData(@sbufLED, sbufLength);//写串口
Sleep(delayTime);
// 显示命令
LEDShowCommand[8] := m;
sum := 0;
for p := 3 to 23 do
Inc(sum, LEDShowCommand[p]);
LEDShowCommand[24] := sum mod 256;
if LEDShowCommand[24] = $FA then
begin
LEDShowCommand[25] := $FF;
sbufLength := 26;
end
else
sbufLength := 25;
Comm1.WriteCommData(@LEDShowCommand,sbufLength);
Sleep(delayTime);
Break;
end; // 字符串最后一个字节是字母
if n = LEDStyle then // 一屏最后一个字符为字母,则输出
begin
Inc(m);
sbufLED[4] := m;
sbufLength := 2 * LEDStyle + 10 + f;
for p := j to (sbufLength - 1) do
sbufLED[p] := 0;
sbufLED[6] := k;//字符个数
sum := 0; //校验位
for p := 3 to (j - 1) do
begin
if sbufLED[p] = $FF then
Continue
else
Inc(sum, sbufLED[p]);
end;
sbufLED[sbufLength] := sum mod 256;
if sbufLED[sbufLength] = $FA then // 校验位为$FA,做相应处理
begin
Inc(sbufLength);
sbufLED[sbufLength] := $FF;
Inc(sbufLength);
end
else
Inc(sbufLength);
Comm1.WriteCommData(@sbufLED, sbufLength);//写串口
Sleep(delayTime);
n := 0;
k := 0;
j := 10;
f := 0;
Continue;
end; // if 一屏最后
end; // 是字符
end; // while
end
else //小于等于一屏的情况
begin
sbufLED[7] := sty_in; //$07; //* 32 + form1.bscbbinmode.ItemIndex; //form1.bscbbinspeed.itemindex
sbufLED[8] := sty_out;//$07; //form1.bscbboutspeed.ItemIndex * 32 + form1.bscbboutmode.ItemIndex;
sbufLED[9] := sty_stop;// $07; //form1.bscbbstaytime.ItemIndex * 8 + form1.bscbbstaymode.ItemIndex;
j := 10;//数据码位号
k := 0;//个数计数器
f := 0;
flag := True;
//不满一屏的,居中显示,前后加空格
for i := 1 to Trunc((LEDStyle - Length(s)) / 2) do
s := ' ' + s;
for i := 1 to (LEDStyle - Length(s)) do
s := s + ' ';
for i := 1 to LEDStyle do
begin
if ord(s[i]) > 128 then //是汉字
begin
if flag then // 汉字高位
begin
Inc(k);
sbufLED[j] := 96;
Inc(j);
sbufLED[j] := ord(s[i]);
Inc(j);
flag := False;
end
else
begin // 汉字低位
sbufLED[j] := ord(s[i]);
if sbufLED[j] = $FA then
begin
Inc(j);
sbufLED[j] := $FF;
Inc(j);
Inc(f);
end
else
Inc(j);
flag := True;
end;
end
else//是字符
begin
Inc(k);
sbufLED[j] := 97;
Inc(j);
sbufLED[j] := ord(s[i]);
Inc(j);
end;
end; // for
sbufLength := 2 * LEDStyle + 10 + f;
sbufLED[6] := k;//字符个数
sum := 0; //校验位
for p := j to (sbufLength - 1) do
sbufLED[p] := 0;
for p := 3 to (j - 1) do
begin
if sbufLED[p] = $FF then
Continue
else
Inc(sum, sbufLED[p]);
end;
sbufLED[sbufLength] := sum mod 256;
if sbufLED[sbufLength] = $FA then // 校验位为$FA,做相应处理
begin
Inc(sbufLength);
sbufLED[sbufLength] := $FF;
Inc(sbufLength);
end
else
Inc(sbufLength);
Comm1.WriteCommData(@sbufLED, sbufLength);//写串口
Sleep(delayTime);
// 显示命令
LEDShowCommand[24] := 1;
Comm1.WriteCommData(@LEDShowCommand, 25);
Sleep(delayTime);
end; // 小于一屏
end;
function getLedName(sName:String):string;
var
i,iCount:integer;
begin
for i:=0 to Length(sName)-1 do
begin
if ord(sName[i]) < 128 then //是英文或数字
inc(iCount);
end;
if iCount mod 2 =1 then //如果是奇数
Result := sName+' '
else
Result := sName;
end;
function creTimeStr(iSec:integer):string;
var
iMin,iSecLeft : integer;
sMin,sSec :String;
begin
if iSec >=60 then
begin
iMin := iSec div 60;
iSecLeft := iSec mod 60;
end
else
begin
iMin := 0;
iSecLeft := iSec;
end;
if iMin >= 10 then
sMin := inttostr(iMin)
else if iMin > 0 then
sMin := '0'+inttostr(iMin)
else
sMin := '00';
if iSecLeft >=10 then
sSec := inttostr(iSecLeft)
else if iSecLeft > 0 then
sSec := '0'+inttostr(iSecLeft)
else
sSec := '00';
Result := sMin+':'+sSec;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -