This commit is contained in:
olikraus
2015-12-22 22:23:42 +01:00
parent 7f02e658de
commit 41fa8da2b4
9 changed files with 594 additions and 17 deletions
+58 -3
View File
@@ -25,7 +25,7 @@ class U8G2 : public Print
protected:
u8g2_t u8g2;
public:
uint8_t tx, ty;
u8g2_uint_t tx, ty;
U8G2(void) { home(); }
u8x8_t *getU8x8(void) { return u8g2_GetU8x8(&u8g2); }
@@ -34,11 +34,66 @@ class U8G2 : public Print
/* u8x8 interface */
uint8_t getCols(void) { return u8x8_GetCols(u8g2_GetU8x8(&u8g2)); }
uint8_t getRows(void) { return u8x8_GetRows(u8g2_GetU8x8(&u8g2)); }
void initDisplay(void) {
u8g2_InitDisplay(&u8g2); }
void clearScreen(void) {
u8g2_ClearDisplay(&u8g2); }
void setPowerSave(uint8_t is_enable) {
u8g2_SetPowerSave(&u8g2, is_enable); }
void begin(void) {
initDisplay(); clearScreen(); setPowerSave(0); }
/* u8g2 */
void firstPage(void) { u8g2_FirstPage(&u8g2); }
uint8_t nextPage(void) { return u8g2_NextPage(&u8g2); }
void setFont(const uint8_t *font) {u8g2_SetFont(&u8g2, font); }
u8g2_uint_t drawStr(u8g2_uint_t x, u8g2_uint_t y, const char *s) { return u8g2_DrawString(&u8g2, x, y, s); }
size_t write(uint8_t v) {
tx += u8g2_DrawGlyph(&u8g2, tx, ty, v);
return 1;
}
/* LiquidCrystal compatible functions */
void home(void) { tx = 0; ty = 0; }
void clear(void) { clearScreen(); home(); }
void noDisplay(void) { u8g2_SetPowerSave(&u8g2, 1); }
void display(void) { u8g2_SetPowerSave(&u8g2, 0); }
void setCursor(uint8_t x, uint8_t y) { tx = x; ty = y; }
};
/*
U8G2_<controller>_<display>_<memory>_<communication>
memory
"1" one page
"2" two pages
"f" full frame buffer
communication
"SW SPI"
*/
class U8G2_SSD1306_128x64_NONAME_1_SW_SPI : public U8G2
{
public:
U8G2_SSD1306_128x64_NONAME_1_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset)
{
u8g2_Setup_ssd1306_128x64_noname_1(&u8g2, u8x8_byte_4wire_sw_spi, u8x8_gpio_and_delay_arduino, rotation);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_CLOCK, clock);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_DATA, data);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, cs);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, dc);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, reset);
}
};
#endif /* _U8G2LIB_HH */
-3
View File
@@ -92,9 +92,6 @@ class U8X8 : public Print
void display(void) { u8x8_SetPowerSave(&u8x8, 0); }
void setCursor(uint8_t x, uint8_t y) { tx = x; ty = y; }
void noCursor(void) {}
void cursor(void) {}
};
// constructor list start