diff --git a/7segment.h b/7segment.h new file mode 100644 index 0000000..184fb45 --- /dev/null +++ b/7segment.h @@ -0,0 +1,25 @@ +#ifndef FONT7SEGMENT_H +#define FONT7SEGMENT_H + +#include + +static const unsigned char sevensegment [] PROGMEM = { + // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) + 10,16,46,12,1,20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x78, 0xFC, 0x02, 0x03, 0x03, 0x03, 0x03, 0x02, 0xFC, 0x78, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7E, 0x00, 0x00, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, + 0xFC, 0x78, 0x00, 0x00, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0xFC, 0x78, 0x7E, 0xFF, 0x00, 0x80, + 0x80, 0x80, 0x80, 0x00, 0xFF, 0x7E, 0x78, 0xFC, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0x00, 0x00, + 0x78, 0xFC, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0x00, 0x00, 0x00, 0x02, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x02, 0xFC, 0x78, 0x78, 0xFC, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0xFC, 0x78, 0x78, 0xFC, + 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0xFC, 0x78, 0x00, 0x00, 0x00, 0x60, 0xF0, 0xF0, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x3F, 0x40, 0xC0, + 0xC0, 0xC0, 0xC0, 0x40, 0x3F, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7E, + 0x1C, 0x3E, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC1, 0xC1, 0xC1, + 0xC1, 0x41, 0x3E, 0x1C, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0x7E, 0x00, 0x00, + 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C, 0x1C, 0x3E, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, + 0x3E, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7E, 0x1C, 0x3E, 0x41, 0xC1, + 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C, 0x00, 0x00, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C +}; +#endif \ No newline at end of file diff --git a/MicroView.cpp b/MicroView.cpp index 8a7ea06..12a062b 100644 --- a/MicroView.cpp +++ b/MicroView.cpp @@ -6,15 +6,16 @@ #include #include #include +#include <7segment.h> #include #include #include // Change the total fonts included -#define TOTALFONTS 6 +#define TOTALFONTS 7 // Add the font name as declared in the header file. -const unsigned char *MICROVIEW::fontsPointer[]={font5x7,font8x16,fontlargenumber, space01,space02,space03}; +const unsigned char *MICROVIEW::fontsPointer[]={font5x7,font8x16,sevensegment,fontlargenumber, space01,space02,space03}; /* @@ -479,21 +480,18 @@ size_t MICROVIEW::write(uint8_t c) { void MICROVIEW::drawChar(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode) { //void MICROVIEW::drawChar(uint8_t x, uint8_t line, uint8_t c, uint8_t mode) { + + // TODO - New routine to take font of any height, at the moment limited to font height in multiple of 8 pixels + uint8_t rowsToDraw,row, tempC; - uint8_t i,j,tempX; + uint8_t i,j,temp; uint16_t charPerBitmapRow,charColPositionOnBitmap,charRowPositionOnBitmap,charBitmapStartPosition; - - // TODO - char must be able to XOR on background - - //if ((line >= LCDHEIGHT/fontHeight) || (x > (LCDWIDTH - fontWidth))) - //return; - + if ((c(fontStartChar+fontTotalChar-1))) // no bitmap for the required c return; tempC=c-fontStartChar; - - tempX=x; + // each row (in datasheet is call page) is 8 bits high, 16 bit high character will have 2 rows to be drawn rowsToDraw=fontHeight/8; // 8 is LCD's page size, see SSD1306 datasheet if (rowsToDraw<=1) rowsToDraw=1; @@ -502,19 +500,19 @@ size_t MICROVIEW::write(uint8_t c) { if (rowsToDraw==1) { for (i=0;i>=1; + temp >>=1; } } return; @@ -530,29 +528,26 @@ size_t MICROVIEW::write(uint8_t c) { // each row on LCD is 8 bit height (see datasheet for explanation) for(row=0;row>=1; + temp >>=1; } } } - - - /* fast direct memory draw but has a limitation to draw in ROWS // only 1 row to draw for font with 8 bit height if (rowsToDraw==1) { for (i=0; i