Forum: Mikrocontroller und Digitale Elektronik STM32 Cube board support package TFT und Farbe


von Markus (Gast)


Lesenswert?

Ich versuche, die Funktion für ein farbiges Rechteck zu schreiben:
1
    void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
2
    {
3
      BSP_LCD_SetTextColor(color);  // keine Farbänderung
4
      BSP_LCD_SetBackColor(color);  // keine Farbänderung
5
      BSP_LCD_SetColorKeying(0, color); // keine Farbänderung
6
      BSP_LCD_FillRect(x, y, w, h); // Rechteck bleibt schwarz
7
    };

Mist, es bleibt schwarz.
Ich finde nirgends ein Beispiel

von W.S. (Gast)


Lesenswert?

bittesehr:
1
/****************************************************************
2
 Rechteck auf Bildschirm mit Farbe füllen.
3
 left/top = erste zu füllende Koordinate
4
 right/bottom = letzte zu füllende Koordinate.
5
 also CgFillRect(.. 3,3,3,3) füllt genau 1 Pixel auf Position 3/3
6
 ****************************************************************/
7
void CgFillRect  (TDCB* DC, RECT* R)
8
{ word* Pb;
9
  int  i, left, top, right, bott;
10
  word  color;
11
12
  left = R->left;
13
  top  = R->top;
14
  right= R->right;
15
  bott = R->bottom;
16
  if (left < DC->CurrentClipRect.left)   left  = DC->CurrentClipRect.left;
17
  if (right> DC->CurrentClipRect.right)  right = DC->CurrentClipRect.right;
18
  if (top  < DC->CurrentClipRect.top)    top   = DC->CurrentClipRect.top;
19
  if (bott > DC->CurrentClipRect.bottom) bott  = DC->CurrentClipRect.bottom;
20
  color = DC->BrushColor;
21
  Pb = DC->Buffer + ( top * DC->PixelPerLine );
22
  while (top <= bott)
23
  {  i = left;
24
     while (i <= right)  Pb[i++] = color;
25
     ++top;
26
     Pb = Pb + DC->PixelPerLine;
27
  }
28
}

W.S.

von Markus (Gast)


Lesenswert?


von dasrotemopped (Gast)


Lesenswert?

aus dem BSP:
#define LCD_COLOR_ORANGE        ((uint32_t)0xFFFFA500)

void BSP_LCD_SetTextColor(uint32_t Color)
{
  DrawProp[ActiveLayer].TextColor = Color;
}

dein Beispiel:
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t 
color)
    {
BSP_LCD_SetTextColor(color);
...
};

ein Byte zuwenig bei der Farbe.

Gruß,

dasrotemopped.

von Markus (Gast)


Lesenswert?

Danke, rotesmoped ;-)

Das Problem bestand im wesentlichen darin, dass ich nicht wusste, dass 
das Farbformat RGB8888 und nicht RGB565 ist.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.