From 8b0426a9e008907b053f7a680b2a16aee7940ca4 Mon Sep 17 00:00:00 2001 From: JiXieShi Date: Sat, 22 Jun 2024 14:45:07 +0800 Subject: [PATCH] =?UTF-8?q?UP=20=E9=80=9A=E7=94=A8OLED?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/oled/oled.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) 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) {