Frage zu Graphios

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Page 1 of 6
wilbo
Benutzer
Avatar
Gender:
Age: 69
Posts: 59
Registered: 11 / 2023
Subject:

Frage zu Graphios

 · 
Posted: 25.06.2025 - 17:26  ·  #1
Hallo,

ich habe folgendes Problem:

gFillRect(110, 195, 210, 220, byte(clRed)); // geht nicht es wird nichts gezeichnet
mDelay(2000);
FillRect(110, 195, 210, 220, $FFE0); // geht
sprich der Aufruf unter umgehung von Graphios funktioniert.
Sind unter Graphios irgendwelche Besonderheiten zu beachten?

Treiber ist aus dem Demo XGraph_TFT320x240

Gruß wilbo
Harry
Moderator
Avatar
Gender:
Location: zwischen Augsburg und Ulm
Age: 60
Posts: 2149
Registered: 03 / 2003
Subject:

Re: Frage zu Graphios

 · 
Posted: 26.06.2025 - 15:56  ·  #2
Hallo Wilbo,

der Farbwert muß ein Word sein. Erstaunlich, daß du das mit Byte() compilieren kannst.

Gruss
Harry
Merlin
Administrator
Avatar
Gender:
Age: 25
Posts: 1468
Registered: 03 / 2005
Subject:

Re: Frage zu Graphios

 · 
Posted: 26.06.2025 - 17:14  ·  #3
Hi Harry, Wilbo.

According to the manual the colour parameter for gFillRect is a byte.

gFillRect (Xs, Ys, Xe, Ye : integer; pattern : byte);
gFillRect (Xs, Ys, Xe, Ye : integer; color : byte); // xy-address mode

@Harry

Have you set your viewport?
wilbo
Benutzer
Avatar
Gender:
Age: 69
Posts: 59
Registered: 11 / 2023
Subject:

Re: Frage zu Graphios

 · 
Posted: 26.06.2025 - 17:43  ·  #4
Hallo Harry und Merlin,
dank euch beiden für die Rückmeldung.
@Harry
die umsetzung von byte in word erfolgt wenn ich es richtig sehe in folgendem Code abschnitt:
Code
 
  // foreground color
  if colorFg > byte(max(tColors)) then
    ColorWfg:= $0000;   // clblack
    colorFg:= 1;
    ColorPfG:= colorFg;
  elsif colorFg <> ColorPfG then
    ColorPfG:= colorFg;
    ColorWfg:= ColorArr[(tColors(colorFg))];
  endif;

  // background color
  if colorBg > byte(max(tColors)) then
    ColorWbg:= $0000;   // clblack
    colorBg:= 1;
    ColorPbg:= colorBg;
  elsif colorBg <> ColorPbg then
    ColorPbg:= colorBg;
    ColorWbg:= ColorArr[(tColors(colorBg))];
  endif;

die Prozedure Fillrect ist meiner meinung nach ok und functioniert beim direkten aufruf bzw. Gclrscr(Byte(clWhite)) richtig.

Hi Harry and Merlin,
thanks to both of you for the feedback.
@Harry
the conversion from byte to word is done in the following code section if I see it correctly:
Code
 
 // foreground color
  if colorFg > byte(max(tColors)) then
    ColorWfg:= $0000;   // clblack
    colorFg:= 1;
    ColorPfG:= colorFg;
  elsif colorFg <> ColorPfG then
    ColorPfG:= colorFg;
    ColorWfg:= ColorArr[(tColors(colorFg))];
  endif;

  // background color
  if colorBg > byte(max(tColors)) then
    ColorWbg:= $0000;   // clblack
    colorBg:= 1;
    ColorPbg:= colorBg;
  elsif colorBg <> ColorPbg then
    ColorPbg:= colorBg;
    ColorWbg:= ColorArr[(tColors(colorBg))];
  endif;

the procedure Fillrect is ok in my opinion and functions correctly when called directly or Gclrscr(Byte(clWhite)).
Attachments
Unit U_ILI9341;
{.$W+} // enable/disable warnings for this unit
{$PCU}
// !!!!!! VON hier an aktuelle Hardware anpassen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Define
MSPIorder_C0 = MSB;
MSPImode_C0 = 0;
MSPIpresc_C0 = 0;
MSPI_SS_C0 = none; // PortE.4

interface

uses;
{$IDATA}

Var
LCD_DDRCTRL[@DDRA] : byte;
LCD_PORTCTRL[@PortA] : byte;
Const
LCD_CSpin : byte = 2;
LCD_RSTpin : byte = 3;
LCD_RSpin : byte = 4;
// LCD_IRQpin : byte = 7; // touch

LCD_RSTmask : byte = 1 shl LCD_RSTpin;
LCD_RSmask : byte = 1 shl LCD_RSpin;
LCD_CSmask : byte = 1 shl LCD_CSpin;
// LCD_IRQmask : byte = 1 shl LCD_IRQpin;
// !!!!! BIS hier an aktuelle Hardware anpassen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

type
// enum for color lookup table
tColors = (clNone, clAqua, clBlack, clBlue, clCream, clDkGray, clFuchsia,
clGray, clGreen, clLime, clLtGray, clMaroon, clMedGray,
clMoneyGreen, clNavy, clOlive, clPurple, clRed, clSilver,
clSkyBlue, clTeal, clWhite, clYellow, clMagenta, clCyan);

tColorArr = array[tColors] of word;

// 0= ribbon cable on down 1= ribbon cable on right, 3= ribbon cable on left
TOrientation = (SWITCH_NONE, FLIP_X, FLIP_Y, FLIP_XY);

{--------------------------------------------------------------}
{ Const Declarations }
const
_TFTWIDTH : word = 240;
_TFTHEIGHT : word = 320;
//TotalPixel2 : word = $9600; // *2

const
DELAY : byte = $80;

MADCTL_MY : byte = $80;
MADCTL_MX : byte = $40;
MADCTL_MV : byte = $20;
MADCTL_ML : byte = $10;
MADCTL_BGR : byte = $08;
MADCTL_MH : byte = $04;

const
// color lookup table
ColorArr : tColorArr = ($8888, // clNone,
$07FF, // clAqua,
$0000, // clBlack,
Filename: U_ILI9341.pas
Filesize: 12.2 KB
Title:
Download counter: 51
Harry
Moderator
Avatar
Gender:
Location: zwischen Augsburg und Ulm
Age: 60
Posts: 2149
Registered: 03 / 2003
Subject:

Re: Frage zu Graphios

 · 
Posted: 26.06.2025 - 18:54  ·  #5
Mir war das so in Erinnerung
Code

Type
  // enum for Color lookup table
  tColors        = (clBlack, clWhite, clBlue, clGreen, clRed, clAqua, clPurple,
                    clYellow, clGrey, clLtGrey, clLtrGrey, clBlue2, clGreen2,
                    clRed2, clAqua2, clPurple2, clYellow2, clBlue3, clGreen3,
                    clRed3, clAqua3, clPurple3, clYellow3);

  tColorArr      = Array[tColors] of Word;



Wieso geht dann das hier?

FillRect(110, 195, 210, 220, $FFE0); --> 1111 1111 1110 0000 --> 11111 rot, 111111 grün, 00000 blau

Gefunden ...

Code

const
   // color lookup table
  ColorArr : tColorArr = ($8888,       // clNone,
                          $07FF,       // clAqua,
                          $0000,       // clBlack,
                          $001F,       // clBlue
                          $E718,       // clCream
                          $7BEF,       // clDkGray
                          $E018,       // clFuchsia  6

                          $9472,       // clGray
                          $07E0,       // clGreen
                          $07F8,       // clLime
                          $C618,       // clLtGray
                          $8000,       // clMaroon
                          $73AE,       // clMedGray
                          $7D0C,       // clMoneyGreen  13

                          $0010,       // clNavy
                          $BCEA,       // clOlive
                          $F81F,       // clPurple
                          $F800,       // clRed
                          $C61C,       // clSilver
                          $9E1C,       // clSkyBlue
                          $0410,       // clTeal    20

                          $FFFF,       // clWhite
                          $FFE0,       // clYellow
                          $F81F,       // clMAGENTA
                          $07FF);      // clCyan    24
Merlin
Administrator
Avatar
Gender:
Age: 25
Posts: 1468
Registered: 03 / 2005
Subject:

Re: Frage zu Graphios

 · 
Posted: 26.06.2025 - 19:27  ·  #6
I have looked at the compiler source for gFillRect. Here is my assessment.

There are two versions of gFillRect, depending on the type of graphic controller that you have. If the controller type is RA8875 then that last parameter should be a tColors type (e.g. clRed). Otherwise that last parameter is a byte.

You appear to be using the second form.

In this form the last parameter is not a colour. It is a fill pattern.

=========================================================================

Ich habe mir den Compiler-Quellcode für gFillRect angesehen. Hier ist meine Einschätzung:

Es gibt zwei Versionen von gFillRect, abhängig vom Typ Ihres Grafikcontrollers. Wenn der Controllertyp RA8875 ist, sollte der letzte Parameter ein tColors-Typ (z. B. clRed) sein. Andernfalls ist der letzte Parameter ein Byte.

Sie scheinen die zweite Version zu verwenden.

In dieser Version ist der letzte Parameter keine Farbe, sondern ein Füllmuster.
wilbo
Benutzer
Avatar
Gender:
Age: 69
Posts: 59
Registered: 11 / 2023
Subject:

Re: Frage zu Graphios

 · 
Posted: 27.06.2025 - 09:52  ·  #7
Hallo Harry, Merlin
Graphios erwartet doch für ColorFg..Bg ein Byte und das kann doch nur ein Index von ColorArr sein. So ergibt byte(clYellow) gleich 22. Oder bin ich da völlig auf dem Holzweg.
userdevice GraphIOS(xs, ys, xe, ye: word; pattern, colorFg, colorBg: byte; draw: gDrawType): byte;

Hello Harry, Merlin
Graphios expects a byte for ColorFg..Bg and that can only be an index of ColorArr. So byte(clYellow) equals 22. or am I completely on the wrong track.
userdevice GraphIOS(xs, ys, xe, ye: word; pattern, colorFg, colorBg: byte; draw: gDrawType): byte;

Gruß wilbo
wilbo
Benutzer
Avatar
Gender:
Age: 69
Posts: 59
Registered: 11 / 2023
Subject:

Re: Frage zu Graphios

 · 
Posted: 27.06.2025 - 15:34  ·  #8
Hallo Merlin & Harry,
Ist es tatsächlich abhängig vom Controller Typ(RA8875) welche der Version von gFillRect verwendet wird, wäre dann nicht besser es vom Import von GraphColor abhängen würde.
Denn ich als Anwender habe ja nicht die Wahl der Version und ich würde denken das Füllmuster ohne Farbe nur bei Monochromen Displays ein Sinn ergibt.

Hi Merlin & Harry,
Is it really dependent on the controller type (RA8875) which version of gFillRect is used, wouldn't it be better if it depended on the import of GraphColor.
Because I as a user do not have the choice of the version and I would think that the fill pattern without color only makes sense for monochrome displays.

Gruß Wilbo
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Page 1 of 6
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 9 · Cache Hits: 15   139   154 · Page-Gen-Time: 0.017426s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI