Industrial/LCDDisplay: implement streaming of the character dot matrices.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8303 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-06-15 15:32:44 +00:00
parent 3d619ce25b
commit 68b436d9f9
5 changed files with 454 additions and 225 deletions

View File

@ -118,11 +118,6 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="untMain"/> <UnitName Value="untMain"/>
</Unit> </Unit>
<Unit>
<Filename Value="..\..\..\..\..\svn\lazarus-ccr\components\industrialstuff\source\indlcldisplay.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="indLCLDisplay"/>
</Unit>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -10,7 +10,7 @@ uses
athreads, athreads,
{$ENDIF} {$ENDIF}
Interfaces, // this includes the LCL widgetset Interfaces, // this includes the LCL widgetset
Forms, untMain, TLCDLines_unit; Forms, untMain;
{$R *.res} {$R *.res}

View File

@ -3,7 +3,7 @@ object frmMain: TfrmMain
Height = 531 Height = 531
Top = 217 Top = 217
Width = 921 Width = 921
Caption = 'LCDLines Demo' Caption = 'LCDDisplay Demo'
ClientHeight = 531 ClientHeight = 531
ClientWidth = 921 ClientWidth = 921
OnCreate = FormCreate OnCreate = FormCreate

View File

@ -63,7 +63,7 @@ type
procedure seDisplayLineCountChange(Sender: TObject); procedure seDisplayLineCountChange(Sender: TObject);
procedure seWidthChange(Sender: TObject); procedure seWidthChange(Sender: TObject);
private private
LCDLines1: TLCDLines; LCDDisplay: TLCDDisplay;
public public
@ -80,28 +80,28 @@ implementation
procedure TfrmMain.cbtFrameColorColorChanged(Sender: TObject); procedure TfrmMain.cbtFrameColorColorChanged(Sender: TObject);
begin begin
LCDLines1.FrameColor := cbtFrameColor.ButtonColor; LCDDisplay.FrameColor := cbtFrameColor.ButtonColor;
end; end;
procedure TfrmMain.cbtBoardColorColorChanged(Sender: TObject); procedure TfrmMain.cbtBoardColorColorChanged(Sender: TObject);
begin begin
LCDLines1.BoardColor := cbtBoardColor.ButtonColor; LCDDisplay.BoardColor := cbtBoardColor.ButtonColor;
end; end;
procedure TfrmMain.cbtDotONColorColorChanged(Sender: TObject); procedure TfrmMain.cbtDotONColorColorChanged(Sender: TObject);
begin begin
LCDLines1.DotColorON := cbtDotONColor.ButtonColor; LCDDisplay.DotColorON := cbtDotONColor.ButtonColor;
end; end;
procedure TfrmMain.cbtDotOFFColorColorChanged(Sender: TObject); procedure TfrmMain.cbtDotOFFColorColorChanged(Sender: TObject);
begin begin
LCDLines1.DotColorOFF := cbtDotOFFColor.ButtonColor; LCDDisplay.DotColorOFF := cbtDotOFFColor.ButtonColor;
end; end;
procedure TfrmMain.FormCreate(Sender: TObject); procedure TfrmMain.FormCreate(Sender: TObject);
begin begin
LCDLines1 := TLCDLines.Create(self); LCDDisplay := TLCDDisplay.Create(self);
with LCDLines1 do with LCDDisplay do
begin begin
Left := 24; Left := 24;
Height := 101; Height := 101;
@ -111,7 +111,7 @@ begin
DotColorOn := 5162664; DotColorOn := 5162664;
DotColorOff := 2900284; DotColorOff := 2900284;
DisplayCharCount := 0; DisplayCharCount := 0;
Lines.Add('TLCDLines'); Lines.Add('TLCDDisplay');
ColorScheme := csInvGreen; ColorScheme := csInvGreen;
Parent := self; Parent := self;
end end
@ -119,111 +119,111 @@ end;
procedure TfrmMain.FormShow(Sender: TObject); procedure TfrmMain.FormShow(Sender: TObject);
begin begin
mmText.Lines := LCDLines1.Lines; mmText.Lines := LCDDisplay.Lines;
seDisplayLineCount.Value := LCDLines1.DisplayLineCount; seDisplayLineCount.Value := LCDDisplay.DisplayLineCount;
seDisplayCharCount.Value := LCDLines1.DisplayCharCount; seDisplayCharCount.Value := LCDDisplay.DisplayCharCount;
seFrameSize.Value := LCDLines1.FrameSize; seFrameSize.Value := LCDDisplay.FrameSize;
seDotSize.Value := LCDLines1.DotSize; seDotSize.Value := LCDDisplay.DotSize;
seDotsSpace.Value := LCDLines1.DotsSpace; seDotsSpace.Value := LCDDisplay.DotsSpace;
seWidth.Value := LCDLines1.Width; seWidth.Value := LCDDisplay.Width;
seHeigth.Value := LCDLines1.Height; seHeigth.Value := LCDDisplay.Height;
cbAutoSize.Checked := LCDLines1.AutoSize; cbAutoSize.Checked := LCDDisplay.AutoSize;
cbCharSpace.Checked := LCDLines1.CharSpace; cbCharSpace.Checked := LCDDisplay.CharSpace;
cbtFrameColor.ButtonColor := LCDLines1.FrameColor; cbtFrameColor.ButtonColor := LCDDisplay.FrameColor;
cbtBoardColor.ButtonColor := LCDLines1.BoardColor; cbtBoardColor.ButtonColor := LCDDisplay.BoardColor;
cbtDotONColor.ButtonColor := LCDLines1.DotColorOn; cbtDotONColor.ButtonColor := LCDDisplay.DotColorOn;
cbtDotOFFColor.ButtonColor := LCDLines1.DotColorOff; cbtDotOFFColor.ButtonColor := LCDDisplay.DotColorOff;
rgFrameStyle.ItemIndex := integer(LCDLines1.FrameStyle); rgFrameStyle.ItemIndex := integer(LCDDisplay.FrameStyle);
rgFrameColorStyle.ItemIndex := integer(LCDLines1.FrameColorStyle); rgFrameColorStyle.ItemIndex := integer(LCDDisplay.FrameColorStyle);
rgDotShape.ItemIndex := integer(LCDLines1.DotShape); rgDotShape.ItemIndex := integer(LCDDisplay.DotShape);
rgFrameHeight.ItemIndex := integer(LCDLines1.FrameHeight); rgFrameHeight.ItemIndex := integer(LCDDisplay.FrameHeight);
cbColorSchemes.ItemIndex:= integer(LCDLines1.ColorScheme); cbColorSchemes.ItemIndex:= integer(LCDDisplay.ColorScheme);
end; end;
procedure TfrmMain.cbAutoSizeChange(Sender: TObject); procedure TfrmMain.cbAutoSizeChange(Sender: TObject);
begin begin
LCDLines1.AutoSize := cbAutoSize.Checked; LCDDisplay.AutoSize := cbAutoSize.Checked;
if not cbAutoSize.Checked then if not cbAutoSize.Checked then
begin begin
LCDLines1.Width := seWidth.Value; LCDDisplay.Width := seWidth.Value;
LCDLines1.Height := seHeigth.Value; LCDDisplay.Height := seHeigth.Value;
end; end;
end; end;
procedure TfrmMain.cbCharSpaceChange(Sender: TObject); procedure TfrmMain.cbCharSpaceChange(Sender: TObject);
begin begin
LCDLines1.CharSpace := cbCharSpace.Checked; LCDDisplay.CharSpace := cbCharSpace.Checked;
end; end;
procedure TfrmMain.cbColorSchemesChange(Sender: TObject); procedure TfrmMain.cbColorSchemesChange(Sender: TObject);
begin begin
LCDLines1.ColorScheme := TColorScheme(cbColorSchemes.ItemIndex); LCDDisplay.ColorScheme := TColorScheme(cbColorSchemes.ItemIndex);
end; end;
procedure TfrmMain.mmTextChange(Sender: TObject); procedure TfrmMain.mmTextChange(Sender: TObject);
begin begin
LCDLines1.Lines.Assign(mmText.Lines); LCDDisplay.Lines.Assign(mmText.Lines);
if LCDLines1.AutoSize then if LCDDisplay.AutoSize then
begin begin
LCDLines1.InvalidatePreferredSize; LCDDisplay.InvalidatePreferredSize;
LCDLines1.AdjustSize; LCDDisplay.AdjustSize;
end; end;
LCDLines1.Invalidate; LCDDisplay.Invalidate;
end; end;
procedure TfrmMain.rgFrameStyleClick(Sender: TObject); procedure TfrmMain.rgFrameStyleClick(Sender: TObject);
begin begin
LCDLines1.FrameStyle := TFrameStyle(rgFrameStyle.ItemIndex); LCDDisplay.FrameStyle := TFrameStyle(rgFrameStyle.ItemIndex);
end; end;
procedure TfrmMain.rgFrameColorStyleClick(Sender: TObject); procedure TfrmMain.rgFrameColorStyleClick(Sender: TObject);
begin begin
LCDLines1.FrameColorStyle := TFrameColorStyle(rgFrameColorStyle.ItemIndex); LCDDisplay.FrameColorStyle := TFrameColorStyle(rgFrameColorStyle.ItemIndex);
end; end;
procedure TfrmMain.rgDotShapeClick(Sender: TObject); procedure TfrmMain.rgDotShapeClick(Sender: TObject);
begin begin
LCDLines1.DotShape := TDotShape(rgDotShape.ItemIndex); LCDDisplay.DotShape := TDotShape(rgDotShape.ItemIndex);
end; end;
procedure TfrmMain.rgFrameHeightClick(Sender: TObject); procedure TfrmMain.rgFrameHeightClick(Sender: TObject);
begin begin
LCDLines1.FrameHeight := TFrameHeight(rgFrameHeight.ItemIndex); LCDDisplay.FrameHeight := TFrameHeight(rgFrameHeight.ItemIndex);
end; end;
procedure TfrmMain.seDisplayCharCountChange(Sender: TObject); procedure TfrmMain.seDisplayCharCountChange(Sender: TObject);
begin begin
LCDLines1.DisplayCharCount := seDisplayCharCount.Value; LCDDisplay.DisplayCharCount := seDisplayCharCount.Value;
end; end;
procedure TfrmMain.seDotSizeChange(Sender: TObject); procedure TfrmMain.seDotSizeChange(Sender: TObject);
begin begin
LCDLines1.DotSize := seDotSize.Value; LCDDisplay.DotSize := seDotSize.Value;
end; end;
procedure TfrmMain.seDotsSpaceChange(Sender: TObject); procedure TfrmMain.seDotsSpaceChange(Sender: TObject);
begin begin
LCDLines1.DotsSpace := seDotsSpace.Value; LCDDisplay.DotsSpace := seDotsSpace.Value;
end; end;
procedure TfrmMain.seFrameSizeChange(Sender: TObject); procedure TfrmMain.seFrameSizeChange(Sender: TObject);
begin begin
LCDLines1.FrameSize := seFrameSize.Value; LCDDisplay.FrameSize := seFrameSize.Value;
end; end;
procedure TfrmMain.seHeigthChange(Sender: TObject); procedure TfrmMain.seHeigthChange(Sender: TObject);
begin begin
LCDLines1.Height := seHeigth.Value; LCDDisplay.Height := seHeigth.Value;
end; end;
procedure TfrmMain.seDisplayLineCountChange(Sender: TObject); procedure TfrmMain.seDisplayLineCountChange(Sender: TObject);
begin begin
LCDLines1.DisplayLineCount := seDisplayLineCount.Value; LCDDisplay.DisplayLineCount := seDisplayLineCount.Value;
end; end;
procedure TfrmMain.seWidthChange(Sender: TObject); procedure TfrmMain.seWidthChange(Sender: TObject);
begin begin
LCDLines1.Width := seWidth.Value; LCDDisplay.Width := seWidth.Value;
end; end;
end. end.

View File

@ -22,20 +22,47 @@ type
TColorScheme = (csCustom, csBlue, csGreen, csInvGreen); TColorScheme = (csCustom, csBlue, csGreen, csInvGreen);
type type
TDotMatrix = array of integer; TDotRow = integer;
TDotMatrixList = specialize TFPGMap<string, TDotMatrix>; TDotRows = array of TDotRow;
TDotMatrixList = specialize TFPGMap<string, TDotRows>;
TCharDefs = class(TPersistent)
private
FCharList: TDotMatrixList;
FColCount: Integer;
FRowCount: Integer;
function GetCount: Integer;
function GetDotRows(AChar: String): TDotRows;
procedure SetColCount(AValue: Integer);
procedure SetDotRows(AChar: String; const AValue: TDotRows);
procedure SetRowCount(AValue: Integer);
function EmptyRows: TDotRows;
procedure ReadCharDefs(Reader: TReader);
procedure WriteCharDefs(Writer: TWriter);
protected
procedure DefineProperties(Filer: TFiler); override;
public
constructor Create;
destructor Destroy; override;
procedure Add(AChar: String; ADotRows: TDotRows);
procedure Delete(AChar: String);
procedure Clear;
property Count: Integer read GetCount;
property DotRows[AChar: String]: TDotRows read GetDotRows write SetDotRows;
published
property ColCount: Integer read FColCount write SetColCount;
property RowCount: Integer read FRowCount write SetRowCount;
end;
TLCDDisplay = class(TGraphicControl) TLCDDisplay = class(TGraphicControl)
private private
BitMap: TBitMap; FBitmap: TBitMap;
{ {
one char consists of Col x Row of dots one char consists of Col x Row of dots
dots have size and space between dots dots have size and space between dots
} }
FDotSize: integer; // dot size in pixels FDotSize: integer; // dot size in pixels
FDotsSpace: integer; // inter-dots space in pixels FDotsSpace: integer; // inter-dots space in pixels
FDotColsCount: integer; // number of dot-cols in char matrix
FDotRowsCount: integer; // number of dot-rows in char matrix
FCharCount: integer; FCharCount: integer;
FGlobalDotColsCount: integer; FGlobalDotColsCount: integer;
FCharWidth: integer; FCharWidth: integer;
@ -63,7 +90,12 @@ type
FFrameColorStyle: TFrameColorStyle; FFrameColorStyle: TFrameColorStyle;
FDotShape: TDotShape; FDotShape: TDotShape;
FCharList: TDotMatrixList; FCharDefs: TCharDefs;
function GetDotColCount: Integer;
function GetDotRowCount: INteger;
procedure SetDotColCount(AValue: Integer);
procedure SetDotRowCount(AValue: Integer);
procedure SetDotShape(const Value: TDotShape); procedure SetDotShape(const Value: TDotShape);
procedure SetFrameColorStyle(const Value: TFrameColorStyle); procedure SetFrameColorStyle(const Value: TFrameColorStyle);
@ -87,8 +119,9 @@ type
function CalcCharCount: integer; function CalcCharCount: integer;
procedure InitCharList(AHorDots, AVertDots: integer); procedure InitCharList(AHorDots, AVertDots: integer);
//calculate widths and heigths of the char matrix, background border and frame //calculate widths and heigths of the char matrix, background border and frame
procedure DrawCalc(); procedure Prepare();
//draw frame //draw frame
procedure DrawBorder(); procedure DrawBorder();
//background grid of dots that are off //background grid of dots that are off
@ -105,27 +138,29 @@ type
procedure DrawBitmapToCanvas(); procedure DrawBitmapToCanvas();
protected protected
// Basic method of auto-size calculation
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer;
{%H-}WithThemeSpace: boolean); override; {%H-}WithThemeSpace: boolean); override;
// Takes care of high-dpi scaling
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: double); override; const AXProportion, AYProportion: double); override;
// inherited painting routine
procedure Paint; override; procedure Paint; override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
procedure AddDotMatrix(AChar: string; const Dots: array of integer); // Adds a user-defined character and its dot matrix.
procedure AddCharDef(AChar: string; const Dots: TDotRows);
property DotColsCount: integer read FDotColsCount;
property DotRowsCount: integer read FDotRowsCount;
property CharCount: longint read GetCharCount; property CharCount: longint read GetCharCount;
property DotColCount: integer read GetDotColCount;
property DotRowCount: integer read GetDotRowCount;
property GlobalDotColsCount: longint read GetGlobalDotColsCount; property GlobalDotColsCount: longint read GetGlobalDotColsCount;
published published
property AutoSize; property AutoSize default true;
property BorderSpacing; property BorderSpacing;
property ShowHint; property ShowHint;
property Visible; property Visible;
@ -135,6 +170,8 @@ type
property OnMouseMove; property OnMouseMove;
property OnMouseUp; property OnMouseUp;
property CharDefs: TCharDefs read FCharDefs write FCharDefs;
property DotSize: integer read FDotSize write SetDotSize default 4; property DotSize: integer read FDotSize write SetDotSize default 4;
property DotsSpace: integer read FDotsSpace write SetDotsSpace default 1; property DotsSpace: integer read FDotsSpace write SetDotsSpace default 1;
property FrameSize: integer read FFrameSize write SetFrameSize default 8; property FrameSize: integer read FFrameSize write SetFrameSize default 8;
@ -182,6 +219,169 @@ implementation
uses uses
Dialogs, LazUTF8, LazUnicode; Dialogs, LazUTF8, LazUnicode;
{ TCharDefs }
constructor TCharDefs.Create;
begin
inherited;
FCharList := TDotMatrixList.Create;
FCharList.Sorted := True;
end;
destructor TCharDefs.Destroy;
begin
FCharList.Free;
inherited;
end;
{ Adds a new character dot matrix. }
procedure TCharDefs.Add(AChar: String; ADotRows: TDotRows);
begin
if Length(ADotRows) <> FRowCount then
raise Exception.Create('Incorrect number of rows.');
FCharList.Add(AChar, ADotRows);
end;
{ Clears all characters and their dot matrices. }
procedure TCharDefs.Clear;
begin
FCharList.Clear;
end;
{ Prepares streaming of the dot matrices }
procedure TCharDefs.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineProperty('CharDefs', @ReadCharDefs, @WriteCharDefs, true);
end;
{ Deletes the specified character and its dot matrix from the list. }
procedure TCharDefs.Delete(AChar: String);
var
idx: Integer;
begin
if FCharList.Find(AChar, idx) then
FCharList.Delete(idx);
end;
{ Creates an empty row in which not dots are set. }
function TCharDefs.EmptyRows: TDotRows;
var
row: Integer;
begin
Result := nil;
SetLength(Result, FRowCount);
for row := 0 to FRowCount-1 do
Result[row] := 0;
end;
{ Returns the number of characters contained. }
function TCharDefs.GetCount: Integer;
begin
Result := FCharList.Count;
end;
{ Returns the dot matrix rows for the specified character. Each row is an
integer in which each bit is interpreted as a dot. }
function TCharDefs.GetDotRows(AChar: String): TDotRows;
var
idx: Integer;
begin
if FCharList.Find(AChar, idx) then
Result := FCharList.Data[idx]
else
Result := EmptyRows;
end;
{ Reads the list of character name and dot matrices from the LFM file. The data
are stored in the LFM as a comma-separated list beginning with the character
name. }
procedure TCharDefs.ReadCharDefs(Reader: TReader);
var
i: Integer;
s: String;
ch: String;
sa: TStringArray;
rows: TDotRows = nil;
begin
Clear;
Reader.ReadListBegin;
while not Reader.EndOfList do
begin
s := Reader.ReadString;
if s[1] = ',' then
begin
ch := ',';
System.Delete(s, 1, 2);
end else
begin
i := pos(',', s);
ch := copy(s, 1, i-1);
System.Delete(s, 1, i);
end;
sa := s.Split(',');
SetLength(rows, Length(sa));
for i := 0 to High(sa) do
rows[i] := StrToInt(sa[i]);
Add(ch, rows);
end;
Reader.ReadListEnd;
end;
{ Returns the number of columns of the dot matrix. }
procedure TCharDefs.SetColCount(AValue: Integer);
begin
if FColCount = AValue then
exit;
FColCount := AValue;
FCharList.Clear;
end;
{ Sets the dot matrix for the specified character }
procedure TCharDefs.SetDotRows(AChar: String; const AValue: TDotRows);
var
idx: Integer;
begin
if FCharList.Find(AChar, idx) then
FCharList.Data[idx] := AValue
else
Add(AChar, AValue);
end;
{ Returns the number of rows of the dot matrix. }
procedure TCharDefs.SetRowCount(AValue: Integer);
begin
if FRowCount = AValue then
exit;
FRowCount := AValue;
FCharList.Clear;
end;
{ Write the character and its dot matrix to the LFM. Each character is stored
as a comma-separated list of character and dotrow values. }
procedure TCharDefs.WriteCharDefs(Writer: TWriter);
var
i, j: Integer;
ch: String;
rows: TDotRows;
s: String;
begin
Writer.WriteListBegin;
for i := 0 to Count-1 do
begin
ch := FCharList.Keys[i];
rows := DotRows[ch];
s := ch;
for j := 0 to FRowCount-1 do
s := s + ',' + IntToStr(rows[j]);
Writer.WriteString(s);
end;
Writer.WriteListEnd;
end;
{ TLCDDisplay}
constructor TLCDDisplay.Create(AOwner: TComponent); constructor TLCDDisplay.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
@ -193,12 +393,10 @@ begin
FDisplayLineCount := 2; FDisplayLineCount := 2;
FDisplayCharCount := 10; FDisplayCharCount := 10;
FCharList := TDotMatrixList.Create; FCharDefs := TCharDefs.Create;
FCharList.Sorted := True; FCharDefs.ColCount := 5;
FCharDefs.RowCount := 7;
FDotColsCount := 5; InitCharList(DotColCount, DotRowCount);
FDotRowsCount := 7;
InitCharList(FDotColsCount, FDotRowsCount);
FDotSize := 4; FDotSize := 4;
FDotsSpace := 1; FDotsSpace := 1;
@ -210,44 +408,43 @@ begin
FDotColorOn := clSkyBlue; FDotColorOn := clSkyBlue;
FDotColorOff := clTeal; FDotColorOff := clTeal;
BitMap := TBitMap.Create; FBitmap := TBitMap.Create;
FCountOn := 255; FCountOn := 255;
FLines := TStringList.Create; FLines := TStringList.Create;
AutoSize := true;
end; end;
destructor TLCDDisplay.Destroy; destructor TLCDDisplay.Destroy;
begin begin
BitMap.Free; FBitmap.Free;
FCharList.Free; FCharDefs.Free;
FLines.Free; FLines.Free;
inherited Destroy; inherited Destroy;
end; end;
procedure TLCDDisplay.AddDotMatrix(AChar: string; const Dots: array of integer); procedure TLCDDisplay.AddCharDef(AChar: string; const Dots: TDotRows);
var
matrix: TDotMatrix = nil;
i: integer;
begin begin
if Length(Dots) <> FDotRowsCount then FCharDefs.Add(AChar, Dots);
raise Exception.Create('AddDotMatrix: Incorrect number of rows.');
SetLength(matrix, FDotRowsCount);
for i := 0 to FDotRowsCount - 1 do
matrix[i] := Dots[i];
FCharList.Add(AChar, matrix);
end; end;
procedure TLCDDisplay.CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; procedure TLCDDisplay.CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: boolean); WithThemeSpace: boolean);
var
nDotCols: Integer;
nDotRows: Integer;
begin begin
FCharWidth := (DotSize * FDotColsCount) + (DotsSpace * (FDotColsCount + 1)); //pixels nDotCols := DotColCount;
nDotRows := DotRowCount;
FCharWidth := (DotSize * nDotCols) + (DotsSpace * (nDotCols + 1)); //pixels
FCharCount := CalcCharCount; FCharCount := CalcCharCount;
FGlobalDotColsCount := (FCharCount * FDotColsCount) + (FCharCount - 1); //dots FGlobalDotColsCount := (FCharCount * nDotCols) + (FCharCount - 1); //dots
// total matrix width // total matrix width
FLEDWidth := (FGlobalDotColsCount * DotSize) + ((FGlobalDotColsCount - 1) * DotsSpace); FLEDWidth := (FGlobalDotColsCount * DotSize) + ((FGlobalDotColsCount - 1) * DotsSpace);
// total matrix height // total matrix height
FLEDHeight := (FDisplayLineCount * FDotRowsCount * (DotSize + DotsSpace)) + FLEDHeight := (FDisplayLineCount * nDotRows * (DotSize + DotsSpace)) +
((FDisplayLineCount - 1) * (DotSize + DotsSpace)); ((FDisplayLineCount - 1) * (DotSize + DotsSpace));
if FCharSpace then if FCharSpace then
FLEDHeight := FLEDHeight + ((FDisplayLineCount - 1) * DotsSpace); FLEDHeight := FLEDHeight + ((FDisplayLineCount - 1) * DotsSpace);
@ -274,16 +471,22 @@ begin
end; end;
end; end;
procedure TLCDDisplay.DrawCalc(); procedure TLCDDisplay.Prepare();
var
nDotCols: Integer;
nDotRows: Integer;
begin begin
FCharWidth := (DotSize * FDotColsCount) + (DotsSpace * (FDotColsCount + 1)); //pixels nDotCols := DotColCount;
nDotRows := DotRowCount;
FCharWidth := (DotSize * nDotCols) + (DotsSpace * (nDotCols + 1)); //pixels
FCharCount := ((Width - (2 * FrameSize)) + DotSize) div (FCharWidth + DotSize); FCharCount := ((Width - (2 * FrameSize)) + DotSize) div (FCharWidth + DotSize);
FGlobalDotColsCount := (FCharCount * FDotColsCount) + (FCharCount - 1); //dots FGlobalDotColsCount := (FCharCount * nDotCols) + (FCharCount - 1); //dots
// total matrix width // total matrix width
FLEDWidth := (FGlobalDotColsCount * DotSize) + ((FGlobalDotColsCount - 1) * DotsSpace); FLEDWidth := (FGlobalDotColsCount * DotSize) + ((FGlobalDotColsCount - 1) * DotsSpace);
// total matrix height // total matrix height
FLEDHeight := (FDisplayLineCount * FDotRowsCount * (DotSize + DotsSpace)) + FLEDHeight := (FDisplayLineCount * nDotRows * (DotSize + DotsSpace)) +
((FDisplayLineCount - 1) * (DotSize + DotsSpace)); ((FDisplayLineCount - 1) * (DotSize + DotsSpace));
if FCharSpace then if FCharSpace then
FLEDHeight := FLEDHeight + ((FDisplayLineCount - 1) * DotsSpace); FLEDHeight := FLEDHeight + ((FDisplayLineCount - 1) * DotsSpace);
@ -291,8 +494,8 @@ begin
FBoardWidth := (Width - 2 * FrameSize - FLEDWidth) div 2; FBoardWidth := (Width - 2 * FrameSize - FLEDWidth) div 2;
FBoardHeight := (Height - 2 * FrameSize - FLEDHeight) div 2; FBoardHeight := (Height - 2 * FrameSize - FLEDHeight) div 2;
BitMap.Width := Width; FBitmap.Width := Width;
BitMap.Height := Height; FBitmap.Height := Height;
end; end;
procedure TLCDDisplay.DrawBorder(); procedure TLCDDisplay.DrawBorder();
@ -314,11 +517,11 @@ begin
BEnd.X := Width - FrameSize; BEnd.X := Width - FrameSize;
BEnd.Y := Height - FrameSize; BEnd.Y := Height - FrameSize;
with BitMap.Canvas do with FBitmap.Canvas do
begin begin
Brush.Color := FrameColor; Brush.Color := FrameColor;
Pen.Color := FrameColor; Pen.Color := FrameColor;
Rectangle(0, 0, BitMap.Width, BitMap.Height); Rectangle(0, 0, FBitmap.Width, FBitmap.Height);
Brush.Color := FBoardColor; Brush.Color := FBoardColor;
Pen.Color := FBoardColor; Pen.Color := FBoardColor;
Rectangle(BStart.X, BStart.Y, BEnd.X, BEnd.Y); Rectangle(BStart.X, BStart.Y, BEnd.X, BEnd.Y);
@ -389,7 +592,7 @@ end;
procedure TLCDDisplay.DrawShadow(StartP, EndP: TPoint; LineColor1, LineColor2: TColor); procedure TLCDDisplay.DrawShadow(StartP, EndP: TPoint; LineColor1, LineColor2: TColor);
begin begin
with BitMap.Canvas do with FBitmap.Canvas do
begin begin
Pen.Color := LineColor1; Pen.Color := LineColor1;
MoveTo(EndP.X, StartP.Y); MoveTo(EndP.X, StartP.Y);
@ -409,8 +612,8 @@ var
NRow, NCol: integer; NRow, NCol: integer;
begin begin
NRow := (FDotRowsCount + 1) * FDisplayLineCount - 1; NRow := (DotRowCount + 1) * FDisplayLineCount - 1;
NCol := (FDotColsCount + 1) * FCharCount - 1; NCol := (DotColCount + 1) * FCharCount - 1;
for y := 0 to NRow - 1 do for y := 0 to NRow - 1 do
for x := 0 to NCol - 1 do for x := 0 to NCol - 1 do
@ -428,8 +631,8 @@ begin
//j - horizontal spaces //j - horizontal spaces
for lc := 0 to FDisplayLineCount - 1 do for lc := 0 to FDisplayLineCount - 1 do
begin begin
NRow := FDotRowsCount + 1; NRow := DotRowCount + 1;
NCol := (FDotColsCount + 1) * FCharCount - 1; NCol := (DotColCount + 1) * FCharCount - 1;
j := 0; j := 0;
for y := 0 to (NRow * (lc + 1)) do for y := 0 to (NRow * (lc + 1)) do
@ -458,12 +661,12 @@ end;
procedure TLCDDisplay.DrawText(); procedure TLCDDisplay.DrawText();
var var
x, y, c: integer; x, y, c: integer;
DotRow: integer; dots: TDotRows;
DotOn: boolean; dotRow: TDotRow;
i, j: integer; dotOn: boolean;
i: integer;
line: string; line: string;
ch: string; ch: string;
matrix: TDotMatrix;
begin begin
for i := 0 to FDisplayLineCount - 1 do for i := 0 to FDisplayLineCount - 1 do
begin begin
@ -476,12 +679,10 @@ begin
for ch in line do for ch in line do
begin begin
Inc(c); Inc(c);
if not FCharList.Find(ch, j) then dots := FCharDefs.DotRows[ch];
exit; for y := 0 to DotRowCount - 1 do
matrix := FCharList[ch];
for y := 0 to FDotRowsCount - 1 do
begin begin
DotRow := matrix[y]; DotRow := dots[y];
for x := 0 to 4 do for x := 0 to 4 do
begin begin
DotOn := DotRow and (1 shl (5 - x - 1)) > 0; DotOn := DotRow and (1 shl (5 - x - 1)) > 0;
@ -501,7 +702,7 @@ end;
procedure TLCDDisplay.DrawChar(Row, Col, NChar: integer); procedure TLCDDisplay.DrawChar(Row, Col, NChar: integer);
begin begin
Col := Col + ((FDotColsCount + 1) * (NChar - 1)); Col := Col + ((DotColCount + 1) * (NChar - 1));
if Col > FGlobalDotColsCount - 1 then if Col > FGlobalDotColsCount - 1 then
Exit; Exit;
if Col < 0 then if Col < 0 then
@ -534,7 +735,7 @@ begin
exit; exit;
end; end;
with BitMap.Canvas do with FBitmap.Canvas do
begin begin
Pen.Color := DotColor; Pen.Color := DotColor;
Brush.Color := DotColor; Brush.Color := DotColor;
@ -548,7 +749,16 @@ end;
procedure TLCDDisplay.DrawBitmapToCanvas(); procedure TLCDDisplay.DrawBitmapToCanvas();
begin begin
Canvas.Draw(0, 0, BitMap); Canvas.Draw(0, 0, FBitmap);
end;
procedure TLCDDisplay.Paint();
begin
Prepare();
DrawBorder();
DrawGrid();
DrawText();
DrawBitmapToCanvas();
end; end;
// Find the longest's line length // Find the longest's line length
@ -578,118 +788,106 @@ procedure TLCDDisplay.InitCharList(AHorDots, AVertDots: integer);
var var
i: integer; i: integer;
begin begin
FCharList.Clear; FCharDefs.Clear;
if (AHorDots = 5) and (AVertDots = 7) then if (AHorDots = 5) and (AVertDots = 7) then
begin begin
for i := 0 to 32 do AddCharDef('!', [4, 4, 4, 4, 4, 0, 4]); // #33
AddDotMatrix(char(i), [0, 0, 0, 0, 0, 0, 0]); AddCharDef('"', [10, 10, 0, 0, 0, 0, 0]); // #34
AddDotMatrix('!', [4, 4, 4, 4, 4, 0, 4]); // #33 AddCharDef('#', [0, 10, 31, 10, 31, 10, 0]); // #35
AddDotMatrix('"', [10, 10, 0, 0, 0, 0, 0]); // #34 AddCharDef('$', [4, 15, 20, 14, 5, 30, 4]); // #36
AddDotMatrix('#', [0, 10, 31, 10, 31, 10, 0]); // #35 AddCharDef('%', [25, 26, 2, 4, 8, 11, 19]); // #37
AddDotMatrix('$', [4, 15, 20, 14, 5, 30, 4]); // #36 AddCharDef('&', [12, 18, 20, 8, 21, 18, 13]); // #38
AddDotMatrix('%', [25, 26, 2, 4, 8, 11, 19]); // #37 AddCharDef('''', [4, 4, 0, 0, 0, 0, 0]); // #39
AddDotMatrix('&', [12, 18, 20, 8, 21, 18, 13]); // #38 AddCharDef('(', [2, 4, 8, 8, 8, 4, 2]); // #40
AddDotMatrix('''', [4, 4, 0, 0, 0, 0, 0]); // #39 AddCharDef(')', [8, 4, 2, 2, 2, 4, 8]); // #41
AddDotMatrix('(', [2, 4, 8, 8, 8, 4, 2]); // #40 AddCharDef('*', [0, 4, 21, 14, 21, 4, 0]); // #42
AddDotMatrix(')', [8, 4, 2, 2, 2, 4, 8]); // #41 AddCharDef('+', [0, 4, 4, 31, 4, 4, 0]); // #43
AddDotMatrix('*', [0, 4, 21, 14, 21, 4, 0]); // #42 AddCharDef(',', [0, 0, 0, 0, 12, 4, 8]); // #44
AddDotMatrix('+', [0, 4, 4, 31, 4, 4, 0]); // #43 AddCharDef('-', [0, 0, 0, 14, 0, 0, 0]); // #45
AddDotMatrix(',', [0, 0, 0, 0, 12, 4, 8]); // #44 AddCharDef('.', [0, 0, 0, 0, 0, 12, 12]); // #46
AddDotMatrix('-', [0, 0, 0, 14, 0, 0, 0]); // #45 AddCharDef('/', [1, 1, 2, 4, 8, 16, 16]); // #47
AddDotMatrix('.', [0, 0, 0, 0, 0, 12, 12]); // #46 AddCharDef('0', [14, 17, 19, 21, 25, 17, 14]); // #48
AddDotMatrix('/', [1, 1, 2, 4, 8, 16, 16]); // #47 AddCharDef('1', [4, 12, 4, 4, 4, 4, 14]); // #49
AddDotMatrix('0', [14, 17, 19, 21, 25, 17, 14]); // #48 AddCharDef('2', [14, 17, 1, 2, 4, 8, 31]); // #50
AddDotMatrix('1', [4, 12, 4, 4, 4, 4, 14]); // #49 AddCharDef('3', [14, 17, 1, 6, 1, 17, 14]); // #51
AddDotMatrix('2', [14, 17, 1, 2, 4, 8, 31]); // #50 AddCharDef('4', [2, 6, 10, 18, 31, 2, 2]); // #52
AddDotMatrix('3', [14, 17, 1, 6, 1, 17, 14]); // #51 AddCharDef('5', [31, 16, 30, 1, 1, 17, 14]); // #53
AddDotMatrix('4', [2, 6, 10, 18, 31, 2, 2]); // #52 AddCharDef('6', [14, 17, 16, 30, 17, 17, 14]); // #54
AddDotMatrix('5', [31, 16, 30, 1, 1, 17, 14]); // #53 AddCharDef('7', [31, 1, 1, 2, 4, 4, 4]); // #55
AddDotMatrix('6', [14, 17, 16, 30, 17, 17, 14]); // #54 AddCharDef('8', [14, 17, 17, 14, 17, 17, 14]); // #56
AddDotMatrix('7', [31, 1, 1, 2, 4, 4, 4]); // #55 AddCharDef('9', [14, 17, 17, 15, 1, 17, 14]); // #57
AddDotMatrix('8', [14, 17, 17, 14, 17, 17, 14]); // #56 AddCharDef(':', [0, 12, 12, 0, 12, 12, 0]); // #58
AddDotMatrix('9', [14, 17, 17, 15, 1, 17, 14]); // #57 AddCharDef(';', [0, 12, 12, 0, 12, 4, 8]); // #59
AddDotMatrix(':', [0, 12, 12, 0, 12, 12, 0]); // #58 AddCharDef('<', [2, 4, 8, 16, 8, 4, 2]); // #60
AddDotMatrix(';', [0, 12, 12, 0, 12, 4, 8]); // #59 AddCharDef('=', [0, 0, 31, 0, 31, 0, 0]); // #61
AddDotMatrix('<', [2, 4, 8, 16, 8, 4, 2]); // #60 AddCharDef('>', [8, 4, 2, 1, 2, 4, 8]); // #62
AddDotMatrix('=', [0, 0, 31, 0, 31, 0, 0]); // #61 AddCharDef('?', [14, 17, 1, 2, 4, 0, 4]); // #63
AddDotMatrix('>', [8, 4, 2, 1, 2, 4, 8]); // #62 AddCharDef('@', [14, 17, 19, 21, 23, 16, 15]); // #64
AddDotMatrix('?', [14, 17, 1, 2, 4, 0, 4]); // #63 AddCharDef('A', [14, 17, 17, 31, 17, 17, 17]); // #65
AddDotMatrix('@', [14, 17, 19, 21, 23, 16, 15]); // #64 AddCharDef('B', [30, 17, 17, 30, 17, 17, 30]); // #66
AddDotMatrix('A', [14, 17, 17, 31, 17, 17, 17]); // #65 AddCharDef('C', [14, 17, 16, 16, 16, 17, 14]); // #67
AddDotMatrix('B', [30, 17, 17, 30, 17, 17, 30]); // #66 AddCharDef('D', [30, 17, 17, 17, 17, 17, 30]); // #68
AddDotMatrix('C', [14, 17, 16, 16, 16, 17, 14]); // #67 AddCharDef('E', [31, 16, 16, 30, 16, 16, 31]); // #69
AddDotMatrix('D', [30, 17, 17, 17, 17, 17, 30]); // #68 AddCharDef('F', [31, 16, 16, 30, 16, 16, 16]); // #70
AddDotMatrix('E', [31, 16, 16, 30, 16, 16, 31]); // #69 AddCharDef('G', [14, 17, 16, 19, 17, 17, 14]); // #71
AddDotMatrix('F', [31, 16, 16, 30, 16, 16, 16]); // #70 AddCharDef('H', [17, 17, 17, 31, 17, 17, 17]); // #72
AddDotMatrix('G', [14, 17, 16, 19, 17, 17, 14]); // #71 AddCharDef('I', [14, 4, 4, 4, 4, 4, 14]); // #73
AddDotMatrix('H', [17, 17, 17, 31, 17, 17, 17]); // #72 AddCharDef('J', [1, 1, 1, 1, 17, 17, 14]); // #74
AddDotMatrix('I', [14, 4, 4, 4, 4, 4, 14]); // #73 AddCharDef('K', [17, 18, 20, 24, 20, 18, 17]); // #75
AddDotMatrix('J', [1, 1, 1, 1, 17, 17, 14]); // #74 AddCharDef('L', [16, 16, 16, 16, 16, 16, 31]); // #76
AddDotMatrix('K', [17, 18, 20, 24, 20, 18, 17]); // #75 AddCharDef('M', [17, 27, 21, 21, 17, 17, 17]); // #77
AddDotMatrix('L', [16, 16, 16, 16, 16, 16, 31]); // #76 AddCharDef('N', [17, 25, 21, 19, 17, 17, 17]); // #78
AddDotMatrix('M', [17, 27, 21, 21, 17, 17, 17]); // #77 AddCharDef('O', [14, 17, 17, 17, 17, 17, 14]); // #79
AddDotMatrix('N', [17, 25, 21, 19, 17, 17, 17]); // #78 AddCharDef('P', [30, 17, 17, 30, 16, 16, 16]); // #80
AddDotMatrix('O', [14, 17, 17, 17, 17, 17, 14]); // #79 AddCharDef('Q', [14, 17, 17, 17, 17, 14, 1]); // #81
AddDotMatrix('P', [30, 17, 17, 30, 16, 16, 16]); // #80 AddCharDef('R', [30, 17, 17, 30, 17, 17, 17]); // #82
AddDotMatrix('Q', [14, 17, 17, 17, 17, 14, 1]); // #81 AddCharDef('S', [14, 17, 16, 14, 1, 17, 14]); // #83
AddDotMatrix('R', [30, 17, 17, 30, 17, 17, 17]); // #82 AddCharDef('T', [31, 4, 4, 4, 4, 4, 4]); // #84
AddDotMatrix('S', [14, 17, 16, 14, 1, 17, 14]); // #83 AddCharDef('U', [17, 17, 17, 17, 17, 17, 14]); // #85
AddDotMatrix('T', [31, 4, 4, 4, 4, 4, 4]); // #84 AddCharDef('V', [17, 17, 17, 17, 17, 10, 4]); // #86
AddDotMatrix('U', [17, 17, 17, 17, 17, 17, 14]); // #85 AddCharDef('W', [17, 17, 17, 17, 21, 27, 17]); // #87
AddDotMatrix('V', [17, 17, 17, 17, 17, 10, 4]); // #86 AddCharDef('X', [17, 10, 4, 4, 4, 10, 17]); // #88
AddDotMatrix('W', [17, 17, 17, 17, 21, 27, 17]); // #87 AddCharDef('Y', [17, 17, 17, 10, 4, 4, 4]); // #89
AddDotMatrix('X', [17, 10, 4, 4, 4, 10, 17]); // #88 AddCharDef('Z', [31, 1, 2, 4, 8, 16, 31]); // #90
AddDotMatrix('Y', [17, 17, 17, 10, 4, 4, 4]); // #89 AddCharDef('[', [12, 8, 8, 8, 8, 8, 12]); // #91
AddDotMatrix('Z', [31, 1, 2, 4, 8, 16, 31]); // #90 AddCharDef('\', [0, 16, 8, 4, 2, 1, 0]); // #92
AddDotMatrix('[', [12, 8, 8, 8, 8, 8, 12]); // #91 AddCharDef(']', [6, 2, 2, 2, 2, 2, 6]); // #93
AddDotMatrix('\', [0, 16, 8, 4, 2, 1, 0]); // #92 AddCharDef('^', [4, 10, 17, 0, 0, 0, 0]); // #94
AddDotMatrix(']', [6, 2, 2, 2, 2, 2, 6]); // #93 AddCharDef('_', [0, 0, 0, 0, 0, 0, 31]); // #95
AddDotMatrix('^', [4, 10, 17, 0, 0, 0, 0]); // #94 AddCharDef('`', [6, 4, 2, 0, 0, 0, 0]); // #96
AddDotMatrix('_', [0, 0, 0, 0, 0, 0, 31]); // #95 AddCharDef('a', [0, 0, 14, 1, 15, 17, 15]); // #97
AddDotMatrix('`', [6, 4, 2, 0, 0, 0, 0]); // #96 AddCharDef('b', [16, 16, 30, 17, 17, 17, 30]); // #98
AddDotMatrix('a', [0, 0, 14, 1, 15, 17, 15]); // #97 AddCharDef('c', [0, 0, 15, 16, 16, 16, 15]); // #99
AddDotMatrix('b', [16, 16, 30, 17, 17, 17, 30]); // #98 AddCharDef('d', [1, 1, 15, 17, 17, 17, 15]); // #100
AddDotMatrix('c', [0, 0, 15, 16, 16, 16, 15]); // #99 AddCharDef('e', [0, 0, 14, 17, 31, 16, 14]); // #101
AddDotMatrix('d', [1, 1, 15, 17, 17, 17, 15]); // #100 AddCharDef('f', [3, 4, 31, 4, 4, 4, 4]); // #102
AddDotMatrix('e', [0, 0, 14, 17, 31, 16, 14]); // #101 AddCharDef('g', [0, 0, 15, 17, 15, 1, 14]); // #103
AddDotMatrix('f', [3, 4, 31, 4, 4, 4, 4]); // #102 AddCharDef('h', [16, 16, 22, 25, 17, 17, 17]);// #104
AddDotMatrix('g', [0, 0, 15, 17, 15, 1, 14]); // #103 AddCharDef('i', [4, 0, 12, 4, 4, 4, 14]); // #105
AddDotMatrix('h', [16, 16, 22, 25, 17, 17, 17]);// #104 AddCharDef('j', [2, 0, 6, 2, 2, 18, 12]); // #106
AddDotMatrix('i', [4, 0, 12, 4, 4, 4, 14]); // #105 AddCharDef('k', [16, 16, 18, 20, 24, 20, 18]);// #107
AddDotMatrix('j', [2, 0, 6, 2, 2, 18, 12]); // #106 AddCharDef('l', [12, 4, 4, 4, 4, 4, 14]); // #108
AddDotMatrix('k', [16, 16, 18, 20, 24, 20, 18]);// #107 AddCharDef('m', [0, 0, 26, 21, 21, 21, 21]); // #109
AddDotMatrix('l', [12, 4, 4, 4, 4, 4, 14]); // #108 AddCharDef('n', [0, 0, 22, 25, 17, 17, 17]); // #110
AddDotMatrix('m', [0, 0, 26, 21, 21, 21, 21]); // #109 AddCharDef('o', [0, 0, 14, 17, 17, 17, 14]); // #111
AddDotMatrix('n', [0, 0, 22, 25, 17, 17, 17]); // #110 AddCharDef('p', [0, 0, 30, 17, 30, 16, 16]); // #112
AddDotMatrix('o', [0, 0, 14, 17, 17, 17, 14]); // #111 AddCharDef('q', [0, 0, 15, 17, 15, 1, 1]); // #113
AddDotMatrix('p', [0, 0, 30, 17, 30, 16, 16]); // #112 AddCharDef('r', [0, 0, 11, 12, 8, 8, 8]); // #114
AddDotMatrix('q', [0, 0, 15, 17, 15, 1, 1]); // #113 AddCharDef('s', [0, 0, 14, 16, 14, 1, 30]); // #115
AddDotMatrix('r', [0, 0, 11, 12, 8, 8, 8]); // #114 AddCharDef('t', [4, 4, 31, 4, 4, 4, 3]); // #116
AddDotMatrix('s', [0, 0, 14, 16, 14, 1, 30]); // #115 AddCharDef('u', [0, 0, 17, 17, 17, 19, 13]); // #117
AddDotMatrix('t', [4, 4, 31, 4, 4, 4, 3]); // #116 AddCharDef('v', [0, 0, 17, 17, 17, 10, 4]); // #118
AddDotMatrix('u', [0, 0, 17, 17, 17, 19, 13]); // #117 AddCharDef('w', [0, 0, 17, 17, 21, 21, 10]); // #119
AddDotMatrix('v', [0, 0, 17, 17, 17, 10, 4]); // #118 AddCharDef('x', [0, 0, 17, 10, 4, 10, 17]); // #120
AddDotMatrix('w', [0, 0, 17, 17, 21, 21, 10]); // #119 AddCharDef('y', [0, 0, 17, 17, 15, 1, 14]); // #121
AddDotMatrix('x', [0, 0, 17, 10, 4, 10, 17]); // #120 AddCharDef('z', [0, 0, 31, 2, 4, 8, 31]); // #122
AddDotMatrix('y', [0, 0, 17, 17, 15, 1, 14]); // #121 AddCharDef('{', [3, 4, 4, 8, 4, 4, 3]); // #123
AddDotMatrix('z', [0, 0, 31, 2, 4, 8, 31]); // #122 AddCharDef('|', [4, 4, 4, 4, 4, 4, 4]); // #124
AddDotMatrix('{', [3, 4, 4, 8, 4, 4, 3]); // #123 AddCharDef('}', [24, 4, 4, 2, 4, 4, 24]); // #125
AddDotMatrix('|', [4, 4, 4, 4, 4, 4, 4]); // #124 AddCharDef('~', [8, 21, 2, 0, 0, 0, 0]); // #126
AddDotMatrix('}', [24, 4, 4, 2, 4, 4, 24]); // #125
AddDotMatrix('~', [8, 21, 2, 0, 0, 0, 0]); // #126
AddDotMatrix(#127, [0, 0, 0, 0, 0, 0, 0]); // #127
end; end;
end; end;
procedure TLCDDisplay.Paint();
begin
DrawCalc();
DrawBorder();
DrawGrid();
DrawText();
DrawBitmapToCanvas();
end;
procedure TLCDDisplay.SetBoardColor(const Value: TColor); procedure TLCDDisplay.SetBoardColor(const Value: TColor);
begin begin
if Value = FBoardColor then if Value = FBoardColor then
@ -885,14 +1083,50 @@ end;
function TLCDDisplay.GetCharCount: longint; function TLCDDisplay.GetCharCount: longint;
begin begin
DrawCalc(); Prepare();
Result := FCharCount; Result := FCharCount;
end; end;
function TLCDDisplay.GetGlobalDotColsCount: longint; function TLCDDisplay.GetGlobalDotColsCount: longint;
begin begin
DrawCalc(); Prepare();
Result := FGlobalDotColsCount; Result := FGlobalDotColsCount;
end; end;
function TLCDDisplay.GetDotColCount: Integer;
begin
Result := FCharDefs.ColCount;
end;
function TLCDDisplay.GetDotRowCount: Integer;
begin
Result := FCharDefs.RowCount;
end;
procedure TLCDDisplay.SetDotColCount(AValue: Integer);
begin
if AValue = DotColCount then
exit;
FCharDefs.ColCount := AValue;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
end;
procedure TLCDDisplay.SetDotRowCount(AValue: Integer);
begin
if AValue = DotRowCount then
exit;
FCharDefs.RowCount := AValue;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
end;
end. end.