BIOS Reference - LCD Functions

From NanoComputerWiki

Revision as of 20:33, 23 November 2008 by FlyingElectron (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

LCD Module Functions

NanoComputer BIOS Reference

LCD Module

Note: This information may be out of date. For the latest information always check the header files shipped with the NanoComputer SDK.

Last update: Oct 31 2008

// --------------------------------------------------
//  Defines
// --------------------------------------------------
    // Color Constants
        #define BLACK                           0x0000
        #define RED                             0x00F8
        #define YELLOW                          0xE0FF
        #define GREEN                           0xE007
        #define CYAN                            0xFF07
        #define BLUE                            0x1F00
        #define MAGENTA                         0x1FF8
        #define WHITE                           0xFFFF

    // Font
        #define LCD_FONT_MONOSPACE              0x00
        #define LCD_FONT_PROPORTIONAL           0x01

    // Mode Flags
        #define LCD_MODE_FLIP_X                 0x01
        #define LCD_MODE_FLIP_Y                 0x02
        #define LCD_MODE_EXCHANGE_XY            0x04

    // Modes
        #define LCD_MODE_NORMAL                 0x00
        #define LCD_MODE_ROTATE_0_DEGREES       LCD_MODE_NORMAL
        #define LCD_MODE_ROTATE_90_DEGREES      LCD_MODE_EXCHANGE_XY | LCD_MODE_FLIP_X
        #define LCD_MODE_ROTATE_180_DEGREES     LCD_MODE_FLIP_X | LCD_MODE_FLIP_Y
        #define LCD_MODE_ROTATE_270_DEGREES     LCD_MODE_EXCHANGE_XY | LCD_MODE_FLIP_Y

    // Properties
        #define LCD_PROP_BACKLIGHT              PROP_LCD + 0x01     // unsigned char*
        #define LCD_PROP_COLOR                  PROP_LCD + 0x02     // COLOR*
        #define LCD_PROP_FONTHANDLE             PROP_LCD + 0x03     // LCD_FontHandle*
        #define LCD_PROP_HEIGHT                 PROP_LCD + 0x04     // unsigned short*
        #define LCD_PROP_MODE                   PROP_LCD + 0x05     // unsigned short*
        #define LCD_PROP_WIDTH                  PROP_LCD + 0x06     // unsigned short*

        #define LCD_BACKLIGHT_OFF               0x00
        #define LCD_BACKLIGHT_ON                0xFF

// --------------------------------------------------
//  Structures & Typedefs
// --------------------------------------------------
    // Color
        typedef unsigned short COLOR;

    // Font
        struct _LCD_FontHandle {
            unsigned char  BytesPerGlyphBSL;            // Number of bits to shift left when calculating char offset on page
            unsigned char  BytesPerGlyphRow;            // Number of bytes per row of a glyph
            unsigned char  GlyphHeight;                 // Height in pixels of a character in the font
            unsigned char  GlyphWidth;                  // Width in pixels of a character in a monospace font, undefined for proportional
            unsigned char  GlyphsPerPageBSR;            // Number of bits to shift right a char value to find the pageNumber
            unsigned char  GlyphsPerPageMask;           // Mask used to mask off only bits for use in computing offset into page
            unsigned char  Spacing;                     // LCD_FONT_MONOSPACE | LCD_FONT_PROPORTIONAL
            unsigned long  BlockNumber;                 // BlockNumber of the FLASH holding the font
            unsigned long  DataStartPage;               // PageNumber inside the block the font starts at
            char           FontName[0x20];              // Name of the font
        };
        typedef struct _LCD_FontHandle LCD_FontHandle;


// --------------------------------------------------
//  Function Prototypes
// --------------------------------------------------
    /**
     * Copies data directly from a buffer to a rectangular area of the LCD
     *
     *  X         - [in] Starting column
     *  Y         - [in] Starting row
     *  W         - [in] Width of the rectangle
     *  H         - [in] Height of the rectanlge
     *  pColorbuf - [in] Buffer to copy data from, should contain an array of COLORs
     **/
    void LCD_Buffer_Fill(unsigned short X, unsigned short Y, unsigned short W, unsigned short H, COLOR* pColorBuf);

    /**
     * Clears the LCD Display
     *
     *  color - [in] Color to clear the display with (See LCD_MakeColor)
     **/
    void LCD_ClearDisplay(COLOR Color);

    /**
     * Draw a line
     *
     *  Note: X1, Y1, X2, and Y2 must be within the bounds of the LCD screen resolution
     *        or else the behavior is undefined.
     *
     *  X1 - [in] Leftmost column of the line
     *  Y1 - [in] Top row of the line
     *  X2 - [in] Rightmost column of the line
     *  Y2 - [in] Bottom row of the line
     **/
    void LCD_Line(unsigned short X1, unsigned short Y1, unsigned short X2, unsigned short Y2);

    /**
     * Creates a color from RGB Values
     *
     *  Red   - [in] Red compononent of the color, can range from 0 to 255
     *  Green - [in] Green compononent of the color, can range from 0 to 255
     *  Blue  - [in] Blue compononent of the color, can range from 0 to 255
     *
     *  Returns a COLOR created from the red, green, and blue components.
     **/
    COLOR LCD_MakeColor(unsigned char Red, unsigned char Green, unsigned char Blue);

    /**
     * Prints formatted text to the LCD
     *
     *  X       - [in] X coordinate to print text at
     *  Y       - [in] Y coordinate to print text at
     *  sFormat - [in] See printf function
     *  ...     - [in] See printf function
     *
     *  Returns the new X value after printing the text
     **/
    unsigned short LCD_Printf(unsigned short X, unsigned short Y, char* sFormat, ...);

    /**
     * Draws a Filled rectangle
     *
     *  X1 - [in] Leftmost column of the rectangle
     *  Y1 - [in] Top row of the rectangle
     *  X2 - [in] Rightmost column of the rectangle
     *  Y2 - [in] Bottom row of the rectangle
     **/
    void LCD_Rect(unsigned short X1, unsigned short Y1, unsigned short X2, unsigned short Y2);

    /**
     * Sets the color to be used for drawing on the LCD
     *
     *  Color - [in] Color to be used in LCD drawing operations.  (See LCD_MakeColor)
     **/
    void LCD_SetColor(COLOR Color);

    /**
     * Sets the drawing font
     *
     *  pFontHandle - [in] FontHandle for the font to draw with
     *
     *  Returns E_OK on success, or other error on failure.
     **/
    void LCD_SetFont(LCD_FontHandle* pFontHandle);

    /**
     * Sets a pixel on the LCD to the current color
     *
     *  X - [in] X coordinate of the pixel to draw
     *  Y - [in] Y coordinate of the pixel to draw
     **/
    void LCD_SetPixel(unsigned char X, unsigned char Y);

    /**
     * Prints formatted text to the LCD
     *
     * Note: LCD_vPrintf is aliased as LCD_Printf with variable number of arguments.
     *
     *  X       - [in] X coordinate to print text at
     *  Y       - [in] Y coordinate to print text at
     *  sFormat - [in] See vprintf function
     *  Args    - [in] See vprintf function
     *
     *  Returns the new X value after printing the text
     **/
    unsigned short LCD_vPrintf(unsigned short X, unsigned short Y, char* sFormat, va_list Args);

Navigation

Click on any of the links below to navigate to a new page