STM32_SSD1306/ssd1306.h
2021-07-01 14:38:54 +02:00

58 lines
1.4 KiB
C

/**
* This Library is written and optimized by Olivier Van den Eede(4ilo) in 2016
* for Stm32 Uc and HAL-i2c lib's.
*
* To use this library with ssd1306 oled display you will need to customize the defines below.
*
* This library uses 2 extra files (fonts.c/h).
* In this files are 3 different fonts you can use:
* - Font_7x10
* - Font_11x18
* - Font_16x26
*
*/
#ifndef _SSD1306_H
#define _SSD1306_H
#include "stm32f4xx_hal.h"
#include "fonts.h"
// I2c address
#define SSD1306_I2C_ADDR 0x78
// SSD1306 width in pixels
#define SSD1306_WIDTH 128
// SSD1306 LCD height in pixels
#define SSD1306_HEIGHT 64
//
// Enumeration for screen colors
//
typedef enum {
Black = 0x00, // Black color, no pixel
White = 0x01 //Pixel is set. Color depends on LCD
} SSD1306_COLOR;
//
// Struct to store transformations
//
typedef struct {
uint16_t CurrentX;
uint16_t CurrentY;
uint8_t Inverted;
uint8_t Initialized;
} SSD1306_t;
//
// Function definitions
//
uint8_t ssd1306_Init(I2C_HandleTypeDef *hi2c);
void ssd1306_UpdateScreen(I2C_HandleTypeDef *hi2c);
void ssd1306_Fill(SSD1306_COLOR color);
void ssd1306_DrawPixel(uint8_t x, uint8_t y, SSD1306_COLOR color);
char ssd1306_WriteChar(char ch, FontDef Font, SSD1306_COLOR color);
char ssd1306_WriteString(char* str, FontDef Font, SSD1306_COLOR color);
void ssd1306_SetCursor(uint8_t x, uint8_t y);
#endif // _SSD1306_H