mirror of
https://github.com/olikraus/U8g2_Arduino.git
synced 2026-07-27 20:06:05 +00:00
update
This commit is contained in:
+7
-2
@@ -43,16 +43,21 @@
|
||||
Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
|
||||
U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.
|
||||
|
||||
This is a frame buffer example.
|
||||
*/
|
||||
|
||||
U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
// Please UNCOMMENT one of the contructor lines below
|
||||
// U8g2 Contructor List (Frame Buffer)
|
||||
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp
|
||||
//U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8G2_UC1701_DOGS102_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_UC1701_DOGS102_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
|
||||
// End of constructor list
|
||||
|
||||
|
||||
void setup(void) {
|
||||
+8
-6
@@ -46,17 +46,19 @@
|
||||
This is a frame buffer example.
|
||||
*/
|
||||
|
||||
//U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R2, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
// Please UNCOMMENT one of the contructor lines below
|
||||
// U8g2 Contructor List (Frame Buffer)
|
||||
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp
|
||||
//U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8G2_UC1701_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
U8G2_UC1701_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
//U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE);
|
||||
//U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE);
|
||||
//U8G2_UC1701_DOGS102_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_UC1701_DOGS102_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
|
||||
// End of constructor list
|
||||
|
||||
//#define MINI_LOGO
|
||||
|
||||
+6
-2
@@ -46,18 +46,22 @@
|
||||
This is a page buffer example.
|
||||
*/
|
||||
|
||||
// Please UNCOMMENT one of the contructor lines below
|
||||
// U8g2 Contructor List (Picture Loop Page Buffer)
|
||||
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp
|
||||
//U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8G2_UC1701_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
U8G2_UC1701_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
U8G2_UC1701_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_UC1701_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
//U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE);
|
||||
//U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE);
|
||||
|
||||
// End of constructor list
|
||||
|
||||
|
||||
|
||||
+9
-1
@@ -46,7 +46,10 @@
|
||||
This is a page buffer example.
|
||||
*/
|
||||
|
||||
U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R2, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
// Please UNCOMMENT one of the contructor lines below
|
||||
// U8g2 Contructor List (Picture Loop Page Buffer)
|
||||
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp
|
||||
//U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8);
|
||||
@@ -54,6 +57,11 @@ U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R2, /* clock=*/ 13, /* data=*/
|
||||
//U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8G2_UC1701_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_UC1701_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
//U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE);
|
||||
//U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE);
|
||||
|
||||
// End of constructor list
|
||||
|
||||
//#define MINI_LOGO
|
||||
|
||||
@@ -41,13 +41,23 @@
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
|
||||
// Please UNCOMMENT one of the contructor lines below
|
||||
// U8x8 Contructor List
|
||||
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8x8setupcpp
|
||||
//U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 2, /* data=*/ 0, /* reset=*/ U8X8_PIN_NONE); /* Digispark ATTiny85 */
|
||||
U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 3, /* data=*/ 2, /* reset=*/ U8X8_PIN_NONE); /* feather 32u4 */
|
||||
//U8X8_SSD1306_128X64_NONAME_6800 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8X8_ST7920_192X32_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
//U8X8_ST7920_192X32_6800 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
//U8X8_UC1701_DOGS102_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_UC1701_DOGS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
|
||||
|
||||
// End of constructor list
|
||||
|
||||
|
||||
void setup(void)
|
||||
|
||||
@@ -42,17 +42,22 @@
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
// Please UNCOMMENT one of the contructor lines below
|
||||
// U8x8 Contructor List
|
||||
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8x8setupcpp
|
||||
//U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 2, /* data=*/ 0, /* reset=*/ U8X8_PIN_NONE); /* Digispark ATTiny85 */
|
||||
//U8X8_SSD1306_128X64_NONAME_6800 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
U8X8_ST7920_192X32_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
//U8X8_ST7920_192X32_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
//U8X8_ST7920_192X32_6800 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
// pin 16 must be low
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8X8_UC1701_DOGS102_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_UC1701_DOGS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
|
||||
|
||||
// End of constructor list
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
|
||||
+34
-5
@@ -55,12 +55,16 @@ class U8G2 : public Print
|
||||
{
|
||||
protected:
|
||||
u8g2_t u8g2;
|
||||
u8x8_char_cb cpp_next_cb; /* the cpp interface has its own decoding function for the Arduino print command */
|
||||
public:
|
||||
u8g2_uint_t tx, ty;
|
||||
|
||||
U8G2(void) { home(); }
|
||||
U8G2(void) { cpp_next_cb = u8x8_ascii_next; home(); }
|
||||
u8x8_t *getU8x8(void) { return u8g2_GetU8x8(&u8g2); }
|
||||
u8g2_t *getU8g2(void) { return &u8g2; }
|
||||
|
||||
void enablePrintUTF8(void) { cpp_next_cb = u8x8_utf8_next; }
|
||||
void disablePrintUTF8(void) { cpp_next_cb = u8x8_ascii_next; }
|
||||
|
||||
/* u8x8 interface */
|
||||
uint8_t getCols(void) { return u8x8_GetCols(u8g2_GetU8x8(&u8g2)); }
|
||||
@@ -80,9 +84,13 @@ class U8G2 : public Print
|
||||
|
||||
void setContrast(uint8_t value) {
|
||||
u8g2_SetContrast(&u8g2, value); }
|
||||
|
||||
void setDisplayRotation(const u8g2_cb_t *u8g2_cb) {
|
||||
u8g2_SetDisplayRotation(&u8g2, u8g2_cb); }
|
||||
|
||||
|
||||
void begin(void) {
|
||||
initDisplay(); clearDisplay(); setPowerSave(0); }
|
||||
initDisplay(); clearDisplay(); setPowerSave(0); u8x8_utf8_init(u8g2_GetU8x8(&u8g2));}
|
||||
|
||||
|
||||
/* u8g2 */
|
||||
@@ -121,6 +129,13 @@ class U8G2 : public Print
|
||||
void drawEllipse(u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t opt = U8G2_DRAW_ALL) { u8g2_DrawEllipse(&u8g2, x0, y0, rx, ry, opt); }
|
||||
void drawFilledEllipse(u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t opt = U8G2_DRAW_ALL) { u8g2_DrawFilledEllipse(&u8g2, x0, y0, rx, ry, opt); }
|
||||
|
||||
/* u8g2_bitmap.c */
|
||||
void drawBitmap(u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t cnt, u8g2_uint_t h, const uint8_t *bitmap)
|
||||
{ u8g2_DrawBitmap(&u8g2, x, y, cnt, h, bitmap); }
|
||||
void drawXBM(u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
|
||||
{ u8g2_DrawXBM(&u8g2, x, y, w, h, bitmap); }
|
||||
|
||||
|
||||
/* u8g2_polygon.c */
|
||||
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2)
|
||||
{ u8g2_DrawTriangle(&u8g2, x0, y0, x1, y1, x2, y2); }
|
||||
@@ -154,17 +169,31 @@ u8g2_uint_t u8g2_GetUTF8Width(u8g2_t *u8g2, const char *str);
|
||||
u8g2_uint_t getStrWidth(const char *s) { return u8g2_GetStrWidth(&u8g2, s); }
|
||||
u8g2_uint_t getUTF8Width(const char *s) { return u8g2_GetUTF8Width(&u8g2, s); }
|
||||
|
||||
void printUTF8(const char *s) { tx += u8g2_DrawUTF8(&u8g2, tx, ty, s); }
|
||||
// not required any more, enable UTF8 for print
|
||||
//void printUTF8(const char *s) { tx += u8g2_DrawUTF8(&u8g2, tx, ty, s); }
|
||||
|
||||
|
||||
/* virtual function for print base class */
|
||||
size_t write(uint8_t v) {
|
||||
tx += u8g2_DrawGlyph(&u8g2, tx, ty, v);
|
||||
uint16_t e = cpp_next_cb(&(u8g2.u8x8), v);
|
||||
|
||||
if ( e < 0x0fffe )
|
||||
tx += u8g2_DrawGlyph(&u8g2, tx, ty, e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t write(const uint8_t *buffer, size_t size) {
|
||||
size_t cnt = 0;
|
||||
while( size > 0 ) {
|
||||
cnt += write(*buffer++);
|
||||
size--;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
/* LiquidCrystal compatible functions */
|
||||
void home(void) { tx = 0; ty = 0; }
|
||||
void home(void) { tx = 0; ty = 0; u8x8_utf8_init(u8g2_GetU8x8(&u8g2)); }
|
||||
void clear(void) { clearBuffer(); home(); }
|
||||
void noDisplay(void) { u8g2_SetPowerSave(&u8g2, 1); }
|
||||
void display(void) { u8g2_SetPowerSave(&u8g2, 0); }
|
||||
|
||||
+16
-7
@@ -151,10 +151,6 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t a
|
||||
|
||||
SPI.end();
|
||||
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_I2C_ADR:
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_DEVICE:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
@@ -178,7 +174,7 @@ void u8x8_SetPin_4Wire_SW_SPI(u8x8_t *u8x8, uint8_t clock, uint8_t data, uint8_t
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _obsolete_com_specific_setup
|
||||
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);
|
||||
@@ -190,6 +186,7 @@ void u8x8_Setup_4Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
#endif /* obsolete com specific setup */
|
||||
|
||||
void u8x8_SetPin_3Wire_SW_SPI(u8x8_t *u8x8, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset)
|
||||
{
|
||||
@@ -199,6 +196,7 @@ void u8x8_SetPin_3Wire_SW_SPI(u8x8_t *u8x8, uint8_t clock, uint8_t data, uint8_t
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
#ifdef _obsolete_com_specific_setup
|
||||
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)
|
||||
{
|
||||
u8x8_Setup(u8x8, display_cb, u8x8_cad_001, u8x8_byte_3wire_sw_spi, u8x8_gpio_and_delay_arduino);
|
||||
@@ -209,6 +207,7 @@ void u8x8_Setup_3Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
#endif /* obsolete com specific setup */
|
||||
|
||||
/*
|
||||
use U8X8_PIN_NONE as value for "reset", if there is no reset line
|
||||
@@ -221,6 +220,7 @@ void u8x8_SetPin_4Wire_HW_SPI(u8x8_t *u8x8, uint8_t cs, uint8_t dc, uint8_t rese
|
||||
}
|
||||
|
||||
|
||||
#ifdef _obsolete_com_specific_setup
|
||||
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);
|
||||
@@ -230,15 +230,17 @@ void u8x8_Setup_4Wire_HW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t cs, u
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
#endif /* obsolete com specific setup */
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
#ifdef _obsolete_com_specific_setup
|
||||
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);
|
||||
@@ -247,8 +249,8 @@ void u8x8_Setup_SSD13xx_SW_I2C(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clo
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_I2C_CLOCK, clock);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_I2C_DATA, data);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
|
||||
}
|
||||
#endif /* obsolete com specific setup */
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -266,6 +268,7 @@ void u8x8_SetPin_8Bit_6800(u8x8_t *u8x8, uint8_t d0, uint8_t d1, uint8_t d2, uin
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
#ifdef _obsolete_com_specific_setup
|
||||
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);
|
||||
@@ -284,6 +287,8 @@ void u8x8_Setup_8Bit_6800(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t d0, uint
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
#endif /* obsolete com specific setup */
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -301,6 +306,8 @@ void u8x8_SetPin_8Bit_8080(u8x8_t *u8x8, uint8_t d0, uint8_t d1, uint8_t d2, uin
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _obsolete_com_specific_setup
|
||||
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);
|
||||
@@ -319,3 +326,5 @@ void u8x8_Setup_8Bit_8080(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t d0, uint
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
#endif /* obsolete com specific setup */
|
||||
|
||||
|
||||
@@ -139,6 +139,15 @@ class U8X8 : public Print
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t write(const uint8_t *buffer, size_t size) {
|
||||
size_t cnt = 0;
|
||||
while( size > 0 ) {
|
||||
cnt += write(*buffer++);
|
||||
size--;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
void inverse(void) { setInverseFont(1); }
|
||||
void noInverse(void) { setInverseFont(0); }
|
||||
|
||||
|
||||
@@ -306,6 +306,7 @@ struct u8g2_struct
|
||||
|
||||
uint8_t draw_color; /* 0: clear pixel, 1: set pixel, modified and restored by font procedures */
|
||||
/* draw_color can be used also directly by the user API */
|
||||
|
||||
|
||||
#ifdef U8G2_WITH_HVLINE_COUNT
|
||||
unsigned long hv_cnt;
|
||||
@@ -330,6 +331,9 @@ struct u8g2_struct
|
||||
#define u8g2_GetDisplayWidth(u8g2) ((u8g2)->width)
|
||||
#define u8g2_GetDrawColor(u8g2) ((u8g2)->draw_color)
|
||||
|
||||
#define u8g2_SetI2CAddress(u8g2, address) ((u8g2_GetU8x8(u8g2))->i2c_address = (address))
|
||||
#define u8g2_GetI2CAddress(u8g2) u8x8_GetI2CAddress(u8g2_GetU8x8(u8g2))
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* u8g2_setup.c */
|
||||
@@ -355,6 +359,7 @@ extern const u8g2_cb_t u8g2_cb_r3;
|
||||
*/
|
||||
|
||||
void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_draw_ll_hvline_cb ll_hvline_cb, const u8g2_cb_t *u8g2_cb);
|
||||
void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
|
||||
|
||||
/*==========================================*/
|
||||
/* u8g2_d_memory.c generated code start */
|
||||
@@ -439,6 +444,13 @@ void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y);
|
||||
void u8g2_SetDrawColor(u8g2_t *u8g2, uint8_t color) U8G2_NOINLINE; /* u8g: u8g_SetColorIndex(u8g_t *u8g, uint8_t idx); */
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* u8g2_bitmap.c */
|
||||
void u8g2_DrawHorizontalBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b);
|
||||
void u8g2_DrawBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t cnt, u8g2_uint_t h, const uint8_t *bitmap);
|
||||
void u8g2_DrawXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap);
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* u8g2_intersection.c */
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
|
||||
u8g2_bitmap.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g2.h"
|
||||
|
||||
/*
|
||||
x,y Position on the display
|
||||
len Length of bitmap line in pixel. Note: This differs from u8glib which had a bytecount here.
|
||||
b Pointer to the bitmap line.
|
||||
*/
|
||||
|
||||
void u8g2_DrawHorizontalBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
|
||||
{
|
||||
uint8_t mask;
|
||||
uint8_t color = u8g2->draw_color;
|
||||
uint8_t ncolor = 1-color;
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
|
||||
return;
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
||||
mask = 128;
|
||||
while(len > 0)
|
||||
{
|
||||
if ( *b & mask )
|
||||
u8g2->draw_color = color;
|
||||
else
|
||||
u8g2->draw_color = ncolor;
|
||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
||||
x++;
|
||||
mask >>= 1;
|
||||
if ( mask == 0 )
|
||||
{
|
||||
mask = 128;
|
||||
b++;
|
||||
}
|
||||
len--;
|
||||
}
|
||||
u8g2->draw_color = color;
|
||||
}
|
||||
|
||||
|
||||
/* u8glib compatible bitmap draw function */
|
||||
void u8g2_DrawBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t cnt, u8g2_uint_t h, const uint8_t *bitmap)
|
||||
{
|
||||
u8g2_uint_t w;
|
||||
w = cnt;
|
||||
w *= 8;
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
||||
return;
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g2_DrawHorizontalBitmap(u8g2, x, y, w, bitmap);
|
||||
bitmap += cnt;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g2_DrawHXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
|
||||
{
|
||||
uint8_t mask;
|
||||
uint8_t color = u8g2->draw_color;
|
||||
uint8_t ncolor = 1-color;
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
|
||||
return;
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
||||
mask = 1;
|
||||
while(len > 0)
|
||||
{
|
||||
if ( *b & mask )
|
||||
u8g2->draw_color = color;
|
||||
else
|
||||
u8g2->draw_color = ncolor;
|
||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
||||
x++;
|
||||
mask <<= 1;
|
||||
if ( mask == 0 )
|
||||
{
|
||||
mask = 1;
|
||||
b++;
|
||||
}
|
||||
len--;
|
||||
}
|
||||
u8g2->draw_color = color;
|
||||
}
|
||||
|
||||
|
||||
void u8g2_DrawXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
|
||||
{
|
||||
u8g2_uint_t blen;
|
||||
blen = w;
|
||||
blen += 7;
|
||||
blen >>= 3;
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
||||
return;
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g2_DrawHXBM(u8g2, x, y, w, bitmap);
|
||||
bitmap += blen;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ static void u8g2_send_tile_row(u8g2_t *u8g2, uint8_t src_tile_row, uint8_t dest_
|
||||
offset *= w;
|
||||
offset *= 8;
|
||||
ptr += offset;
|
||||
|
||||
u8x8_DrawTile(u8g2_GetU8x8(u8g2), 0, dest_tile_row, w, ptr);
|
||||
}
|
||||
|
||||
|
||||
+38
-28
@@ -713,41 +713,46 @@ static u8g2_uint_t u8g2_draw_string(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y,
|
||||
{
|
||||
uint16_t e;
|
||||
u8g2_uint_t delta, sum;
|
||||
u8x8_utf8_init(u8g2_GetU8x8(u8g2));
|
||||
sum = 0;
|
||||
for(;;)
|
||||
{
|
||||
e = u8g2->u8x8.char_cb(&str);
|
||||
if ( e == 0 )
|
||||
e = u8g2->u8x8.next_cb(u8g2_GetU8x8(u8g2), (uint8_t)*str);
|
||||
if ( e == 0x0ffff )
|
||||
break;
|
||||
delta = u8g2_DrawGlyph(u8g2, x, y, e);
|
||||
str++;
|
||||
if ( e != 0x0fffe )
|
||||
{
|
||||
delta = u8g2_DrawGlyph(u8g2, x, y, e);
|
||||
|
||||
#ifdef U8G2_WITH_FONT_ROTATION
|
||||
switch(u8g2->font_decode.dir)
|
||||
{
|
||||
case 0:
|
||||
x += delta;
|
||||
break;
|
||||
case 1:
|
||||
y += delta;
|
||||
break;
|
||||
case 2:
|
||||
x -= delta;
|
||||
break;
|
||||
case 3:
|
||||
y -= delta;
|
||||
break;
|
||||
}
|
||||
switch(u8g2->font_decode.dir)
|
||||
{
|
||||
case 0:
|
||||
x += delta;
|
||||
break;
|
||||
case 1:
|
||||
y += delta;
|
||||
break;
|
||||
case 2:
|
||||
x -= delta;
|
||||
break;
|
||||
case 3:
|
||||
y -= delta;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
x += delta;
|
||||
x += delta;
|
||||
#endif
|
||||
sum += delta;
|
||||
sum += delta;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
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;
|
||||
u8g2->u8x8.next_cb = u8x8_ascii_next;
|
||||
return u8g2_draw_string(u8g2, x, y, str);
|
||||
}
|
||||
|
||||
@@ -763,7 +768,7 @@ Bits from to bytes Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6
|
||||
*/
|
||||
u8g2_uint_t u8g2_DrawUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str)
|
||||
{
|
||||
u8g2->u8x8.char_cb = u8x8_get_encoding_from_utf8_string;
|
||||
u8g2->u8x8.next_cb = u8x8_utf8_next;
|
||||
return u8g2_draw_string(u8g2, x, y, str);
|
||||
}
|
||||
|
||||
@@ -940,23 +945,28 @@ static u8g2_uint_t u8g2_string_width(u8g2_t *u8g2, const char *str)
|
||||
uint16_t e;
|
||||
u8g2_uint_t w;
|
||||
|
||||
u8x8_utf8_init(u8g2_GetU8x8(u8g2));
|
||||
|
||||
/* reset the total width to zero, this will be expanded during calculation */
|
||||
w = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
e = u8g2->u8x8.char_cb(&str);
|
||||
if ( e == 0 )
|
||||
e = u8g2->u8x8.next_cb(u8g2_GetU8x8(u8g2), (uint8_t)*str);
|
||||
if ( e == 0x0ffff )
|
||||
break;
|
||||
w += u8g2_GetGlyphWidth(u8g2, e);
|
||||
|
||||
str++;
|
||||
if ( e != 0x0fffe )
|
||||
{
|
||||
w += u8g2_GetGlyphWidth(u8g2, e);
|
||||
}
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
u8g2_uint_t u8g2_GetStrWidth(u8g2_t *u8g2, const char *s)
|
||||
{
|
||||
u8g2->u8x8.char_cb = u8x8_get_char_from_string;
|
||||
u8g2->u8x8.next_cb = u8x8_ascii_next;
|
||||
return u8g2_string_width(u8g2, s);
|
||||
}
|
||||
|
||||
@@ -972,7 +982,7 @@ Bits from to bytes Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6
|
||||
*/
|
||||
u8g2_uint_t u8g2_GetUTF8Width(u8g2_t *u8g2, const char *str)
|
||||
{
|
||||
u8g2->u8x8.char_cb = u8x8_get_encoding_from_utf8_string;
|
||||
u8g2->u8x8.next_cb = u8x8_utf8_next;
|
||||
return u8g2_string_width(u8g2, str);
|
||||
}
|
||||
|
||||
|
||||
+9
-11
@@ -120,9 +120,11 @@ static void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u
|
||||
|
||||
y -= u8g2->tile_curr_row*8;
|
||||
|
||||
h = u8g2->pixel_buf_height;
|
||||
w = u8g2->pixel_buf_width;
|
||||
|
||||
h = u8g2->pixel_buf_height; // this must be the real buffer height
|
||||
w = u8g2->pixel_buf_width; // this could be replaced by u8g2->u8x8.display_info->pixel_width
|
||||
|
||||
|
||||
if ( dir == 0 )
|
||||
{
|
||||
if ( y >= h )
|
||||
@@ -221,13 +223,13 @@ void u8g2_DrawVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
|
||||
void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
|
||||
{
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
if ( x < u8g2->user_x0 )
|
||||
return;
|
||||
if ( x >= u8g2->user_x1 )
|
||||
return;
|
||||
if ( y < u8g2->user_y0 )
|
||||
return;
|
||||
if ( y >= u8g2->user_y1 )
|
||||
if ( y > u8g2->user_y1 )
|
||||
return;
|
||||
if ( x < u8g2->user_x0 )
|
||||
return;
|
||||
if ( x > u8g2->user_x1 )
|
||||
return;
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
||||
@@ -249,7 +251,3 @@ void u8g2_SetDrawColor(u8g2_t *u8g2, uint8_t color)
|
||||
u8g2->draw_color = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ static void u8g2_draw_pixel_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_u
|
||||
asumption:
|
||||
all clipping done
|
||||
*/
|
||||
void u8g2_ll_hvline_vertical_top_lsb_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
||||
void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
||||
{
|
||||
if ( dir == 0 )
|
||||
{
|
||||
|
||||
+14
-4
@@ -57,6 +57,16 @@ void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Usually the display rotation is set initially, but it could be done later also
|
||||
u8g2_cb can be U8G2_R0..U8G2_R3
|
||||
*/
|
||||
void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
|
||||
{
|
||||
u8g2->cb = u8g2_cb;
|
||||
u8g2->cb->update(u8g2);
|
||||
}
|
||||
|
||||
|
||||
/*============================================*/
|
||||
/*
|
||||
@@ -103,7 +113,7 @@ void u8g2_update_dimension_r0(u8g2_t *u8g2)
|
||||
u8g2_update_dimension_common(u8g2);
|
||||
|
||||
u8g2->user_x0 = 0;
|
||||
u8g2->user_x1 = u8g2->pixel_buf_width;
|
||||
u8g2->user_x1 = u8g2->pixel_buf_width; /* pixel_buf_width replaced with width */
|
||||
|
||||
u8g2->user_y0 = u8g2->buf_y0;
|
||||
u8g2->user_y1 = u8g2->buf_y1;
|
||||
@@ -123,7 +133,7 @@ void u8g2_update_dimension_r1(u8g2_t *u8g2)
|
||||
u8g2->user_x1 = u8g2->buf_y1;
|
||||
|
||||
u8g2->user_y0 = 0;
|
||||
u8g2->user_y1 = u8g2->pixel_buf_width;
|
||||
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (which is the real pixel width) */
|
||||
|
||||
//printf("x0=%d x1=%d y0=%d y1=%d\n",
|
||||
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
|
||||
@@ -134,7 +144,7 @@ void u8g2_update_dimension_r2(u8g2_t *u8g2)
|
||||
u8g2_update_dimension_common(u8g2);
|
||||
|
||||
u8g2->user_x0 = 0;
|
||||
u8g2->user_x1 = u8g2->pixel_buf_width;
|
||||
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
|
||||
|
||||
u8g2->user_y0 = u8g2->height - u8g2->buf_y1;
|
||||
u8g2->user_y1 = u8g2->height - u8g2->buf_y0;
|
||||
@@ -154,7 +164,7 @@ void u8g2_update_dimension_r3(u8g2_t *u8g2)
|
||||
u8g2->user_x1 = u8g2->width - u8g2->buf_y0;
|
||||
|
||||
u8g2->user_y0 = 0;
|
||||
u8g2->user_y1 = u8g2->pixel_buf_width;
|
||||
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (pixel_width) */
|
||||
|
||||
// printf("x0=%d x1=%d y0=%d y1=%d\n",
|
||||
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
|
||||
|
||||
+32
-13
@@ -53,8 +53,8 @@
|
||||
to communicate with the display hardware.
|
||||
This layer only deals with data, commands and arguments. D/C line is unknown.
|
||||
U8X8_MSG_CAD_INIT
|
||||
U8X8_MSG_CAD_SET_I2C_ADR
|
||||
U8X8_MSG_CAD_SET_DEVICE
|
||||
U8X8_MSG_CAD_SET_I2C_ADR (obsolete)
|
||||
U8X8_MSG_CAD_SET_DEVICE (obsolete)
|
||||
U8X8_MSG_CAD_START_TRANSFER
|
||||
U8X8_MSG_CAD_SEND_CMD
|
||||
U8X8_MSG_CAD_SEND_ARG
|
||||
@@ -71,8 +71,8 @@
|
||||
U8X8_MSG_BYTE_SET_DC 31
|
||||
U8X8_MSG_BYTE_START_TRANSFER
|
||||
U8X8_MSG_BYTE_END_TRANSFER
|
||||
U8X8_MSG_BYTE_SET_I2C_ADR
|
||||
U8X8_MSG_BYTE_SET_DEVICE
|
||||
U8X8_MSG_BYTE_SET_I2C_ADR (obsolete)
|
||||
U8X8_MSG_BYTE_SET_DEVICE (obsolete)
|
||||
|
||||
GPIO and Delay
|
||||
U8X8_MSG_GPIO_INIT
|
||||
@@ -120,6 +120,13 @@ extern "C" {
|
||||
/*==========================================*/
|
||||
/* U8G2 internal defines */
|
||||
|
||||
/* the following macro returns the first value for the normal mode */
|
||||
/* or the second argument for the flip mode */
|
||||
#if U8X8_DEFAULT_FLIP_MODE == 0
|
||||
#define U8X8_IF_DEFAULT_NORMAL_OR_FLIP(normal, flipmode) (normal)
|
||||
#else
|
||||
#define U8X8_IF_DEFAULT_NORMAL_OR_FLIP(normal, flipmode) (flipmode)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define U8X8_NOINLINE __attribute__((noinline))
|
||||
@@ -155,7 +162,8 @@ typedef struct u8x8_display_info_struct u8x8_display_info_t;
|
||||
typedef struct u8x8_tile_struct u8x8_tile_t;
|
||||
|
||||
typedef uint8_t (*u8x8_msg_cb)(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
typedef uint16_t (*u8x8_char_cb)(const char **s);
|
||||
typedef uint16_t (*u8x8_char_cb)(u8x8_t *u8x8, uint8_t b);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -221,7 +229,7 @@ struct u8x8_display_info_struct
|
||||
uint8_t default_x_offset; /* default x offset for the display */
|
||||
|
||||
/* pixel width is not used by the u8x8 procedures */
|
||||
/* instead it will be used by the u8g2 procedure, because the pixel dimension can */
|
||||
/* instead it will be used by the u8g2 procedures, because the pixel dimension can */
|
||||
/* not always be calculated from the tile_width/_height */
|
||||
/* the following conditions must be true: */
|
||||
/* pixel_width <= tile_width*8 */
|
||||
@@ -240,16 +248,21 @@ struct u8x8_display_info_struct
|
||||
struct u8x8_struct
|
||||
{
|
||||
const u8x8_display_info_t *display_info;
|
||||
u8x8_char_cb next_cb; /* procedure, which will be used to get the next char from the string */
|
||||
u8x8_msg_cb display_cb;
|
||||
u8x8_msg_cb cad_cb;
|
||||
u8x8_msg_cb byte_cb;
|
||||
u8x8_msg_cb gpio_and_delay_cb;
|
||||
const uint8_t *font;
|
||||
u8x8_char_cb char_cb; /* procedure, which will be used to get the next char from the string */
|
||||
uint16_t encoding; /* encoding result for utf8 decoder in next_cb */
|
||||
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_address; /* a valid i2c adr. Initially this is 255, but this is set to something usefull during DISPLAY_INIT */
|
||||
/* i2c_address is the address for writing data to the display */
|
||||
/* usually, the lowest bit must be zero for a valid address */
|
||||
uint8_t i2c_started; /* for i2c interface */
|
||||
uint8_t device_address; /* this is the device address, replacement for U8X8_MSG_CAD_SET_DEVICE */
|
||||
uint8_t utf8_state; /* number of chars which are still to scan */
|
||||
#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 */
|
||||
#endif
|
||||
@@ -437,8 +450,8 @@ void u8x8_ClearDisplay(u8x8_t *u8x8);
|
||||
/* arg_int: expected cs level after processing this msg */
|
||||
#define U8X8_MSG_CAD_END_TRANSFER 25
|
||||
/* arg_int = 0: disable chip, arg_int = 1: enable chip */
|
||||
#define U8X8_MSG_CAD_SET_I2C_ADR 26
|
||||
#define U8X8_MSG_CAD_SET_DEVICE 27
|
||||
//#define U8X8_MSG_CAD_SET_I2C_ADR 26
|
||||
//#define U8X8_MSG_CAD_SET_DEVICE 27
|
||||
|
||||
|
||||
|
||||
@@ -489,8 +502,8 @@ uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
|
||||
#define U8X8_MSG_BYTE_START_TRANSFER U8X8_MSG_CAD_START_TRANSFER
|
||||
#define U8X8_MSG_BYTE_END_TRANSFER U8X8_MSG_CAD_END_TRANSFER
|
||||
|
||||
#define U8X8_MSG_BYTE_SET_I2C_ADR U8X8_MSG_CAD_SET_I2C_ADR
|
||||
#define U8X8_MSG_BYTE_SET_DEVICE U8X8_MSG_CAD_SET_DEVICE
|
||||
//#define U8X8_MSG_BYTE_SET_I2C_ADR U8X8_MSG_CAD_SET_I2C_ADR
|
||||
//#define U8X8_MSG_BYTE_SET_DEVICE U8X8_MSG_CAD_SET_DEVICE
|
||||
|
||||
|
||||
uint8_t u8x8_byte_SetDC(u8x8_t *u8x8, uint8_t dc) U8X8_NOINLINE;
|
||||
@@ -605,13 +618,19 @@ void utf8_show(void); /* show content of UTF-8 frame buffer */
|
||||
/* u8x8_d_XXX.c */
|
||||
uint8_t u8x8_d_uc1701_dogs102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_sh1106_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7920_192x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_st7920_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
|
||||
/*==========================================*/
|
||||
/* u8x8_8x8.c */
|
||||
uint16_t u8x8_get_encoding_from_utf8_string(const char **str);
|
||||
uint16_t u8x8_get_char_from_string(const char **str);
|
||||
|
||||
void u8x8_utf8_init(u8x8_t *u8x8);
|
||||
uint16_t u8x8_ascii_next(u8x8_t *u8x8, uint8_t b);
|
||||
uint16_t u8x8_utf8_next(u8x8_t *u8x8, uint8_t b);
|
||||
// the following two functions are replaced by the init/next functions
|
||||
//uint16_t u8x8_get_encoding_from_utf8_string(const char **str);
|
||||
//uint16_t u8x8_get_char_from_string(const char **str);
|
||||
|
||||
void u8x8_SetFont(u8x8_t *u8x8, const uint8_t *font_8x8);
|
||||
void u8x8_DrawGlyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding);
|
||||
|
||||
+113
-20
@@ -95,6 +95,7 @@ Bits from to bytes Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6
|
||||
This function returns 0x0ffff for end of string (0x0ffff is not a unicode glyph)
|
||||
|
||||
*/
|
||||
#ifdef OBSOLETE
|
||||
uint16_t u8x8_get_encoding_from_utf8_string(const char **str)
|
||||
{
|
||||
uint16_t e;
|
||||
@@ -133,7 +134,82 @@ uint16_t u8x8_get_encoding_from_utf8_string(const char **str)
|
||||
}
|
||||
return e;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* reset the internal state machine */
|
||||
void u8x8_utf8_init(u8x8_t *u8x8)
|
||||
{
|
||||
u8x8->utf8_state = 0;
|
||||
}
|
||||
|
||||
uint16_t u8x8_ascii_next(u8x8_t *u8x8, uint8_t b)
|
||||
{
|
||||
if ( b == 0 )
|
||||
return 0x0ffff; /* end of string detected*/
|
||||
return b;
|
||||
}
|
||||
|
||||
/*
|
||||
pass a byte from an utf8 encoded string to the utf8 decoder state machine
|
||||
returns
|
||||
0x0fffe: no glyph, just continue
|
||||
0x0ffff: end of string
|
||||
anything else: The decoded encoding
|
||||
*/
|
||||
uint16_t u8x8_utf8_next(u8x8_t *u8x8, uint8_t b)
|
||||
{
|
||||
if ( b == 0 )
|
||||
return 0x0ffff; /* end of string detected, pending UTF8 is discarded */
|
||||
if ( u8x8->utf8_state == 0 )
|
||||
{
|
||||
if ( b >= 0xfc ) /* 6 byte sequence */
|
||||
{
|
||||
u8x8->utf8_state = 5;
|
||||
b &= 1;
|
||||
}
|
||||
else if ( b >= 0xf8 )
|
||||
{
|
||||
u8x8->utf8_state = 4;
|
||||
b &= 3;
|
||||
}
|
||||
else if ( b >= 0xf0 )
|
||||
{
|
||||
u8x8->utf8_state = 3;
|
||||
b &= 7;
|
||||
}
|
||||
else if ( b >= 0xe0 )
|
||||
{
|
||||
u8x8->utf8_state = 2;
|
||||
b &= 15;
|
||||
}
|
||||
else if ( b >= 0xc0 )
|
||||
{
|
||||
u8x8->utf8_state = 1;
|
||||
b &= 0x01f;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* do nothing, just use the value as encoding */
|
||||
return b;
|
||||
}
|
||||
u8x8->encoding = b;
|
||||
return 0x0fffe;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8->utf8_state--;
|
||||
/* The case b < 0x080 (an illegal UTF8 encoding) is not checked here. */
|
||||
u8x8->encoding<<=6;
|
||||
b &= 0x03f;
|
||||
u8x8->encoding |= b;
|
||||
if ( u8x8->utf8_state != 0 )
|
||||
return 0x0fffe; /* nothing to do yet */
|
||||
}
|
||||
return u8x8->encoding;
|
||||
}
|
||||
|
||||
|
||||
#ifdef OBSOLETE
|
||||
uint16_t u8x8_get_char_from_string(const char **str)
|
||||
{
|
||||
uint8_t b = **str;
|
||||
@@ -160,41 +236,58 @@ static uint8_t u8x8_draw_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t u8x8_DrawString(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
||||
static uint8_t u8x8_draw_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s) U8X8_NOINLINE;
|
||||
static uint8_t u8x8_draw_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
||||
{
|
||||
u8x8->char_cb = u8x8_get_char_from_string;
|
||||
return u8x8_draw_string(u8x8, x, y, s);
|
||||
}
|
||||
|
||||
uint8_t u8x8_DrawUTF8(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
||||
{
|
||||
u8x8->char_cb = u8x8_get_encoding_from_utf8_string;
|
||||
return u8x8_draw_string(u8x8, x, y, s);
|
||||
}
|
||||
|
||||
static uint8_t u8x8_strlen(u8x8_t *u8x8, const char *s) U8X8_NOINLINE;
|
||||
static uint8_t u8x8_strlen(u8x8_t *u8x8, const char *s)
|
||||
{
|
||||
uint16_t c;
|
||||
uint16_t e;
|
||||
uint8_t cnt = 0;
|
||||
u8x8_utf8_init(u8x8);
|
||||
for(;;)
|
||||
{
|
||||
c = u8x8->char_cb(&s);
|
||||
if ( c == 0 )
|
||||
e = u8x8->next_cb(u8x8, (uint8_t)*s);
|
||||
if ( e == 0x0ffff )
|
||||
break;
|
||||
if ( c <= 255 )
|
||||
s++;
|
||||
if ( e != 0x0fffe )
|
||||
{
|
||||
u8x8_DrawGlyph(u8x8, x, y, e);
|
||||
x++;
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8x8_DrawString(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
||||
{
|
||||
u8x8->next_cb = u8x8_ascii_next;
|
||||
return u8x8_draw_string(u8x8, x, y, s);
|
||||
}
|
||||
|
||||
uint8_t u8x8_DrawUTF8(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
||||
{
|
||||
u8x8->next_cb = u8x8_utf8_next;
|
||||
return u8x8_draw_string(u8x8, x, y, s);
|
||||
}
|
||||
|
||||
uint8_t u8x8_GetUTF8Len(u8x8_t *u8x8, const char *s)
|
||||
{
|
||||
u8x8->char_cb = u8x8_get_encoding_from_utf8_string;
|
||||
return u8x8_strlen(u8x8, s);
|
||||
uint16_t e;
|
||||
uint8_t cnt = 0;
|
||||
u8x8_utf8_init(u8x8);
|
||||
for(;;)
|
||||
{
|
||||
e = u8x8_utf8_next(u8x8, *s);
|
||||
if ( e == 0x0ffff )
|
||||
break;
|
||||
s++;
|
||||
if ( e != 0x0fffe )
|
||||
cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -83,8 +83,6 @@ uint8_t u8x8_byte_EndTransfer(u8x8_t *u8x8)
|
||||
U8X8_MSG_BYTE_SET_DC
|
||||
U8X8_MSG_BYTE_START_TRANSFER
|
||||
U8X8_MSG_BYTE_END_TRANSFER
|
||||
U8X8_MSG_BYTE_SET_I2C_ADR (ignored)
|
||||
U8X8_MSG_BYTE_SET_DEVICE (ignored)
|
||||
*/
|
||||
|
||||
uint8_t u8x8_byte_4wire_sw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
@@ -138,10 +136,6 @@ uint8_t u8x8_byte_4wire_sw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_I2C_ADR:
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_DEVICE:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -194,10 +188,6 @@ uint8_t u8x8_byte_8bit_6800mode(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_I2C_ADR:
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_DEVICE:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -248,10 +238,6 @@ uint8_t u8x8_byte_8bit_8080mode(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_I2C_ADR:
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_DEVICE:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -315,10 +301,6 @@ uint8_t u8x8_byte_3wire_sw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_I2C_ADR:
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_DEVICE:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -407,10 +389,6 @@ uint8_t u8x8_byte_st7920_sw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_I2C_ADR:
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_DEVICE:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -596,10 +574,6 @@ uint8_t u8x8_byte_ssd13xx_sw_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, voi
|
||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
||||
i2c_stop(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_I2C_ADR:
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_DEVICE:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -637,10 +611,6 @@ uint8_t u8x8_byte_sw_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_p
|
||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
||||
i2c_stop(u8x8);
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_I2C_ADR:
|
||||
break;
|
||||
case U8X8_MSG_BYTE_SET_DEVICE:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -75,10 +75,6 @@ uint8_t u8x8_cad_template(u8x8_t *u8x8, uint8_t msg, uint16_t arg_int, void *arg
|
||||
return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr);
|
||||
case U8X8_MSG_CAD_END_TRANSFER:
|
||||
return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr);
|
||||
case U8X8_MSG_CAD_SET_I2C_ADR:
|
||||
return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr);
|
||||
case U8X8_MSG_CAD_SET_DEVICE:
|
||||
return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -187,8 +183,6 @@ uint8_t u8x8_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
case U8X8_MSG_CAD_INIT:
|
||||
case U8X8_MSG_CAD_START_TRANSFER:
|
||||
case U8X8_MSG_CAD_END_TRANSFER:
|
||||
case U8X8_MSG_CAD_SET_I2C_ADR:
|
||||
case U8X8_MSG_CAD_SET_DEVICE:
|
||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
||||
default:
|
||||
return 0;
|
||||
@@ -221,8 +215,6 @@ uint8_t u8x8_cad_001(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
case U8X8_MSG_CAD_INIT:
|
||||
case U8X8_MSG_CAD_START_TRANSFER:
|
||||
case U8X8_MSG_CAD_END_TRANSFER:
|
||||
case U8X8_MSG_CAD_SET_I2C_ADR:
|
||||
case U8X8_MSG_CAD_SET_DEVICE:
|
||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
||||
default:
|
||||
return 0;
|
||||
@@ -271,8 +263,6 @@ uint8_t u8x8_cad_st7920_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
|
||||
case U8X8_MSG_CAD_INIT:
|
||||
case U8X8_MSG_CAD_START_TRANSFER:
|
||||
case U8X8_MSG_CAD_END_TRANSFER:
|
||||
case U8X8_MSG_CAD_SET_I2C_ADR:
|
||||
case U8X8_MSG_CAD_SET_DEVICE:
|
||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
||||
default:
|
||||
return 0;
|
||||
@@ -310,9 +300,6 @@ uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
|
||||
/* apply default i2c adr if required so that the start transfer msg can use this */
|
||||
if ( u8x8->i2c_address == 255 )
|
||||
u8x8->i2c_address = 0x078;
|
||||
/* fall through */
|
||||
case U8X8_MSG_CAD_SET_I2C_ADR:
|
||||
case U8X8_MSG_CAD_SET_DEVICE:
|
||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
||||
case U8X8_MSG_CAD_START_TRANSFER:
|
||||
case U8X8_MSG_CAD_END_TRANSFER:
|
||||
|
||||
@@ -105,37 +105,18 @@ static const uint8_t u8x8_d_ssd1306_128x64_noname_flip1_seq[] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_128x64_noname_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_takeover_edge = */ 1, /* rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
static uint8_t u8x8_d_ssd1306_sh1106_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t x, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
/* handled by the calling function
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq);
|
||||
@@ -196,3 +177,67 @@ uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_ssd1306_128x64_noname_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_takeover_edge = */ 1, /* rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_sh1106_128x64_noname_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 20,
|
||||
/* pre_chip_disable_wait_ns = */ 10,
|
||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
||||
/* sck_takeover_edge = */ 1, /* rising edge */
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 40,
|
||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 2,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_sh1106_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
||||
{
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_128x64_noname_display_info);
|
||||
return 1;
|
||||
}
|
||||
return u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
||||
@@ -115,13 +115,9 @@ static const u8x8_display_info_t u8x8_uc1701_display_info =
|
||||
/* i2c_bus_clock_100kHz = */ 37,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 13,
|
||||
/* tile_width = */ 13, /* width of 13*8=104 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
#if U8X8_DEFAULT_FLIP_MODE == 0
|
||||
/* default_x_offset = */ 0,
|
||||
#else
|
||||
/* default_x_offset = */ 30,
|
||||
#endif
|
||||
/* default_x_offset = */ U8X8_IF_DEFAULT_NORMAL_OR_FLIP(0, 30),
|
||||
/* pixel_width = */ 102,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
@@ -177,11 +173,22 @@ uint8_t u8x8_d_uc1701_dogs102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
|
||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
c *= 8;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
/*
|
||||
The following if condition checks the hardware limits of the uc1701
|
||||
controller: It is not allowed to write beyond the display limits.
|
||||
This is in fact an issue within flip mode.
|
||||
*/
|
||||
if ( c + x > 132u )
|
||||
{
|
||||
c = 132u;
|
||||
c -= x;
|
||||
}
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ void u8x8_SetupDefaults(u8x8_t *u8x8)
|
||||
u8x8->gpio_and_delay_cb = u8x8_dummy_cb;
|
||||
u8x8->is_font_inverse_mode = 0;
|
||||
u8x8->i2c_address = 255;
|
||||
u8x8->device_address = 0;
|
||||
|
||||
#ifdef U8X8_USE_PINS
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user