回答

收藏

GD32方案分享④:OLED综合显示实验

GD32 GD32 4671 人阅读 | 0 人回复 | 2017-05-25


  1. #include "include.h"

  2. int main(void)
  3. {
  4.     systick_config();
  5.         
  6.           UART_Init(USART0,115200);
  7.     LED_Init();
  8.           KEY_Init();
  9.           OLED_Init();
  10.          
  11.           OLED_Print(0,0,"GD32f450 test!");
  12.           OLED_Print(0,2,"KEY1:");
  13.           OLED_Print(0,4,"KEY2:");
  14.           OLED_Print(0,6,"KEY3:");
  15.         
  16.           while(1)
  17.          {
  18.                           LED_Troggle();
  19.                     delay_1ms(200);
  20.                     printf("综合测试实验\r\n");
  21.                     printf("%d %d %d\r\n",KEY1_State,KEY2_State,KEY3_State);
  22.                           OLED_PrintInt(64,2,KEY1_State);
  23.                                  OLED_PrintInt(64,4,KEY2_State);
  24.                            OLED_PrintInt(64,6,KEY3_State);
  25.     }
  26. }
复制代码

  1. #ifndef  _OLED_H_
  2. #define  _OLED_H_

  3. #include "gpio.h"        

  4. #define X_WIDTH    128
  5. #define Y_WIDTH    64

  6. #define OLED_CLK      RCU_GPIOD
  7. #define OLED_PORT     GPIOD

  8. #define OLED_RST       GPIO_PIN_3
  9. #define OLED_DC        GPIO_PIN_4
  10. #define OLED_D0_SCL    GPIO_PIN_5
  11. #define OLED_D1_SDA    GPIO_PIN_6

  12. #define OUT_High(pin)  GPIO_BOP(OLED_PORT)=pin
  13. #define OUT_Low(pin)   GPIO_BC(OLED_PORT)=pin

  14. extern uint8 OLED_Rev;
复制代码
由于OLED驱动文件较大,会上传附件,只需要更改OLED.h里的引脚即可 非常方便 代码移植性高
myGD32.rar (6.85 MB, 下载次数: 34)


看下效果图:


分享到:
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条