mirror of
https://github.com/Matiasus/SSD1306.git
synced 2024-10-03 18:18:46 -04:00
Small modifications
This commit is contained in:
parent
59d4912c0f
commit
2ce548baba
104
lib/ssd1306.h
104
lib/ssd1306.h
@ -1,22 +1,23 @@
|
|||||||
/**
|
/**
|
||||||
* ---------------------------------------------------------------+
|
* -------------------------------------------------------------------------------------+
|
||||||
* @desc SSD1306 OLED Driver
|
* @desc SSD1306 OLED Driver
|
||||||
* ---------------------------------------------------------------+
|
* -------------------------------------------------------------------------------------+
|
||||||
* Copyright (C) 2020 Marian Hrinko.
|
* Copyright (C) 2020 Marian Hrinko.
|
||||||
* Written by Marian Hrinko (mato.hrinko@gmail.com)
|
* Written by Marian Hrinko (mato.hrinko@gmail.com)
|
||||||
*
|
*
|
||||||
* @author Marian Hrinko
|
* @author Marian Hrinko
|
||||||
* @datum 06.10.2020
|
* @datum 06.10.2020
|
||||||
* @update 19.07.2021
|
* @update 21.11.2022
|
||||||
* @file ssd1306.h
|
* @file ssd1306.h
|
||||||
* @version 2.0
|
* @version 3.0
|
||||||
* @tested AVR Atmega328
|
* @tested AVR Atmega328p
|
||||||
*
|
*
|
||||||
* @depend font.h, twi.h
|
* @depend font.h, twi.h
|
||||||
* ---------------------------------------------------------------+
|
* -------------------------------------------------------------------------------------+
|
||||||
* @descr Version 1.0 -> applicable for 1 display
|
* @descr Version 1.0 -> applicable for 1 display
|
||||||
* Version 2.0 -> rebuild to 'cacheMemLcd' array
|
* Version 2.0 -> rebuild to 'cacheMemLcd' array
|
||||||
* ---------------------------------------------------------------+
|
* Version 3.0 -> remove 'cacheMemLcd' approach
|
||||||
|
* -------------------------------------------------------------------------------------+
|
||||||
* @usage Basic Setup for OLED Display
|
* @usage Basic Setup for OLED Display
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -24,24 +25,20 @@
|
|||||||
#define __SSD1306_H__
|
#define __SSD1306_H__
|
||||||
|
|
||||||
// includes
|
// includes
|
||||||
#include <string.h>
|
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "twi.h"
|
#include "twi.h"
|
||||||
|
|
||||||
// Success
|
// Success / Error
|
||||||
// -------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
#define SSD1306_SUCCESS 0
|
#define SSD1306_SUCCESS 0
|
||||||
|
|
||||||
// Error
|
|
||||||
// -------------------------------------------
|
|
||||||
#define SSD1306_ERROR 1
|
#define SSD1306_ERROR 1
|
||||||
|
|
||||||
// Address definition
|
// Address definition
|
||||||
// -----------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
#define SSD1306_ADDR 0x3C
|
#define SSD1306_ADDR 0x3C
|
||||||
|
|
||||||
// Command definition
|
// Command definition
|
||||||
// -----------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
#define SSD1306_COMMAND 0x80 // Continuation bit=1, D/C=0; 1000 0000
|
#define SSD1306_COMMAND 0x80 // Continuation bit=1, D/C=0; 1000 0000
|
||||||
#define SSD1306_COMMAND_STREAM 0x00 // Continuation bit=0, D/C=0; 0000 0000
|
#define SSD1306_COMMAND_STREAM 0x00 // Continuation bit=0, D/C=0; 0000 0000
|
||||||
#define SSD1306_DATA 0xC0 // Continuation bit=1, D/C=1; 1100 0000
|
#define SSD1306_DATA 0xC0 // Continuation bit=1, D/C=1; 1100 0000
|
||||||
@ -73,27 +70,24 @@
|
|||||||
#define SSD1306_VCOM_DESELECT 0xDB
|
#define SSD1306_VCOM_DESELECT 0xDB
|
||||||
|
|
||||||
// Clear Color
|
// Clear Color
|
||||||
// -----------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
#define CLEAR_COLOR 0x00
|
#define CLEAR_COLOR 0x00
|
||||||
|
|
||||||
// Init Status
|
// Init Status
|
||||||
// -----------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
#define INIT_STATUS 0xFF
|
#define INIT_STATUS 0xFF
|
||||||
|
|
||||||
// AREA definition
|
// AREA definition
|
||||||
// -----------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
#define START_PAGE_ADDR 0
|
#define START_PAGE_ADDR 0
|
||||||
#define END_PAGE_ADDR 7
|
#define END_PAGE_ADDR 7 // 7 for 128x64, 3 for 128x32 version
|
||||||
#define START_COLUMN_ADDR 0
|
#define START_COL_ADDR 0
|
||||||
#define END_COLUMN_ADDR 127
|
#define END_COL_ADDR 127
|
||||||
|
|
||||||
#define CACHE_SIZE_MEM (1 + END_PAGE_ADDR) * (1 + END_COLUMN_ADDR)
|
#define CACHE_SIZE_MEM (1 + END_PAGE_ADDR) * (1 + END_COL_ADDR)
|
||||||
|
|
||||||
#define MAX_X END_COLUMN_ADDR
|
#define MAX_X END_COL_ADDR
|
||||||
#define MAX_Y (END_PAGE_ADDR+1)*8
|
#define MAX_Y (END_PAGE_ADDR + 1) * 8
|
||||||
|
|
||||||
// @var set area
|
|
||||||
unsigned int _counter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc SSD1306 Init
|
* @desc SSD1306 Init
|
||||||
@ -107,7 +101,7 @@
|
|||||||
/**
|
/**
|
||||||
* @desc SSD1306 Send Start and SLAW request
|
* @desc SSD1306 Send Start and SLAW request
|
||||||
*
|
*
|
||||||
* @param uint8_t
|
* @param uint8_t address
|
||||||
*
|
*
|
||||||
* @return uint8_t
|
* @return uint8_t
|
||||||
*/
|
*/
|
||||||
@ -116,7 +110,7 @@
|
|||||||
/**
|
/**
|
||||||
* @desc SSD1306 Send command
|
* @desc SSD1306 Send command
|
||||||
*
|
*
|
||||||
* @param uint8_t
|
* @param uint8_t command
|
||||||
*
|
*
|
||||||
* @return uint8_t
|
* @return uint8_t
|
||||||
*/
|
*/
|
||||||
@ -149,6 +143,15 @@
|
|||||||
*/
|
*/
|
||||||
uint8_t SSD1306_InverseScreen (void);
|
uint8_t SSD1306_InverseScreen (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc SSD1306 Update screen
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
*
|
||||||
|
* @return uint8_t
|
||||||
|
*/
|
||||||
|
uint8_t SSD1306_UpdateScreen (void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc SSD1306 Update text position
|
* @desc SSD1306 Update text position
|
||||||
*
|
*
|
||||||
@ -161,13 +164,25 @@
|
|||||||
/**
|
/**
|
||||||
* @desc SSD1306 Set position
|
* @desc SSD1306 Set position
|
||||||
*
|
*
|
||||||
* @param uint8_t
|
* @param uint8_t x
|
||||||
* @param uint8_t
|
* @param uint8_t y
|
||||||
*
|
*
|
||||||
* @return uint8_t
|
* @return uint8_t
|
||||||
*/
|
*/
|
||||||
uint8_t SSD1306_SetPosition (uint8_t, uint8_t);
|
uint8_t SSD1306_SetPosition (uint8_t, uint8_t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc SSD1306 Set window
|
||||||
|
*
|
||||||
|
* @param uint8_t x1
|
||||||
|
* @param uint8_t x2
|
||||||
|
* @param uint8_t y1
|
||||||
|
* @param uint8_t y2
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
uint8_t SSD1306_SetWindow (uint8_t, uint8_t, uint8_t, uint8_t);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc SSD1306 Draw character
|
* @desc SSD1306 Draw character
|
||||||
*
|
*
|
||||||
@ -189,20 +204,31 @@
|
|||||||
/**
|
/**
|
||||||
* @desc Draw pixel
|
* @desc Draw pixel
|
||||||
*
|
*
|
||||||
* @param uint8_t
|
* @param uint8_t x
|
||||||
* @param uint8_t
|
* @param uint8_t y
|
||||||
*
|
*
|
||||||
* @return uint8_t
|
* @return uint8_t
|
||||||
*/
|
*/
|
||||||
uint8_t SSD1306_DrawPixel (uint8_t, uint8_t);
|
uint8_t SSD1306_DrawPixel (uint8_t, uint8_t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc Draw line horizontal
|
||||||
|
*
|
||||||
|
* @param uint8_t y
|
||||||
|
* @param uint8_t x1
|
||||||
|
* @param uint8_t x2
|
||||||
|
*
|
||||||
|
* @return uint8_t
|
||||||
|
*/
|
||||||
|
uint8_t SSD1306_DrawLineHorz (uint8_t, uint8_t, uint8_t);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc Draw line
|
* @desc Draw line
|
||||||
*
|
*
|
||||||
* @param uint8_t
|
* @param uint8_t x1
|
||||||
* @param uint8_t
|
* @param uint8_t x2
|
||||||
* @param uint8_t
|
* @param uint8_t y1
|
||||||
* @param uint8_t
|
* @param uint8_t y2
|
||||||
*
|
*
|
||||||
* @return uint8_t
|
* @return uint8_t
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user