@@ -88,14 +88,15 @@ int main(void)
// Init OLED over SPI
ssd1306_Init();
ssd1306_clearscreen();
// 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
//Set_System(); // hw_config.h
Set_USBClock();
USB_Interrupts_Config();
@@ -289,13 +290,13 @@ void draw_setpoint() {
ssd1306_DrawString("-> ", 3, 80);
itoa(setpoint, tempstr);
ssd1306_DrawString(" ", 3, 95);
ssd1306_DrawString(tempstr, 3, 95);
uint8_t goto_mode = 1;
uint8_t goto_mode = 2;
// State machine
uint8_t sw_btn_last = 0;
uint8_t sw_up_last = 0;
uint8_t sw_down_last = 0;
uint8_t sw_left_last = 0;
@@ -256,13 +256,13 @@ void ssd1306_drawlogo()
WriteData(0x00);
/* 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];
setStartPage(row);
setStartColumn(xPos);
@@ -272,12 +272,75 @@ void ssd1306_DrawChar(char ascii, unsign
WriteData(*srcPointer);
srcPointer++;
void ssd1306_DrawCharBig(char ascii, unsigned char row, unsigned char xPos)
setStartPage(row-1);
// 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);
srcPointer -= 5;
// Write second row
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
void ssd1306_DrawString(const char *dataPtr, unsigned char row, unsigned char xPos)
char *srcPointer;
srcPointer = (char*)dataPtr;
ssd1306_DrawChar(' ',row,xPos); // NBSP must be written first before the string start
@@ -288,7 +351,25 @@ void ssd1306_DrawString(const char *data
xPos+=6;
if(*srcPointer == 0) break;
void ssd1306_DrawStringBig(const char *dataPtr, unsigned char row, unsigned char xPos)
ssd1306_DrawCharBig(' ',row,xPos); // NBSP must be written first before the string start
while(1)
ssd1306_DrawCharBig(*srcPointer,row,xPos);
xPos+=12;
// vim:softtabstop=4 shiftwidth=4 expandtab
@@ -16,13 +16,15 @@
#define SPI_SendByte(data) SPI_I2S_SendData(SPI1,data)
#define SPI_Wait() while(!(SPI1->SR&SPI_I2S_FLAG_TXE));while(SPI1->SR&SPI_I2S_FLAG_BSY);
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();
#endif
Status change: