⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.h

📁 MSP acquires data and sends through USB to PC. Check the link for PC capture software and project d
💻 H
字号:
/*
 * File:        lcd.h
 * Purpose:     Prototypes of Nokia 6610 LCD handling functions
 * Author:      Peter Ivanov, Olimex Ltd.
 * Modified by:
 * Created:     2007-05-19 11:29:32
 * Last modify: 2007-10-21 10:37:03 ivanovp {Time-stamp}
 * Copyright:   (C) Peter Ivanov, Olimex Ltd., 2007
 * Licence:     GPL
 */
/**
 * \file lcd.h
 * \brief Prototypes of Nokia 6610 LCD handling functions
 * \author Peter Ivanov, Olimex Ltd.
 */
#ifndef __INCLUDE_LCD_H
#define __INCLUDE_LCD_H

// Nokia 6610 LCD type is GE12 or GE8?
// NOTE: You should uncomment next line if you've got LCD type GE12.
//#define GE12

#define LCD_PRINTF_BUF_SIZE 256

#define LCD_BKLGHT_ON   1
#define LCD_BKLGHT_OFF  0

#define LCD_X_OFFSET    0
#ifdef GE12
#define LCD_Y_OFFSET    0
#else
#define LCD_Y_OFFSET    2
#endif

#define LCD_COLOR_BLACK         0x070           ///< Black color
#define LCD_COLOR_YELLOW        0x1EF           ///< Yellow color
#define LCD_COLOR_GRAY          0xCCC           ///< Gray
#define LCD_COLOR_BLUE          0xF00           ///< Blue
#define LCD_COLOR_GREEN         0x0F0           ///< Green
#define LCD_COLOR_RED           0x00F           ///< Red
#define LCD_COLOR_WHITE         0xFFF           ///< White
#define LCD_DEFAULT_FG_COLOR    LCD_COLOR_BLACK   // black
#define LCD_DEFAULT_BG_COLOR    LCD_COLOR_WHITE   // white

// Warning: maybe some correction needed to GE12!!!
#define LCD_WIDTH               (130)     ///< in pixels
#define LCD_HEIGHT              (131)     ///< in pixels
#define LCD_COLORS              (4096)    ///< 12 bits
//#define LCD_MEM_SIZE          (25350)   // 130*130*12/8
#define LCD_MEM_SIZE            (25740)   ///< 130*132*12/8

/**
 * Initializes LCD.
 */
void LCD_init (void);

/**
 * Switch on/off backlight
 *
 * @param state FALSE: switch on, TRUE: switch off
 */
void LCD_setBacklight (unsigned char state);

/**
 * Displays a bitmap array.
 * Bitmap size is equal to LCD_MEM_SIZE (25740).
 *
 * @param bmp Pointer to the bitmap array.
 */
void LCD_write130x130bmp (const unsigned char *bmp);

/**
 * Initializes LCD to show a bitmap. You should put the data byte by byte or word  by word to the memory
 * using LCD_write130x130bmpData16() or LCD_write130x130bmpData8(). After that you
 * should call LCD_write130x130bmpEnd(). 
 * Bitmap size is equal to LCD_MEM_SIZE (25740).
 * @see LCD_write130x130bmpData16, LCD_write130x130bmpData8, LCD_write130x130bmpEnd, LCD_MEM_SIZE
 */
void LCD_write130x130bmpStart ();

/**
 * Put one word to the LCD's memory.
 * @see LCD_write130x130bmpStart, LCD_write130x130bmpData8, LCD_write130x130bmpEnd
 *
 * @param data One word of bitmap.
 */
void LCD_write130x130bmpData16 (const uint16_t *data);

/**
 * Put one byte to the LCD's memory.
 * @see LCD_write130x130bmpStart, LCD_write130x130bmpData16, LCD_write130x130bmpEnd
 *
 * @param data One byte of bitmap.
 */
void LCD_write130x130bmpData8 (const uint8_t *data);

/**
 * Switches on the display, so the bitmap will be visible.
 * @see LCD_write130x130bmpStart, LCD_write130x130bmpData8, LCD_write130x130bmpData16
 */
void LCD_write130x130bmpEnd ();

/**
 * Clear display.
 */
void LCD_clear(void);

/**
 * Clears ball symbol.
 *
 * @param x Coordinate X.
 * @param y Coordinate Y.
 */
void LCD_clearBall (unsigned char x, unsigned char y);

/**
 * Draws ball symbol.
 *
 * @param x Coordinate X.
 * @param y Coordinate Y.
 */
void LCD_writeBall (unsigned char x, unsigned char y);

/**
 * Set display's contrast. Supported only on type GE8!
 *
 * @param contrast Valid values: 0..223 (?)
 */
void LCD_setContrast (unsigned char contrast);

/**
 * Write a character to specified position with specified color.
 * LCD_printf() is a bit more user friendly.
 *
 * @see LCD_printf()
 */
void LCD_writeChar(unsigned char Ascii, 
                  unsigned char x,
                  unsigned char y,
                  unsigned short FG_Colour, unsigned short BG_Colour);

/**
 * Set coordinate X. 
 * This data is used by LCD_printf() and LCD_write().
 * @see LCD_WIDTH
 *
 * @param x X coordinate. Valid values: 0..LCD_WIDTH.
 */
inline void LCD_setX (uint8_t x);

/**
 * Set coordinate Y.
 * This data is used by LCD_printf() and LCD_write().
 * @see LCD_HEIGHT
 *
 * @param y Y coordinate. Valid values: 0..LCD_HEIGHT.
 */
inline void LCD_setY (uint8_t y);

/**
 * Get coordinate Y.
 * This data is used by LCD_printf() and LCD_write().
 * @see LCD_HEIGHT
 *
 * @return X coordinate. Valid values: 0..LCD_WIDTH.
 */
inline uint8_t LCD_getX ();

/**
 * Get coordinate Y.
 * This data is used by LCD_printf() and LCD_write().
 * @see LCD_HEIGHT
 *
 * @return Y coordinate. Valid values: 0..LCD_HEIGHT.
 */
inline uint8_t LCD_getY ();

/**
 * Set coordinates X and Y.
 * This data is used by LCD_printf() and LCD_write().
 * @see LCD_HEIGHT, LCD_WIDTH
 *
 * @param x X coordinate. Valid values: 0..LCD_WIDTH.
 * @param y Y coordinate. Valid values: 0..LCD_HEIGHT.
 */
inline void LCD_setXY (uint8_t x, uint8_t y);

/**
 * Set foreground's color.
 * This data is used by LCD_printf() and LCD_write().
 *
 * @param fgColor Color of foreground (12 bit). Example: LCD_COLOR_WHITE
 */
inline void LCD_setFGColor (uint16_t fgColor);

/**
 * Set backround's color.
 * This data is used by LCD_printf() and LCD_write().
 *
 * @param bgColor Color of background (12 bit). Example: LCD_COLOR_RED
 */
inline void LCD_setBGColor (uint16_t bgColor);

/**
 * Set color of foreground and background.
 * This data is used by LCD_printf() and LCD_write().
 *
 * @param fgColor Color of foreground (12 bit). Example: LCD_COLOR_WHITE
 * @param bgColor Color of background (12 bit). Example: LCD_COLOR_RED
 */
inline void LCD_setColor (uint16_t fgColor, uint16_t bgColor);

/**
 * Write a character buffer to LCD.
 *
 * @author Peter Ivanov
 *
 * @param buf Pointer to buffer.
 * @param length Length of buffer.
 */
void LCD_write (const char *buf, uint16_t length);

/**
 * Write a formatted string to the LCD.
 * Example:
<pre>
LCD_setXY (0, LCD_HEIGHT - FONT_HEIGHT);
LCD_setColor (LCD_COLOR_RED, LCD_COLOR_WHITE);
LCD_printf ("I %02i", i);
</pre>
 *
 * @author Peter Ivanov
 *
 * @param fmt Printf format string. e.g.: "I %02i"
 */
void LCD_printf (const char *fmt, ...);

#ifdef GE12

#define NOP           0x00     // nop
#define SOFTRST       0x01     // software reset
#define BOOSTVOFF     0x02     // booster voltage OFF
#define BOOSTVON      0x03     // booster voltage ON
#define TESTMODE1     0x04     // test mode
#define DISPSTATUS    0x09     // display status
#define SLEEPIN       0x10     // sleep in
#define SLEEPOUT      0x11     // sleep out
#define PARTIAL       0x12     // partial display mode
#define NORMALMODE    0x13     // display normal mode
#define INVERSIONOFF  0x20     // inversion OFF
#define INVERSIONON   0x21     // inversion ON
#define ALLPIXELOFF   0x22     // all pixel OFF
#define ALLPIXELON    0x23     // all pixel ON
#define CONTRAST      0x25     // write contrast
#define DISPLAYOFF    0x28     // display OFF
#define DISPLAYON     0x29     // display ON
#define COLADDRSET    0x2A     // column address set
#define PAGEADDRSET   0x2B     // page address set
#define MEMWRITE      0x2C     // memory write
#define COLORSET      0x2D     // colour set
#define READRAMDATA   0x2E     // RAM data read
#define PARTIALAREA   0x30     // partial area
#define VERTSCROLL    0x33     // vertical scrolling definition
#define TESTMODE2     0x34     // test mode
#define TESTMODE3     0x35     // test mode
#define ACCESSCTRL    0x36     // memory access control
#define VSCRLSADDR    0x37     // vertical scrolling start address
#define IDLEOFF       0x38     // idle mode OFF
#define IDLEON        0x39     // idle mode ON
#define PIXELFORMAT   0x3A     // interface pixel format
#define TESTMODE4     0xDE     // test mode
#define NOP2          0xAA     // nop
#define INITESC       0xC6     // initial escape
#define TESTMODE5     0xDA     // test mode
#define TESTMODE6     0xDB     // test mode
#define TESTMODE7     0xDC     // test mode
#define TESTMODE8     0xB2     // test mode
#define GRAYSCALE0    0xB3     // gray scale position set 0
#define GRAYSCALE1    0xB4     // gray scale position set 1
#define GAMMA         0xB5     // gamma curve set
#define DISPCTRL      0xB6     // display control
#define TEMPGRADIENT  0xB7     // temp gradient set
#define TESTMODE9     0xB8     // test mode
#define REFSET        0xB9     // refresh set
#define VOLTCTRL      0xBA     // voltage control
#define COMMONDRV     0xBD     // common driver output select
#define PWRCTRL       0xBE     // power control

#else

#define DISON     0xAF      // Display on
#define DISOFF    0xAE      // Display off
#define DISPLAYON   DISON
#define DISPLAYOFF  DISOFF
#define DISNOR    0xA6      // Normal display
#define DISINV    0xA7      // Inverse display
#define COMSCN    0xBB      // Common scan direction
#define DISCTL    0xCA      // Display control
//  #define DISCTL    0xBA      // Display control
#define SLPIN     0x95      // Sleep in
#define SLPOUT    0x94      // Sleep out
#define PASET     0x75      // Page address set
#define CASET     0x15      // Column address set
#define PAGEADDRSET PASET
#define COLADDRSET  CASET
#define DATCTL    0xBC      // Data scan direction, etc.
#define RGBSET8   0xCE      // 256-color position set
#define RAMWR     0x5C      // Writing to memory
#define MEMWRITE    RAMWR
#define RAMRD     0x5D      // Reading from memory
#define PTLIN     0xA8      // Partial display in
#define PTLOUT    0xA9      // Partial display out
#define RMWIN     0xE0      // Read and modify write
#define RMWOUT    0xEE      // End
#define ASCSET    0xAA      // Area scroll set
#define SCSTART   0xAB      // Scroll start set
#define IOSCON    0xD1      // Internal oscillation on
#define IOSCOFF   0xD2      // Internal oscillation off
#define PWRCTR    0x20      // Power control
#define VOLCTR    0x81      // Electronic volume control
#define VOLUP     0xD6      // Increment electronic control by 1
#define VOLDOWN   0xD7      // Decrement electronic control by 1
#define TMPGRD    0x82      // Temperature gradient set
#define EPCTIN    0xCD      // Control EEPROM
#define EPCOUT    0xCC      // Cancel EEPROM control
#define EPMWR     0xFC      // Write into EEPROM
#define EPMRD     0xFD      // Read from EEPROM
#define EPSRRD1   0x7C      // Read register 1
#define EPSRRD2   0x7D      // Read register 2
#define NOP       0x25      // NOP instruction

#endif
#endif // __INCLUDE_LCD_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -