Skip to content

Commit

Permalink
Get device name from Kconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Han committed Apr 7, 2019
1 parent 14452c9 commit 9cb076d
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 176 deletions.
42 changes: 21 additions & 21 deletions examples/ssd1306_12864_4wire_hw_spi_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@
// You may reference Drivers/drv_gpio.c for pinout
// In u8x8.h #define U8X8_USE_PINS

#define OLED_SPI_PIN_RES 16 // PA2
#define OLED_SPI_PIN_DC 15 // PA1
#define OLED_SPI_PIN_CS 14 // PA0
#define OLED_SPI_PIN_RES 16 // PA2
#define OLED_SPI_PIN_DC 15 // PA1
#define OLED_SPI_PIN_CS 14 // PA0

static void ssd1306_12864_4wire_hw_spi_example(int argc,char *argv[])
{
u8g2_t u8g2;
u8g2_t u8g2;

// Initialization
u8g2_Setup_ssd1306_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_rt_4wire_hw_spi, u8x8_rt_gpio_and_delay);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, OLED_SPI_PIN_CS);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, OLED_SPI_PIN_DC);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, OLED_SPI_PIN_RES);
// Initialization
u8g2_Setup_ssd1306_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_rt_4wire_hw_spi, u8x8_rt_gpio_and_delay);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, OLED_SPI_PIN_CS);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, OLED_SPI_PIN_DC);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, OLED_SPI_PIN_RES);

u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);
// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);

u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
}
MSH_CMD_EXPORT(ssd1306_12864_4wire_hw_spi_example, sw 4wire spi ssd1306 sample);
52 changes: 26 additions & 26 deletions examples/ssd1306_12864_4wire_sw_spi_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@
// You may reference Drivers/drv_gpio.c for pinout
// In u8x8.h #define U8X8_USE_PINS

#define OLED_SPI_PIN_CLK 21 // PA5
#define OLED_SPI_PIN_MOSI 23 // PA7
#define OLED_SPI_PIN_RES 16 // PA2
#define OLED_SPI_PIN_DC 15 // PA1
#define OLED_SPI_PIN_CS 14 // PA0
#define OLED_SPI_PIN_CLK 21 // PA5
#define OLED_SPI_PIN_MOSI 23 // PA7
#define OLED_SPI_PIN_RES 16 // PA2
#define OLED_SPI_PIN_DC 15 // PA1
#define OLED_SPI_PIN_CS 14 // PA0

static void ssd1306_12864_4wire_sw_spi_example(int argc,char *argv[])
{
u8g2_t u8g2;
u8g2_t u8g2;

// Initialization
u8g2_Setup_ssd1306_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_4wire_sw_spi, u8x8_rt_gpio_and_delay);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_CLOCK, OLED_SPI_PIN_CLK);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_DATA, OLED_SPI_PIN_MOSI);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, OLED_SPI_PIN_CS);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, OLED_SPI_PIN_DC);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, OLED_SPI_PIN_RES);

u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);
// Initialization
u8g2_Setup_ssd1306_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_4wire_sw_spi, u8x8_rt_gpio_and_delay);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_CLOCK, OLED_SPI_PIN_CLK);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_DATA, OLED_SPI_PIN_MOSI);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, OLED_SPI_PIN_CS);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, OLED_SPI_PIN_DC);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, OLED_SPI_PIN_RES);

u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);

u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
}
MSH_CMD_EXPORT(ssd1306_12864_4wire_sw_spi_example, sw 4wire spi ssd1306 sample);
32 changes: 16 additions & 16 deletions examples/ssd1306_12864_hw_i2c_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@

static void ssd1306_12864_hw_i2c_example(int argc,char *argv[])
{
u8g2_t u8g2;

// Initialization
u8g2_Setup_ssd1306_i2c_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_rt_hw_i2c, u8x8_rt_gpio_and_delay);
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);
u8g2_t u8g2;

// Draw Graphics
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
// Initialization
u8g2_Setup_ssd1306_i2c_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_rt_hw_i2c, u8x8_rt_gpio_and_delay);
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);

// Draw Graphics
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
}
MSH_CMD_EXPORT(ssd1306_12864_hw_i2c_example, i2c ssd1306 sample);
40 changes: 20 additions & 20 deletions examples/ssd1306_12864_sw_i2c_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
#include <rtdevice.h>
#include <u8g2_port.h>

#define OLED_I2C_PIN_SCL 58 // PB6
#define OLED_I2C_PIN_SDA 59 // PB7
#define OLED_I2C_PIN_SCL 58 // PB6
#define OLED_I2C_PIN_SDA 59 // PB7

static void ssd1306_12864_sw_i2c_example(int argc,char *argv[])
{
u8g2_t u8g2;

// Initialization
u8g2_Setup_ssd1306_i2c_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_sw_i2c, u8x8_rt_gpio_and_delay);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_CLOCK, OLED_I2C_PIN_SCL);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_DATA, OLED_I2C_PIN_SDA);
u8g2_t u8g2;

u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);
// Initialization
u8g2_Setup_ssd1306_i2c_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_sw_i2c, u8x8_rt_gpio_and_delay);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_CLOCK, OLED_I2C_PIN_SCL);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_DATA, OLED_I2C_PIN_SDA);

u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);

u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
}
MSH_CMD_EXPORT(ssd1306_12864_sw_i2c_example, i2c ssd1306 software i2c sample);
94 changes: 47 additions & 47 deletions examples/st7920_12864_8080_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,61 @@
// You may reference Drivers/drv_gpio.c for pinout
// In u8x8.h #define U8X8_USE_PINS

#define ST7920_8080_PIN_D0 36 // PB15
#define ST7920_8080_PIN_D1 35 // PB14
#define ST7920_8080_PIN_D2 34 // PB13
#define ST7920_8080_PIN_D3 33 // PB12
#define ST7920_8080_PIN_D4 37 // PC6
#define ST7920_8080_PIN_D5 38 // PC7
#define ST7920_8080_PIN_D6 39 // PC8
#define ST7920_8080_PIN_D7 40 // PC9
#define ST7920_8080_PIN_EN 50 // PA15
#define ST7920_8080_PIN_CS U8X8_PIN_NONE
#define ST7920_8080_PIN_DC 44 // PA11
#define ST7920_8080_PIN_RST 45 // PA12
#define ST7920_8080_PIN_D0 36 // PB15
#define ST7920_8080_PIN_D1 35 // PB14
#define ST7920_8080_PIN_D2 34 // PB13
#define ST7920_8080_PIN_D3 33 // PB12
#define ST7920_8080_PIN_D4 37 // PC6
#define ST7920_8080_PIN_D5 38 // PC7
#define ST7920_8080_PIN_D6 39 // PC8
#define ST7920_8080_PIN_D7 40 // PC9
#define ST7920_8080_PIN_EN 50 // PA15
#define ST7920_8080_PIN_CS U8X8_PIN_NONE
#define ST7920_8080_PIN_DC 44 // PA11
#define ST7920_8080_PIN_RST 45 // PA12

void u8x8_SetPin_8Bit_8080(u8x8_t *u8x8, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t wr, uint8_t cs, uint8_t dc, uint8_t reset)
{
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);
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);
}

static void st7920_12864_8080_example(int argc,char *argv[])
{
u8g2_t u8g2;
u8g2_t u8g2;

// Initialization
u8g2_Setup_st7920_p_128x64_f(&u8g2, U8G2_R0, u8x8_byte_8bit_8080mode, u8x8_rt_gpio_and_delay);
u8x8_SetPin_8Bit_8080(u8g2_GetU8x8(&u8g2),
ST7920_8080_PIN_D0, ST7920_8080_PIN_D1,
ST7920_8080_PIN_D2, ST7920_8080_PIN_D3,
ST7920_8080_PIN_D4, ST7920_8080_PIN_D5,
ST7920_8080_PIN_D6, ST7920_8080_PIN_D7,
ST7920_8080_PIN_EN, ST7920_8080_PIN_CS,
ST7920_8080_PIN_DC, ST7920_8080_PIN_RST);

u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);
// Initialization
u8g2_Setup_st7920_p_128x64_f(&u8g2, U8G2_R0, u8x8_byte_8bit_8080mode, u8x8_rt_gpio_and_delay);
u8x8_SetPin_8Bit_8080(u8g2_GetU8x8(&u8g2),
ST7920_8080_PIN_D0, ST7920_8080_PIN_D1,
ST7920_8080_PIN_D2, ST7920_8080_PIN_D3,
ST7920_8080_PIN_D4, ST7920_8080_PIN_D5,
ST7920_8080_PIN_D6, ST7920_8080_PIN_D7,
ST7920_8080_PIN_EN, ST7920_8080_PIN_CS,
ST7920_8080_PIN_DC, ST7920_8080_PIN_RST);

u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SendBuffer(&u8g2);

u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
}
MSH_CMD_EXPORT(st7920_12864_8080_example, st7920 12864 LCD sample);
Loading

0 comments on commit 9cb076d

Please sign in to comment.