73 lines
3.4 KiB
C
73 lines
3.4 KiB
C
/*--------------------------------------------------------------------------------------------------
|
|
|
|
Name : nokia_5110.h
|
|
|
|
Description : Header file for Nokia 84x48 graphic LCD driver.
|
|
|
|
Author : 2014-01-08 - Paolo Iocco
|
|
|
|
History : 2014-01-08 - Date of creation
|
|
2014-02-03 - First release (non buffered)
|
|
|
|
--------------------------------------------------------------------------------------------------*/
|
|
#ifndef _NOKIALCD_H_
|
|
#define _NOKIALCD_H_
|
|
|
|
//#define __DELAY_BACKWARD_COMPATIBLE__
|
|
#include <avr/io.h>
|
|
#include <util/delay.h>
|
|
#include <avr/pgmspace.h>
|
|
|
|
/*--------------------------------------------------------------------------------------------------
|
|
Interface definition prototypes
|
|
--------------------------------------------------------------------------------------------------*/
|
|
#ifndef _LCD_PINS_
|
|
#define _LCD_PINS_
|
|
#define SCLK_PIN PD7 // SCLK pin
|
|
#define SDIN_PIN PD6 // SDIN pin
|
|
#define LCD_DC_PIN PD5 // Data/Command pin
|
|
#define LCD_CE_PIN PD4 // Chip Enable pin
|
|
#define LCD_RST_PIN PD3 // Reset pin
|
|
#define LCD_DDR DDRD // Display Port DDR
|
|
#define LCD_PORT PORTD // Display Port PORT
|
|
#endif // _LCD_PINS_
|
|
|
|
#define BIT(i) (1<<i)
|
|
#define SCLK_set LCD_PORT|=BIT(SCLK_PIN) //serial clock input
|
|
#define SCLK_clr LCD_PORT&=~BIT(SCLK_PIN)
|
|
#define SDIN_set LCD_PORT|=BIT(SDIN_PIN) //serial data input
|
|
#define SDIN_clr LCD_PORT&=~BIT(SDIN_PIN)
|
|
#define LCD_DC_set LCD_PORT|=BIT(LCD_DC_PIN) //data/command
|
|
#define LCD_DC_clr LCD_PORT&=~BIT(LCD_DC_PIN)
|
|
#define LCD_CE_set LCD_PORT|=BIT(LCD_CE_PIN) //chip enable
|
|
#define LCD_CE_clr LCD_PORT&=~BIT(LCD_CE_PIN)
|
|
#define LCD_RST_set LCD_PORT|=BIT(LCD_RST_PIN) //external reset input
|
|
#define LCD_RST_clr LCD_PORT&=~BIT(LCD_RST_PIN)
|
|
#define CMD 0
|
|
#define DATA 1
|
|
|
|
/*--------------------------------------------------------------------------------------------------
|
|
Public function prototypes
|
|
--------------------------------------------------------------------------------------------------*/
|
|
#define delay_1us _delay_us(1); //delay 1us
|
|
#define delay_1ms _delay_ms(1); //delay 1ms
|
|
|
|
void LCD_write_byte(unsigned char dat, unsigned char command); // Writes data to LCD
|
|
void LCD_Char(unsigned char c); // Displays a character
|
|
void LCD_Cls(void); // Clears the LCD
|
|
void LCD_DrawBmp(unsigned char X,unsigned char Y, unsigned char w,unsigned char h, const unsigned char *map); // Bitmap drawing function
|
|
void LCD_DrawCircle (unsigned char x1, unsigned char y1, unsigned char radius, unsigned char mode); // Draws a circle
|
|
void LCD_DrawLine (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2); // Draws a line
|
|
void LCD_DrawRect (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char mode); // Draws a rectangle
|
|
void LCD_GotoXY(unsigned char X, unsigned char Y); // Sets the LCD coordinate functions
|
|
void LCD_Init(void); // LCD initialization
|
|
void LCD_Pixel(unsigned char x, unsigned char y); // Displays a pixel
|
|
void LCD_SetContrast(unsigned char contrast); // sets the contrast
|
|
void LCD_String_P(unsigned char X,unsigned char Y, char *characters); // Displays a string from flash-memory
|
|
void LCD_WriteXY(unsigned char X,unsigned char Y, char *characters); // write a string in x,y
|
|
|
|
#endif // _NOKIALCD_H_
|
|
|
|
|
|
|