remove BaseSyncronousStream interface from GLCDDriver
This commit is contained in:
parent
23a3bf0efa
commit
08a70cc3ce
2 changed files with 17 additions and 109 deletions
97
glcd.c
97
glcd.c
|
@ -3,73 +3,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver local functions. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Interface implementation. The interface is write only
|
|
||||||
*/
|
|
||||||
|
|
||||||
static size_t writes(void *ip, const uint8_t *bp, size_t n) {
|
|
||||||
(void)ip;
|
|
||||||
return lcdWriteString(bp, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t reads(void *ip, uint8_t *bp, size_t n) {
|
|
||||||
(void)ip;
|
|
||||||
(void)bp;
|
|
||||||
(void)n;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static msg_t put(void *ip, uint8_t b) {
|
|
||||||
(void)ip;
|
|
||||||
return lcdDrawChar((char)b);
|
|
||||||
}
|
|
||||||
|
|
||||||
static msg_t get(void *ip) {
|
|
||||||
(void)ip;
|
|
||||||
return RDY_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static msg_t putt(void *ip, uint8_t b, systime_t timeout) {
|
|
||||||
(void)ip;
|
|
||||||
(void)timeout;
|
|
||||||
/* TODO: handle timeout */
|
|
||||||
return lcdDrawChar((char)b);
|
|
||||||
}
|
|
||||||
|
|
||||||
static msg_t gett(void *ip, systime_t timeout) {
|
|
||||||
(void)ip;
|
|
||||||
(void)timeout;
|
|
||||||
return RDY_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
|
|
||||||
(void)ip;
|
|
||||||
(void)time;
|
|
||||||
return lcdWriteString(bp, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
|
|
||||||
(void)ip;
|
|
||||||
(void)bp;
|
|
||||||
(void)n;
|
|
||||||
(void)time;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static chnflags_t getflags(void *ip) {
|
|
||||||
_chn_get_and_clear_flags_impl(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct GLCDDriverVMT vmt = {
|
|
||||||
writes, reads, put, get,
|
|
||||||
putt, gett, writet, readt,
|
|
||||||
getflags
|
|
||||||
};
|
|
||||||
|
|
||||||
uint16_t lcd_width, lcd_height;
|
uint16_t lcd_width, lcd_height;
|
||||||
uint16_t bgcolor = White, fgcolor = Black;
|
uint16_t bgcolor = White, fgcolor = Black;
|
||||||
uint16_t cx = 0, cy = 0;
|
uint16_t cx = 0, cy = 0;
|
||||||
|
@ -77,7 +10,6 @@ static uint8_t tpText = 0;
|
||||||
const uint8_t* font;
|
const uint8_t* font;
|
||||||
|
|
||||||
void lcdInit(GLCDDriver *glcdp) {
|
void lcdInit(GLCDDriver *glcdp) {
|
||||||
glcdp->vmt = &vmt;
|
|
||||||
|
|
||||||
lld_lcdInit();
|
lld_lcdInit();
|
||||||
lcd_width = SCREEN_WIDTH;
|
lcd_width = SCREEN_WIDTH;
|
||||||
|
@ -116,6 +48,14 @@ void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t co
|
||||||
lld_lcdFillArea(x0, y0, x1, y1, color);
|
lld_lcdFillArea(x0, y0, x1, y1, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcdWriteArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t *buffer, size_t n) {
|
||||||
|
lld_lcdSetWindow(x0, y0, x1, y1);
|
||||||
|
|
||||||
|
lld_lcdWriteStreamStart();
|
||||||
|
lld_lcdWriteStream(buffer, n);
|
||||||
|
lld_lcdWriteStreamStop();
|
||||||
|
}
|
||||||
|
|
||||||
void lcdClear(uint16_t color) {
|
void lcdClear(uint16_t color) {
|
||||||
lld_lcdClear(color);
|
lld_lcdClear(color);
|
||||||
}
|
}
|
||||||
|
@ -203,11 +143,11 @@ msg_t lcdDrawChar(char c) {
|
||||||
uint8_t sps = font[FONT_TABLE_PAD_AFTER_CHAR_IDX];
|
uint8_t sps = font[FONT_TABLE_PAD_AFTER_CHAR_IDX];
|
||||||
uint16_t chi;
|
uint16_t chi;
|
||||||
uint16_t x,y;
|
uint16_t x,y;
|
||||||
|
uint16_t buf[20*16];
|
||||||
|
|
||||||
|
|
||||||
// No support for nongraphic characters, so just ignore them
|
// No support for nongraphic characters, so just ignore them
|
||||||
if(c < 0x20 || c > 0x7F) {
|
if(c < 0x20 || c > 0x7F) {
|
||||||
if(c == '\n')
|
|
||||||
lcdLineBreak();
|
|
||||||
return RDY_OK;
|
return RDY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,28 +157,21 @@ msg_t lcdDrawChar(char c) {
|
||||||
|
|
||||||
uint8_t fontWidth = *(ptr++);
|
uint8_t fontWidth = *(ptr++);
|
||||||
|
|
||||||
if(cx + fontWidth > lcdGetWidth())
|
|
||||||
lcdLineBreak();
|
|
||||||
|
|
||||||
for(x = 0; x < fontWidth; x++) {
|
for(x = 0; x < fontWidth; x++) {
|
||||||
chi = *(uint16_t*)ptr;
|
chi = *(uint16_t*)ptr;
|
||||||
for(y = 0; y < fontHeight; y++) {
|
for(y = 0; y < fontHeight; y++) {
|
||||||
if(chi & 0x01)
|
if(!tpText) {
|
||||||
|
buf[y*fontWidth+x] = (chi & 0x01) ? fgcolor : bgcolor;
|
||||||
|
} else {
|
||||||
lcdDrawPixel(cx+x, cy+y, fgcolor);
|
lcdDrawPixel(cx+x, cy+y, fgcolor);
|
||||||
else if(!tpText)
|
}
|
||||||
lcdDrawPixel(cx+x, cy+y, bgcolor);
|
|
||||||
|
|
||||||
chi >>= 1;
|
chi >>= 1;
|
||||||
}
|
}
|
||||||
ptr += 2;
|
ptr += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
cx += fontWidth;
|
|
||||||
if(sps != 0) {
|
|
||||||
if(!tpText)
|
if(!tpText)
|
||||||
lcdFillArea(cx, cy, cx+sps, cy+fontHeight, bgcolor);
|
lcdWriteArea(cx, cy, cx+fontWidth, cy+fontHeight, buf, fontWidth*fontHeight);
|
||||||
cx += sps;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: proper return codes */
|
/* TODO: proper return codes */
|
||||||
return RDY_OK;
|
return RDY_OK;
|
||||||
|
|
27
glcd.h
27
glcd.h
|
@ -46,33 +46,7 @@ extern const uint8_t* font;
|
||||||
*/
|
*/
|
||||||
typedef struct GLCDDriver GLCDDriver;
|
typedef struct GLCDDriver GLCDDriver;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief @p GLCDDriver specific methods.
|
|
||||||
*/
|
|
||||||
#define _glcd_driver_methods \
|
|
||||||
_base_asynchronous_channel_methods
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @extends BaseAsynchronousChannelVMT
|
|
||||||
*
|
|
||||||
* @brief @p GLCDDriver virtual methods table.
|
|
||||||
*/
|
|
||||||
struct GLCDDriverVMT {
|
|
||||||
_glcd_driver_methods
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @extends BaseAsynchronousChannel
|
|
||||||
*
|
|
||||||
* @brief GLCD driver class.
|
|
||||||
* @details This class extends @p BaseAsynchronousChannel by adding physical
|
|
||||||
* I/O queues.
|
|
||||||
*/
|
|
||||||
struct GLCDDriver {
|
struct GLCDDriver {
|
||||||
/** @brief Virtual Methods Table.*/
|
|
||||||
const struct GLCDDriverVMT *vmt;
|
|
||||||
_base_asynchronous_channel_data
|
|
||||||
/* WARNING: Do not add any data to this struct above this comment, only below */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -86,6 +60,7 @@ void lcdClear(uint16_t color);
|
||||||
void lcdSetOrientation(uint8_t newOrientation);
|
void lcdSetOrientation(uint8_t newOrientation);
|
||||||
void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||||
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||||
|
void lcdWriteArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t *buffer, size_t n);
|
||||||
|
|
||||||
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t point);
|
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t point);
|
||||||
void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||||
|
|
Loading…
Add table
Reference in a new issue