Exemple #1
0
//*****************************************************************************
//
//! Turns off the OLED display.
//!
//! This function will turn off the OLED display.  This will stop the scanning
//! of the panel and turn off the on-chip DC-DC converter, preventing damage to
//! the panel due to burn-in (it has similar characters to a CRT in this
//! respect).
//!
//! This function is contained in <tt>osram96x16.c</tt>, with
//! <tt>osram96x16.h</tt> containing the API definition for use by
//! applications.
//!
//! \return None.
//
//*****************************************************************************
void
OSRAMDisplayOff(void)
{
    //
    // Turn off the DC-DC converter and the display.
    //
    OSRAMWriteFirst(0x80);
    OSRAMWriteByte(0xae);
    OSRAMWriteByte(0x80);
    OSRAMWriteByte(0xad);
    OSRAMWriteByte(0x80);
    OSRAMWriteFinal(0x8a);
}
Exemple #2
0
//*****************************************************************************
//
//! Turns on the OLED display.
//!
//! This function will turn on the OLED display, causing it to display the
//! contents of its internal frame buffer.
//!
//! This function is contained in <tt>osram96x16.c</tt>, with
//! <tt>osram96x16.h</tt> containing the API definition for use by
//! applications.
//!
//! \return None.
//
//*****************************************************************************
void
OSRAMDisplayOn(void)
{
    //
    // Turn on the DC-DC converter and the display.
    //
    OSRAMWriteFirst(0x80);
    OSRAMWriteByte(0xad);
    OSRAMWriteByte(0x80);
    OSRAMWriteByte(0x8b);
    OSRAMWriteByte(0x80);
    OSRAMWriteFinal(0xaf);
}
Exemple #3
0
//*****************************************************************************
//
//! Displays an image on the OLED display.
//!
//! \param pucImage is a pointer to the image data.
//! \param ulX is the horizontal position to display this image, specified in
//! columns from the left edge of the display.
//! \param ulY is the vertical position to display this image, specified in
//! eight scan line blocks from the top of the display (i.e. only 0 and 1 are
//! valid).
//! \param ulWidth is the width of the image, specified in columns.
//! \param ulHeight is the height of the image, specified in eight row blocks
//! (i.e. only 1 and 2 are valid).
//!
//! This function will display a bitmap graphic on the display.  The image to
//! be displayed must be a multiple of eight scan lines high (i.e. one row) and
//! will be drawn at a vertical position that is a multiple of eight scan lines
//! (i.e. scan line zero or scan line eight, corresponding to row zero or row
//! one).
//!
//! The image data is organized with the first row of image data appearing left
//! to right, followed immediately by the second row of image data.  Each byte
//! contains the data for the eight scan lines of the column, with the top scan
//! line being in the least significant bit of the byte and the bottom scan
//! line being in the most significant bit of the byte.
//!
//! For example, an image four columns wide and sixteen scan lines tall would
//! be arranged as follows (showing how the eight bytes of the image would
//! appear on the display):
//!
//! \verbatim
//!     +-------+  +-------+  +-------+  +-------+
//!     |   | 0 |  |   | 0 |  |   | 0 |  |   | 0 |
//!     | B | 1 |  | B | 1 |  | B | 1 |  | B | 1 |
//!     | y | 2 |  | y | 2 |  | y | 2 |  | y | 2 |
//!     | t | 3 |  | t | 3 |  | t | 3 |  | t | 3 |
//!     | e | 4 |  | e | 4 |  | e | 4 |  | e | 4 |
//!     |   | 5 |  |   | 5 |  |   | 5 |  |   | 5 |
//!     | 0 | 6 |  | 1 | 6 |  | 2 | 6 |  | 3 | 6 |
//!     |   | 7 |  |   | 7 |  |   | 7 |  |   | 7 |
//!     +-------+  +-------+  +-------+  +-------+
//!
//!     +-------+  +-------+  +-------+  +-------+
//!     |   | 0 |  |   | 0 |  |   | 0 |  |   | 0 |
//!     | B | 1 |  | B | 1 |  | B | 1 |  | B | 1 |
//!     | y | 2 |  | y | 2 |  | y | 2 |  | y | 2 |
//!     | t | 3 |  | t | 3 |  | t | 3 |  | t | 3 |
//!     | e | 4 |  | e | 4 |  | e | 4 |  | e | 4 |
//!     |   | 5 |  |   | 5 |  |   | 5 |  |   | 5 |
//!     | 4 | 6 |  | 5 | 6 |  | 6 | 6 |  | 7 | 6 |
//!     |   | 7 |  |   | 7 |  |   | 7 |  |   | 7 |
//!     +-------+  +-------+  +-------+  +-------+
//! \endverbatim
//!
//! This function is contained in <tt>osram96x16.c</tt>, with
//! <tt>osram96x16.h</tt> containing the API definition for use by
//! applications.
//!
//! \return None.
//
//*****************************************************************************
void
OSRAMImageDraw(const unsigned char *pucImage, unsigned long ulX,
               unsigned long ulY, unsigned long ulWidth,
               unsigned long ulHeight)
{
    //
    // Check the arguments.
    //
    ASSERT(ulX < 96);
    ASSERT(ulY < 2);
    ASSERT((ulX + ulWidth) <= 96);
    ASSERT((ulY + ulHeight) <= 2);

    //
    // The first 36 columns of the LCD buffer are not displayed, so increment
    // the X coorddinate by 36 to account for the non-displayed frame buffer
    // memory.
    //
    ulX += 36;

    //
    // Loop while there are more rows to display.
    //
    while(ulHeight--)
    {
        //
        // Write the starting address within this row.
        //
        OSRAMWriteFirst(0x80);
        OSRAMWriteByte((ulY == 0) ? 0xb0 : 0xb1);
        OSRAMWriteByte(0x80);
        OSRAMWriteByte(ulX & 0x0f);
        OSRAMWriteByte(0x80);
        OSRAMWriteByte(0x10 | ((ulX >> 4) & 0x0f));
        OSRAMWriteByte(0x40);

        //
        // Write this row of image data.
        //
        OSRAMWriteArray(pucImage, ulWidth - 1);
        OSRAMWriteFinal(pucImage[ulWidth - 1]);

        //
        // Advance to the next row of the image.
        //
        pucImage += ulWidth;
        ulY++;
    }
}
Exemple #4
0
//*****************************************************************************
//
//! Clears the OLED display.
//!
//! This function will clear the display.  All pixels in the display will be
//! turned off.
//!
//! This function is contained in <tt>osram96x16.c</tt>, with
//! <tt>osram96x16.h</tt> containing the API definition for use by
//! applications.
//!
//! \return None.
//
//*****************************************************************************
void
OSRAMClear(void)
{
    static const unsigned char pucRow1[] =
    {
        0xb0, 0x80, 0x04, 0x80, 0x12, 0x40
    };
    static const unsigned char pucRow2[] =
    {
        0xb1, 0x80, 0x04, 0x80, 0x12, 0x40
    };
    unsigned long ulIdx;

    //
    // Move the display cursor to the first column of the first row.
    //
    OSRAMWriteFirst(0x80);
    OSRAMWriteArray(pucRow1, sizeof(pucRow1));

    //
    // Fill this row with zeros.
    //
    for(ulIdx = 0; ulIdx < 95; ulIdx++)
    {
        OSRAMWriteByte(0x00);
    }
    OSRAMWriteFinal(0x00);

    //
    // Move the display cursor to the first column of the second row.
    //
    OSRAMWriteFirst(0x80);
    OSRAMWriteArray(pucRow2, sizeof(pucRow2));

    //
    // Fill this row with zeros.
    //
    for(ulIdx = 0; ulIdx < 95; ulIdx++)
    {
        OSRAMWriteByte(0x00);
    }
    OSRAMWriteFinal(0x00);
}
Exemple #5
0
//*****************************************************************************
//
//! Displays a string on the OLED display.
//!
//! \param pcStr is a pointer to the string to display.
//! \param ulX is the horizontal position to display the string, specified in
//! columns from the left edge of the display.
//! \param ulY is the vertical position to display the string, specified in
//! eight scan line blocks from the top of the display (i.e. only 0 and 1 are
//! valid).
//!
//! This function will draw a string on the display.  Only the ASCII characters
//! between 32 (space) and 126 (tilde) are supported; other characters will
//! result in random data being draw on the display (based on whatever appears
//! before/after the font in memory).  The font is mono-spaced, so characters
//! such as "i" and "l" have more white space around them than characters such
//! as "m" or "w".
//!
//! If the drawing of the string reaches the right edge of the display, no more
//! characters will be drawn.  Therefore, special care is not required to avoid
//! supplying a string that is "too long" to display.
//!
//! This function is contained in <tt>osram96x16.c</tt>, with
//! <tt>osram96x16.h</tt> containing the API definition for use by
//! applications.
//!
//! \return None.
//
//*****************************************************************************
void
OSRAMStringDraw(const char *pcStr, unsigned long ulX, unsigned long ulY)
{
    //
    // Check the arguments.
    //
    ASSERT(ulX < 96);
    ASSERT(ulY < 2);

    //
    // Move the display cursor to the requested position on the display.
    //
    OSRAMWriteFirst(0x80);
    OSRAMWriteByte((ulY == 0) ? 0xb0 : 0xb1);
    OSRAMWriteByte(0x80);
    OSRAMWriteByte((ulX + 36) & 0x0f);
    OSRAMWriteByte(0x80);
    OSRAMWriteByte(0x10 | (((ulX + 36) >> 4) & 0x0f));
    OSRAMWriteByte(0x40);

    //
    // Loop while there are more characters in the string.
    //
    while(*pcStr != 0) {
        //
        // See if there is enough space on the display for this entire
        // character.
        //
        if(ulX <= 90) {
            //
            // Write the contents of this character to the display.
            //
            OSRAMWriteArray(g_pucFont[*pcStr - ' '], 5);

            //
            // See if this is the last character to display (either because the
            // right edge has been reached or because there are no more
            // characters).
            //
            if((ulX == 90) || (pcStr[1] == 0)) {
                //
                // Write the final column of the display.
                //
                OSRAMWriteFinal(0x00);

                //
                // The string has been displayed.
                //
                return;
            }

            //
            // Write the inter-character padding column.
            //
            OSRAMWriteByte(0x00);
        } else {
            //
            // Write the portion of the character that will fit onto the
            // display.
            //
            OSRAMWriteArray(g_pucFont[*pcStr - ' '], 95 - ulX);
            OSRAMWriteFinal(g_pucFont[*pcStr - ' '][95 - ulX]);

            //
            // The string has been displayed.
            //
            return;
        }

        //
        // Advance to the next character.
        //
        pcStr++;

        //
        // Increment the X coordinate by the six columns that were just
        // written.
        //
        ulX += 6;
    }
}