Antonorosso / u8glib

Automatically exported from code.google.com/p/u8glib
Other
0 stars 0 forks source link

USART Support (Arduino ATMEGA32U4) #198

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello Olivier,

I managed to add USART SPI support!
Attached are the modifications I made. I realize that my coding style may not 
be exactly what you'd like, so please let me know what you'd want me to change 
so you might include this changes to the next version of u8glib.
I also attached a small picture of the platform.

Regards,
Mathieu

to add in u8g.h: 
/* Display: Newhaven NHD-C12832 */
extern u8g_dev_t u8g_dev_st7565_nhd_c12832_sw_spi;
extern u8g_dev_t u8g_dev_st7565_nhd_c12832_hw_spi;
extern u8g_dev_t u8g_dev_st7565_nhd_c12832_hw_usart_spi;
extern u8g_dev_t u8g_dev_st7565_nhd_c12832_parallel;

uint8_t u8g_com_arduino_hw_usart_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t 
arg_val, void *arg_ptr);      /* u8g_com_atmega_hw_usart_spi.c */
uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void 
*arg_ptr);      /* u8g_com_atmega_hw_spi.c */
uint8_t u8g_com_atmega_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void 
*arg_ptr);      /* u8g_com_atmega_sw_spi.c */

/* ==== HW SPI, Arduino ====*/
#if defined(ARDUINO)
#if defined(__AVR__)
#define U8G_COM_HW_SPI u8g_com_arduino_hw_spi_fn
#define U8G_COM_HW_USART_SPI u8g_com_arduino_hw_usart_spi_fn
#define U8G_COM_ST7920_HW_SPI u8g_com_arduino_st7920_hw_spi_fn 
#elif defined(__18CXX) || defined(__PIC32MX)
#define U8G_COM_HW_SPI u8g_com_null_fn
#define U8G_COM_HW_USART_SPI u8g_com_null_fn
#define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
#elif defined(__arm__)   /* Arduino Due */
#define U8G_COM_HW_SPI u8g_com_arduino_hw_spi_fn
#define U8G_COM_HW_USART_SPI u8g_com_arduino_hw_usart_spi_fn
#define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
#endif

to add in U8glib.h (set up like this as it has the same number of args as 
U8GLIB_NHD_C12832)
class U8GLIB_NHD_C12832_USART : public U8GLIB 
{
  public:
    U8GLIB_NHD_C12832_USART(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
      : U8GLIB(&u8g_dev_st7565_nhd_c12832_hw_usart_spi, cs, a0, reset)
      { }
};

to add in u8g_dev_st7565_nhd_c12832.c:

U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, 
u8g_dev_st7565_c12832_fn, U8G_COM_SW_SPI);
U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, 
u8g_dev_st7565_c12832_fn, U8G_COM_HW_SPI);
U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_hw_usart_spi, WIDTH, HEIGHT, PAGE_HEIGHT, 
u8g_dev_st7565_c12832_fn, U8G_COM_HW_USART_SPI);

Original issue reported on code.google.com by olikr...@gmail.com on 12 Sep 2013 at 8:12

Attachments:

GoogleCodeExporter commented 8 years ago
this has been added

Original comment by olikr...@gmail.com on 3 Oct 2013 at 6:28