towards arduino support

This commit is contained in:
olikraus 2015-12-08 21:30:14 +01:00
parent 67cdf8c8be
commit a802f8fb17
5 changed files with 236 additions and 48 deletions

View File

@ -1,2 +1,151 @@
/*
use U8X8_PIN_NONE as value for "reset", if there is no reset line
*/
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)
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_SPI_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_SPI_DATA, data);
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_4wire_sw_spi;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
}
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)
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_SPI_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_SPI_DATA, data);
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_3wire_sw_spi;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
}
/*
use U8X8_PIN_NONE as value for "reset", if there is no reset line
*/
void u8x8_Setup_4Wire_HW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t cs, uint8_t dc, uint8_t reset)
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_arduino_hw_spi;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
}
void u8x8_Setup_SSD13xx_SW_I2C(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock, uint8_t data, uint8_t reset)
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_I2C_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_I2C_DATA, data);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_ssd13xx_sw_i2c;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
}
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)
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_D0, d0);
u8x8_SetPin(u8x8, U8X8_PIN_D1, d1);
u8x8_SetPin(u8x8, U8X8_PIN_D2, d2);
u8x8_SetPin(u8x8, U8X8_PIN_D3, d3);
u8x8_SetPin(u8x8, U8X8_PIN_D4, d4);
u8x8_SetPin(u8x8, U8X8_PIN_D5, d5);
u8x8_SetPin(u8x8, U8X8_PIN_D6, d6);
u8x8_SetPin(u8x8, U8X8_PIN_D7, d7);
u8x8_SetPin(u8x8, U8X8_PIN_E, enable);
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_8bit_6800mode;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
}
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)
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_D0, d0);
u8x8_SetPin(u8x8, U8X8_PIN_D1, d1);
u8x8_SetPin(u8x8, U8X8_PIN_D2, d2);
u8x8_SetPin(u8x8, U8X8_PIN_D3, d3);
u8x8_SetPin(u8x8, U8X8_PIN_D4, d4);
u8x8_SetPin(u8x8, U8X8_PIN_D5, d5);
u8x8_SetPin(u8x8, U8X8_PIN_D6, d6);
u8x8_SetPin(u8x8, U8X8_PIN_D7, d7);
u8x8_SetPin(u8x8, U8X8_PIN_E, wr);
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_8bit_8080mode;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
}

View File

@ -327,12 +327,34 @@ void u8x8_d_helper_display_init(u8x8_t *u8g2);
/* arg_ptr: layout struct */
//#define U8X8_MSG_DISPLAY_GET_LAYOUT 16
/*==========================================*/
/* u8x8_setup.c */
/*
Setup u8x8 object itself. This should be the very first function
called on the new u8x8 object. After this call, assign the callback
functions. Optional: Set the pins
*/
void u8x8_SetupDefaults(u8x8_t *u8x8);
/*==========================================*/
/* u8x8_display.c */
uint8_t u8x8_DrawTile(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr);
/* setup u8x8 memory structures */
/*
After a call to u8x8_SetupDefaults,
setup u8x8 memory structures & inform callbacks
*/
void u8x8_SetupMemory(u8x8_t *u8x8);
/* Init display, but keep display in power save mode. Usually this command must be followed by u8x8_SetPowerSave() */
/*
After calling u8x8_SetupMemory(), init the display hardware itself.
This will will the first time, u8x8 talks to the display.
It will init the display, but keep display in power save mode.
Usually this command must be followed by u8x8_SetPowerSave()
*/
void u8x8_InitDisplay(u8x8_t *u8x8);
/* wake up display from power save mode */
void u8x8_SetPowerSave(u8x8_t *u8x8, uint8_t is_enable);
@ -499,9 +521,6 @@ void u8x8_gpio_call(u8x8_t *u8x8, uint8_t msg, uint8_t arg) U8X8_NOINLINE;
//void u8x8_gpio_Delay(u8x8_t *u8x8, uint8_t msg, uint8_t dly) U8X8_NOINLINE;
/*==========================================*/
/* u8x8_setup.c */
void u8x8_SetupDefaults(u8x8_t *u8x8);
/*==========================================*/

18
doc/device_matrix.txt Normal file
View File

@ -0,0 +1,18 @@
3=3 wire SPI
4=4 wire SPI
2=I2C
6=6800 8 bit parallel
8=8080 8 bit parallel
s=Arduino Standard Software Communication
pinMode and digitalWrite are used for communication
o=Arduino Optimized Software Communication
uC Specific low level functions for digital write and read
h=Hardware Communication with Standard Libs
TWI and SPI library
H=uC specific hardware communication
SSD1306 128x64
Arduino with ATMega328 (e.g. Uno) s2s3s4s6s8 h2h4
Arduino with AT91SAM3X8E (Due) s2s3s4s6s8 h2h4

View File

@ -3,6 +3,7 @@ U8glib V2: Features and Limitations
- Arduino Standard Libs
- Full Memory Buffer
- 3-wire-SPI
- Unicode Support
Unicode plane 0 (Basic Multilingual Plane, BMP, glyphs with 0x0000-0xffff)

View File

@ -155,13 +155,6 @@ void u8x8_Setup_4Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_SPI_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_SPI_DATA, data);
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
@ -171,6 +164,13 @@ void u8x8_Setup_4Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock
/* setup display info */
u8x8_SetupMemory(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_SPI_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_SPI_DATA, data);
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
}
@ -179,12 +179,6 @@ void u8x8_Setup_3Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_SPI_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_SPI_DATA, data);
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
@ -193,6 +187,12 @@ void u8x8_Setup_3Wire_SW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock
/* setup display info */
u8x8_SetupMemory(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_SPI_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_SPI_DATA, data);
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
}
/*
@ -202,11 +202,6 @@ void u8x8_Setup_4Wire_HW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t cs, u
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
@ -216,6 +211,11 @@ void u8x8_Setup_4Wire_HW_SPI(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t cs, u
/* setup display info */
u8x8_SetupMemory(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
}
void u8x8_Setup_SSD13xx_SW_I2C(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clock, uint8_t data, uint8_t reset)
@ -223,11 +223,6 @@ void u8x8_Setup_SSD13xx_SW_I2C(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clo
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_I2C_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_I2C_DATA, data);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
@ -236,12 +231,27 @@ void u8x8_Setup_SSD13xx_SW_I2C(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t clo
/* setup display info */
u8x8_SetupMemory(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_I2C_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_I2C_DATA, data);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
}
void u8x8_Setup_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)
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_8bit_6800mode;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_D0, d0);
@ -256,15 +266,6 @@ void u8x8_Setup_8Bit_6800(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t d0, uint
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_8bit_6800mode;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
}
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)
@ -272,6 +273,15 @@ void u8x8_Setup_8Bit_8080(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t d0, uint
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_8bit_8080mode;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
/* assign individual pin values (only for ARDUINO, if pin_list is available) */
u8x8_SetPin(u8x8, U8X8_PIN_D0, d0);
u8x8_SetPin(u8x8, U8X8_PIN_D1, d1);
@ -285,15 +295,6 @@ void u8x8_Setup_8Bit_8080(u8x8_t *u8x8, u8x8_msg_cb display_cb, uint8_t d0, uint
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = u8x8_cad_001;
u8x8->byte_cb = u8x8_byte_8bit_8080mode;
u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino;
/* setup display info */
u8x8_SetupMemory(u8x8);
}
@ -318,8 +319,8 @@ void setup(void)
//u8x8_Setup_4Wire_HW_SPI(&u8x8, u8x8_d_ssd1306_128x64_noname, 10, 9, 8);
//u8x8_Setup_SSD13xx_SW_I2C(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 8);
//u8x8_Setup_8Bit_6800(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
u8x8_Setup_8Bit_8080(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
u8x8_Setup_8Bit_6800(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
//u8x8_Setup_8Bit_8080(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
//u8x8_Setup_SW_4Wire_SPI(&u8x8, u8x8_d_uc1701_dogs102, 13, 11, 10, 9, 8);
//u8x8_Setup_HW_4Wire_SPI(&u8x8, u8x8_d_uc1701_dogs102, 10, 9, 8);