📄 glcd.inc
字号:
/*
Port&Copyright: Mark de Jong, mail to mark at mdejong.de
Copyright: Hagen Reddmann mailto HaReddmann at T-Online dot de
Author: Hagen Reddmann
Remarks: this Copyright must be included
known Problems: none
Version: 2.1. 2004
Description: Graphic Library for Nokia 6100 Display and compatible
*/
#ifdef AVR
#include <avr/io.h>
#endif
#if defined (__AVR_ATmega8__)
#define LCD_PORT _SFR_IO_ADDR(PORTB)
#define LCD_PIN _SFR_IO_ADDR(PINB)
#define LCD_DDR _SFR_IO_ADDR(DDRB)
#define LCD_CS PB0
#define LCD_RESET PB6
#define LCD_RS PB7
#define LCD_MOSI PB2
#define LCD_MISO PB3
#define LCD_SCK PB1
#elif defined (__AVR_ATmega16__)
#define LCD_PORT _SFR_IO_ADDR(PORTB)
#define LCD_PIN _SFR_IO_ADDR(PINB)
#define LCD_DDR _SFR_IO_ADDR(DDRB)
#define LCD_CS PB0
#define LCD_RESET PB6
#define LCD_RS PB7
#define LCD_MOSI PB2
#define LCD_MISO PB3
#define LCD_SCK PB1
#elif defined (__AVR_ATmega32__)
#define LCD_PORT _SFR_IO_ADDR(PORTB)
#define LCD_PIN _SFR_IO_ADDR(PINB)
#define LCD_DDR _SFR_IO_ADDR(DDRB)
#define LCD_CS PB0
#define LCD_RESET PB6
#define LCD_RS PB7
#define LCD_MOSI PB2
#define LCD_MISO PB3
#define LCD_SCK PB1
#elif defined (__AVR_ATmega128__)
#define LCD_PORT _SFR_IO_ADDR(PORTB)
#define LCD_PIN _SFR_IO_ADDR(PINB)
#define LCD_DDR _SFR_IO_ADDR(DDRB)
#define LCD_CS PB0
#define LCD_RESET PB6
#define LCD_RS PB7
#define LCD_MOSI PB2
#define LCD_MISO PB3
#define LCD_SCK PB1
#elif defined (__SAB_C165__)
#define SIG_SPI
#ifdef TARGET_C164CI
#include <C164CXSX.H>
// S65 Display power enable
sbit S65_PEN_LCD = P1L^1;
sbit S65_PEN_LCD_DIR = DP1L^1;
// S65 Display backlight control
sbit S65_EN_LCDB = P1L^0;
sbit S65_EN_LCDB_DIR = DP1L^0;
// S65 Display Dlock
sbit S65_uC_DISPL_CLK = P3^13;
sbit S65_uC_DISPL_CLK_DIR = DP3^13;
// S65 Display Data
sbit S65_uC_DISPL_DAT = P3^9;
sbit S65_uC_DISPL_DAT_DIR = DP3^9;
// S65 Display Select
sbit S65_uC_DISPL_CS = P1L^2;
sbit S65_uC_DISPL_CS_DIR = DP1L^2;
// S65 Display Reset
sbit S65_uC_DISPL_RESET = P1L^3;
sbit S65_uC_DISPL_RESET_DIR = DP1L^3;
// S65 Display Register/Data Select
sbit S65_uC_DISPL_RS = P1L^4;
sbit S65_uC_DISPL_RS_DIR = DP1L^4;
#endif //TARGET_C164CI
#define S65_IO_RESET S65_uC_DISPL_RESET
#define S65_IO_RESET_DIR S65_uC_DISPL_RESET_DIR
#define S65_IO_RS S65_uC_DISPL_RS
#define S65_IO_RS_DIR S65_uC_DISPL_RS_DIR
#define S65_IO_CS S65_uC_DISPL_CS
#define S65_IO_CS_DIR S65_uC_DISPL_CS_DIR
#define S65_IO_CLK S65_uC_DISPL_CLK
#define S65_IO_CLK_DIR S65_uC_DISPL_CLK_DIR
#define S65_IO_DATA S65_uC_DISPL_DAT
#define S65_IO_DATA_DIR S65_uC_DISPL_DAT_DIR
#define S65_IO_DETECT
#define S65_IO_DETECT_DIR
#define S65_POWER S65_PEN_LCD
#define S65_POWER_DIR S65_PEN_LCD_DIR
#define S65_BACKLIGHT_POWER S65_EN_LCDB
#define S65_BACKLIGHT_POWER_DIR S65_EN_LCDB_DIR
// hardware pin access macros defines
#define io_set_dir_in( port_pin ) port_pin##_DIR = 0x00;
#define io_set_dir_out( port_pin ) port_pin##_DIR = 0x01;
#define io_set_io( port_pin ) port_pin = 0x01;
#define io_reset_io( port_pin ) port_pin = 0x00;
#elif defined (__SAB_C167__)
#define SIG_SPI
#ifdef TARGET_MM167
#include <C167CS.H>
// S65 Display power enable
sbit S65_PEN_LCD = P8^1;
sbit S65_PEN_LCD_DIR = DP8^1;
// S65 Display backlight control
sbit S65_EN_LCDB = P8^0;
sbit S65_EN_LCDB_DIR = DP8^0;
// S65 Display Dlock
sbit S65_uC_DISPL_CLK = P3^13;
sbit S65_uC_DISPL_CLK_DIR = DP3^13;
// S65 Display Data
sbit S65_uC_DISPL_DAT = P3^9;
sbit S65_uC_DISPL_DAT_DIR = DP3^9;
// S65 Display Select
sbit S65_uC_DISPL_CS = P8^2;
sbit S65_uC_DISPL_CS_DIR = DP8^2;
// S65 Display Reset
sbit S65_uC_DISPL_RESET = P8^3;
sbit S65_uC_DISPL_RESET_DIR = DP8^3;
// S65 Display Register/Data Select
sbit S65_uC_DISPL_RS = P8^4;
sbit S65_uC_DISPL_RS_DIR = DP8^4;
#endif //TARGET_MM167
#define S65_IO_RESET S65_uC_DISPL_RESET
#define S65_IO_RESET_DIR S65_uC_DISPL_RESET_DIR
#define S65_IO_RS S65_uC_DISPL_RS
#define S65_IO_RS_DIR S65_uC_DISPL_RS_DIR
#define S65_IO_CS S65_uC_DISPL_CS
#define S65_IO_CS_DIR S65_uC_DISPL_CS_DIR
#define S65_IO_CLK S65_uC_DISPL_CLK
#define S65_IO_CLK_DIR S65_uC_DISPL_CLK_DIR
#define S65_IO_DATA S65_uC_DISPL_DAT
#define S65_IO_DATA_DIR S65_uC_DISPL_DAT_DIR
#define S65_IO_DETECT
#define S65_IO_DETECT_DIR
#define S65_POWER S65_PEN_LCD
#define S65_POWER_DIR S65_PEN_LCD_DIR
#define S65_BACKLIGHT_POWER S65_EN_LCDB
#define S65_BACKLIGHT_POWER_DIR S65_EN_LCDB_DIR
// hardware pin access macros defines
#define io_set_dir_in( port_pin ) port_pin##_DIR = 0x00;
#define io_set_dir_out( port_pin ) port_pin##_DIR = 0x01;
#define io_set_io( port_pin ) port_pin = 0x01;
#define io_reset_io( port_pin ) port_pin = 0x00;
#else
#error Please define in glcd.inc the hardware pins for your device !
#endif
#ifndef SIG_SPI
#error Selected device do not support SPI !
#endif
#define LCD_SPCR _SFR_IO_ADDR(SPCR)
#define LCD_SPDR _SFR_IO_ADDR(SPDR)
#define LCD_SPSR _SFR_IO_ADDR(SPSR)
#ifndef XTAL
#define XTAL 16000000 // must be changed
#endif
#define DELAY_ONE_MILLISECOND (XTAL / 4 / 1000) // must > 8
#define USE_CLIPPING // support clipping
// #define USE_HIGHCOLOR // 65536 color mode
// #define USE_ORGINALCOLORS // in 256 color mode use original color table
// #define USE_AUTOINIT // call glcdDisplayInit() automaticaly on startup
#define USE_LINES // Linien und Frame Routinen aktivieren, vertikale+horizontale Linien sind immer m鰃lich mit FilllRect
#define USE_ELLIPSES // Kreise und Ellipsen
#define USE_FONTS // Schriftausgaben
#define RGB(r,g,b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3))
#define NONE RGB(0x00, 0x40, 0x00) // == tansparent, one green color reduced !!
#define BLACK RGB(0x00, 0x00, 0x00) // for 8 bit colors R,G,B 3,3,2 Bits
#define WHITE RGB(0xFF, 0xFF, 0xFF) // for 16 bit colors R,G,B 5,6,5 bits
#define RED RGB(0xFF, 0x00, 0x00)
#define GREEN RGB(0x00, 0xFF, 0x00)
#define BLUE RGB(0x00, 0x00, 0xFF)
#define YELLOW RGB(0xFF, 0xFF, 0x00)
#define MAGENTA RGB(0xFF, 0x00, 0xFF)
#define CYAN RGB(0x00, 0xFF, 0xFF)
#define GRAY RGB(0x80, 0x80, 0x40)
#define SILVER RGB(0xA0, 0xA0, 0x80)
#define GOLD RGB(0xA0, 0xA0, 0x40)
#ifndef COLOR_TABLE_BITS
#define COLOR_TABLE_BITS 2 // 2^2 = 4 colors in color table (minimum)
#endif
#define COLOR_TABLE_SIZE 2 << COLOR_TABLE_BITS // sizeof glcd_Colors[]
#define COLOR_INDEX_BK 0 // index into glcd_Colors[] color table
#define COLOR_INDEX_FG 1
#define COLOR_INDEX_FR 2
#define COLOR_INDEX_SH 3
#ifndef SCREEN_COLOR0 // default SCREEN_COLOR background
#define SCREEN_COLOR0 YELLOW
#endif
#ifndef SCREEN_COLOR1 // default foreground color
#define SCREEN_COLOR1 BLACK
#endif
#ifndef SCREEN_COLOR2 // default frame color
#define SCREEN_COLOR2 GRAY
#endif
#ifndef SCREEN_COLOR3 // default shadow color
#define SCREEN_COLOR3 SILVER
#endif
#define SCREEN_COLOR WHITE
// Attention! a copy of the screen definition is in glcd.h!
#ifndef SCREEN_WIDTH
#define SCREEN_WIDTH 132 // Siemens S65
#endif
#ifndef SCREEN_HEIGHT
#define SCREEN_HEIGHT 176 // to (0,0,131,175) to support hardware scrolling and splitting of display
#endif
#ifndef SCREEN_LEFT
#define SCREEN_LEFT 0
#endif
#ifndef SCREEN_TOP
#define SCREEN_TOP 0
#endif
#ifndef SCREEN_RIGHT
#define SCREEN_RIGHT (SCREEN_WIDTH -1)
#endif
#ifndef SCREEN_BOTTOM
#define SCREEN_BOTTOM (SCREEN_HEIGHT -1)
#endif
// glcd_MemCtrl initialization state change default orientation of display
#define ORIENTATION_0 (1 << MEM_RGB) | (1 << MEM_MX)
#define ORIENTATION_90 (1 << MEM_RGB) | (1 << MEM_VW) | (1 << MEM_90)
#define ORIENTATION_180 (1 << MEM_RGB) | (1 << MEM_MY) | (1 << MEM_180)
#define ORIENTATION_270 (1 << MEM_RGB) | (1 << MEM_MX) | (1 << MEM_MY) | (1 << MEM_VW) | (1 << MEM_90) | (1 << MEM_180)
#define ORIENTATION_DEFAULT ORIENTATION_0
#define FLAGS_DEFAULT 0x00
#define FONT_HEADER_SIZE 7 // header size of fonts
#define INIT_DELAY 0 // delay in milliseconds in glcdDisplayInit() sometimes needed if instable
#define MEM_90 0 // virtual flag for orientation, does not exist in PCF8833
#define MEM_180 1 // virtual flag for orientation
#define MEM_RGB 3
#define MEM_LAO 4
#define MEM_VW 5
#define MEM_MX 6
#define MEM_MY 7
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -