Преглед на файлове

Added transparency support

master
Dejvino преди 3 години
родител
ревизия
e7b5cfdf7e
променени са 3 файла, в които са добавени 32 реда и са изтрити 12 реда
  1. +9
    -0
      spilcd.h
  2. +5
    -4
      spilcd_font.c
  3. +18
    -8
      st7735.c

+ 9
- 0
spilcd.h Целия файл

@@ -62,6 +62,15 @@ uint8 lcd_setWindow(lcd_t* lcd, uint8 x1, uint8 y1, uint8 x2, uint8 y2);
*/
void lcd_pushPixel(lcd_t* lcd, uint8 r, uint8 g, uint8 b);

/*
* Push a 'transparent' pixel into the previously set drawing area.
* Requires buffering to be enabled.
*
* Parameters:
* lcd - display to use
*/
void lcd_pushPixelSkip(lcd_t* lcd);

/*
* Push an array of pixels into the previously set drawing area.
* Significantly faster than pushing pixels individually.


+ 5
- 4
spilcd_font.c Целия файл

@@ -5,7 +5,7 @@
#include "spilcd_font.h"
#include "font8x8_basic.h"

static void lcd_pushChar(lcd_t* lcd, char c)
static void lcd_pushChar(lcd_t* lcd, char c, uint8 r, uint8 g, uint8 b)
{
char* bitmap = font8x8_basic[(unsigned int) c];
int x,y;
@@ -14,9 +14,10 @@ static void lcd_pushChar(lcd_t* lcd, char c)
for (y=0; y < 8; y++) {
set = bitmap[x] & 1 << y;
if (set) {
lcd_pushPixel(lcd, 200, 0, 0);
lcd_pushPixel(lcd, r, g, b);
} else {
lcd_pushPixel(lcd, 0, 0, 0);
//lcd_pushPixel(lcd, 0, 0, 0);
lcd_pushPixelSkip(lcd);
}
}
}
@@ -25,7 +26,7 @@ static void lcd_pushChar(lcd_t* lcd, char c)
void lcd_drawChar(lcd_t* lcd, uint8 x, uint8 y, char c, uint8 r, uint8 g, uint8 b)
{
lcd_setWindow(lcd, x, y, x+8 - 1, y+8 - 1);
lcd_pushChar(lcd, c);
lcd_pushChar(lcd, c, r, g, b);
}

void lcd_drawText(lcd_t* lcd, uint8 x, uint8 y, char* text, uint8 r, uint8 g, uint8 b)


+ 18
- 8
st7735.c Целия файл

@@ -36,6 +36,18 @@ static uint8 screen_window_y2;
static uint8 screen_cursor_x;
static uint8 screen_cursor_y;

void advance_screen_cursor()
{
screen_cursor_x++;
if (screen_cursor_x > screen_window_x2) {
screen_cursor_x = screen_window_x1;
screen_cursor_y++;
if (screen_cursor_y > screen_window_y2) {
screen_cursor_y = screen_window_y1;
}
}
}

static lcd_t *activeDisplay;

/*
@@ -298,14 +310,12 @@ void lcd_pushPixel(lcd_t* lcd, uint8 r, uint8 g, uint8 b)
screen_buffer[i * 3 + 1] = g;
screen_buffer[i * 3 + 2] = b;
screen_cursor_x++;
if (screen_cursor_x > screen_window_x2) {
screen_cursor_x = screen_window_x1;
screen_cursor_y++;
if (screen_cursor_y > screen_window_y2) {
screen_cursor_y = screen_window_y1;
}
}
advance_screen_cursor();
}

void lcd_pushPixelSkip(lcd_t* lcd)
{
advance_screen_cursor();
}

void lcd_pushPixels(lcd_t* lcd, uint8* pixels, size_t count)


Зареждане…
Отказ
Запис