diff --git a/README.md b/README.md index 4afc19e5..dffd33fa 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,5 @@ Description: https://github.com/olikraus/u8g2/wiki Issue Tracker: https://github.com/olikraus/u8g2/issues -Download (2.36.5): https://github.com/olikraus/U8g2_Arduino/archive/master.zip +Download (2.36.6): https://github.com/olikraus/U8g2_Arduino/archive/master.zip diff --git a/examples/page_buffer/HelloWorld/HelloWorld.ino b/examples/page_buffer/HelloWorld/HelloWorld.ino index 60df7fc9..0f0fb550 100644 --- a/examples/page_buffer/HelloWorld/HelloWorld.ino +++ b/examples/page_buffer/HelloWorld/HelloWorld.ino @@ -105,7 +105,7 @@ //U8G2_SH1106_128X32_VISIONOX_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X32_VISIONOX_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); -//U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); +U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_128X80_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); @@ -199,7 +199,7 @@ //U8G2_SSD1320_160X132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1320_160X80_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1320_160X80_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); -U8G2_SSD1320_128X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); +//U8G2_SSD1320_128X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1320_128X72_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! diff --git a/library.json b/library.json index be40f955..70c1941b 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/olikraus/u8g2.git" }, - "version": "2.36.5", + "version": "2.36.6", "license": "BSD-2-Clause", "authors": { "name": "Oliver Kraus", diff --git a/library.properties b/library.properties index 6c85a9b0..2a797875 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=U8g2 -version=2.36.5 +version=2.36.6 author=oliver maintainer=oliver sentence=Monochrome LCD, OLED and eInk Library. Display controller: SSD1305, SSD1306, SSD1309, SSD1312, SSD1316, SSD1318, SSD1320, SSD1322, SSD1325, SSD1327, SSD1329, SSD1362, SSD1363, SSD1606, SSD1607, SH1106, SH1107, SH1108, SH1122, T6963, RA8835, LC7981, PCD8544, PCF8812, HX1230, UC1601, UC1604, UC1608, UC1610, UC1611, UC1617, UC1628, UC1638, UC1701, ST7302, ST7511, ST7528, ST7539, ST7565, ST7567, ST7571, ST7586, ST7588, ST75160, ST75161, ST75256, ST75320, NT7534, ST7920, IST3020, IST3088, IST7920, LD7032, KS0108, KS0713, HD44102, T7932, SSD1312, SED1330, SED1520, SBN1661, IL3820, MAX7219, GP1287, GP1247, GP1294, GU800. Interfaces: I2C, SPI, Parallel. diff --git a/src/U8g2lib.h b/src/U8g2lib.h index 9162b781..21a870e2 100644 --- a/src/U8g2lib.h +++ b/src/U8g2lib.h @@ -19703,6 +19703,132 @@ class U8G2_ST7567_ERC13232_F_2ND_HW_I2C : public U8G2 { u8x8_SetPin_HW_I2C(getU8x8(), reset); } }; +class U8G2_ST7567_ERC12864_1_4W_SW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_1_4W_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() { + u8g2_Setup_st7567_erc12864_1(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_1_4W_HW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_1_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_1(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_1_2ND_4W_HW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_1_2ND_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_1(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_1_3W_SW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_1_3W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_1(&u8g2, rotation, u8x8_byte_arduino_3wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset); + } +}; +class U8G2_ST7567_ERC12864_1_3W_HW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_1_3W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_1(&u8g2, rotation, u8x8_byte_arduino_3wire_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_HW_SPI(getU8x8(), cs, reset); + } +}; +class U8G2_ST7567_ERC12864_1_6800 : public U8G2 { + public: U8G2_ST7567_ERC12864_1_6800(const u8g2_cb_t *rotation, 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_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_1(&u8g2, rotation, u8x8_byte_8bit_6800mode, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_8Bit_6800(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_1_8080 : public U8G2 { + public: U8G2_ST7567_ERC12864_1_8080(const u8g2_cb_t *rotation, 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_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_1(&u8g2, rotation, u8x8_byte_arduino_8bit_8080mode, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_2_4W_SW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_2_4W_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() { + u8g2_Setup_st7567_erc12864_2(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_2_4W_HW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_2_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_2(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_2_2ND_4W_HW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_2_2ND_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_2(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_2_3W_SW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_2_3W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_2(&u8g2, rotation, u8x8_byte_arduino_3wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset); + } +}; +class U8G2_ST7567_ERC12864_2_3W_HW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_2_3W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_2(&u8g2, rotation, u8x8_byte_arduino_3wire_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_HW_SPI(getU8x8(), cs, reset); + } +}; +class U8G2_ST7567_ERC12864_2_6800 : public U8G2 { + public: U8G2_ST7567_ERC12864_2_6800(const u8g2_cb_t *rotation, 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_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_2(&u8g2, rotation, u8x8_byte_8bit_6800mode, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_8Bit_6800(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_2_8080 : public U8G2 { + public: U8G2_ST7567_ERC12864_2_8080(const u8g2_cb_t *rotation, 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_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_2(&u8g2, rotation, u8x8_byte_arduino_8bit_8080mode, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_F_4W_SW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_F_4W_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() { + u8g2_Setup_st7567_erc12864_f(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_F_4W_HW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_F_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_f(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_F_2ND_4W_HW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_F_2ND_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_f(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_F_3W_SW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_F_3W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_f(&u8g2, rotation, u8x8_byte_arduino_3wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset); + } +}; +class U8G2_ST7567_ERC12864_F_3W_HW_SPI : public U8G2 { + public: U8G2_ST7567_ERC12864_F_3W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_f(&u8g2, rotation, u8x8_byte_arduino_3wire_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_HW_SPI(getU8x8(), cs, reset); + } +}; +class U8G2_ST7567_ERC12864_F_6800 : public U8G2 { + public: U8G2_ST7567_ERC12864_F_6800(const u8g2_cb_t *rotation, 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_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_f(&u8g2, rotation, u8x8_byte_8bit_6800mode, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_8Bit_6800(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset); + } +}; +class U8G2_ST7567_ERC12864_F_8080 : public U8G2 { + public: U8G2_ST7567_ERC12864_F_8080(const u8g2_cb_t *rotation, 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_PIN_NONE) : U8G2() { + u8g2_Setup_st7567_erc12864_f(&u8g2, rotation, u8x8_byte_arduino_8bit_8080mode, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset); + } +}; class U8G2_ST7567_96X65_1_4W_SW_SPI : public U8G2 { public: U8G2_ST7567_96X65_1_4W_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() { u8g2_Setup_st7567_96x65_1(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); @@ -28631,6 +28757,150 @@ class U8G2_GP1294AI_256X48_F_2ND_4W_HW_SPI : public U8G2 { u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); } }; +class U8G2_SSD1315_128X64_NONAME_1_4W_SW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_1_4W_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() { + u8g2_Setup_ssd1315_128x64_noname_1(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_1_4W_HW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_1_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_1(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_1_2ND_4W_HW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_1_2ND_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_1(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_1_3W_SW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_1_3W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_1(&u8g2, rotation, u8x8_byte_arduino_3wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_1_3W_HW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_1_3W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_1(&u8g2, rotation, u8x8_byte_arduino_3wire_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_HW_SPI(getU8x8(), cs, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_2_4W_SW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_2_4W_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() { + u8g2_Setup_ssd1315_128x64_noname_2(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_2_4W_HW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_2_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_2(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_2_2ND_4W_HW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_2_2ND_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_2(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_2_3W_SW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_2_3W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_2(&u8g2, rotation, u8x8_byte_arduino_3wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_2_3W_HW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_2_3W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_2(&u8g2, rotation, u8x8_byte_arduino_3wire_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_HW_SPI(getU8x8(), cs, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_F_4W_SW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_F_4W_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() { + u8g2_Setup_ssd1315_128x64_noname_f(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_F_4W_HW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_F_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_f(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_F_2ND_4W_HW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_F_2ND_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_f(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_F_3W_SW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_F_3W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_f(&u8g2, rotation, u8x8_byte_arduino_3wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_F_3W_HW_SPI : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_F_3W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_128x64_noname_f(&u8g2, rotation, u8x8_byte_arduino_3wire_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_HW_SPI(getU8x8(), cs, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_1_SW_I2C : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_1_SW_I2C(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_i2c_128x64_noname_1(&u8g2, rotation, u8x8_byte_arduino_sw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_SW_I2C(getU8x8(), clock, data, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_1_HW_I2C : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_1_HW_I2C(const u8g2_cb_t *rotation, uint8_t reset = U8X8_PIN_NONE, uint8_t clock = U8X8_PIN_NONE, uint8_t data = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_i2c_128x64_noname_1(&u8g2, rotation, u8x8_byte_arduino_hw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_HW_I2C(getU8x8(), reset, clock, data); + } +}; +class U8G2_SSD1315_128X64_NONAME_1_2ND_HW_I2C : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_1_2ND_HW_I2C(const u8g2_cb_t *rotation, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_i2c_128x64_noname_1(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_HW_I2C(getU8x8(), reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_2_SW_I2C : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_2_SW_I2C(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_i2c_128x64_noname_2(&u8g2, rotation, u8x8_byte_arduino_sw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_SW_I2C(getU8x8(), clock, data, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_2_HW_I2C : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_2_HW_I2C(const u8g2_cb_t *rotation, uint8_t reset = U8X8_PIN_NONE, uint8_t clock = U8X8_PIN_NONE, uint8_t data = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_i2c_128x64_noname_2(&u8g2, rotation, u8x8_byte_arduino_hw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_HW_I2C(getU8x8(), reset, clock, data); + } +}; +class U8G2_SSD1315_128X64_NONAME_2_2ND_HW_I2C : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_2_2ND_HW_I2C(const u8g2_cb_t *rotation, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_i2c_128x64_noname_2(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_HW_I2C(getU8x8(), reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_F_SW_I2C : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_F_SW_I2C(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_i2c_128x64_noname_f(&u8g2, rotation, u8x8_byte_arduino_sw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_SW_I2C(getU8x8(), clock, data, reset); + } +}; +class U8G2_SSD1315_128X64_NONAME_F_HW_I2C : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_F_HW_I2C(const u8g2_cb_t *rotation, uint8_t reset = U8X8_PIN_NONE, uint8_t clock = U8X8_PIN_NONE, uint8_t data = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_i2c_128x64_noname_f(&u8g2, rotation, u8x8_byte_arduino_hw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_HW_I2C(getU8x8(), reset, clock, data); + } +}; +class U8G2_SSD1315_128X64_NONAME_F_2ND_HW_I2C : public U8G2 { + public: U8G2_SSD1315_128X64_NONAME_F_2ND_HW_I2C(const u8g2_cb_t *rotation, uint8_t reset = U8X8_PIN_NONE) : U8G2() { + u8g2_Setup_ssd1315_i2c_128x64_noname_f(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_HW_I2C(getU8x8(), reset); + } +}; /* Arduino constructor list end */ diff --git a/src/U8x8lib.h b/src/U8x8lib.h index e7348e9c..7b29bd30 100644 --- a/src/U8x8lib.h +++ b/src/U8x8lib.h @@ -6837,6 +6837,48 @@ class U8X8_ST7567_ERC13232_2ND_HW_I2C : public U8X8 { u8x8_SetPin_HW_I2C(getU8x8(), reset); } }; +class U8X8_ST7567_ERC12864_4W_SW_SPI : public U8X8 { + public: U8X8_ST7567_ERC12864_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_st7567_erc12864, u8x8_cad_001, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset); + } +}; +class U8X8_ST7567_ERC12864_4W_HW_SPI : public U8X8 { + public: U8X8_ST7567_ERC12864_4W_HW_SPI(uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_st7567_erc12864, u8x8_cad_001, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8X8_ST7567_ERC12864_2ND_4W_HW_SPI : public U8X8 { + public: U8X8_ST7567_ERC12864_2ND_4W_HW_SPI(uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_st7567_erc12864, u8x8_cad_001, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8X8_ST7567_ERC12864_3W_SW_SPI : public U8X8 { + public: U8X8_ST7567_ERC12864_3W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_st7567_erc12864, u8x8_cad_001, u8x8_byte_arduino_3wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset); + } +}; +class U8X8_ST7567_ERC12864_3W_HW_SPI : public U8X8 { + public: U8X8_ST7567_ERC12864_3W_HW_SPI(uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_st7567_erc12864, u8x8_cad_001, u8x8_byte_arduino_3wire_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_HW_SPI(getU8x8(), cs, reset); + } +}; +class U8X8_ST7567_ERC12864_6800 : public U8X8 { + public: U8X8_ST7567_ERC12864_6800(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_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_st7567_erc12864, u8x8_cad_001, u8x8_byte_8bit_6800mode, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_8Bit_6800(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset); + } +}; +class U8X8_ST7567_ERC12864_8080 : public U8X8 { + public: U8X8_ST7567_ERC12864_8080(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_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_st7567_erc12864, u8x8_cad_001, u8x8_byte_arduino_8bit_8080mode, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset); + } +}; class U8X8_ST7567_96X65_4W_SW_SPI : public U8X8 { public: U8X8_ST7567_96X65_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() { u8x8_Setup(getU8x8(), u8x8_d_st7567_96x65, u8x8_cad_001, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); @@ -9813,6 +9855,54 @@ class U8X8_GP1294AI_256X48_2ND_4W_HW_SPI : public U8X8 { u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); } }; +class U8X8_SSD1315_128X64_NONAME_4W_SW_SPI : public U8X8 { + public: U8X8_SSD1315_128X64_NONAME_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_ssd1315_128x64_noname, u8x8_cad_001, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset); + } +}; +class U8X8_SSD1315_128X64_NONAME_4W_HW_SPI : public U8X8 { + public: U8X8_SSD1315_128X64_NONAME_4W_HW_SPI(uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_ssd1315_128x64_noname, u8x8_cad_001, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8X8_SSD1315_128X64_NONAME_2ND_4W_HW_SPI : public U8X8 { + public: U8X8_SSD1315_128X64_NONAME_2ND_4W_HW_SPI(uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_ssd1315_128x64_noname, u8x8_cad_001, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset); + } +}; +class U8X8_SSD1315_128X64_NONAME_3W_SW_SPI : public U8X8 { + public: U8X8_SSD1315_128X64_NONAME_3W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_ssd1315_128x64_noname, u8x8_cad_001, u8x8_byte_arduino_3wire_sw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset); + } +}; +class U8X8_SSD1315_128X64_NONAME_3W_HW_SPI : public U8X8 { + public: U8X8_SSD1315_128X64_NONAME_3W_HW_SPI(uint8_t cs, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_ssd1315_128x64_noname, u8x8_cad_001, u8x8_byte_arduino_3wire_hw_spi, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_3Wire_HW_SPI(getU8x8(), cs, reset); + } +}; +class U8X8_SSD1315_128X64_NONAME_SW_I2C : public U8X8 { + public: U8X8_SSD1315_128X64_NONAME_SW_I2C(uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_ssd1315_128x64_noname, u8x8_cad_ssd13xx_fast_i2c, u8x8_byte_arduino_sw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_SW_I2C(getU8x8(), clock, data, reset); + } +}; +class U8X8_SSD1315_128X64_NONAME_HW_I2C : public U8X8 { + public: U8X8_SSD1315_128X64_NONAME_HW_I2C(uint8_t reset = U8X8_PIN_NONE, uint8_t clock = U8X8_PIN_NONE, uint8_t data = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_ssd1315_128x64_noname, u8x8_cad_ssd13xx_fast_i2c, u8x8_byte_arduino_hw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_HW_I2C(getU8x8(), reset, clock, data); + } +}; +class U8X8_SSD1315_128X64_NONAME_2ND_HW_I2C : public U8X8 { + public: U8X8_SSD1315_128X64_NONAME_2ND_HW_I2C(uint8_t reset = U8X8_PIN_NONE) : U8X8() { + u8x8_Setup(getU8x8(), u8x8_d_ssd1315_128x64_noname, u8x8_cad_ssd13xx_fast_i2c, u8x8_byte_arduino_2nd_hw_i2c, u8x8_gpio_and_delay_arduino); + u8x8_SetPin_HW_I2C(getU8x8(), reset); + } +}; // constructor list end diff --git a/src/clib/mui_u8g2.c b/src/clib/mui_u8g2.c index 140e284b..115197e6 100644 --- a/src/clib/mui_u8g2.c +++ b/src/clib/mui_u8g2.c @@ -1360,6 +1360,234 @@ uint8_t mui_u8g2_s8_min_max_wm_mud_pf(mui_t *ui, uint8_t msg) } +/*===============================================================================*/ +/* x8 min max */ + +static void mui_u8g2_x8_vmm_draw_wm_pi(mui_t *ui) MUI_NOINLINE; +static void mui_u8g2_x8_vmm_draw_wm_pi(mui_t *ui) +{ + u8g2_t *u8g2 = mui_get_U8g2(ui); + mui_u8g2_u8_min_max_t *vmm= (mui_u8g2_u8_min_max_t *)muif_get_data(ui->uif); + char buf[3] = "FF"; + char *s = buf; + uint8_t *value = mui_u8g2_u8mm_get_valptr(vmm); + uint8_t min = mui_u8g2_u8mm_get_min(vmm); + uint8_t max = mui_u8g2_u8mm_get_max(vmm); + uint8_t cnt = 2; + + if ( *value > max ) + *value = max; + if ( *value <= min ) + *value = min; + if ( max < 16 ) + { + s++; + cnt--; + } + mui_u8g2_draw_button_pi(ui, u8g2_GetStrWidth(u8g2, s)+1, 1, u8x8_u8tox(*value, cnt)); +} + + +uint8_t mui_x8g2_x8_min_max_wm_mse_pi(mui_t *ui, uint8_t msg) +{ + mui_u8g2_u8_min_max_t *vmm= (mui_u8g2_u8_min_max_t *)muif_get_data(ui->uif); + uint8_t *value = mui_u8g2_u8mm_get_valptr(vmm); + uint8_t min = mui_u8g2_u8mm_get_min(vmm); + uint8_t max = mui_u8g2_u8mm_get_max(vmm); + switch(msg) + { + case MUIF_MSG_DRAW: + mui_u8g2_x8_vmm_draw_wm_pi(ui); + break; + case MUIF_MSG_FORM_START: + break; + case MUIF_MSG_FORM_END: + break; + case MUIF_MSG_CURSOR_ENTER: + break; + case MUIF_MSG_CURSOR_SELECT: + case MUIF_MSG_VALUE_INCREMENT: + (*value)++; + if ( *value > max ) *value = min; + break; + case MUIF_MSG_VALUE_DECREMENT: + if ( *value > min ) (*value)--; else *value = max; + break; + case MUIF_MSG_CURSOR_LEAVE: + break; + case MUIF_MSG_TOUCH_DOWN: + break; + case MUIF_MSG_TOUCH_UP: + break; + } + return 0; +} + +uint8_t mui_u8g2_x8_min_max_wm_mud_pi(mui_t *ui, uint8_t msg) +{ + mui_u8g2_u8_min_max_t *vmm= (mui_u8g2_u8_min_max_t *)muif_get_data(ui->uif); + uint8_t *value = mui_u8g2_u8mm_get_valptr(vmm); + uint8_t min = mui_u8g2_u8mm_get_min(vmm); + uint8_t max = mui_u8g2_u8mm_get_max(vmm); + switch(msg) + { + case MUIF_MSG_DRAW: + mui_u8g2_x8_vmm_draw_wm_pi(ui); + break; + case MUIF_MSG_FORM_START: + break; + case MUIF_MSG_FORM_END: + break; + case MUIF_MSG_CURSOR_ENTER: + break; + case MUIF_MSG_CURSOR_SELECT: + case MUIF_MSG_VALUE_INCREMENT: + case MUIF_MSG_VALUE_DECREMENT: + /* toggle between normal mode and capture next/prev mode */ + ui->is_mud = !ui->is_mud; + break; + case MUIF_MSG_CURSOR_LEAVE: + break; + case MUIF_MSG_TOUCH_DOWN: + break; + case MUIF_MSG_TOUCH_UP: + break; + case MUIF_MSG_EVENT_NEXT: + if ( ui->is_mud ) + { + (*value)++; + if ( *value > max ) + *value = min; + return 1; + } + break; + case MUIF_MSG_EVENT_PREV: + if ( ui->is_mud ) + { + if ( *value <= min ) + *value = max; + else + (*value)--; + return 1; + } + break; + } + return 0; +} + + + +static void mui_u8g2_x8_vmm_draw_wm_pf(mui_t *ui) MUI_NOINLINE; +static void mui_u8g2_x8_vmm_draw_wm_pf(mui_t *ui) +{ + u8g2_t *u8g2 = mui_get_U8g2(ui); + mui_u8g2_u8_min_max_t *vmm= (mui_u8g2_u8_min_max_t *)muif_get_data(ui->uif); + char buf[3] = "FF"; + char *s = buf; + uint8_t *value = mui_u8g2_u8mm_get_valptr(vmm); + uint8_t min = mui_u8g2_u8mm_get_min(vmm); + uint8_t max = mui_u8g2_u8mm_get_max(vmm); + uint8_t cnt = 2; + + if ( *value > max ) + *value = max; + if ( *value <= min ) + *value = min; + if ( max < 16 ) + { + s++; + cnt--; + } + mui_u8g2_draw_button_pf(ui, u8g2_GetStrWidth(u8g2, s)+1, 1, u8x8_u8tox(*value, cnt)); +} + + +uint8_t mui_u8g2_x8_min_max_wm_mse_pf(mui_t *ui, uint8_t msg) +{ + mui_u8g2_u8_min_max_t *vmm= (mui_u8g2_u8_min_max_t *)muif_get_data(ui->uif); + uint8_t *value = mui_u8g2_u8mm_get_valptr(vmm); + uint8_t min = mui_u8g2_u8mm_get_min(vmm); + uint8_t max = mui_u8g2_u8mm_get_max(vmm); + switch(msg) + { + case MUIF_MSG_DRAW: + mui_u8g2_x8_vmm_draw_wm_pf(ui); + break; + case MUIF_MSG_FORM_START: + break; + case MUIF_MSG_FORM_END: + break; + case MUIF_MSG_CURSOR_ENTER: + break; + case MUIF_MSG_CURSOR_SELECT: + case MUIF_MSG_VALUE_INCREMENT: + (*value)++; + if ( *value > max ) *value = min; + break; + case MUIF_MSG_VALUE_DECREMENT: + if ( *value > min ) (*value)--; else *value = max; + break; + case MUIF_MSG_CURSOR_LEAVE: + break; + case MUIF_MSG_TOUCH_DOWN: + break; + case MUIF_MSG_TOUCH_UP: + break; + } + return 0; +} + +uint8_t mui_u8g2_x8_min_max_wm_mud_pf(mui_t *ui, uint8_t msg) +{ + mui_u8g2_u8_min_max_t *vmm= (mui_u8g2_u8_min_max_t *)muif_get_data(ui->uif); + uint8_t *value = mui_u8g2_u8mm_get_valptr(vmm); + uint8_t min = mui_u8g2_u8mm_get_min(vmm); + uint8_t max = mui_u8g2_u8mm_get_max(vmm); + switch(msg) + { + case MUIF_MSG_DRAW: + mui_u8g2_x8_vmm_draw_wm_pf(ui); + break; + case MUIF_MSG_FORM_START: + break; + case MUIF_MSG_FORM_END: + break; + case MUIF_MSG_CURSOR_ENTER: + break; + case MUIF_MSG_CURSOR_SELECT: + case MUIF_MSG_VALUE_INCREMENT: + case MUIF_MSG_VALUE_DECREMENT: + /* toggle between normal mode and capture next/prev mode */ + ui->is_mud = !ui->is_mud; + break; + case MUIF_MSG_CURSOR_LEAVE: + break; + case MUIF_MSG_TOUCH_DOWN: + break; + case MUIF_MSG_TOUCH_UP: + break; + case MUIF_MSG_EVENT_NEXT: + if ( ui->is_mud ) + { + (*value)++; + if ( *value > max ) + *value = min; + return 1; + } + break; + case MUIF_MSG_EVENT_PREV: + if ( ui->is_mud ) + { + if ( *value <= min ) + *value = max; + else + (*value)--; + return 1; + } + break; + } + return 0; +} diff --git a/src/clib/mui_u8g2.h b/src/clib/mui_u8g2.h index 22e2cf33..0f5e1fec 100644 --- a/src/clib/mui_u8g2.h +++ b/src/clib/mui_u8g2.h @@ -283,6 +283,12 @@ uint8_t mui_u8g2_u8_min_max_wm_mud_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G uint8_t mui_u8g2_u8_min_max_wm_mse_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */ uint8_t mui_u8g2_u8_min_max_wm_mud_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */ +/* hex format */ +uint8_t mui_u8g2_x8_min_max_wm_mse_pi(mui_t *ui, uint8_t msg); +uint8_t mui_u8g2_x8_min_max_wm_mud_pi(mui_t *ui, uint8_t msg); +uint8_t mui_u8g2_x8_min_max_wm_mse_pf(mui_t *ui, uint8_t msg); +uint8_t mui_u8g2_x8_min_max_wm_mud_pf(mui_t *ui, uint8_t msg); + #define MUIF_U8G2_S8_MIN_MAX(id, valptr, min, max, muif) \ MUIF(id, MUIF_CFLAG_IS_CURSOR_SELECTABLE, \ (void *)((mui_u8g2_s8_min_max_t [] ) {{ (valptr) MUI_U8G2_COMMA (min) MUI_U8G2_COMMA (max)}}), \ diff --git a/src/clib/u8g2.h b/src/clib/u8g2.h index e7aa6277..fa866a35 100644 --- a/src/clib/u8g2.h +++ b/src/clib/u8g2.h @@ -1367,6 +1367,9 @@ void u8g2_Setup_st7567_erc13232_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ void u8g2_Setup_st7567_i2c_erc13232_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); void u8g2_Setup_st7567_i2c_erc13232_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); void u8g2_Setup_st7567_i2c_erc13232_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_st7567_erc12864_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_st7567_erc12864_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_st7567_erc12864_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); void u8g2_Setup_st7567_96x65_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); void u8g2_Setup_st7567_96x65_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); void u8g2_Setup_st7567_96x65_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); @@ -1718,6 +1721,12 @@ void u8g2_Setup_gp1294ai_256x48_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ void u8g2_Setup_a2printer_384x240_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); void u8g2_Setup_a2printer_384x240_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); void u8g2_Setup_a2printer_384x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_ssd1315_128x64_noname_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_ssd1315_128x64_noname_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_ssd1315_128x64_noname_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_ssd1315_i2c_128x64_noname_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_ssd1315_i2c_128x64_noname_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_ssd1315_i2c_128x64_noname_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); /* u8g2_d_setup.c generated code end */ diff --git a/src/clib/u8g2_d_setup.c b/src/clib/u8g2_d_setup.c index 93be0ada..8aea4fb0 100644 --- a/src/clib/u8g2_d_setup.c +++ b/src/clib/u8g2_d_setup.c @@ -6189,6 +6189,34 @@ void u8g2_Setup_st7567_i2c_erc13232_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u } /* st7567 */ /* st7567 1 */ +void u8g2_Setup_st7567_erc12864_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_st7567_erc12864, u8x8_cad_001, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_16_8_1(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); +} +/* st7567 2 */ +void u8g2_Setup_st7567_erc12864_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_st7567_erc12864, u8x8_cad_001, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_16_8_2(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); +} +/* st7567 f */ +void u8g2_Setup_st7567_erc12864_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_st7567_erc12864, u8x8_cad_001, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_16_8_f(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); +} +/* st7567 */ +/* st7567 1 */ void u8g2_Setup_st7567_96x65_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) { uint8_t tile_buf_height; @@ -9383,4 +9411,60 @@ void u8g2_Setup_a2printer_384x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x buf = u8g2_m_48_30_f(&tile_buf_height); u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation); } +/* ssd1315 */ +/* ssd1315 1 */ +void u8g2_Setup_ssd1315_128x64_noname_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_ssd1315_128x64_noname, u8x8_cad_001, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_16_8_1(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); +} +/* ssd1315 2 */ +void u8g2_Setup_ssd1315_128x64_noname_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_ssd1315_128x64_noname, u8x8_cad_001, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_16_8_2(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); +} +/* ssd1315 f */ +void u8g2_Setup_ssd1315_128x64_noname_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_ssd1315_128x64_noname, u8x8_cad_001, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_16_8_f(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); +} +/* ssd1315 */ +/* ssd1315 1 */ +void u8g2_Setup_ssd1315_i2c_128x64_noname_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_ssd1315_128x64_noname, u8x8_cad_ssd13xx_fast_i2c, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_16_8_1(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); +} +/* ssd1315 2 */ +void u8g2_Setup_ssd1315_i2c_128x64_noname_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_ssd1315_128x64_noname, u8x8_cad_ssd13xx_fast_i2c, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_16_8_2(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); +} +/* ssd1315 f */ +void u8g2_Setup_ssd1315_i2c_128x64_noname_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_ssd1315_128x64_noname, u8x8_cad_ssd13xx_fast_i2c, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_16_8_f(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); +} /* end of generated code */ diff --git a/src/clib/u8g2_selection_list.c b/src/clib/u8g2_selection_list.c index a74e2bd2..bd2092f2 100644 --- a/src/clib/u8g2_selection_list.c +++ b/src/clib/u8g2_selection_list.c @@ -63,6 +63,11 @@ void u8g2_DrawUTF8Line(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w /* calculate the width of the string in pixel */ str_width = u8g2_GetUTF8Width(u8g2, s); +#ifdef U8G2_BALANCED_STR_WIDTH_CALCULATION + /* subtract the first character offset added by the width calculation */ + str_width -= u8g2_GetXOffsetUTF8(u8g2, s); +#endif + /* calculate delta d within the box */ d = 0; if ( str_width < w ) diff --git a/src/clib/u8x8.h b/src/clib/u8x8.h index 99d951a3..0ef8f23e 100644 --- a/src/clib/u8x8.h +++ b/src/clib/u8x8.h @@ -923,6 +923,7 @@ uint8_t u8x8_d_st7567_64x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar uint8_t u8x8_d_st7567_hem6432(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_d_st7567_os12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_d_st7567_erc13232(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); +uint8_t u8x8_d_st7567_erc12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_d_st7567_lw12832(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_d_st7567_yxd12832(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_d_st7567_96x65(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); @@ -1059,7 +1060,7 @@ uint8_t u8x8_d_gu800_160x16(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar uint8_t u8x8_d_gp1287ai_256x50(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_d_gp1247ai_253x63(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_d_gp1294ai_256x48(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); - +uint8_t u8x8_d_ssd1315_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /*==========================================*/ @@ -1093,6 +1094,7 @@ uint8_t u8x8_GetUTF8Len(u8x8_t *u8x8, const char *s); /* itoa procedures */ const char *u8x8_u8toa(uint8_t v, uint8_t d); const char *u8x8_s8toa(int8_t v, uint8_t d); +const char *u8x8_u8tox(uint8_t v, uint8_t d); const char *u8x8_u16toa(uint16_t v, uint8_t d); const char *u8x8_utoa(uint16_t v); diff --git a/src/clib/u8x8_d_ssd1315_128x64_noname.c b/src/clib/u8x8_d_ssd1315_128x64_noname.c new file mode 100644 index 00000000..8862b83a --- /dev/null +++ b/src/clib/u8x8_d_ssd1315_128x64_noname.c @@ -0,0 +1,215 @@ +/* + + u8x8_d_ssd1315_128x64_noname.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 "u8x8.h" + +/* more or less generic setup of all these small OLEDs */ +static const uint8_t u8x8_d_ssd1315_128x64_noname_init_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + + U8X8_C(0x0ae), /* display off */ + U8X8_CA(0x0d5, 0x090), /* Set Display Clock Divide */ + U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */ + U8X8_CA(0x0d3, 0x000), /* display offset */ + U8X8_C(0x040), /* set display start line to 0 */ + U8X8_C(0x0a1), /* segment remap a0/a1*/ + U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ + U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */ + U8X8_CA(0x081, 0x07f), /* set contrast control */ + U8X8_CA(0x0d9, 0x022), /* pre-charge period 0x022/f1*/ + U8X8_CA(0x0db, 0x030), /* vcomh deselect level */ + U8X8_C(0x0a4), /* output ram to display */ + U8X8_C(0x0a6), /* none inverted normal display mode */ + U8X8_CA(0x0ad, 0x010), /* Select External or Internal Iref: 0x20 External Iref = 200kΩ = (9 - 3) / 30uA, 0x10 or 0x30 Internal Iref */ + U8X8_CA(0x08d, 0x014), /* charge pump setting: 0x14 enable, VCC=7.5V, 0x00 disable */ + + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_ssd1315_128x64_noname_powersave0_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0af), /* display on */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_ssd1315_128x64_noname_powersave1_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0ae), /* display off */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_ssd1315_128x64_noname_flip0_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0a1), /* segment remap a0/a1*/ + U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_ssd1315_128x64_noname_flip1_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0a0), /* segment remap a0/a1*/ + U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + + +static uint8_t u8x8_d_ssd1315_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; + */ + /* handled by the calling function + case U8X8_MSG_DISPLAY_INIT: + u8x8_d_helper_display_init(u8x8); + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq); + break; + */ + case U8X8_MSG_DISPLAY_SET_POWER_SAVE: + if ( arg_int == 0 ) + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1315_128x64_noname_powersave0_seq); + else + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1315_128x64_noname_powersave1_seq); + break; + case U8X8_MSG_DISPLAY_SET_FLIP_MODE: + if ( arg_int == 0 ) + { + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1315_128x64_noname_flip0_seq); + u8x8->x_offset = u8x8->display_info->default_x_offset; + } + else + { + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1315_128x64_noname_flip1_seq); + u8x8->x_offset = u8x8->display_info->flipmode_x_offset; + } + break; +#ifdef U8X8_WITH_SET_CONTRAST + case U8X8_MSG_DISPLAY_SET_CONTRAST: + u8x8_cad_StartTransfer(u8x8); + u8x8_cad_SendCmd(u8x8, 0x081 ); + u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */ + u8x8_cad_EndTransfer(u8x8); + break; +#endif + case U8X8_MSG_DISPLAY_DRAW_TILE: + u8x8_cad_StartTransfer(u8x8); + x = ((u8x8_tile_t *)arg_ptr)->x_pos; + x *= 8; + x += u8x8->x_offset; + + u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */ + + u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) ); + u8x8_cad_SendArg(u8x8, 0x000 | ((x&15))); /* probably wrong, should be SendCmd */ + u8x8_cad_SendArg(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */ + + 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 */ + /* + do + { + u8x8_cad_SendData(u8x8, 8, ptr); + ptr += 8; + c--; + } while( c > 0 ); + */ + arg_int--; + } while( arg_int > 0 ); + + u8x8_cad_EndTransfer(u8x8); + break; + default: + return 0; + } + return 1; +} + +static const u8x8_display_info_t u8x8_ssd1315_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_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ + /* spi_mode = */ 0, /* active high, 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_height = */ 8, + /* default_x_offset = */ 0, + /* flipmode_x_offset = */ 0, + /* pixel_width = */ 128, + /* pixel_height = */ 64 +}; + +uint8_t u8x8_d_ssd1315_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + + if ( u8x8_d_ssd1315_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) + return 1; + + switch(msg) + { + case U8X8_MSG_DISPLAY_INIT: + u8x8_d_helper_display_init(u8x8); + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1315_128x64_noname_init_seq); + break; + case U8X8_MSG_DISPLAY_SETUP_MEMORY: + u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1315_128x64_noname_display_info); + break; + default: + return 0; + } + return 1; +} diff --git a/src/clib/u8x8_d_st7305.c b/src/clib/u8x8_d_st7305.c new file mode 100644 index 00000000..0fc368c4 --- /dev/null +++ b/src/clib/u8x8_d_st7305.c @@ -0,0 +1,503 @@ +/* + + u8x8_d_st7305.c + + Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) + + Copyright (c) 2025, 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. + + + st7305: 240 x 320 122x250 + st7305: 264 x 320 168x384 + Mono TFT Display Driver with Controller + + st7305 seems to be almost compatible to the st7305, however they have a different memory architecture + + https://github.com/olikraus/u8g2/issues/2436 + + No Hardware Flip + No U8x8 Support + +*/ + + +#include "u8x8.h" +#include + +static const uint8_t u8x8_d_st7305_122x250_powersave0_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x29), // display on + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_st7305_122x250_powersave1_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x028), /* display off */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_st7305_122x250_flip0_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + //U8X8_CA(0x36, 0x60), // Memory Control + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_st7305_122x250_flip1_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + //U8X8_CA(0x36, 0xa0), // Memory Control + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + + + + +/*===================================================*/ +/* see also: http://www.technoblogy.com/show?3YB0 */ + + +#ifdef NOT_USED +static uint8_t *u8x8_st7305_convert_60(u8x8_t *u8x8, uint8_t *p) +{ + static uint8_t buf[6]; + uint8_t bytes_per_row = u8x8->display_info->tile_width; + + + memset(buf, 0, 6); + + // U8X8_CA(0x36, 0x60), // Memory Control + + + // first row, left 12 pixel + + if ( p[0] & 0x80 ) + buf[2] |= 0x02; + if ( p[0] & 0x40 ) + buf[2] |= 0x08; + if ( p[0] & 0x20 ) + buf[2] |= 0x20; + if ( p[0] & 0x10 ) + buf[2] |= 0x80; + + if ( p[0] & 0x08 ) + buf[1] |= 0x02; + if ( p[0] & 0x04 ) + buf[1] |= 0x08; + if ( p[0] & 0x02 ) + buf[1] |= 0x20; + if ( p[0] & 0x01 ) + buf[1] |= 0x80; + + if ( p[1] & 0x80 ) + buf[0] |= 0x02; + if ( p[1] & 0x40 ) + buf[0] |= 0x08; + if ( p[1] & 0x20 ) + buf[0] |= 0x20; + if ( p[1] & 0x10 ) + buf[0] |= 0x80; + + // first row, right 12 pixel + + if ( p[1] & 0x08 ) + buf[5] |= 0x02; + if ( p[1] & 0x04 ) + buf[5] |= 0x08; + if ( p[1] & 0x02 ) + buf[5] |= 0x20; + if ( p[1] & 0x01 ) + buf[5] |= 0x80; + + if ( p[2] & 0x80 ) + buf[4] |= 0x02; + if ( p[2] & 0x40 ) + buf[4] |= 0x08; + if ( p[2] & 0x20 ) + buf[4] |= 0x20; + if ( p[2] & 0x10 ) + buf[4] |= 0x80; + + if ( p[2] & 0x08 ) + buf[3] |= 0x02; + if ( p[2] & 0x04 ) + buf[3] |= 0x08; + if ( p[2] & 0x02 ) + buf[3] |= 0x20; + if ( p[2] & 0x01 ) + buf[3] |= 0x80; + + p += u8x8->display_info->tile_width; + + // second row, left 12 pixel + + if ( p[0] & 0x80 ) + buf[2] |= 0x01; + if ( p[0] & 0x40 ) + buf[2] |= 0x04; + if ( p[0] & 0x20 ) + buf[2] |= 0x10; + if ( p[0] & 0x10 ) + buf[2] |= 0x40; + + if ( p[0] & 0x08 ) + buf[1] |= 0x01; + if ( p[0] & 0x04 ) + buf[1] |= 0x04; + if ( p[0] & 0x02 ) + buf[1] |= 0x10; + if ( p[0] & 0x01 ) + buf[1] |= 0x40; + + if ( p[1] & 0x80 ) + buf[0] |= 0x01; + if ( p[1] & 0x40 ) + buf[0] |= 0x04; + if ( p[1] & 0x20 ) + buf[0] |= 0x10; + if ( p[1] & 0x10 ) + buf[0] |= 0x40; + + // second row, right 12 pixel + + if ( p[1] & 0x08 ) + buf[5] |= 0x01; + if ( p[1] & 0x04 ) + buf[5] |= 0x04; + if ( p[1] & 0x02 ) + buf[5] |= 0x10; + if ( p[1] & 0x01 ) + buf[5] |= 0x40; + + if ( p[2] & 0x80 ) + buf[4] |= 0x01; + if ( p[2] & 0x40 ) + buf[4] |= 0x04; + if ( p[2] & 0x20 ) + buf[4] |= 0x10; + if ( p[2] & 0x10 ) + buf[4] |= 0x40; + + if ( p[2] & 0x08 ) + buf[3] |= 0x01; + if ( p[2] & 0x04 ) + buf[3] |= 0x04; + if ( p[2] & 0x02 ) + buf[3] |= 0x10; + if ( p[2] & 0x01 ) + buf[3] |= 0x40; + + return buf; +} +#endif + +static uint8_t *u8x8_st7305_convert_a0(u8x8_t *u8x8, uint8_t *p) +{ + static uint8_t buf[6]; + /* u8g2 first row */ + static uint8_t map1[16] = { + /* 0x00 0000 */ 0, + /* 0x01 0001 */0x01, + /* 0x02 0010 */0x04, + /* 0x03 0011 */0x04+0x01, + /* 0x04 0100 */0x10, + /* 0x05 0101 */0x10+0x01, + /* 0x06 0110 */0x10+0x04, + /* 0x07 0111 */0x10+0x04+0x01, + /* 0x08 1000 */ 0x40, + /* 0x09 1001 */ 0x40+0x01, + /* 0x0a 1010 */ 0x40+0x04, + /* 0x0b 1011 */ 0x40+0x04+0x01, + /* 0x0c 1100 */ 0x40+0x10, + /* 0x0d 1101 */ 0x40+0x10+0x01, + /* 0x0e 1110 */ 0x40+0x10+0x04, + /* 0x0f 1111 */ 0x40+0x10+0x04+0x01 + }; + /* u8g2 second row */ + static uint8_t map2[16] = { + /* 0x00 0000 */ 0, + /* 0x01 0001 */0x02, + /* 0x02 0010 */0x08, + /* 0x03 0011 */0x08+0x02, + /* 0x04 0100 */0x20, + /* 0x05 0101 */0x20+0x02, + /* 0x06 0110 */0x20+0x08, + /* 0x07 0111 */0x20+0x08+0x02, + /* 0x08 1000 */ 0x80, + /* 0x09 1001 */ 0x80+0x02, + /* 0x0a 1010 */ 0x80+0x08, + /* 0x0b 1011 */ 0x80+0x08+0x02, + /* 0x0c 1100 */ 0x80+0x20, + /* 0x0d 1101 */ 0x80+0x20+0x02, + /* 0x0e 1110 */ 0x80+0x20+0x08, + /* 0x0f 1111 */ 0x80+0x20+0x08+0x02 + }; + + + memset(buf, 0, 6); + + + // first row, left 12 pixel out of 24 pixel (=3 bytes) + + buf[0] |= map1[p[0]>>4]; + buf[1] |= map1[p[0] & 0x0f]; + buf[2] |= map1[p[1]>>4]; + + // first row, right 12 pixel + + buf[3] |= map1[p[1] & 0x0f]; + buf[4] |= map1[p[2]>>4]; + buf[5] |= map1[p[2] & 0x0f]; + + p += u8x8->display_info->tile_width; + + // second row, left 12 pixel + + buf[0] |= map2[p[0]>>4]; + buf[1] |= map2[p[0] & 0x0f]; + buf[2] |= map2[p[1]>>4]; + + // second row, right 12 pixel + + buf[3] |= map2[p[1] & 0x0f]; + buf[4] |= map2[p[2]>>4]; + buf[5] |= map2[p[2] & 0x0f]; + return buf; +} + + + + +/*===================================================*/ +/* + see also: + https://github.com/zhcong/st7302-for-arduino/blob/c9390fabcacefe7c36a113cd3e62959418c13b97/libraries/st7305SPI/st7305SPI.cpp#L21 +*/ +static const uint8_t u8x8_d_st7305_122x250_init_seq[] = { + + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + + U8X8_C(0x01), // software reset + U8X8_DLY(100), + U8X8_C(0x28), // display off + U8X8_CAA(0xC7, 0x26, 0xE9), // disable OSC + U8X8_CA(0xD1, 0x00), // Booster disable + U8X8_DLY(20), + U8X8_C(0x10), // sleep in: enter sleep mode + U8X8_DLY(20), + U8X8_C(0x01), // software reset + U8X8_DLY(20), // wait + U8X8_C(0x38), // High Power Mode + U8X8_CA(0xEB, 0x02), // Disable NVM Load + U8X8_CA(0xD7, 0x68), // NVM Load Control: Enable ID1 ID2 ID3 Load + U8X8_CA(0xD1, 0x01), // Booster Enable + U8X8_CA(0xC0, 0x80), // Gate Voltage Setting VGH=12V (upper 4 bit, 8V-15V); VGL=-5V (lower 4 bit, -5V .. -10V) + U8X8_C(0x0C1), // Source Voltage Control 1 + U8X8_A6(0x28,0x28,0x28,0x28,0x14,0x00), // Source high voltage in reflective and transmissive mode, gamma voltage 1&2 + U8X8_C(0x0C2), // Source Voltage Control 1 + U8X8_A4(0x00,0x00,0x00,0x00), // Source low voltage in reflective and transmissive mode + U8X8_CA(0xCB, 0x14), // VCOMH: 0x14 = 4V (0x28 = 5V) + U8X8_CAA(0xB4, 0xE5, 0x77), // Update Period Gate EQ Control, why 0x77??? it should be 0x66 according to the datasheet + U8X8_A8(0xF1, 0xFF, 0xFF, 0x4F, 0xF1, 0xFF, 0xFF, 0X4F), + U8X8_CA(0xB0, 0x64), // Duty Cycle... this must be before sleep out + U8X8_C(0x11), // sleep out: furn off sleep mode + U8X8_DLY(120), + U8X8_CAA(0xC7, 0xA6, 0xE9), // Enable OSC + U8X8_CA(0x36, 0xa0), // Memory Control + + U8X8_CA(0x3A, 0x11), // Data Format + U8X8_CA(0xB9, 0x23), // Source Setting: Clear RAM off + U8X8_CA(0xB8, 0x09), // Panel Setting / Panel Layout + U8X8_CAA(0x2A, 0x05, 0x36), // col addr + U8X8_CAA(0x2B, 0x00, 0xC7), // row addr + U8X8_CA(0xD0, 0x1F), // Not in datasheet + U8X8_C(0x29), // display on + U8X8_CA(0x72, 0x00), // Not in datasheet + U8X8_CAA(0xB2,1, 5), // Frame Rate for High and Low Power Mode (hier: 32Hz and 8Hz) + U8X8_C(0x39), // enable Low Power Mode...: 8Hz, see above + U8X8_DLY(100), + + /* + U8X8_CAA(0x2A, 0x19, 0x3a), // col addr 0x14 < col < 0x3b + U8X8_CAA(0x2B, 115, 115), // row addr (0..250, y in u8g2), 0 is top row in u8g2 + U8X8_C(0x2C), // write start + U8X8_D1(0xff), // pixel data + U8X8_D1(0xff), // pixel data + U8X8_D1(0xff), // pixel data + + U8X8_D1(0xff), // pixel data + U8X8_D1(0xff), // pixel data + U8X8_D1(0xff), // pixel data + + U8X8_D1(0xff), // pixel data + U8X8_D1(0xff), // pixel data + U8X8_D1(0xff), // pixel data + + U8X8_D1(0xff), // pixel data + U8X8_D1(0xff), // pixel data + U8X8_D1(0xff), // pixel data + + U8X8_CAA(0x2A, 0x19, 0x3a), // col addr 0x14 < col < 0x3b + U8X8_CAA(0x2B, 116, 116), // row addr (0..250, y in u8g2), 0 is top row in u8g2 + U8X8_C(0x2C), // write start + U8X8_D1(0x80), // pixel data + U8X8_D1(0x00), // pixel data + U8X8_D1(0x00), // pixel data + + U8X8_D1(0x00), // pixel data + U8X8_D1(0x00), // pixel data + U8X8_D1(0x00), // pixel data + + U8X8_D1(0x00), // pixel data + U8X8_D1(0x00), // pixel data + U8X8_D1(0x00), // pixel data + + U8X8_D1(0x00), // pixel data + U8X8_D1(0x00), // pixel data + U8X8_D1(0x00), // pixel data + */ + + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + + + + +static const u8x8_display_info_t u8x8_st7305_122x250_display_info = +{ + /* chip_enable_level = */ 0, + /* chip_disable_level = */ 1, + + /* post_chip_enable_wait_ns = */ 20, + /* pre_chip_disable_wait_ns = */ 20, + /* reset_pulse_width_ms = */ 3, + /* post_reset_wait_ms = */ 3, /**/ + /* sda_setup_time_ns = */ 10, /* */ + /* sck_pulse_width_ns = */ 30, /* */ + /* sck_clock_hz = */ 2000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ + /* spi_mode = */ 0, /* active high, rising edge */ + /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ + /* data_setup_time_ns = */ 15, + /* write_pulse_width_ns = */ 70, + /* tile_width = */ 16, + /* tile_height = */ 32, + /* default_x_offset = */ 0, + /* flipmode_x_offset = */ 0, + /* pixel_width = */ 122, + /* pixel_height = */ 250 +}; + +uint8_t u8x8_d_st7305_122x250(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + uint16_t x; + uint8_t c, i, y; + uint8_t *ptr; + switch(msg) + { + case U8X8_MSG_DISPLAY_INIT: + u8x8_d_helper_display_init(u8x8); + u8x8_cad_SendSequence(u8x8, u8x8_d_st7305_122x250_init_seq); + break; + case U8X8_MSG_DISPLAY_SETUP_MEMORY: + u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7305_122x250_display_info); + break; + case U8X8_MSG_DISPLAY_SET_POWER_SAVE: + if ( arg_int == 0 ) + u8x8_cad_SendSequence(u8x8, u8x8_d_st7305_122x250_powersave0_seq); + else + u8x8_cad_SendSequence(u8x8, u8x8_d_st7305_122x250_powersave1_seq); + break; + case U8X8_MSG_DISPLAY_SET_FLIP_MODE: + if ( arg_int == 0 ) + { + u8x8_cad_SendSequence(u8x8, u8x8_d_st7305_122x250_flip0_seq); + u8x8->x_offset = u8x8->display_info->default_x_offset; + } + else + { + u8x8_cad_SendSequence(u8x8, u8x8_d_st7305_122x250_flip1_seq); + u8x8->x_offset = u8x8->display_info->flipmode_x_offset; + } + break; +#ifdef U8X8_WITH_SET_CONTRAST + case U8X8_MSG_DISPLAY_SET_CONTRAST: + u8x8_cad_StartTransfer(u8x8); + u8x8_cad_SendCmd(u8x8, 0x081 ); + u8x8_cad_SendArg(u8x8, arg_int<<2 ); + u8x8_cad_SendArg(u8x8, arg_int>>6 ); + u8x8_cad_EndTransfer(u8x8); + break; +#endif + case U8X8_MSG_DISPLAY_DRAW_TILE: + x = ((u8x8_tile_t *)arg_ptr)->x_pos; + x *= 8; + x += u8x8->x_offset; + y= (((u8x8_tile_t *)arg_ptr)->y_pos); + y*=4; + + y+=115; // specific for the 122x250 LCD + + u8x8_cad_StartTransfer(u8x8); + + for( i = 0; i < 4; i++ ) + { + + u8x8_cad_SendCmd(u8x8, 0x2a); + u8x8_cad_SendArg(u8x8, 0x19); // specific for the 122x250 LCD + u8x8_cad_SendArg(u8x8, 0x3a ); + + u8x8_cad_SendCmd(u8x8, 0x2b ); + u8x8_cad_SendArg(u8x8, y+i); + u8x8_cad_SendArg(u8x8, y+i); + u8x8_cad_SendCmd(u8x8, 0x02c ); // write data + + c = ((u8x8_tile_t *)arg_ptr)->cnt; + ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; + + ptr += u8x8->display_info->tile_width*i*2; + + c = (c+2)/3; // calculate the number of 24 bit blocks to send + + + while( c > 0 ) + { + u8x8_cad_SendData(u8x8, 6, u8x8_st7305_convert_a0(u8x8, ptr)); + ptr+=3; + --c; + } + } + u8x8_cad_EndTransfer(u8x8); + break; + default: + return 0; + } + return 1; +} diff --git a/src/clib/u8x8_d_st7567.c b/src/clib/u8x8_d_st7567.c index 5f7125e7..eecfa2da 100644 --- a/src/clib/u8x8_d_st7567.c +++ b/src/clib/u8x8_d_st7567.c @@ -73,6 +73,11 @@ static const uint8_t u8x8_d_st7567_132x64_flip1_seq[] = { U8X8_END() /* end of sequence */ }; +#define u8x8_d_st7567_128x64_powersave0_seq u8x8_d_st7567_132x64_powersave0_seq +#define u8x8_d_st7567_128x64_powersave1_seq u8x8_d_st7567_132x64_powersave1_seq +#define u8x8_d_st7567_128x64_flip0_seq u8x8_d_st7567_132x64_flip0_seq +#define u8x8_d_st7567_128x64_flip1_seq u8x8_d_st7567_132x64_flip1_seq + static const uint8_t u8x8_d_st7567_n_flip0_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ U8X8_C(0x0a0), /* segment remap a0/a1*/ @@ -1308,6 +1313,149 @@ uint8_t u8x8_d_st7567_erc13232(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void } +/*=====================================================*/ +/* + + https://www.buydisplay.com/2-inch-low-cost-white-128x64-graphic-cog-lcd-display-st7567-spi + + ERC12864FSF-20 + + copied from u8x8_st7567_132x32 +*/ + +static const u8x8_display_info_t u8x8_st7567_128x64_display_info = +{ + /* chip_enable_level = */ 0, + /* chip_disable_level = */ 1, + + /* post_chip_enable_wait_ns = */ 150, + /* pre_chip_disable_wait_ns = */ 50, + /* reset_pulse_width_ms = */ 1, + /* post_reset_wait_ms = */ 1, + /* sda_setup_time_ns = */ 50, + /* sck_pulse_width_ns = */ 120, + /* sck_clock_hz = */ 4000000UL, + /* spi_mode = */ 0, /* active high, rising edge */ + /* i2c_bus_clock_100kHz = */ 4, + /* data_setup_time_ns = */ 40, + /* write_pulse_width_ns = */ 80, + /* tile_width = */ 16, /* width of 16*8=128 pixels */ + /* tile_height = */ 8, /* height of 8*8= 64 pixels */ + /* default_x_offset = */ 4, + /* flipmode_x_offset = */ 0, + /* pixel_width = */ 128, + /* pixel_height = */ 64 +}; + +static const uint8_t u8x8_d_st7567_erc12864_init_seq[] = { + + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + + U8X8_C(0x0e2), /* soft reset */ + U8X8_C(0x0ae), /* display off */ + U8X8_C(0x040), /* set display start line to 0 */ + + U8X8_C(0x0a1), /* ADC set to reverse */ + U8X8_C(0x0c0), /* common output mode */ + + U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ + U8X8_C(0x0a3), /* LCD bias 1/7 */ + /* power on sequence from paxinstruments */ + U8X8_C(0x028|4), /* all power control circuits on */ + U8X8_DLY(50), + U8X8_C(0x028|6), /* all power control circuits on */ + U8X8_DLY(50), + U8X8_C(0x028|7), /* all power control circuits on */ + U8X8_DLY(50), + + U8X8_C(0x026), /* v0 voltage resistor ratio */ + U8X8_CA(0x081, 0x027), /* set contrast, contrast value*/ + + U8X8_C(0x0ae), /* display off */ + U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ + + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +/* ERC12864 */ +uint8_t u8x8_d_st7567_erc12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + uint8_t x, c; + uint8_t *ptr; + switch(msg) + { + case U8X8_MSG_DISPLAY_SETUP_MEMORY: + u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7567_128x64_display_info); + break; + case U8X8_MSG_DISPLAY_INIT: + u8x8_d_helper_display_init(u8x8); + u8x8_cad_SendSequence(u8x8, u8x8_d_st7567_erc12864_init_seq); + break; + case U8X8_MSG_DISPLAY_SET_POWER_SAVE: + if ( arg_int == 0 ) + u8x8_cad_SendSequence(u8x8, u8x8_d_st7567_128x64_powersave0_seq); + else + u8x8_cad_SendSequence(u8x8, u8x8_d_st7567_128x64_powersave1_seq); + break; + case U8X8_MSG_DISPLAY_SET_FLIP_MODE: + if ( arg_int == 0 ) + { + u8x8_cad_SendSequence(u8x8, u8x8_d_st7567_128x64_flip0_seq); + u8x8->x_offset = u8x8->display_info->default_x_offset; + } + else + { + u8x8_cad_SendSequence(u8x8, u8x8_d_st7567_128x64_flip1_seq); + u8x8->x_offset = u8x8->display_info->flipmode_x_offset; + } + break; +#ifdef U8X8_WITH_SET_CONTRAST + case U8X8_MSG_DISPLAY_SET_CONTRAST: + u8x8_cad_StartTransfer(u8x8); + u8x8_cad_SendCmd(u8x8, 0x081 ); + u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* st7567 has range from 0 to 63 */ + u8x8_cad_EndTransfer(u8x8); + break; +#endif + case U8X8_MSG_DISPLAY_DRAW_TILE: + u8x8_cad_StartTransfer(u8x8); + + x = ((u8x8_tile_t *)arg_ptr)->x_pos; + x *= 8; + x += u8x8->x_offset; + u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) ); + 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 st7567 + 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 + { + u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */ + arg_int--; + } while( arg_int > 0 ); + + u8x8_cad_EndTransfer(u8x8); + break; + default: + return 0; + } + return 1; +} + + /*=====================================================*/ /* LW12864 display, 128x32 (actually 142x36, but with border of weird behavior) */ @@ -1340,7 +1488,7 @@ static const u8x8_display_info_t u8x8_st7567_lw12832_display_info = static const uint8_t u8x8_st7567_lw12832_init_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ - + U8X8_C(0x0e2), /* soft reset */ U8X8_C(0x0ae), /* display off */ U8X8_C(0x040), /* set display start line to 0 */ @@ -1380,7 +1528,7 @@ static void st7567_lw12832_clear_ddram(u8x8_t *u8x8) uint8_t buf[8] = {0, 0, 0, 0, 0, 0, 0, 0}; uint8_t h = u8x8->display_info->tile_height; - + u8x8_tile_t tile; tile.x_pos = 0; tile.y_pos = 0; diff --git a/src/clib/u8x8_u8toa.c b/src/clib/u8x8_u8toa.c index 44e08dde..ada192b3 100644 --- a/src/clib/u8x8_u8toa.c +++ b/src/clib/u8x8_u8toa.c @@ -90,4 +90,19 @@ const char *u8x8_s8toa(int8_t v, uint8_t d) return buf; } - \ No newline at end of file +const char *u8x8_u8tox(uint8_t v, uint8_t d) +{ + const char hexdigit[]="0123456789ABCDEF"; + static char buf[3]; + if ( d == 1 ) + { + buf[0] = hexdigit[v & 0xF]; + buf[1] = '\0'; + } + else if ( d == 2 ) + { + buf[0] = hexdigit[v >> 4 & 0xF]; + buf[1] = hexdigit[v & 0xF]; + buf[2] = '\0'; + } +}