Changeset - 4157af9eb546
[Not reviewed]
default
0 3 0
Ethan Zonca - 10 years ago 2014-10-18 17:09:51
ez@ethanzonca.com
Large font rendering supported
3 files changed with 88 insertions and 4 deletions:
0 comments (0 inline, 0 general)
main.c
Show inline comments
 
@@ -91,8 +91,9 @@ int main(void)
 
 
    // Check for problems on startup
 
    if(clock_fail) {
 
        ssd1306_DrawString("ERROR: Check Xtal", 3, 0);
 
        delay(2000);
 
        //ssd1306_DrawStringBig("ERROR: Check Xtal", 2, 0);
 
        ssd1306_DrawStringBig("XTAL ERR", 2, 0);
 
        delay(5000);
 
    }
 
 
    // Init USB
 
@@ -292,7 +293,7 @@ void draw_setpoint() {
 
    ssd1306_DrawString(tempstr, 3, 95);
 
}
 
 
uint8_t goto_mode = 1;
 
uint8_t goto_mode = 2;
 
 
// State machine
 
uint8_t sw_btn_last = 0;
ssd1306.c
Show inline comments
 
@@ -259,7 +259,7 @@ void ssd1306_drawlogo()
 
/* Print a single character from font.cpp */
 
void ssd1306_DrawChar(char ascii, unsigned char row, unsigned char xPos)
 
{
 
    char *srcPointer = 0;
 
    char *srcPointer = -1;
 
    unsigned char i;
 
 
    srcPointer = &fontData[(ascii-32)][0];
 
@@ -275,6 +275,69 @@ void ssd1306_DrawChar(char ascii, unsign
 
    WriteData(0x00);
 
}
 
 
void ssd1306_DrawCharBig(char ascii, unsigned char row, unsigned char xPos)
 
{
 
    char *srcPointer = -1;
 
    unsigned char i;
 
 
    srcPointer = &fontData[(ascii-32)][0];
 
 
    setStartPage(row-1);
 
    setStartColumn(xPos);
 
 
    // Write first row
 
    for(i=0;i<5;i++)
 
    {
 
        uint8_t data = 0;
 
        data |= ((*srcPointer) & 0b1000) << 4; // get top 4 bits
 
        data |= ((*srcPointer) & 0b1000) << 3; // get top 4 bits
 
 
        data |= ((*srcPointer) & 0b0100) << 3; // get top 4 bits
 
        data |= ((*srcPointer) & 0b0100) << 2; // get top 4 bits
 
 
        data |= ((*srcPointer) & 0b0010) << 2; // get top 4 bits
 
        data |= ((*srcPointer) & 0b0010) << 1; // get top 4 bits
 
 
        data |= ((*srcPointer) & 0b0001) << 1; // get top 4 bits
 
        data |= ((*srcPointer) & 0b0001); // get top 4 bits
 
 
        WriteData(data);
 
        WriteData(data);
 
 
        srcPointer++;
 
    }
 
    WriteData(0x00);
 
 
    srcPointer -= 5;
 
 
    setStartPage(row);
 
    setStartColumn(xPos);
 
 
    // Write second row
 
    for(i=0;i<5;i++)
 
    {
 
        uint8_t data = 0;
 
        data |=  (*srcPointer) & 0b10000000; // get top 4 bits
 
        data |= ((*srcPointer) & 0b10000000) >> 1; // get top 4 bits
 
 
        data |= ((*srcPointer) & 0b01000000) >> 1; // get top 4 bits
 
        data |= ((*srcPointer) & 0b01000000) >> 2; // get top 4 bits
 
 
        data |= ((*srcPointer) & 0b00100000) >> 2; // get top 4 bits
 
        data |= ((*srcPointer) & 0b00100000) >> 3; // get top 4 bits
 
 
        data |= ((*srcPointer) & 0b00010000) >> 3; // get top 4 bits
 
        data |= ((*srcPointer) & 0b00010000) >> 4; // get top 4 bits
 
 
        WriteData(data);
 
        WriteData(data);
 
 
        srcPointer++;
 
    }
 
    WriteData(0x00);
 
 
 
}
 
 
void ssd1306_DrawString(const char *dataPtr, unsigned char row, unsigned char xPos)
 
{
 
    char *srcPointer;
 
@@ -291,4 +354,22 @@ void ssd1306_DrawString(const char *data
 
    }
 
}
 
 
 
void ssd1306_DrawStringBig(const char *dataPtr, unsigned char row, unsigned char xPos)
 
{
 
    char *srcPointer;
 
 
    srcPointer = (char*)dataPtr;
 
    ssd1306_DrawCharBig(' ',row,xPos); // NBSP must be written first before the string start
 
 
    while(1)
 
    {
 
        ssd1306_DrawCharBig(*srcPointer,row,xPos);
 
        srcPointer++;
 
        xPos+=12;
 
        if(*srcPointer == 0) break;
 
    }
 
}
 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab 
ssd1306.h
Show inline comments
 
@@ -19,7 +19,9 @@
 
 
void ssd1306_Init(void);
 
void ssd1306_DrawChar(char ascii, unsigned char row, unsigned char xPos);
 
void ssd1306_DrawCharBig(char ascii, unsigned char row, unsigned char xPos);
 
void ssd1306_DrawString(const char *dataPtr, unsigned char row, unsigned char xPos);
 
void ssd1306_DrawStringBig(const char *dataPtr, unsigned char row, unsigned char xPos);
 
void ssd1306_drawlogo();
 
void ssd1306_clearscreen();
 
0 comments (0 inline, 0 general)