towards cpp interface
This commit is contained in:
parent
41fa8da2b4
commit
97299ec5f8
|
@ -53,7 +53,7 @@ class U8G2 : public Print
|
|||
|
||||
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); }
|
||||
u8g2_uint_t drawStr(u8g2_uint_t x, u8g2_uint_t y, const char *s) { return u8g2_DrawStr(&u8g2, x, y, s); }
|
||||
|
||||
size_t write(uint8_t v) {
|
||||
tx += u8g2_DrawGlyph(&u8g2, tx, ty, v);
|
||||
|
@ -84,14 +84,10 @@ class U8G2 : public Print
|
|||
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_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 = U8X8_PIN_NONE)
|
||||
{
|
||||
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);
|
||||
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -121,6 +121,17 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t a
|
|||
/*
|
||||
use U8X8_PIN_NONE as value for "reset", if there is no reset line
|
||||
*/
|
||||
|
||||
void u8x8_SetPin_4Wire_SW_SPI(u8x8_t *u8x8, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset)
|
||||
{
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_SPI_CLOCK, clock);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_SPI_DATA, data);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
|
||||
void u8x8_Setup_4Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset)
|
||||
{
|
||||
u8x8_Setup(u8x8, display_cb, u8x8_cad_001, u8x8_byte_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
|
||||
|
@ -133,6 +144,13 @@ void u8x8_Setup_4Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock
|
|||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
void u8x8_SetPin_3Wire_SW_SPI(u8x8_t *u8x8, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset)
|
||||
{
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_SPI_CLOCK, clock);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_SPI_DATA, data);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
void u8x8_Setup_3Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset)
|
||||
{
|
||||
|
@ -148,6 +166,14 @@ void u8x8_Setup_3Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock
|
|||
/*
|
||||
use U8X8_PIN_NONE as value for "reset", if there is no reset line
|
||||
*/
|
||||
void u8x8_SetPin_4Wire_HW_SPI(u8x8_t *u8x8, uint8_t cs, uint8_t dc, uint8_t reset)
|
||||
{
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
|
||||
void u8x8_Setup_4Wire_HW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t cs, uint8_t dc, uint8_t reset)
|
||||
{
|
||||
u8x8_Setup(u8x8, display_cb, u8x8_cad_001, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
|
||||
|
@ -158,6 +184,14 @@ void u8x8_Setup_4Wire_HW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t cs, u
|
|||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
void u8x8_SetPin_SSD13xx_SW_I2C(u8x8_t *u8x8, uint8_t clock, uint8_t data, uint8_t reset)
|
||||
{
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_I2C_CLOCK, clock);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_I2C_DATA, data);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
|
||||
}
|
||||
|
||||
void u8x8_Setup_SSD13xx_SW_I2C(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock, uint8_t data, uint8_t reset)
|
||||
{
|
||||
u8x8_Setup(u8x8, display_cb, u8x8_cad_001, u8x8_byte_ssd13xx_sw_i2c, u8x8_gpio_and_delay_arduino);
|
||||
|
@ -169,6 +203,22 @@ void u8x8_Setup_SSD13xx_SW_I2C(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clo
|
|||
|
||||
}
|
||||
|
||||
void u8x8_SetPin_8Bit_6800(u8x8_t *u8x8, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t cs, uint8_t dc, uint8_t reset)
|
||||
{
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D0, d0);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D1, d1);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D2, d2);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D3, d3);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D4, d4);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D5, d5);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D6, d6);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D7, d7);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_E, enable);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
void u8x8_Setup_8Bit_6800(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t cs, uint8_t dc, uint8_t reset)
|
||||
{
|
||||
u8x8_Setup(u8x8, display_cb, u8x8_cad_001, u8x8_byte_8bit_6800mode, u8x8_gpio_and_delay_arduino);
|
||||
|
@ -188,6 +238,22 @@ void u8x8_Setup_8Bit_6800(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t d0, uint
|
|||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
void u8x8_SetPin_8Bit_8080(u8x8_t *u8x8, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t wr, uint8_t cs, uint8_t dc, uint8_t reset)
|
||||
{
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D0, d0);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D1, d1);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D2, d2);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D3, d3);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D4, d4);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D5, d5);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D6, d6);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_D7, d7);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_E, wr);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
void u8x8_Setup_8Bit_8080(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t wr, uint8_t cs, uint8_t dc, uint8_t reset)
|
||||
{
|
||||
u8x8_Setup(u8x8, display_cb, u8x8_cad_001, u8x8_byte_8bit_8080mode, u8x8_gpio_and_delay_arduino);
|
||||
|
|
|
@ -17,6 +17,13 @@
|
|||
extern "C" uint8_t u8x8_gpio_and_delay_arduino(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
|
||||
void u8x8_SetPin_4Wire_SW_SPI(u8x8_t *u8x8, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset);
|
||||
void u8x8_SetPin_3Wire_SW_SPI(u8x8_t *u8x8, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset);
|
||||
void u8x8_SetPin_4Wire_HW_SPI(u8x8_t *u8x8, uint8_t cs, uint8_t dc, uint8_t reset);
|
||||
void u8x8_SetPin_SSD13xx_SW_I2C(u8x8_t *u8x8, uint8_t clock, uint8_t data, uint8_t reset);
|
||||
void u8x8_SetPin_8Bit_6800(u8x8_t *u8x8, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t cs, uint8_t dc, uint8_t reset);
|
||||
void u8x8_SetPin_8Bit_8080(u8x8_t *u8x8, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t wr, uint8_t cs, uint8_t dc, uint8_t reset);
|
||||
|
||||
void u8x8_Setup_4Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset);
|
||||
void u8x8_Setup_3Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset);
|
||||
void u8x8_Setup_4Wire_HW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t cs, uint8_t dc, uint8_t reset);
|
||||
|
|
|
@ -331,7 +331,7 @@ int8_t u8g2_GetGlyphWidth(u8g2_t *u8g2, uint16_t requested_encoding);
|
|||
u8g2_uint_t u8g2_DrawGlyph(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, uint16_t encoding);
|
||||
|
||||
void u8g2_SetFontDirection(u8g2_t *u8g2, uint8_t dir);
|
||||
u8g2_uint_t u8g2_DrawString(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str);
|
||||
u8g2_uint_t u8g2_DrawStr(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str);
|
||||
u8g2_uint_t u8g2_DrawUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str);
|
||||
|
||||
#define u8g2_GetMaxCharHeight(u8g2) ((u8g2)->font_info.max_char_height)
|
||||
|
|
|
@ -673,7 +673,7 @@ u8g2_uint_t u8g2_DrawGlyph(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, uint16_t
|
|||
}
|
||||
|
||||
#ifdef OBSOLETE
|
||||
u8g2_uint_t u8g2_DrawString(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str)
|
||||
u8g2_uint_t u8g2_DrawStr(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str)
|
||||
{
|
||||
u8g2_uint_t delta, sum;
|
||||
sum = 0;
|
||||
|
@ -744,7 +744,7 @@ static u8g2_uint_t u8g2_draw_string(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y,
|
|||
return sum;
|
||||
}
|
||||
|
||||
u8g2_uint_t u8g2_DrawString(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str)
|
||||
u8g2_uint_t u8g2_DrawStr(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str)
|
||||
{
|
||||
u8g2->u8x8.char_cb = u8x8_get_char_from_string;
|
||||
return u8g2_draw_string(u8g2, x, y, str);
|
||||
|
@ -769,7 +769,7 @@ u8g2_uint_t u8g2_DrawUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char
|
|||
|
||||
#ifdef OBSOLETE
|
||||
/* UTF-8 version */
|
||||
u8g2_uint_t u8g2_DrawString(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str)
|
||||
u8g2_uint_t u8g2_DrawStr(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str)
|
||||
{
|
||||
uint16_t e;
|
||||
u8g2_uint_t delta, sum;
|
||||
|
|
|
@ -14,7 +14,7 @@ U8glib V2: Features and Limitations
|
|||
Limitation:
|
||||
Behavior for sequences with more than 3 bytes is unknown.
|
||||
|
||||
- Compilation speed improved (font file)
|
||||
- Compilation speed improved (font data)
|
||||
|
||||
- "Text only" sub library
|
||||
|
||||
|
@ -24,3 +24,7 @@ U8glib V2: Features and Limitations
|
|||
|
||||
- Better hardware support
|
||||
|
||||
|
||||
u8g vs. u8g2
|
||||
- begin() must be called
|
||||
- constructor contains name of communicaton interface
|
|
@ -381,13 +381,13 @@ void loop(void)
|
|||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
if ( i == 1 )
|
||||
{
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
|
||||
|
|
|
@ -31,13 +31,13 @@ int main(void)
|
|||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
|
||||
u8g2_SendBuffer(&u8g2);
|
||||
*/
|
||||
|
@ -47,13 +47,13 @@ int main(void)
|
|||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "123");
|
||||
u8g2_DrawStr(&u8g2, x, y, "123");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "123");
|
||||
u8g2_DrawStr(&u8g2, x, y, "123");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "123");
|
||||
u8g2_DrawStr(&u8g2, x, y, "123");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "123");
|
||||
u8g2_DrawStr(&u8g2, x, y, "123");
|
||||
if ( i == 1 )
|
||||
{
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
|
||||
|
|
|
@ -30,13 +30,13 @@ int main(void)
|
|||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
|
||||
u8g2_SendBuffer(&u8g2);
|
||||
*/
|
||||
|
|
|
@ -220,13 +220,13 @@ int main(void)
|
|||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "A");
|
||||
u8g2_DrawStr(&u8g2, x, y, "A");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "a");
|
||||
u8g2_DrawStr(&u8g2, x, y, "a");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "a");
|
||||
u8g2_DrawStr(&u8g2, x, y, "a");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "a");
|
||||
u8g2_DrawStr(&u8g2, x, y, "a");
|
||||
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0);
|
||||
|
@ -240,13 +240,13 @@ int main(void)
|
|||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
if ( i == 1 )
|
||||
{
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
|
||||
|
|
|
@ -31,13 +31,13 @@ int main(void)
|
|||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
|
||||
u8g2_SendBuffer(&u8g2);
|
||||
*/
|
||||
|
@ -47,13 +47,13 @@ int main(void)
|
|||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
if ( i == 1 )
|
||||
{
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
|
||||
|
|
|
@ -316,13 +316,13 @@ int main(void)
|
|||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
|
||||
u8g2_SendBuffer(&u8g2);
|
||||
*/
|
||||
|
@ -332,17 +332,17 @@ int main(void)
|
|||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
//u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
//u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawUTF8(&u8g2, x, y, "\316\221\316\222\316\223"); /* UTF-8 Uppercase Greek ABC */
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
//u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
//u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_DrawUTF8(&u8g2, x, y, "\316\261\316\262\316\263"); /* UTF-8 Lowercase Greek abc */
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
//u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
//u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_DrawUTF8(&u8g2, x, y, "\316\261\316\262\316\263");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
//u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
//u8g2_DrawString(&u8g2, x, y, "\316\261\316\262\316\263");
|
||||
//u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
//u8g2_DrawStr(&u8g2, x, y, "\316\261\316\262\316\263");
|
||||
u8g2_DrawUTF8(&u8g2, x, y, "αβγ"); /* Lowercase Greek abc... requires UTF-8 editor */
|
||||
if ( i == 1 )
|
||||
{
|
||||
|
|
|
@ -78,13 +78,13 @@ int main(void)
|
|||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
|
||||
u8g2_SendBuffer(&u8g2);
|
||||
*/
|
||||
|
@ -94,13 +94,13 @@ int main(void)
|
|||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
if ( i == 1 )
|
||||
{
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
|
||||
|
|
|
@ -42,7 +42,7 @@ void ra(uint8_t tx, uint8_t ty, const char *s)
|
|||
u8g2_DrawHVLine(&desc, x-30, y+1, 28, 0);
|
||||
|
||||
w = u8g2_GetStringWidth(&desc, s);
|
||||
u8g2_DrawString(&desc, x-34-w, y+u8g2_GetAscent(&desc)/2, s);
|
||||
u8g2_DrawStr(&desc, x-34-w, y+u8g2_GetAscent(&desc)/2, s);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ int main(void)
|
|||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
|
||||
u8g2_SendBuffer(&u8g2);
|
||||
*/
|
||||
|
@ -45,13 +45,13 @@ int main(void)
|
|||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawString(&u8g2, x, y, "ABC");
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawString(&u8g2, x, y, "abc");
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
if ( i == 1 )
|
||||
{
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
|
||||
|
|
|
@ -5,6 +5,23 @@
|
|||
|
||||
/*===========================================*/
|
||||
|
||||
#define COM_4WSPI 0x0001
|
||||
#define COM_3WSPI 0x0002
|
||||
#define COM_6800 0x0004
|
||||
#define COM_8080 0x0008
|
||||
#define COM_SSDI2C 0x0010
|
||||
|
||||
struct interface
|
||||
{
|
||||
const char *interface_name; /* SW_SPI */
|
||||
const char *setpin_function; /* u8x8_SetPin_4Wire_SW_SPI */
|
||||
const char *arduino_com_procedure; /* u8x8_byte_4wire_sw_spi */
|
||||
const char *arduino_gpio_procedure; /* u8x8_gpio_and_delay_arduino */
|
||||
const char *pins_with_type; /* uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE */
|
||||
const char *pins_plain; /* clock, data, cs, dc, reset */
|
||||
};
|
||||
|
||||
|
||||
struct display
|
||||
{
|
||||
const char *name;
|
||||
|
@ -16,20 +33,21 @@ struct controller
|
|||
int tile_width;
|
||||
int tile_height;
|
||||
const char *cad;
|
||||
unsigned com;
|
||||
struct display display_list[10]; /* usually not used completly, but space does not matter much here */
|
||||
};
|
||||
|
||||
struct controller controller_list[] =
|
||||
{
|
||||
{
|
||||
"ssd1306", 16, 8, "u8x8_cad_001",
|
||||
"ssd1306", 16, 8, "u8x8_cad_001", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080|COM_SSDI2C,
|
||||
{
|
||||
{ "128x64_noname" },
|
||||
{ NULL }
|
||||
}
|
||||
},
|
||||
{
|
||||
"uc1701", 13, 8, "u8x8_cad_001",
|
||||
"uc1701", 13, 8, "u8x8_cad_001", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
|
||||
{
|
||||
{ "dogs102" },
|
||||
{ NULL }
|
||||
|
@ -37,6 +55,27 @@ struct controller controller_list[] =
|
|||
}
|
||||
};
|
||||
|
||||
struct interface interface_list[] =
|
||||
{
|
||||
{
|
||||
"SW_SPI",
|
||||
"u8x8_SetPin_4Wire_SW_SPI",
|
||||
"u8x8_byte_4wire_sw_spi",
|
||||
"u8x8_gpio_and_delay_arduino",
|
||||
"uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE",
|
||||
"clock, data, cs, dc, reset"
|
||||
},
|
||||
{
|
||||
"HW_SPI",
|
||||
"u8x8_SetPin_4Wire_HW_SPI",
|
||||
"u8x8_byte_4wire_hw_spi",
|
||||
"u8x8_gpio_and_delay_arduino",
|
||||
"uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE",
|
||||
"cs, dc, reset"
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*===========================================*/
|
||||
|
||||
|
@ -162,6 +201,54 @@ void do_setup_prototype(FILE *fp, int controller_idx, int display_idx, const cha
|
|||
fprintf(fp, "%s(u8g2_t *u8g2, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb, const u8g2_cb_t *rotation)", postfix);
|
||||
}
|
||||
|
||||
/*===========================================*/
|
||||
/*
|
||||
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 = U8X8_PIN_NONE)
|
||||
{
|
||||
u8g2_Setup_ssd1306_128x64_noname_1(&u8g2, u8x8_byte_4wire_sw_spi, u8x8_gpio_and_delay_arduino, rotation);
|
||||
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
void do_display_interface(int controller_idx, int display_idx, const char *postfix, int interface_idx)
|
||||
{
|
||||
FILE *fp = stdout;
|
||||
fprintf(fp, "class U8G2_");
|
||||
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
|
||||
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].display_list[display_idx].name));
|
||||
fprintf(fp, "%s_", struppercase(postfix));
|
||||
fprintf(fp, "%s", struppercase(interface_list[interface_idx].interface_name));
|
||||
fprintf(fp, " : public U8G2 {\n");
|
||||
fprintf(fp, " public: ");
|
||||
fprintf(fp, "U8G2_");
|
||||
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
|
||||
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].display_list[display_idx].name));
|
||||
fprintf(fp, "%s_", struppercase(postfix));
|
||||
fprintf(fp, "%s", struppercase(interface_list[interface_idx].interface_name));
|
||||
fprintf(fp, "(const u8g2_cb_t *rotation, ");
|
||||
fprintf(fp, "%s) {\n", interface_list[interface_idx].pins_with_type);
|
||||
fprintf(fp, " ");
|
||||
fprintf(fp, "u8g2_Setup_");
|
||||
fprintf(fp, "%s_", strlowercase(controller_list[controller_idx].name));
|
||||
fprintf(fp, "%s_", strlowercase(controller_list[controller_idx].display_list[display_idx].name));
|
||||
fprintf(fp, "%s", postfix);
|
||||
fprintf(fp, "(&u8g2, ");
|
||||
fprintf(fp, "%s, ", interface_list[interface_idx].arduino_com_procedure);
|
||||
fprintf(fp, "%s, ", interface_list[interface_idx].arduino_gpio_procedure);
|
||||
fprintf(fp, "rotation);\n");
|
||||
fprintf(fp, " ");
|
||||
fprintf(fp, "%s(getU8x8(), ", interface_list[interface_idx].setpin_function);
|
||||
fprintf(fp, "%s);\n", interface_list[interface_idx].pins_plain);
|
||||
fprintf(fp, " }\n");
|
||||
fprintf(fp, "}\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*===========================================*/
|
||||
|
||||
void do_display(int controller_idx, int display_idx, const char *postfix)
|
||||
|
@ -183,6 +270,30 @@ void do_display(int controller_idx, int display_idx, const char *postfix)
|
|||
fprintf(setup_code_fp, "u8g2_m_%s_%d_%s(&tile_buf_height);\n", strlowercase(controller_list[controller_idx].name), controller_list[controller_idx].tile_width, postfix);
|
||||
fprintf(setup_code_fp, " u8g2_SetupBuffer(u8g2, buf, tile_buf_height, rotation);\n");
|
||||
fprintf(setup_code_fp, "}\n");
|
||||
|
||||
/* generate interfaces for this display */
|
||||
if ( controller_list[controller_idx].com & COM_4WSPI )
|
||||
{
|
||||
do_display_interface(controller_idx, display_idx, postfix, 0); /* SW SPI */
|
||||
do_display_interface(controller_idx, display_idx, postfix, 1); /* HW SPI */
|
||||
}
|
||||
if ( controller_list[controller_idx].com & COM_3WSPI )
|
||||
{
|
||||
|
||||
}
|
||||
if ( controller_list[controller_idx].com & COM_6800 )
|
||||
{
|
||||
|
||||
}
|
||||
if ( controller_list[controller_idx].com & COM_8080 )
|
||||
{
|
||||
|
||||
}
|
||||
if ( controller_list[controller_idx].com & COM_SSDI2C )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void do_controller_buffer_code(int idx, const char *postfix, int buf_len, int rows)
|
||||
|
|
|
@ -608,11 +608,11 @@ void overview_draw_table(int i, uint16_t x, uint16_t y)
|
|||
u8g2_GetAscent(&u8g2));
|
||||
|
||||
u8g2_SetFont(&u8g2, u8g2_font_7x13_tr);
|
||||
u8g2_DrawString(&u8g2, 0, h, u8g2_font_names[u8g2_fnt_cnt]);
|
||||
u8g2_DrawString(&u8g2, 0, h*2, s);
|
||||
u8g2_DrawStr(&u8g2, 0, h, u8g2_font_names[u8g2_fnt_cnt]);
|
||||
u8g2_DrawStr(&u8g2, 0, h*2, s);
|
||||
|
||||
sprintf(s, "Font Data Size: %d Bytes", u8g2_GetFontSize(u8g2_font_list[u8g2_fnt_cnt]));
|
||||
u8g2_DrawString(&u8g2, 0, h*3, s);
|
||||
u8g2_DrawStr(&u8g2, 0, h*3, s);
|
||||
|
||||
u8g2_SetFont(&u8g2, u8g2_font_list[u8g2_fnt_cnt]);
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
|
@ -632,7 +632,7 @@ void overview_draw_table(int i, uint16_t x, uint16_t y)
|
|||
u8g2_SetFont(&u8g2, u8g2_font_7x13_tr);
|
||||
sprintf(s, "%5d/%04x ", encoding, encoding);
|
||||
|
||||
x = u8g2_DrawString(&u8g2, 0, y, s);
|
||||
x = u8g2_DrawStr(&u8g2, 0, y, s);
|
||||
overview_draw_line(i, encoding, x, y, cw+1);
|
||||
y += ch;
|
||||
}
|
||||
|
@ -647,11 +647,11 @@ void overview_draw_table(int i, uint16_t x, uint16_t y)
|
|||
u8g2_SetFont(&u8g2, u8g2_font_list[u8g2_fnt_cnt]);
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
//y += u8g2_GetMaxCharHeight(&u8g2);
|
||||
u8g2_DrawString(&u8g2, 0, y, "The quick brown fox");
|
||||
u8g2_DrawStr(&u8g2, 0, y, "The quick brown fox");
|
||||
y += u8g2_GetMaxCharHeight(&u8g2);
|
||||
u8g2_DrawString(&u8g2, 0, y, "jumps over the lazy dog.");
|
||||
u8g2_DrawStr(&u8g2, 0, y, "jumps over the lazy dog.");
|
||||
}
|
||||
//u8g2_DrawString(&u8g2, 0, y, "Woven silk pyjamas exchanged for blue quartz");
|
||||
//u8g2_DrawStr(&u8g2, 0, y, "Woven silk pyjamas exchanged for blue quartz");
|
||||
|
||||
}
|
||||
|
||||
|
@ -771,11 +771,11 @@ void overviewshortpic(int i, int fm, char *fms, int bm, char *bms, int mm, char
|
|||
{
|
||||
|
||||
if ( mm == MM_N )
|
||||
u8g2_DrawString(&u8g2, 0, ch, "1234567890");
|
||||
u8g2_DrawStr(&u8g2, 0, ch, "1234567890");
|
||||
else if ( mm == MM_U )
|
||||
u8g2_DrawString(&u8g2, 0, ch, "ABCDEF 123");
|
||||
u8g2_DrawStr(&u8g2, 0, ch, "ABCDEF 123");
|
||||
else
|
||||
u8g2_DrawString(&u8g2, 0, ch, "Abcdefg 123");
|
||||
u8g2_DrawStr(&u8g2, 0, ch, "Abcdefg 123");
|
||||
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue