This commit is contained in:
olikraus
2016-08-21 21:31:48 +02:00
parent 88764aa76a
commit 8bd08c31de
18 changed files with 53 additions and 31 deletions
+1 -1
View File
@@ -65,7 +65,7 @@
//U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
//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_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED
//U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED
//U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED
+3 -2
View File
@@ -36,5 +36,6 @@ https://github.com/olikraus/u8g2 ChangeLog
* Fixed ST7920 HW SPI with very fast uC, issue 50
* Improved HW SPI for SH1106 and SSD1306 displays
* Fixed issue with missing fonts
2016-xx-xx v2.4.x olikraus@gmail.com
2016-08-21 v2.4.1 olikraus@gmail.com
* Fixed HW SPI Modes (issue 52)
+1 -1
View File
@@ -1,5 +1,5 @@
name=U8g2
version=2.4.0
version=2.4.1
author=oliver <olikraus@gmail.com>
maintainer=oliver <olikraus@gmail.com>
sentence=Library for monochrome LCDs and OLEDs. Successor of U8glib.
+15 -2
View File
@@ -278,6 +278,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t a
{
#ifdef U8X8_HAVE_HW_SPI
uint8_t *data;
uint8_t internal_spi_mode;
switch(msg)
{
@@ -310,8 +311,18 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t a
break;
case U8X8_MSG_BYTE_START_TRANSFER:
/* SPI mode has to be mapped to the mode of the current controller, at least Uno, Due, 101 have different SPI_MODEx values */
internal_spi_mode = 0;
switch(u8x8->display_info->spi_mode)
{
case 0: internal_spi_mode = SPI_MODE0; break;
case 1: internal_spi_mode = SPI_MODE1; break;
case 2: internal_spi_mode = SPI_MODE2; break;
case 3: internal_spi_mode = SPI_MODE3; break;
}
#if ARDUINO >= 10600
SPI.beginTransaction(SPISettings(u8x8->display_info->sck_clock_hz, MSBFIRST, u8x8->display_info->spi_mode));
SPI.beginTransaction(SPISettings(u8x8->display_info->sck_clock_hz, MSBFIRST, internal_spi_mode));
#else
SPI.begin();
@@ -321,7 +332,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t a
SPI.setClockDivider( SPI_CLOCK_DIV4 );
else
SPI.setClockDivider( SPI_CLOCK_DIV8 );
SPI.setDataMode(u8x8->display_info->spi_mode);
SPI.setDataMode(internal_spi_mode);
SPI.setBitOrder(MSBFIRST);
#endif
@@ -343,6 +354,8 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t a
default:
return 0;
}
#else
#endif
return 1;
}
+5 -4
View File
@@ -215,10 +215,10 @@ struct u8x8_display_info_struct
uint32_t sck_clock_hz;
/* previous name "sck_takeover_edge" renamed to "spi_mode" */
/* bit 0 of spi_mode is equal to the value of the previous variable sck_takeover_edge */
/* bit 0 of spi_mode is equal to the value of the previous variable sck_takeover_edge, 20 Aug 16: This is wrong the bit is actually inverted */
/* SPI has four clock modes: */
/* 0: clock active high, data out on falling edge */
/* 1: clock active high, data out on rising edge */
/* 0: clock active high, data out on falling edge, clock default value is zero, takover on rising edge */
/* 1: clock active high, data out on rising edge, clock default value is zero, takover on falling edge */
/* 2: clock active low, data out on rising edge */
/* 3: clock active low, data out on falling edge */
/* most displays have clock mode 1 */
@@ -322,8 +322,9 @@ struct u8x8_struct
#define u8x8_GetRows(u8x8) ((u8x8)->display_info->tile_height)
#define u8x8_GetI2CAddress(u8x8) ((u8x8)->i2c_address)
#define u8x8_SetGPIOResult(u8x8, val) ((u8x8)->gpio_result = (val))
#define u8x8_GetSPIClockPhase(u8x8) ((u8x8)->display_info->spi_mode & 0x01) /* this returns "sck_takeover_edge" */
#define u8x8_GetSPIClockPhase(u8x8) ((u8x8)->display_info->spi_mode & 0x01) /* 0 means rising edge */
#define u8x8_GetSPIClockPolarity(u8x8) (((u8x8)->display_info->spi_mode & 0x02) >> 1)
#define u8x8_GetSPIClockDefaultLevel(u8x8) (((u8x8)->display_info->spi_mode & 0x02) >> 1)
#ifdef U8X8_USE_PINS
+5
View File
@@ -321,8 +321,11 @@ uint8_t u8x8_cad_st7920_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
case U8X8_MSG_CAD_SEND_CMD:
//u8x8_byte_SetDC(u8x8, 0);
u8x8_byte_SendByte(u8x8, 0x0f8);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
u8x8_byte_SendByte(u8x8, arg_int & 0x0f0);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
u8x8_byte_SendByte(u8x8, arg_int << 4);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
break;
case U8X8_MSG_CAD_SEND_ARG:
//u8x8_byte_SetDC(u8x8, 0);
@@ -334,6 +337,7 @@ uint8_t u8x8_cad_st7920_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
//u8x8_byte_SetDC(u8x8, 1);
u8x8_byte_SendByte(u8x8, 0x0fa);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
/* this loop should be optimized: multiple bytes should be sent */
/* u8x8_byte_SendBytes(u8x8, arg_int, arg_ptr); */
@@ -348,6 +352,7 @@ uint8_t u8x8_cad_st7920_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
data++;
arg_int--;
}
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
break;
case U8X8_MSG_CAD_INIT:
case U8X8_MSG_CAD_START_TRANSFER:
+1 -1
View File
@@ -150,7 +150,7 @@ static const u8x8_display_info_t u8x8_a2printer_384x240_display_info =
/* sda_setup_time_ns = */ 20,
/* sck_pulse_width_ns = */ 140,
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* old: sck_takeover_edge, new: active high (bit 1), rising edge (bit 0) */
/* spi_mode = */ 0, /* old: sck_takeover_edge, new: active high (bit 1), rising edge (bit 0) */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 30,
/* write_pulse_width_ns = */ 40,
+1 -1
View File
@@ -182,7 +182,7 @@ static const u8x8_display_info_t u8x8_ld7032_60x32_display_info =
/* sda_setup_time_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
/* sck_pulse_width_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* active high, rising edge */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 20,
/* write_pulse_width_ns = */ 40,
+1 -1
View File
@@ -55,7 +55,7 @@ static const u8x8_display_info_t u8x8_ls013b7dh03_128x128_display_info =
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 3, /* active low, rising edge */
/* spi_mode = */ 2, /* active low, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 100,
/* write_pulse_width_ns = */ 100,
+1 -1
View File
@@ -126,7 +126,7 @@ static const u8x8_display_info_t u8x8_sed1330_240x128_display_info =
/* sda_setup_time_ns = */ 20,
/* sck_pulse_width_ns = */ 140,
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1,
/* spi_mode = */ 0,
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */
/* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */
+1 -1
View File
@@ -189,7 +189,7 @@ static const u8x8_display_info_t u8x8_ssd1306_128x32_univision_display_info =
/* 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 = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* active high, rising edge */
/* 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 */
+2 -2
View File
@@ -193,7 +193,7 @@ static const u8x8_display_info_t u8x8_ssd1306_128x64_noname_display_info =
/* 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 = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* active high, rising edge */
/* 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 */
@@ -228,7 +228,7 @@ static const u8x8_display_info_t u8x8_sh1106_128x64_noname_display_info =
/* 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 = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* active high, rising edge */
/* spi_mode = */ 3, /* active low (clock is high by default), rising edge, this seems to be a difference to the ssd1306 */
/* 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 */
+1 -1
View File
@@ -199,7 +199,7 @@ static const u8x8_display_info_t u8x8_ssd1322_256x64_display_info =
/* sda_setup_time_ns = */ 50, /* SSD1322: 15ns, but cycle time is 100ns, so use 100/2 */
/* sck_pulse_width_ns = */ 50, /* SSD1322: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* active high, rising edge */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 10,
/* write_pulse_width_ns = */ 150, /* SSD1322: cycle time is 300ns, so use 300/2 = 150 */
+2 -2
View File
@@ -82,7 +82,7 @@ static const u8x8_display_info_t u8x8_st7565_128x64_display_info =
/* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */
/* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* active high, rising edge */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */
/* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */
@@ -106,7 +106,7 @@ static const u8x8_display_info_t u8x8_st7565_128x32_display_info =
/* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */
/* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* active high, rising edge */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */
/* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */
+8 -6
View File
@@ -45,14 +45,14 @@ static const uint8_t u8x8_d_st7920_init_seq[] = {
U8X8_DLY(100),
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_DLY(100),
U8X8_DLY(10),
U8X8_C(0x038), /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
U8X8_C(0x00c), /* display on, cursor & blink off; 0x08: all off */
U8X8_C(0x008), /* display on, cursor & blink off; 0x08: all off */
U8X8_C(0x006), /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
U8X8_C(0x002), /* disable scroll, enable CGRAM adress */
//U8X8_C(0x001), /* clear RAM, needs 1.6 ms */
U8X8_DLY(2), /* delay 2ms */
U8X8_C(0x001), /* clear RAM, needs 1.6 ms */
U8X8_DLY(4), /* delay 2ms */
U8X8_END_TRANSFER(), /* disable chip */
@@ -133,10 +133,10 @@ uint8_t u8x8_d_st7920_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
u8x8_cad_SendCmd(u8x8, 0x080 | x ); /* set x pos */
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
//u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
ptr += c;
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
//u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
}
u8x8_cad_EndTransfer(u8x8);
@@ -161,6 +161,7 @@ static const u8x8_display_info_t u8x8_st7920_192x32_display_info =
/* sck_pulse_width_ns = */ 140, /* datasheet ST7920 */
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 3, /* old: sck_takeover_edge, new: active high (bit 1), rising edge (bit 0), 18 Aug 16: changed from 1 to 3 which works for 101 */
/* Arduino mode 3: aktive low clock, but use rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 30,
/* write_pulse_width_ns = */ 40,
@@ -186,6 +187,7 @@ static const u8x8_display_info_t u8x8_st7920_128x64_display_info =
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* ST7920+Due work with 1MHz but not with 2MHz, ST7920+Uno works with 2MHz */
/* spi_mode = */ 3, /* active high, rising edge, 18 Aug 16: changed from 1 to 3 which works for 101 */
/* in theory mode 3 should be correct */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 30,
/* write_pulse_width_ns = */ 40,
+3 -3
View File
@@ -135,7 +135,7 @@ static const u8x8_display_info_t u8x8_t6963_240x128_display_info =
/* sda_setup_time_ns = */ 20,
/* sck_pulse_width_ns = */ 140,
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1,
/* spi_mode = */ 0,
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 80,
/* write_pulse_width_ns = */ 80,
@@ -222,7 +222,7 @@ static const u8x8_display_info_t u8x8_t6963_256x64_display_info =
/* sda_setup_time_ns = */ 20,
/* sck_pulse_width_ns = */ 140,
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1,
/* spi_mode = */ 0,
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 80,
/* write_pulse_width_ns = */ 80,
@@ -305,7 +305,7 @@ static const u8x8_display_info_t u8x8_t6963_128x64_display_info =
/* sda_setup_time_ns = */ 20,
/* sck_pulse_width_ns = */ 140,
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1,
/* spi_mode = */ 0,
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 80,
/* write_pulse_width_ns = */ 80,
+1 -1
View File
@@ -108,7 +108,7 @@ static const u8x8_display_info_t u8x8_uc1701_display_info =
/* sda_setup_time_ns = */ 12,
/* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* active high, rising edge */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 30,
/* write_pulse_width_ns = */ 40,
+1 -1
View File
@@ -109,7 +109,7 @@ static const u8x8_display_info_t u8x8_uc1701_display_info =
/* sda_setup_time_ns = */ 12,
/* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 1, /* active high, rising edge */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 30,
/* write_pulse_width_ns = */ 40,