luat_disp_rtt.c 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #include "luat_disp.h"
  2. #include "rtthread.h"
  3. #ifdef PKG_USING_U8G2
  4. #include "u8g2_port.h"
  5. #define LUAT_LOG_TAG "disp"
  6. #include "luat_log.h"
  7. uint8_t luat_u8x8_gpio_and_delay(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
  8. int luat_disp_setup(luat_disp_conf_t *conf) {
  9. LLOGD("setup disp@rtt pinType=%ld", conf->pinType);
  10. u8g2_t* u8g2 = (u8g2_t*)conf->ptr;
  11. if (conf->pinType == 1) {
  12. u8g2_Setup_ssd1306_i2c_128x64_noname_f( u8g2, U8G2_R0, u8x8_byte_sw_i2c, luat_u8x8_gpio_and_delay);
  13. // u8g2_Setup_ssd1306_i2c_128x64_noname_f( u8g2, U8G2_R0, u8x8_byte_sw_i2c, u8x8_rt_gpio_and_delay);
  14. u8g2->u8x8.pins[U8X8_PIN_I2C_CLOCK] = conf->pin0;
  15. u8g2->u8x8.pins[U8X8_PIN_I2C_DATA] = conf->pin1;
  16. LLOGD("setup disp i2c.sw SCL=%ld SDA=%ld", conf->pin0, conf->pin1);
  17. }
  18. else {
  19. u8g2_Setup_ssd1306_i2c_128x64_noname_f( u8g2, U8G2_R0, u8x8_byte_rt_hw_i2c, u8x8_rt_gpio_and_delay);
  20. }
  21. u8g2_InitDisplay(u8g2);
  22. u8g2_SetPowerSave(u8g2, 0);
  23. return 0;
  24. }
  25. #endif