From 8c24f968a58d0e95ced6286de8c4ab558e6b6cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20R=C3=B6mer?= Date: Wed, 20 Sep 2023 20:05:45 +0200 Subject: [PATCH] set frame in SRAM sequential mode, saving more power (#43) --- thermidity-avr/display.c | 14 ++++++++++---- thermidity-avr/sram.c | 6 ++++++ thermidity-avr/sram.h | 7 +++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/thermidity-avr/display.c b/thermidity-avr/display.c index b93d427..127f027 100644 --- a/thermidity-avr/display.c +++ b/thermidity-avr/display.c @@ -118,17 +118,23 @@ void sramToDisplay(void) { byte = transmit(~byte); } displayDes(); - sramDes(); + sramDes(); sramWriteStatus(SRAM_BYTE); } void setFrame(uint8_t byte) { uint16_t bytes = DISPLAY_WIDTH * DISPLAY_H_BYTES; - - for (int i = 0; i < bytes; i++) { - sramWrite(i, byte); + + sramWriteStatus(SRAM_SEQU); + + sramSel(); + sramInitWrite(0x0); + for (uint16_t i = 0; i < bytes; i++) { + transmit(byte); } + sramDes(); + sramWriteStatus(SRAM_BYTE); } width_t writeBitmap(row_t row, col_t col, uint16_t index) { diff --git a/thermidity-avr/sram.c b/thermidity-avr/sram.c index d7ec69c..55e8d9a 100644 --- a/thermidity-avr/sram.c +++ b/thermidity-avr/sram.c @@ -71,6 +71,12 @@ uint8_t sramReadStatus(void) { return status; } +void sramInitWrite(uint16_t address) { + transmit(SRAM_WRITE); + transmit(address >> 8); + transmit(address); +} + void sramInitRead(uint16_t address) { transmit(SRAM_READ); transmit(address >> 8); diff --git a/thermidity-avr/sram.h b/thermidity-avr/sram.h index a5f1b52..8fae657 100644 --- a/thermidity-avr/sram.h +++ b/thermidity-avr/sram.h @@ -65,6 +65,13 @@ void sramWriteStatus(uint8_t status); */ uint8_t sramReadStatus(void); +/** + * Sends write command and sets the given address. + * Useful for writing in sequential or page mode. + * @param address + */ +void sramInitWrite(uint16_t address); + /** * Sends read command and sets the given address. * Useful for reading in sequential or page mode.