-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split examples (sw_i2c,hw_i2c,sw_spi,hw_spi)
- Loading branch information
Wu Han
committed
Dec 27, 2018
1 parent
f2cbd70
commit 7df33e5
Showing
7 changed files
with
152 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <rthw.h> | ||
#include <rtthread.h> | ||
#include <rtdevice.h> | ||
#include <u8g2_port.h> | ||
|
||
// 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 | ||
|
||
static void ssd1306_example_4wire_hw_spi(int argc,char *argv[]) | ||
{ | ||
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); | ||
|
||
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_example_4wire_hw_spi, sw 4wire spi ssd1306 sample); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <rthw.h> | ||
#include <rtthread.h> | ||
#include <rtdevice.h> | ||
#include <u8g2_port.h> | ||
|
||
// 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 | ||
|
||
static void ssd1306_example_4wire_sw_spi(int argc,char *argv[]) | ||
{ | ||
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); | ||
|
||
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols); | ||
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 ); | ||
u8g2_SendBuffer(&u8g2); | ||
} | ||
MSH_CMD_EXPORT(ssd1306_example_4wire_sw_spi, sw 4wire spi ssd1306 sample); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <rthw.h> | ||
#include <rtthread.h> | ||
#include <rtdevice.h> | ||
#include <u8g2_port.h> | ||
|
||
static void ssd1306_example_hw_i2c(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); | ||
|
||
// Draw Graphics | ||
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols); | ||
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 ); | ||
u8g2_SendBuffer(&u8g2); | ||
} | ||
MSH_CMD_EXPORT(ssd1306_example_hw_i2c, i2c ssd1306 sample); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <rthw.h> | ||
#include <rtthread.h> | ||
#include <rtdevice.h> | ||
#include <u8g2_port.h> | ||
|
||
#define OLED_I2C_PIN_SCL 58 // PB6 | ||
#define OLED_I2C_PIN_SDA 59 // PB7 | ||
|
||
static void ssd1306_example_sw_i2c(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_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_example_sw_i2c, i2c ssd1306 software i2c sample); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters