u8x8 lc procedures
This commit is contained in:
parent
82a166f411
commit
9a2eb639b0
|
@ -22,7 +22,9 @@ class U8X8 : public Print
|
|||
protected:
|
||||
u8x8_t u8x8;
|
||||
public:
|
||||
U8X8(void) {}
|
||||
uint8_t tx, ty;
|
||||
|
||||
U8X8(void) { home(); }
|
||||
u8x8_t *getU8x8(void) { return &u8x8; }
|
||||
|
||||
void drawTile(uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr) {
|
||||
|
@ -46,6 +48,9 @@ class U8X8 : public Print
|
|||
void setContrast(uint8_t value) {
|
||||
u8x8_SetContrast(&u8x8, value); }
|
||||
|
||||
void setInverseFont(uint8_t value) {
|
||||
u8x8_SetInverseFont(&u8x8, value); }
|
||||
|
||||
void setFont(const uint8_t *font_8x8) {
|
||||
u8x8_SetFont(&u8x8, font_8x8); }
|
||||
|
||||
|
@ -62,8 +67,24 @@ class U8X8 : public Print
|
|||
return u8x8_GetUTF8Len(&u8x8, s); }
|
||||
|
||||
size_t write(uint8_t v) {
|
||||
u8x8_DrawGlyph(&u8x8, tx, ty, v);
|
||||
tx++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void inverse(void) { u8x8_SetInverseFont(&u8x8, 1); }
|
||||
void noInverse(void) { u8x8_SetInverseFont(&u8x8, 0); }
|
||||
|
||||
/* LiquidCrystal compatible functions */
|
||||
void home(void) { tx = 0; ty = 0; }
|
||||
void clear(void) { clearScreen(); home(); }
|
||||
void noDisplay(void) { u8x8_SetPowerSave(&u8x8, 1); }
|
||||
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
|
||||
|
|
|
@ -206,6 +206,7 @@ struct u8x8_struct
|
|||
const uint8_t *font;
|
||||
u8x8_char_cb char_cb; /* procedure, which will be used to get the next char from the string */
|
||||
uint8_t x_offset; /* copied from info struct, can be modified in flip mode */
|
||||
uint8_t is_font_inverse_mode; /* 0: normal, 1: font glyphs are inverted */
|
||||
uint8_t i2c_started; /* for i2c interface */
|
||||
#ifdef U8X8_USE_PINS
|
||||
uint8_t pins[U8X8_PIN_CNT]; /* defines a pinlist: Mainly a list of pins for the Arduino Envionment, use U8X8_PIN_xxx to access */
|
||||
|
@ -558,6 +559,8 @@ void u8x8_DrawGlyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding);
|
|||
uint8_t u8x8_DrawString(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s);
|
||||
uint8_t u8x8_DrawUTF8(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s);
|
||||
uint8_t u8x8_GetUTF8Len(u8x8_t *u8x8, const char *s);
|
||||
#define u8x8_SetInverseFont(u8x8, b) (u8x8)->is_font_inverse_mode = (b)
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* start font list */
|
||||
|
|
|
@ -43,6 +43,13 @@ void u8x8_DrawGlyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding)
|
|||
buf[i] = 0;
|
||||
}
|
||||
}
|
||||
if ( u8x8->is_font_inverse_mode )
|
||||
{
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
buf[i] ^= 255;
|
||||
}
|
||||
}
|
||||
u8x8_DrawTile(u8x8, x, y, 1, buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ void u8x8_SetupDefaults(u8x8_t *u8x8)
|
|||
u8x8->cad_cb = u8x8_dummy_cb;
|
||||
u8x8->byte_cb = u8x8_dummy_cb;
|
||||
u8x8->gpio_and_delay_cb = u8x8_dummy_cb;
|
||||
u8x8->is_font_inverse_mode = 0;
|
||||
|
||||
#ifdef U8X8_USE_PINS
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <U8x8lib.h>
|
||||
|
||||
//U8X8_SSD1306_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
U8X8_SSD1306_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_6800 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
|
|
Loading…
Reference in New Issue