Add comments to commands

This commit is contained in:
Marián 2023-12-20 11:38:18 +01:00 committed by GitHub
parent 7881fde0b3
commit b530953d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,22 +1,21 @@
/**
* -------------------------------------------------------------------------------------+
* @desc SSD1306 OLED Driver
* @brief SSD1306 OLED Driver
* -------------------------------------------------------------------------------------+
* Copyright (C) 2020 Marian Hrinko.
* Written by Marian Hrinko (mato.hrinko@gmail.com)
*
* @author Marian Hrinko
* @date 06.10.2020
* @update 21.11.2022
* @file ssd1306.h
* @version 2.0.0
* @tested AVR Atmega328p
* @test AVR Atmega328p
*
* @depend string.h, font.h, twi.h
* -------------------------------------------------------------------------------------+
* @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
* @brief Version 1.0 -> applicable for 1 display
* Version 2.0 -> rebuild to 'cacheMemLcd' array
* Version 3.0 -> simplified alphanumeric version for 1 display
* -------------------------------------------------------------------------------------+
* @usage Basic Setup for OLED Display
*/
@ -45,30 +44,40 @@
#define SSD1306_DATA 0xC0 // Continuation bit=1, D/C=1; 1100 0000
#define SSD1306_DATA_STREAM 0x40 // Continuation bit=0, D/C=1; 0100 0000
#define SSD1306_SET_MUX_RATIO 0xA8
#define SSD1306_DISPLAY_OFFSET 0xD3
#define SSD1306_DISPLAY_ON 0xAF
#define SSD1306_DISPLAY_OFF 0xAE
#define SSD1306_DIS_ENT_DISP_ON 0xA4
#define SSD1306_DIS_IGNORE_RAM 0xA5
#define SSD1306_DIS_NORMAL 0xA6
#define SSD1306_DIS_INVERSE 0xA7
#define SSD1306_DEACT_SCROLL 0x2E
#define SSD1306_ACTIVE_SCROLL 0x2F
#define SSD1306_SET_START_LINE 0x40
#define SSD1306_MEMORY_ADDR_MODE 0x20
#define SSD1306_SET_COLUMN_ADDR 0x21
#define SSD1306_SET_PAGE_ADDR 0x22
#define SSD1306_SEG_REMAP 0xA0
#define SSD1306_SEG_REMAP_OP 0xA1
#define SSD1306_COM_SCAN_DIR 0xC0
#define SSD1306_COM_SCAN_DIR_OP 0xC8
#define SSD1306_COM_PIN_CONF 0xDA
#define SSD1306_SET_CONTRAST 0x81
#define SSD1306_SET_OSC_FREQ 0xD5
#define SSD1306_SET_CHAR_REG 0x8D
#define SSD1306_SET_PRECHARGE 0xD9
#define SSD1306_VCOM_DESELECT 0xDB
#define SSD1306_SET_MUX_RATIO 0xA8 // Set MUX ratio to N+1 MUX, N=A[5:0] : from 16MUX to 64MUX
#define SSD1306_DISPLAY_OFFSET 0xD3 // Set Display Offset
#define SSD1306_DISPLAY_ON 0xAF // Display ON in normal mode
#define SSD1306_DISPLAY_OFF 0xAE // Display OFF (sleep mode)
#define SSD1306_DIS_ENT_DISP_ON 0xA4 // Entire Display ON, Output ignores RAM content
#define SSD1306_DIS_IGNORE_RAM 0xA5 // Resume to RAM content display, Output follows RAM content
#define SSD1306_DIS_NORMAL 0xA6 // Normal display, 0 in RAM: OFF in display panel, 1 in RAM: ON in display panel
#define SSD1306_DIS_INVERSE 0xA7 // Inverse display, 0 in RAM: ON in display panel, 1 in RAM: OFF in display panel
#define SSD1306_DEACT_SCROLL 0x2E // Stop scrolling that is configured by command 26h/27h/29h/2Ah
#define SSD1306_ACTIVE_SCROLL 0x2F // Start scrolling that is configured by the scrolling setup commands:26h/27h/29h/2Ah
#define SSD1306_SET_START_LINE 0x40 // Set Display Start Line
#define SSD1306_MEMORY_ADDR_MODE 0x20 // Set Memory, Addressing Mode
#define SSD1306_SET_COLUMN_ADDR 0x21 // Set Column Address
#define SSD1306_SET_PAGE_ADDR 0x22 // Set Page Address
#define SSD1306_SEG_REMAP 0xA0 // Set Segment Re-map, X[0]=0b column address 0 is mapped to SEG0
#define SSD1306_SEG_REMAP_OP 0xA1 // Set Segment Re-map, X[0]=1b: column address 127 is mapped to SEG0
#define SSD1306_COM_SCAN_DIR 0xC0 // Set COM Output, X[3]=0b: normal mode (RESET) Scan from COM0 to COM[N 1], e N is the Multiplex ratio
#define SSD1306_COM_SCAN_DIR_OP 0xC8 // Set COM Output, X[3]=1b: remapped mode. Scan from COM[N-1] to COM0, e N is the Multiplex ratio
#define SSD1306_COM_PIN_CONF 0xDA // Set COM Pins Hardware Configuration,
// A[4]=0b, Sequential COM pin configuration, A[4]=1b(RESET), Alternative COM pin configuration
// A[5]=0b(RESET), Disable COM Left/Right remap, A[5]=1b, Enable COM Left/Right remap
#define SSD1306_SET_CONTRAST 0x81 // Set Contrast Control, Double byte command to select 1 to 256 contrast steps, increases as the value increases
#define SSD1306_SET_OSC_FREQ 0xD5 // Set Display Clock Divide Ratio/Oscillator Frequency
// A[3:0] : Define the divide ratio (D) of the display clocks (DCLK): Divide ratio= A[3:0] + 1, RESET is 0000b (divide ratio = 1)
// A[7:4] : Set the Oscillator Frequency, FOSC. Oscillator Frequency increases with the value of A[7:4] and vice versa. RESET is 1000b
#define SSD1306_SET_CHAR_REG 0x8D // Charge Pump Setting, A[2] = 0b, Disable charge pump(RESET), A[2] = 1b, Enable charge pump during display on
// The Charge Pump must be enabled by the following command:
// 8Dh ; Charge Pump Setting
// 14h ; Enable Charge Pump
// AFh; Display ON
#define SSD1306_SET_PRECHARGE 0xD9 // Set Pre-charge Period
#define SSD1306_VCOM_DESELECT 0xDB // Set VCOMH Deselect Leve
#define SSD1306_NOP 0xE3 // No operation
#define SSD1306_RESET 0xE4 // Maybe SW RESET, @source https://github.com/SmingHub/Sming/issues/501
// Clear Color
// ------------------------------------------------------------------------------------
@ -96,7 +105,13 @@
unsigned int _counter;
/**
* @desc SSD1306 Init
* --------------------------------------------------------------------------------------------+
* PRIVATE FUNCTIONS
* --------------------------------------------------------------------------------------------+
*/
/**
* @brief SSD1306 Init
*
* @param uint8_t
*
@ -105,7 +120,7 @@
uint8_t SSD1306_Init (uint8_t);
/**
* @desc SSD1306 Send Start and SLAW request
* @brief SSD1306 Send Start and SLAW request
*
* @param uint8_t
*
@ -114,7 +129,7 @@
uint8_t SSD1306_Send_StartAndSLAW (uint8_t);
/**
* @desc SSD1306 Send command
* @brief SSD1306 Send command
*
* @param uint8_t
*
@ -123,7 +138,13 @@
uint8_t SSD1306_Send_Command (uint8_t);
/**
* @desc SSD1306 Clear screen
* +------------------------------------------------------------------------------------+
* |== PUBLIC FUNCTIONS ================================================================|
* +------------------------------------------------------------------------------------+
*/
/**
* @brief SSD1306 Clear screen
*
* @param void
*
@ -132,7 +153,7 @@
void SSD1306_ClearScreen (void);
/**
* @desc SSD1306 Normal colors
* @brief SSD1306 Normal colors
*
* @param uint8_t
*
@ -141,7 +162,7 @@
uint8_t SSD1306_NormalScreen (uint8_t);
/**
* @desc SSD1306 Inverse colors
* @brief SSD1306 Inverse colors
*
* @param uint8_t
*
@ -150,7 +171,7 @@
uint8_t SSD1306_InverseScreen (uint8_t);
/**
* @desc SSD1306 Update screen
* @brief SSD1306 Update screen
*
* @param uint8_t
*
@ -159,7 +180,7 @@
uint8_t SSD1306_UpdateScreen (uint8_t);
/**
* @desc SSD1306 Update text position
* @brief SSD1306 Update text position
*
* @param void
*
@ -168,7 +189,7 @@
uint8_t SSD1306_UpdatePosition (void);
/**
* @desc SSD1306 Set position
* @brief SSD1306 Set position
*
* @param uint8_t
* @param uint8_t
@ -178,7 +199,7 @@
void SSD1306_SetPosition (uint8_t, uint8_t);
/**
* @desc SSD1306 Draw character
* @brief SSD1306 Draw character
*
* @param char
*
@ -187,7 +208,7 @@
uint8_t SSD1306_DrawChar (char);
/**
* @desc SSD1306 Draw string
* @brief SSD1306 Draw string
*
* @param char *
*
@ -196,7 +217,7 @@
void SSD1306_DrawString (char *);
/**
* @desc Draw pixel
* @brief Draw pixel
*
* @param uint8_t
* @param uint8_t
@ -206,7 +227,7 @@
uint8_t SSD1306_DrawPixel (uint8_t, uint8_t);
/**
* @desc Draw line
* @brief Draw line
*
* @param uint8_t
* @param uint8_t