diff --git a/README.md b/README.md
index f3090ed..43529bf 100644
--- a/README.md
+++ b/README.md
@@ -6,29 +6,28 @@ Detailed information are described in [Datasheet SSD1306](https://cdn-shop.adafr
## Library
C library is aimed for driving [0.96" OLED display with SSD1306 driver](#demonstration) 128x64 or 128x32 version through TWI's (I2C). Settings for particular versions:
- 128x64 version
- - command argument **SSD1306_SET_MUX_RATIO** set to *63* (ssd1306.c)
+ - command argument **SSD1306_SET_MUX_RATIO** set to *0x3F* (ssd1306.c)
- command argument **SSD1306_COM_PIN_CONF** set to *0x12* (ssd1306.c)
- **END_PAGE_ADDR** set to 7 (ssd1306.h)
- 128x32 version
- - command argument **SSD1306_SET_MUX_RATIO** set to *31* (ssd1306.c)
+ - command argument **SSD1306_SET_MUX_RATIO** set to *0x1F* (ssd1306.c)
- command argument **SSD1306_COM_PIN_CONF** set to *0x02* (ssd1306.c)
- **END_PAGE_ADDR** set to 3 (ssd1306.h)
### Versions
-- 1.0 - basic functions. The first publication.
-- 2.0 - more changes:
- - rebuild to cacheMemLcd array. It means that every request is stored in cache array and then is depicted on the display by function [SSD1306_UpdateScreen (uint8_t)](#ssd1306_updatescreen).
- - Added new function -> [SSD1306_DrawLine (uint8_t, uint8_t, uint8_t, uint8_t)](#ssd1306_drawline). Possible depicted any line (horizontal, vertical, with slope).
- - Possible to use for more than 1 display (not tested, cause displays that I have avialable had the same addresses).
+- 1.0.0 - basic functions. The first publication.
+- [2.0.0](https://github.com/Matiasus/SSD1306/tree/v2.0.0) - more changes:
+ - rebuild to 'cacheMemLcd' array approach. It means that every request is stored in 'cacheMemLcd' array (RAM) and by the [SSD1306_UpdateScreen (uint8_t)](#ssd1306_updatescreen) function is printed on the display.
+ - added new function -> [SSD1306_DrawLine (uint8_t, uint8_t, uint8_t, uint8_t)](#ssd1306_drawline). Possible depicted any line (horizontal, vertical, with slope).
+ - possible to use for more than 1 display (not tested).
- **!!!** ~1kB RAM memory consumption.
-- 3.0 - simplified alphanumeric version
- - used for displaying alphanumeric characters
- - **one display** applicable
+- [3.0.0](https://github.com/Matiasus/SSD1306/tree/v3.0.0) - simplified alphanumeric version
+ - displaying alphanumeric characters
+ - for **one display** applicable
- **only few RAM bytes** consumption
- - **!!!** no graphic functions
+ - **!!!** no graphic functions like drawLine
## Dependencies
-- [font.c](https://github.com/Matiasus/SSD1306/blob/readme-edits/lib/font.c)
- [font.h](https://github.com/Matiasus/SSD1306/blob/readme-edits/lib/font.h)
- [twi.c](https://github.com/Matiasus/SSD1306/blob/readme-edits/lib/twi.c)
- [twi.h](https://github.com/Matiasus/SSD1306/blob/readme-edits/lib/twi.h)
@@ -125,17 +124,13 @@ Init sequence OLED display was defined according to page 64 (next to last page)
// | 0xAF |
// +---------------------------+
```
-## Functions
-- [SSD1306_Init (void)](#ssd1306_init) - Init display
-- [SSD1306_ClearScreen (void)](#ssd1306_clearscreen) - Clear screen
-- [SSD1306_NormalScreen (void)](#ssd1306_normalscreen) - Normal screen
-- [SSD1306_InverseScreen (void)](#ssd1306_inversescreen) - Inverse screen
-- [SSD1306_SetWindow (uint8_t, uint8_t, uint8_t, uint8_t)](#ssd1306_setwindow) - Set window
-- [SSD1306_SetPosition (uint8_t, uint8_t)](#ssd1306_setposition) - Set position
-- [SSD1306_DrawChar (char, enum E_Font)](#ssd1306_drawchar) - Draw specific character (bold | underline | normal)
-- [SSD1306_DrawString (char*, enum E_Font)](#ssd1306_drawstring) - Draw specific string (bold | underline | normal)
+## Demonstration version v1.0.0
+
-## Demonstration
+## Demonstration version v2.0.0
+
+
+## Demonstration version v3.0.0
## Acknowledgement
diff --git a/img/demonstration_ssd1306.jpg b/img/ssd1306_v100.jpg
similarity index 100%
rename from img/demonstration_ssd1306.jpg
rename to img/ssd1306_v100.jpg
diff --git a/lib/ssd1306.c b/lib/ssd1306.c
index ae60fce..f816695 100644
--- a/lib/ssd1306.c
+++ b/lib/ssd1306.c
@@ -7,16 +7,16 @@
*
* @author Marian Hrinko
* @date 06.10.2020
- * @update 06.12.2022
+ * @update 15.12.2022
* @file ssd1306.c
- * @version 3.0
+ * @version 3.0.0
* @tested AVR Atmega328p
*
- * @depend font.h, twi.h
+ * @depend ssd1306.h
* --------------------------------------------------------------------------------------+
- * @descr Version 1.0 -> applicable for 1 display
- * Version 2.0 -> rebuild to 'cacheMemLcd' array
- * Version 3.0 -> simplified alphanumeric version
+ * @descr Version 1.0.0 -> applicable for 1 display
+ * Version 2.0.0 -> rebuild to 'cacheMemLcd' array
+ * Version 3.0.0 -> simplified alphanumeric version for 1 display
* --------------------------------------------------------------------------------------+
* @usage Basic Setup for OLED Display
*/
diff --git a/lib/ssd1306.h b/lib/ssd1306.h
index 296d247..ba62d56 100644
--- a/lib/ssd1306.h
+++ b/lib/ssd1306.h
@@ -7,16 +7,16 @@
*
* @author Marian Hrinko
* @date 06.10.2020
- * @update 21.11.2022
+ * @update 15.12.2022
* @file ssd1306.h
- * @version 3.0
+ * @version 3.0.0
* @tested AVR Atmega328p
*
* @depend font.h, twi.h
* -------------------------------------------------------------------------------------+
- * @descr Version 1.0 -> applicable for 1 display
- * Version 2.0 -> rebuild to 'cacheMemLcd' array
- * Version 3.0 -> simplified alphanumeric version
+ * @descr Version 1.0.0 -> applicable for 1 display
+ * Version 2.0.0 -> rebuild to 'cacheMemLcd' array
+ * Version 3.0.0 -> simplified alphanumeric version for 1 display
* -------------------------------------------------------------------------------------+
* @usage Basic Setup for OLED Display
*/
diff --git a/lib/twi.c b/lib/twi.c
index 4667ca3..73d9d7b 100644
--- a/lib/twi.c
+++ b/lib/twi.c
@@ -1,7 +1,7 @@
/**
- * ---------------------------------------------------------------+
+ * --------------------------------------------------------------------------------------+
* @desc Two Wire Interface / I2C Communication
- * ---------------------------------------------------------------+
+ * --------------------------------------------------------------------------------------+
* Copyright (C) 2020 Marian Hrinko.
* Written by Marian Hrinko (mato.hrinko@gmail.com)
*
@@ -10,13 +10,12 @@
* @file twi.c
* @tested AVR Atmega16, ATmega8, Atmega328
*
- * @depend
- * ---------------------------------------------------------------+
+ * @depend twi.h
+ * --------------------------------------------------------------------------------------+
* @usage Master Transmit Operation
*/
// include libraries
-#include
#include "twi.h"
/**
@@ -28,16 +27,16 @@
*/
void TWI_Init (void)
{
- // +++++++++++++++++++++++++++++++++++++++++++++
+ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Calculation fclk:
//
// fclk = (fcpu)/(16+2*TWBR*4^Prescaler) m16
// fclk = (fcpu)/(16+2*TWBR*Prescaler) m328p
- // ---------------------------------------------
+ // -------------------------------------------------------------------------------------
// Calculation TWBR:
//
// TWBR = {(fcpu/fclk) - 16 } / (2*4^Prescaler)
- // +++++++++++++++++++++++++++++++++++++++++++++
+ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// @param1 value of TWBR (m16)
// fclk = 400kHz; TWBR = 3
// fclk = 100kHz; TWBR = 20
@@ -59,7 +58,7 @@ char TWI_MT_Start (void)
// null status flag
TWI_TWSR &= ~0xA8;
// START
- // ----------------------------------------------
+ // -------------------------------------------------------------------------------------
// request for bus
TWI_START();
// wait till flag set
@@ -83,7 +82,7 @@ char TWI_MT_Start (void)
char TWI_MT_Send_SLAW (char address)
{
// SLA+W
- // ----------------------------------------------
+ // -------------------------------------------------------------------------------------
TWI_TWDR = (address << 1);
// enable
TWI_ENABLE();
@@ -109,7 +108,7 @@ char TWI_MT_Send_SLAW (char address)
char TWI_MT_Send_Data (char data)
{
// DATA
- // ----------------------------------------------
+ // -------------------------------------------------------------------------------------
TWI_TWDR = data;
// enable
TWI_ENABLE();
@@ -135,7 +134,7 @@ char TWI_MT_Send_Data (char data)
char TWI_MR_Send_SLAR (char address)
{
// SLA+R
- // ----------------------------------------------
+ // -------------------------------------------------------------------------------------
TWI_TWDR = (address << 1) | 0x01;
// enable
TWI_ENABLE();
@@ -161,7 +160,7 @@ char TWI_MR_Send_SLAR (char address)
void TWI_Stop (void)
{
// End TWI
- // -------------------------------------------------
+ // -------------------------------------------------------------------------------------
// send stop sequence
TWI_STOP ();
// wait for TWINT flag is set
diff --git a/lib/twi.h b/lib/twi.h
index 8c4d356..d2049a8 100644
--- a/lib/twi.h
+++ b/lib/twi.h
@@ -1,7 +1,7 @@
/**
- * ---------------------------------------------------------------+
+ * --------------------------------------------------------------------------------------+
* @desc Two Wire Interface / I2C Communication
- * ---------------------------------------------------------------+
+ * --------------------------------------------------------------------------------------+
* Copyright (C) 2020 Marian Hrinko.
* Written by Marian Hrinko (mato.hrinko@gmail.com)
*
@@ -10,16 +10,19 @@
* @file twi.h
* @tested AVR Atmega16, ATmega8, Atmega328
*
- * @depend
- * ---------------------------------------------------------------+
+ * @depend avr/io.h
+ * --------------------------------------------------------------------------------------+
* @usage Basic Master Transmit Operation
*/
#ifndef __TWI_H__
#define __TWI_H__
+ // @includes
+ #include
+
// define register for TWI communication
- // -------------------------------------------
+ // -------------------------------------------------------------------------------------
#if defined(__AVR_ATmega16__) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega328P__)
#define TWI_TWAR TWAR // TWI (Slave) Address Register
@@ -31,22 +34,22 @@
#endif
// Success
- // -------------------------------------------
+ // -------------------------------------------------------------------------------------
#ifndef SUCCESS
#define SUCCESS 0
#endif
// Error
- // -------------------------------------------
+ // -------------------------------------------------------------------------------------
#ifndef ERROR
#define ERROR 1
#endif
- // ++++++++++++++++++++++++++++++++++++++++++
+ // -------------------------------------------------------------------------------------
//
// M A S T E R M O D E
//
- // ++++++++++++++++++++++++++++++++++++++++++
+ // -------------------------------------------------------------------------------------
// Master Mode - Transmitter / Receiver
#define TWI_START_ACK 0x08 // A START condition has been transmitted
#define TWI_REP_START_ACK 0x10 // A repeated START condition has been transmitted
@@ -62,11 +65,11 @@
#define TWI_MR_DATA_ACK 0x50 // Data byte has been received; ACK has been received
#define TWI_MR_DATA_NACK 0x58 // Data byte has been received; NOT ACK has been received
- // ++++++++++++++++++++++++++++++++++++++++++
+ // -------------------------------------------------------------------------------------
//
// S L A V E M O D E
//
- // ++++++++++++++++++++++++++++++++++++++++++
+ // -------------------------------------------------------------------------------------
// Slave Receiver Mode
#define TWI_SR_SLAW_ACK 0x60 // Own Slave address has been received; ACK returned
#define TWI_SR_ALMOA_ACK 0x68 // Arbitration Lost in SLA+R/W as Master; Own Slave address has been received; ACK returned
@@ -85,7 +88,7 @@
#define TWI_ST_DATA_LOST_ACK 0xC8 // Last data byte in TWDR has been transmitted (TWEA = '0'); ACK has been received
// TWI CLK frequency
- // -------------------------------------------
+ // -------------------------------------------------------------------------------------
// @param TWBR
// @param Prescaler
// TWPS1 TWPS0 - PRESCALER
@@ -96,21 +99,21 @@
#define TWI_FREQ(BIT_RATE, PRESCALER) { TWI_TWBR = BIT_RATE; TWI_TWSR |= (TWI_TWSR & 0x03) | PRESCALER; }
// TWI start condition
- // -------------------------------------------
+ // -------------------------------------------------------------------------------------
// (1 << TWEN) - TWI Enable
// (1 << TWINT) - TWI Interrupt Flag - must be cleared by set
// (1 << TWSTA) - TWI Start
#define TWI_START() { TWI_TWCR = (1 << TWEN) | (1 << TWINT) | (1 << TWSTA); }
// TWI stop condition
- // -------------------------------------------
+ // -------------------------------------------------------------------------------------
// (1 << TWEN) - TWI Enable
// (1 << TWINT) - TWI Interrupt Flag - must be cleared by set
// (1 << TWSTO) - TWI Stop
#define TWI_STOP() { TWI_TWCR = (1 << TWEN) | (1 << TWINT) | (1 << TWSTO); }
// TWI enable
- // -------------------------------------------
+ // -------------------------------------------------------------------------------------
// (1 << TWEN) - TWI Enable
// (1 << TWINT) - TWI Interrupt Flag - must be cleared by set
#define TWI_ENABLE() { TWI_TWCR = (1 << TWEN) | (1 << TWINT); }
diff --git a/main.c b/main.c
index 18196e5..2814074 100644
--- a/main.c
+++ b/main.c
@@ -9,14 +9,14 @@
* @date 06.10.2020
* @update 19.07.2021
* @file main.c
- * @version 3.0
+ * @version 3.0.0
* @tested AVR Atmega328p
*
* @depend lib/ssd1306.h
* --------------------------------------------------------------------------------------+
- * @descr Version 1.0 -> applicable for 1 display
- * Version 2.0 -> rebuild to 'cacheMemLcd' array
- * Version 3.0 -> simplified alphanumeric version
+ * @descr Version 1.0.0 -> applicable for 1 display
+ * Version 2.0.0 -> rebuild to 'cacheMemLcd' array
+ * Version 3.0.0 -> simplified alphanumeric version for 1 display
* --------------------------------------------------------------------------------------+
*/