24 #include "mb96348hs.h"
30 #if LCD_FRAMEBUFFER_MODE==1
31 static uint8_t lcd_buffer[128][8];
34 static uint8_t setEnable(
void) {
45 static void selectDisplay(
uint8_t disp) {
53 static void setReadWrite(
uint8_t write) {
124 for (y = 0; y < 8; y++) {
125 #if LCD_FRAMEBUFFER_MODE == 1
126 for (x = 0; x < 128; x++) {
127 lcd_buffer[x][y] = (color ? 0xff : 0x00);
131 for (x= 0; x < 64; x++)
132 writeData((color ? 0xff : 0x00), 0);
134 for (x= 0; x < 64; x++)
135 writeData((color ? 0xff : 0x00), 1);
141 #if LCD_FRAMEBUFFER_MODE==0
144 if ((page > 7) || (x > 127))
146 #if LCD_FRAMEBUFFER_MODE==1
147 lcd_buffer[x][page] = data;
149 disp = setXY(x, page * 8);
150 writeData(data, disp);
155 #if LCD_FRAMEBUFFER_MODE==1
156 if ((x > 127) || (y > 63) || (x < 0) || (y < 0))
160 lcd_buffer[x][y / 8] |= (1 << (y % 8));
162 lcd_buffer[x][y / 8] &= ~(1 << (y % 8));
166 if ((x > 127) || (y > 63) || (x < 0) || (y < 0))
170 data = readData(disp);
172 data |= (1 << (y % 8));
174 data &= ~(1 << (y % 8));
177 writeData(data, disp);
183 #if LCD_FRAMEBUFFER_MODE==1
184 if ((x > 127) || (y > 63) || (x < 0) || (y < 0))
186 return (lcd_buffer[x][y / 8] >> (y % 8)) & 0x01;
189 if ((x > 127) || (y > 63) || (x < 0) || (y < 0))
192 return (readData(disp) >> (y % 8)) & 0x01;
245 uint8_t startPage, endPage, pages;
256 if ((x > 127) || (y > 63) || (x+w < 0) || (y+h < 0))
259 if (x+w > 128) w = 128-x;
260 if (y+h > 64) h = 64-y;
261 if (x < 0) {w+=x; x=0;}
262 if (y < 0) {h+=y; y=0;}
265 endPage = (y + h - 1) / 8;
266 pages = endPage - startPage + 1;
268 for (iPage = startPage; iPage < endPage + 1; iPage++) {
270 if (iPage == startPage) {
272 data = 0xff << (y - startPage * 8);
274 data = (0xff >> (8 - h)) << (y - startPage * 8);
275 }
else if (iPage == endPage) {
276 data = 0xff >> (7 - (y + h - 1) % 8);
280 for (ix = x; ix < (x + w); ix++) {
281 #if LCD_FRAMEBUFFER_MODE == 0
282 uint8_t disp = setXY(ix, iPage * 8);
290 #if LCD_FRAMEBUFFER_MODE == 0
291 curData = readData(disp);
292 setXY(ix, iPage * 8);
294 curData = lcd_buffer[ix][iPage];
301 #if LCD_FRAMEBUFFER_MODE == 0
302 writeData(curData, disp);
304 lcd_buffer[ix][iPage] = curData;
315 int16_t x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
361 for (t = 0; t < el; t++) {
385 if ((x > 127) || (page > 7) || (ascii > 127))
391 for (i = 0; i < 5; i++) {
392 #if LCD_FRAMEBUFFER_MODE == 1
393 uint8_t curData = (black ? 0 : 255);
395 curData = lcd_buffer[x][page];
400 curData &= ~(*pages++);
401 lcd_buffer[x][page] = curData;
403 uint8_t disp = setXY(x, page * 8);
404 uint8_t curData = (black ? 0 : 255);
406 curData = readData(disp);
411 curData &= ~(*pages++);
413 writeData(curData, disp);
429 if ((x1 > 127) || (page1 > 7) || (x2 > 128) || (page2 > 8))
436 for (curChar = *firstChar++; curChar != 0; curChar = *firstChar++) {
437 if (curChar ==
'\n') {
448 if ((curX + 5) > x2) {
465 uint8_t fontwidth = font_getWidth(font);
466 uint8_t fontheight = font_getHeight(font);
467 uint8_t offset = (8-fontheight);
472 if (orientation & (LCD_ORIENTATION_90 | LCD_ORIENTATION_270)) {
478 if (orientation & LCD_ORIENTATION_90) {
479 for (i = 0; i < fontwidth; i++) {
480 for (j = 0; j < fontheight; j++) {
481 if (pages[i] & 1<<(j+offset)) {
488 }
else if (orientation & LCD_ORIENTATION_180) {
489 for (i = 0; i < fontwidth; i++) {
490 for (j = 0; j < fontheight; j++) {
491 if (pages[i] & 1<<(j+offset)) {
498 }
else if (orientation & LCD_ORIENTATION_270) {
499 for (i = 0; i < fontwidth; i++) {
500 for (j = 0; j < fontheight; j++) {
501 if (pages[i] & 1<<(j+offset)) {
509 for (i = 0; i < fontwidth; i++) {
510 for (j = 0; j < fontheight; j++) {
511 if (pages[i] & 1<<(j+8-fontheight)) {
526 while (firstChar[len++] != 0);
529 width = (len*font_getWidth(font));
530 height = font_getHeight(font);
533 if (settings & LCD_ORIENTATION_90)
535 if (settings & LCD_ALIGNMENT_CENTER) {
537 }
else if (settings & LCD_ALIGNMENT_RIGHT) {
540 if (settings & LCD_ALIGNMENT_MIDDLE) {
542 }
else if (settings & LCD_ALIGNMENT_BOTTOM) {
546 else if (settings & LCD_ORIENTATION_180)
548 if (settings & LCD_ALIGNMENT_CENTER) {
550 }
else if (settings & LCD_ALIGNMENT_RIGHT) {
553 if (settings & LCD_ALIGNMENT_MIDDLE) {
555 }
else if (settings & LCD_ALIGNMENT_BOTTOM) {
559 else if (settings & LCD_ORIENTATION_270)
561 if (settings & LCD_ALIGNMENT_CENTER) {
563 }
else if (settings & LCD_ALIGNMENT_RIGHT) {
566 if (settings & LCD_ALIGNMENT_MIDDLE) {
568 }
else if (settings & LCD_ALIGNMENT_BOTTOM) {
574 if (settings & LCD_ALIGNMENT_CENTER) {
576 }
else if (settings & LCD_ALIGNMENT_RIGHT) {
579 if (settings & LCD_ALIGNMENT_MIDDLE) {
581 }
else if (settings & LCD_ALIGNMENT_BOTTOM) {
588 if (settings & (LCD_ORIENTATION_90 | LCD_ORIENTATION_270)) {
589 while (*firstChar != 0) {
595 while (*firstChar != 0) {
604 #if LCD_FRAMEBUFFER_MODE==1
606 for (disp = 0; disp < 2; disp++) {
607 for (page = 0; page < 8; page++) {
610 for (x = 0; x < 64; x++) {
611 writeData(lcd_buffer[x+64*disp][page], disp);
#define LCD_CTRL_DI
Data/Instruction pin.
#define LCD_CTRL_CS1
Chip 1 select pin.
#define LCD_CTRL_E
Enable pin.
#define LCD_CTRL_RESET
Reset pint.
void delay_us(uint16_t us)
void lcd_drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t black)
#define LCD_CTRL_DDR
Direction register of the control pins port.
#define LCD_DATA_PORT
Port where the data pins of the display are connected.
void delay_ms(uint16_t ms)
#define LCD_DATA_DDR
Direction register of the data pins port.
int16_t lcd_drawCharacterPrecise(int16_t x, int16_t y, char ascii, uint8_t black, uint8_t orientation, uint8_t font)
#define LCD_CTRL_RW
Read/Write pin.
uint8_t * font_getChar(uint8_t ascii, uint8_t font)
#define LCD_DATA_PIER
Input enable register of the data pins port.
#define LCD_CMD_STARTLINE
Set startline.
#define LCD_CTRL_PORT
Port where the control lines of the display are connected.
int16_t lcd_drawStringPrecise(int16_t x, int16_t y, char *firstChar, uint8_t black, uint8_t settings, uint8_t font)
uint8_t lcd_drawCharacter(uint8_t x, uint8_t page, char ascii, uint8_t black, uint8_t overlay)
#define LCD_CMD_SETADDRESS
Set address.
#define LCD_CMD_SETPAGE
Set page.
#define LCD_CMD_ON
Display on.
void lcd_drawPage(uint8_t x, uint8_t page, uint8_t data)
void lcd_drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint8_t black, uint8_t filled)
int8_t lcd_getPixel(int16_t x, int16_t y)
#define LCD_CTRL_CS2
Chip 2 select pin.
void lcd_clear(uint8_t color)
void lcd_drawCircle(int16_t x, int16_t y, uint8_t r, uint8_t black, uint8_t filled)
void lcd_drawPixel(int16_t x, int16_t y, uint8_t color)
uint8_t lcd_drawString(uint8_t x1, uint8_t page1, uint8_t x2, uint8_t page2, uint8_t wrap, uint16_t delay, char *firstChar, uint8_t black, uint8_t overlay)