From 9f7eb043eae1b5b0196354c373c6aae987695b86 Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Sun, 14 Jun 2020 10:57:41 +0100 Subject: tidy --- app/oled.c | 65 +++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 30 deletions(-) (limited to 'app/oled.c') diff --git a/app/oled.c b/app/oled.c index 69b2580..dec54f2 100644 --- a/app/oled.c +++ b/app/oled.c @@ -8,36 +8,38 @@ uint8_t update_buf[DMA_BUF_SZ]; static int dma_in_progress = 0; static int refresh_enabled = 0; static uint32_t refresh_wdt = 0; -static int oled_sad=0; +static int oled_sad = 0; int ssd1306_cmds (uint8_t * buf, size_t len, int delay) { - int ret=-1; + int ret = -1; while (i2c_lock ()); - do { + do + { - if (i2cp_start_transaction (SSD1306_I2C_ADDRESS, I2C_WRITE)) - break; + if (i2cp_start_transaction (SSD1306_I2C_ADDRESS, I2C_WRITE)) + break; - if (i2cp_send (SSD1306_COMMAND)) - break; - - while (len--) - if (i2cp_send (*(buf++))) - break; + if (i2cp_send (SSD1306_COMMAND)) + break; - i2cp_stop (); + while (len--) + if (i2cp_send (*(buf++))) + break; + + i2cp_stop (); - if (delay) - delay_us (delay); + if (delay) + delay_us (delay); - ret=0; - } while(0); + ret = 0; + } + while (0); i2c_unlock (); @@ -67,15 +69,17 @@ start_dma (void) memcpy (dma_buf, update_buf, DMA_BUF_SZ); - if (ssd1306_cmds (cmds, sizeof (cmds), 0)) { - oled_sad++; - return; - } - - if (i2cp_start_transaction (SSD1306_I2C_ADDRESS, I2C_WRITE)) { - oled_sad++; - return; - } + if (ssd1306_cmds (cmds, sizeof (cmds), 0)) + { + oled_sad++; + return; + } + + if (i2cp_start_transaction (SSD1306_I2C_ADDRESS, I2C_WRITE)) + { + oled_sad++; + return; + } refresh_wdt = 0; dma_in_progress = 1; @@ -122,11 +126,12 @@ oled_refresh_wdt (void) i2cp_stop (); dma_in_progress = 0; - if (oled_sad) { - oled_sad=0; - i2cp_reset_sm(); - } - + if (oled_sad) + { + oled_sad = 0; + i2cp_reset_sm (); + } + start_dma (); } -- cgit v1.2.3