📄 glcd.h
字号:
/* GLCD Library f黵's Nokia 6100
copyright 2004 Hagen Reddmann */
#include <avr/io.h>
#include <avr/pgmspace.h>
#ifndef GLCD_H
#define GLCD_H
#if defined (__AVR_ATmega8__)
#define LCD_PORT PORTB
#define LCD_PIN PINB
#define LCD_DDR DDRB
#define LCD_CS PB2 // SS
#define LCD_SDA PB3 // MOSI
#define LCD_RESET PB4 // MISO
#define LCD_SCL PB5 // SCK
#elif defined (__AVR_ATmega16__)
#define LCD_PORT PORTB
#define LCD_PIN PINB
#define LCD_DDR DDRB
#define LCD_CS PB4 // SS
#define LCD_SDA PB5 // MOSI
#define LCD_RESET PB6 // MISO
#define LCD_SCL PB7 // SCK
#elif defined (__AVR_ATmega32__)
#define LCD_PORT PORTB
#define LCD_PIN PINB
#define LCD_DDR DDRB
#define LCD_CS PB4 // SS
#define LCD_SDA PB5 // MOSI
#define LCD_RESET PB6 // MISO
#define LCD_SCL PB7 // SCK
#elif defined (__AVR_ATmega128__)
#define LCD_PORT PORTB
#define LCD_PIN PINB
#define LCD_DDR DDRB
#define LCD_CS 0 // SS
#define LCD_SDA 2 // MOSI
#define LCD_RESET 3 // MISO
#define LCD_SCL 1 // SCK
#else
#error Please define in glcd.h the hardware pins for your device !
#endif
#define DELAY_ONE_MILLISECOND 2000 // 1 millisecond at 16Mhz
#define SCREEN_WIDTH 98 // Nokia6100, wobei aber nur 1,1-130,130 sichtbar sind. Denoch ben鰐igen wir vollen
#define SCREEN_HEIGHT 67 // Zugriff auf den RAM wenn wir zB. das Scrolling nutzen wollen
#define SCREEN_LEFT 0
#define SCREEN_TOP 0
#define SCREEN_RIGHT (SCREEN_WIDTH)
#define SCREEN_BOTTOM (SCREEN_HEIGHT)
#define SCREEN_COLOR WHITE // sollte ge鋘dert werden f黵 andere Hintergrundfarbe
#define COLOR_TABLE_BITS 8 // 2^2 = 4 Farben in Farbtabelle, wichtig f黵 Fonts
#define FONT_HEADER_SIZE 7 // Header gr鲞e eines Fonts
#define RGB(r,g,b) ((r & 0xE0) | ((g & 0xE0) >> 3) | (b >> 6))
#define NONE RGB(0x00, 0x20, 0x00) // == tansparent, ein gr黱 Ton weniger !!
#define BLACK RGB(0x00, 0x00, 0x00) // f黵 8 Bit Farben R,G,B 3,3,2 Bits
#define WHITE RGB(0xFF, 0xFF, 0xFF)
#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)
#define USE_ISR // SPI ISR aktivieren um das Chip Select Signal des Displays zur點kzusetzen.
#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
typedef uint8_t glcdCoord_t; // Koordinaten
typedef uint16_t glcdCoord2_t; // intern zur Koordinatenberechnung
typedef uint8_t glcdColor_t; // Farbe, f黵 256 Farbe uint8_t
typedef uint8_t *glcdFontData_t; // zeiger auf Fontdaten
typedef uint8_t (*glcdFontFunc_t)(const glcdFontData_t index); // Fontdaten-Lese-Callback, somit k鰊nen die Fontdaten extern gespeichert sein
typedef struct {
glcdCoord_t X;
glcdCoord_t Y;
} glcdPoint_t;
typedef struct {
glcdCoord_t X1;
glcdCoord_t Y1;
glcdCoord_t X2;
glcdCoord_t Y2;
} glcdRect_t;
typedef struct {
uint8_t AutoLineFeed:1, // Fontroutine nutzt einen impliziten Zeilenumbruch innerhalb von glcd_Window
FixedFont:1; // Fontroutine soll Font mit fester Zeichenbreite darstellen, ansonsten proportional
} glcdFlags_t;
glcdColor_t glcd_Colors[1 << COLOR_TABLE_BITS]; // Farbtabelle, Colors[0] = Hintergrund = F黮lfarbe, Color[1] = Vordergrund = Linienfarbe
uint8_t glcd_MemCtrl;
glcdFlags_t glcd_Flags;
glcdRect_t glcd_Clip; // Clipping Koordinaten, alles was ausserhalb ist wird nicht dargestellt
#ifdef USE_FONTS
glcdPoint_t glcd_Cursor; // aktuelle Position f黵 Schriften
glcdRect_t glcd_Window; // aktuelles Fenster f黵 Textausgaben
char glcd_FontFirstChar; // erstes Zeichen im Font
char glcd_FontLastChar; // letztes Zeichen im Font
uint8_t glcd_FontWidth; // fixed Zeichenbreite des Fonts
uint8_t glcd_FontHeight; // Zeichenh鰄e
uint8_t glcd_FontBitsPixel; // Farbtiefe des Fonts
glcdFontFunc_t glcd_FontRead; // User definierte Readcallback f黵 die Fontdaten
glcdFontData_t glcd_FontData; // die eigentlichen Fontdaten beginnen hier, abh鋘gig von der Readcallback
#endif
// todo: F黮len mit Brush, Linien mit Pen
void glcdDisplayInit(void); // initialize GLCD
void glcdDisplayCommand(const uint8_t cmd); // send GLCD 9bit command
void glcdDisplayData(const uint8_t data); // send GLCD 9bit data
void glcdDisplaySend(const uint8_t data, const uint8_t cmd); // transfer to GLCD
uint32_t glcdDisplayRead(uint8_t bitcount); // read bitcount bits from GLCD
void glcdWait(uint16_t ms);
void glcdSetOrientation(const uint8_t orientation); // Display Orientation {0,1,2,3} -> {0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -