Skip to content

nokia5110.h 完整代码

c
/**
 * @file nokia5110.h
 * @brief Nokia 5110 LCD Display Driver Header File
 */

#ifndef __NOKIA5110_H
#define __NOKIA5110_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include <stdint.h>

/* Exported types ------------------------------------------------------------*/
typedef enum {
  LCD_CMD  = 0,  // Command
  LCD_DATA = 1   // Data
} LcdCmdDataType;

/* Exported constants --------------------------------------------------------*/
#define LCD_WIDTH   84   // Nokia 5110 LCD width in pixels
#define LCD_HEIGHT  48   // Nokia 5110 LCD height in pixels

// LCD Commands
#define LCD_CLEARDISPLAY    0x0E
#define LCD_DISPLAYALLON    0x09
#define LCD_DISPLAYALLON_RESUME 0x0C
#define LCD_DISPLAYALLON_NORMAL 0x0A
#define LCD_DISPLAYCONTROL_NORMAL 0x0C
#define LCD_DISPLAYCONTROL_BLANK 0x08
#define LCD_DISPLAYCONTROL_INVERSE 0x0D
#define LCD_FUNCTIONSET_BASIC 0x20
#define LCD_FUNCTIONSET_EXTENDED 0x21
#define LCD_DISPLAYCONTROL 0x08
#define LCD_DISPLAYBLANK 0x08
#define LCD_DISPLAYNORMAL 0x0C
#define LCD_DISPLAYINVERTED 0x0D
#define LCD_SETYADDR 0x40
#define LCD_SETXADDR 0x80
#define LCD_TEMP_COEF 0x04
#define LCD_BIAS_MODE 0x10
#define LCD_VOP 0x80
#define LCD_POWERDOWN 0x04

/* Exported macro ------------------------------------------------------------*/

/* Exported functions prototypes ---------------------------------------------*/
void LCD_Init(void);
void LCD_Clear(void);
void LCD_SetCursor(uint8_t x, uint8_t y);
void LCD_WriteChar(char ch, uint8_t reverse);
void LCD_WriteString(const char* str, uint8_t reverse);
void LCD_WriteBinary(uint8_t value);
void LCD_SetContrast(uint8_t contrast);
void LCD_InvertDisplay(uint8_t invert);
void LCD_DisplayOn(void);
void LCD_DisplayOff(void);
void LCD_DrawPixel(uint8_t x, uint8_t y, uint8_t color);
void LCD_DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
void LCD_DrawRectangle(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
void LCD_DrawFilledRectangle(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
void LCD_DrawCircle(uint8_t x0, uint8_t y0, uint8_t radius, uint8_t color);
void LCD_DrawBitmap(uint8_t x, uint8_t y, const uint8_t* bitmap, uint8_t w, uint8_t h);

#ifdef __cplusplus
}
#endif

#endif /* __NOKIA5110_H */