Skip to content

Commit 9cb076d

Browse files
author
Wu Han
committed
Get device name from Kconfig
1 parent 14452c9 commit 9cb076d

File tree

6 files changed

+174
-176
lines changed

6 files changed

+174
-176
lines changed

examples/ssd1306_12864_4wire_hw_spi_example.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@
66
// You may reference Drivers/drv_gpio.c for pinout
77
// In u8x8.h #define U8X8_USE_PINS
88

9-
#define OLED_SPI_PIN_RES 16 // PA2
10-
#define OLED_SPI_PIN_DC 15 // PA1
11-
#define OLED_SPI_PIN_CS 14 // PA0
9+
#define OLED_SPI_PIN_RES 16 // PA2
10+
#define OLED_SPI_PIN_DC 15 // PA1
11+
#define OLED_SPI_PIN_CS 14 // PA0
1212

1313
static void ssd1306_12864_4wire_hw_spi_example(int argc,char *argv[])
1414
{
15-
u8g2_t u8g2;
15+
u8g2_t u8g2;
1616

17-
// Initialization
18-
u8g2_Setup_ssd1306_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_rt_4wire_hw_spi, u8x8_rt_gpio_and_delay);
19-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, OLED_SPI_PIN_CS);
20-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, OLED_SPI_PIN_DC);
21-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, OLED_SPI_PIN_RES);
17+
// Initialization
18+
u8g2_Setup_ssd1306_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_rt_4wire_hw_spi, u8x8_rt_gpio_and_delay);
19+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, OLED_SPI_PIN_CS);
20+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, OLED_SPI_PIN_DC);
21+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, OLED_SPI_PIN_RES);
22+
23+
u8g2_InitDisplay(&u8g2);
24+
u8g2_SetPowerSave(&u8g2, 0);
2225

23-
u8g2_InitDisplay(&u8g2);
24-
u8g2_SetPowerSave(&u8g2, 0);
25-
26-
// Draw Graphics
27-
/* full buffer example, setup procedure ends in _f */
28-
u8g2_ClearBuffer(&u8g2);
29-
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
30-
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
31-
u8g2_SendBuffer(&u8g2);
26+
// Draw Graphics
27+
/* full buffer example, setup procedure ends in _f */
28+
u8g2_ClearBuffer(&u8g2);
29+
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
30+
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
31+
u8g2_SendBuffer(&u8g2);
3232

33-
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
34-
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
35-
u8g2_SendBuffer(&u8g2);
33+
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
34+
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
35+
u8g2_SendBuffer(&u8g2);
3636
}
3737
MSH_CMD_EXPORT(ssd1306_12864_4wire_hw_spi_example, sw 4wire spi ssd1306 sample);

examples/ssd1306_12864_4wire_sw_spi_example.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,36 @@
66
// You may reference Drivers/drv_gpio.c for pinout
77
// In u8x8.h #define U8X8_USE_PINS
88

9-
#define OLED_SPI_PIN_CLK 21 // PA5
10-
#define OLED_SPI_PIN_MOSI 23 // PA7
11-
#define OLED_SPI_PIN_RES 16 // PA2
12-
#define OLED_SPI_PIN_DC 15 // PA1
13-
#define OLED_SPI_PIN_CS 14 // PA0
9+
#define OLED_SPI_PIN_CLK 21 // PA5
10+
#define OLED_SPI_PIN_MOSI 23 // PA7
11+
#define OLED_SPI_PIN_RES 16 // PA2
12+
#define OLED_SPI_PIN_DC 15 // PA1
13+
#define OLED_SPI_PIN_CS 14 // PA0
1414

1515
static void ssd1306_12864_4wire_sw_spi_example(int argc,char *argv[])
1616
{
17-
u8g2_t u8g2;
17+
u8g2_t u8g2;
1818

19-
// Initialization
20-
u8g2_Setup_ssd1306_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_4wire_sw_spi, u8x8_rt_gpio_and_delay);
21-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_CLOCK, OLED_SPI_PIN_CLK);
22-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_DATA, OLED_SPI_PIN_MOSI);
23-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, OLED_SPI_PIN_CS);
24-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, OLED_SPI_PIN_DC);
25-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, OLED_SPI_PIN_RES);
26-
27-
u8g2_InitDisplay(&u8g2);
28-
u8g2_SetPowerSave(&u8g2, 0);
29-
30-
// Draw Graphics
31-
/* full buffer example, setup procedure ends in _f */
32-
u8g2_ClearBuffer(&u8g2);
33-
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
34-
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
35-
u8g2_SendBuffer(&u8g2);
19+
// Initialization
20+
u8g2_Setup_ssd1306_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_4wire_sw_spi, u8x8_rt_gpio_and_delay);
21+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_CLOCK, OLED_SPI_PIN_CLK);
22+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_DATA, OLED_SPI_PIN_MOSI);
23+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, OLED_SPI_PIN_CS);
24+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, OLED_SPI_PIN_DC);
25+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, OLED_SPI_PIN_RES);
3626

37-
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
38-
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
39-
u8g2_SendBuffer(&u8g2);
27+
u8g2_InitDisplay(&u8g2);
28+
u8g2_SetPowerSave(&u8g2, 0);
29+
30+
// Draw Graphics
31+
/* full buffer example, setup procedure ends in _f */
32+
u8g2_ClearBuffer(&u8g2);
33+
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
34+
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
35+
u8g2_SendBuffer(&u8g2);
36+
37+
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
38+
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
39+
u8g2_SendBuffer(&u8g2);
4040
}
4141
MSH_CMD_EXPORT(ssd1306_12864_4wire_sw_spi_example, sw 4wire spi ssd1306 sample);

examples/ssd1306_12864_hw_i2c_example.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55

66
static void ssd1306_12864_hw_i2c_example(int argc,char *argv[])
77
{
8-
u8g2_t u8g2;
9-
10-
// Initialization
11-
u8g2_Setup_ssd1306_i2c_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_rt_hw_i2c, u8x8_rt_gpio_and_delay);
12-
u8g2_InitDisplay(&u8g2);
13-
u8g2_SetPowerSave(&u8g2, 0);
14-
15-
/* full buffer example, setup procedure ends in _f */
16-
u8g2_ClearBuffer(&u8g2);
17-
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
18-
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
19-
u8g2_SendBuffer(&u8g2);
8+
u8g2_t u8g2;
209

21-
// Draw Graphics
22-
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
23-
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
24-
u8g2_SendBuffer(&u8g2);
10+
// Initialization
11+
u8g2_Setup_ssd1306_i2c_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_rt_hw_i2c, u8x8_rt_gpio_and_delay);
12+
u8g2_InitDisplay(&u8g2);
13+
u8g2_SetPowerSave(&u8g2, 0);
14+
15+
/* full buffer example, setup procedure ends in _f */
16+
u8g2_ClearBuffer(&u8g2);
17+
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
18+
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
19+
u8g2_SendBuffer(&u8g2);
20+
21+
// Draw Graphics
22+
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
23+
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
24+
u8g2_SendBuffer(&u8g2);
2525
}
2626
MSH_CMD_EXPORT(ssd1306_12864_hw_i2c_example, i2c ssd1306 sample);

examples/ssd1306_12864_sw_i2c_example.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
#include <rtdevice.h>
44
#include <u8g2_port.h>
55

6-
#define OLED_I2C_PIN_SCL 58 // PB6
7-
#define OLED_I2C_PIN_SDA 59 // PB7
6+
#define OLED_I2C_PIN_SCL 58 // PB6
7+
#define OLED_I2C_PIN_SDA 59 // PB7
88

99
static void ssd1306_12864_sw_i2c_example(int argc,char *argv[])
1010
{
11-
u8g2_t u8g2;
12-
13-
// Initialization
14-
u8g2_Setup_ssd1306_i2c_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_sw_i2c, u8x8_rt_gpio_and_delay);
15-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_CLOCK, OLED_I2C_PIN_SCL);
16-
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_DATA, OLED_I2C_PIN_SDA);
11+
u8g2_t u8g2;
1712

18-
u8g2_InitDisplay(&u8g2);
19-
u8g2_SetPowerSave(&u8g2, 0);
20-
21-
// Draw Graphics
22-
/* full buffer example, setup procedure ends in _f */
23-
u8g2_ClearBuffer(&u8g2);
24-
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
25-
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
26-
u8g2_SendBuffer(&u8g2);
13+
// Initialization
14+
u8g2_Setup_ssd1306_i2c_128x64_noname_f( &u8g2, U8G2_R0, u8x8_byte_sw_i2c, u8x8_rt_gpio_and_delay);
15+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_CLOCK, OLED_I2C_PIN_SCL);
16+
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_DATA, OLED_I2C_PIN_SDA);
2717

28-
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
29-
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
30-
u8g2_SendBuffer(&u8g2);
18+
u8g2_InitDisplay(&u8g2);
19+
u8g2_SetPowerSave(&u8g2, 0);
20+
21+
// Draw Graphics
22+
/* full buffer example, setup procedure ends in _f */
23+
u8g2_ClearBuffer(&u8g2);
24+
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
25+
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
26+
u8g2_SendBuffer(&u8g2);
27+
28+
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
29+
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
30+
u8g2_SendBuffer(&u8g2);
3131
}
3232
MSH_CMD_EXPORT(ssd1306_12864_sw_i2c_example, i2c ssd1306 software i2c sample);

examples/st7920_12864_8080_example.c

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,61 @@
66
// You may reference Drivers/drv_gpio.c for pinout
77
// In u8x8.h #define U8X8_USE_PINS
88

9-
#define ST7920_8080_PIN_D0 36 // PB15
10-
#define ST7920_8080_PIN_D1 35 // PB14
11-
#define ST7920_8080_PIN_D2 34 // PB13
12-
#define ST7920_8080_PIN_D3 33 // PB12
13-
#define ST7920_8080_PIN_D4 37 // PC6
14-
#define ST7920_8080_PIN_D5 38 // PC7
15-
#define ST7920_8080_PIN_D6 39 // PC8
16-
#define ST7920_8080_PIN_D7 40 // PC9
17-
#define ST7920_8080_PIN_EN 50 // PA15
18-
#define ST7920_8080_PIN_CS U8X8_PIN_NONE
19-
#define ST7920_8080_PIN_DC 44 // PA11
20-
#define ST7920_8080_PIN_RST 45 // PA12
9+
#define ST7920_8080_PIN_D0 36 // PB15
10+
#define ST7920_8080_PIN_D1 35 // PB14
11+
#define ST7920_8080_PIN_D2 34 // PB13
12+
#define ST7920_8080_PIN_D3 33 // PB12
13+
#define ST7920_8080_PIN_D4 37 // PC6
14+
#define ST7920_8080_PIN_D5 38 // PC7
15+
#define ST7920_8080_PIN_D6 39 // PC8
16+
#define ST7920_8080_PIN_D7 40 // PC9
17+
#define ST7920_8080_PIN_EN 50 // PA15
18+
#define ST7920_8080_PIN_CS U8X8_PIN_NONE
19+
#define ST7920_8080_PIN_DC 44 // PA11
20+
#define ST7920_8080_PIN_RST 45 // PA12
2121

2222
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)
2323
{
24-
u8x8_SetPin(u8x8, U8X8_PIN_D0, d0);
25-
u8x8_SetPin(u8x8, U8X8_PIN_D1, d1);
26-
u8x8_SetPin(u8x8, U8X8_PIN_D2, d2);
27-
u8x8_SetPin(u8x8, U8X8_PIN_D3, d3);
28-
u8x8_SetPin(u8x8, U8X8_PIN_D4, d4);
29-
u8x8_SetPin(u8x8, U8X8_PIN_D5, d5);
30-
u8x8_SetPin(u8x8, U8X8_PIN_D6, d6);
31-
u8x8_SetPin(u8x8, U8X8_PIN_D7, d7);
32-
u8x8_SetPin(u8x8, U8X8_PIN_E, wr);
33-
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
34-
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
35-
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
24+
u8x8_SetPin(u8x8, U8X8_PIN_D0, d0);
25+
u8x8_SetPin(u8x8, U8X8_PIN_D1, d1);
26+
u8x8_SetPin(u8x8, U8X8_PIN_D2, d2);
27+
u8x8_SetPin(u8x8, U8X8_PIN_D3, d3);
28+
u8x8_SetPin(u8x8, U8X8_PIN_D4, d4);
29+
u8x8_SetPin(u8x8, U8X8_PIN_D5, d5);
30+
u8x8_SetPin(u8x8, U8X8_PIN_D6, d6);
31+
u8x8_SetPin(u8x8, U8X8_PIN_D7, d7);
32+
u8x8_SetPin(u8x8, U8X8_PIN_E, wr);
33+
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
34+
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
35+
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
3636
}
3737

3838
static void st7920_12864_8080_example(int argc,char *argv[])
3939
{
40-
u8g2_t u8g2;
40+
u8g2_t u8g2;
4141

42-
// Initialization
43-
u8g2_Setup_st7920_p_128x64_f(&u8g2, U8G2_R0, u8x8_byte_8bit_8080mode, u8x8_rt_gpio_and_delay);
44-
u8x8_SetPin_8Bit_8080(u8g2_GetU8x8(&u8g2),
45-
ST7920_8080_PIN_D0, ST7920_8080_PIN_D1,
46-
ST7920_8080_PIN_D2, ST7920_8080_PIN_D3,
47-
ST7920_8080_PIN_D4, ST7920_8080_PIN_D5,
48-
ST7920_8080_PIN_D6, ST7920_8080_PIN_D7,
49-
ST7920_8080_PIN_EN, ST7920_8080_PIN_CS,
50-
ST7920_8080_PIN_DC, ST7920_8080_PIN_RST);
51-
52-
u8g2_InitDisplay(&u8g2);
53-
u8g2_SetPowerSave(&u8g2, 0);
54-
55-
// Draw Graphics
56-
/* full buffer example, setup procedure ends in _f */
57-
u8g2_ClearBuffer(&u8g2);
58-
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
59-
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
60-
u8g2_SendBuffer(&u8g2);
42+
// Initialization
43+
u8g2_Setup_st7920_p_128x64_f(&u8g2, U8G2_R0, u8x8_byte_8bit_8080mode, u8x8_rt_gpio_and_delay);
44+
u8x8_SetPin_8Bit_8080(u8g2_GetU8x8(&u8g2),
45+
ST7920_8080_PIN_D0, ST7920_8080_PIN_D1,
46+
ST7920_8080_PIN_D2, ST7920_8080_PIN_D3,
47+
ST7920_8080_PIN_D4, ST7920_8080_PIN_D5,
48+
ST7920_8080_PIN_D6, ST7920_8080_PIN_D7,
49+
ST7920_8080_PIN_EN, ST7920_8080_PIN_CS,
50+
ST7920_8080_PIN_DC, ST7920_8080_PIN_RST);
6151

62-
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
63-
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
64-
u8g2_SendBuffer(&u8g2);
52+
u8g2_InitDisplay(&u8g2);
53+
u8g2_SetPowerSave(&u8g2, 0);
54+
55+
// Draw Graphics
56+
/* full buffer example, setup procedure ends in _f */
57+
u8g2_ClearBuffer(&u8g2);
58+
u8g2_SetFont(&u8g2, u8g2_font_baby_tf);
59+
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
60+
u8g2_SendBuffer(&u8g2);
61+
62+
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
63+
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
64+
u8g2_SendBuffer(&u8g2);
6565
}
6666
MSH_CMD_EXPORT(st7920_12864_8080_example, st7920 12864 LCD sample);

0 commit comments

Comments
 (0)