diff --git a/lib/src/oled/oled.cpp b/lib/src/oled/oled.cpp index 547f8a3..e2077b0 100644 --- a/lib/src/oled/oled.cpp +++ b/lib/src/oled/oled.cpp @@ -45,6 +45,9 @@ void OLED_Turn(OLED_T *dev, bool e) { void OLED_Refresh(OLED_T *dev) { uint8_t i, cmd[3] = {0xb0, 0x00, 0x10}; +#if REFRESH_CALL_ENABLE + dev->call(); +#else if (dev->state == IDLE) { dev->state = REFRESH; for (i = 0; i < (dev->height >> 3); i++) { @@ -52,10 +55,9 @@ void OLED_Refresh(OLED_T *dev) { dev->cmd(cmd, 3); dev->data(dev->buf + (i * dev->width), dev->width); } -#if REFRESH_CALL_ENABLE - dev->call(); -#endif + dev->state=IDLE; } +#endif } void OLED_DisplayTurn(OLED_T *dev, bool e) { @@ -180,9 +182,22 @@ void OLED_ShowString(OLED_T *dev, uint8_t x, uint8_t y, uint8_t *chr, uint8_t si } } +void OLED_Fill(OLED_T *dev, uint8_t data) { + uint8_t x, y; + for (y = 0; y < (dev->height >> 3); y++) { + for (x = 0; x < dev->width; x++) { + BUFPOINT(x, y) = data; + } + } +} + +void OLED_CLS(OLED_T *dev) { + OLED_Fill(dev, 0x00); +} + void OLED_SPos(OLED_T *dev, uint8_t x, uint8_t y) { uint8_t cmd[3]; - cmd[0] = (uint8_t) 0xb0 + y; + cmd[0] = 0xb0 + y; cmd[1] = ((x & 0xf0) >> 4) | 0x10; cmd[2] = (x & 0x0f) | 0x01; if (dev->state == IDLE) {