Beispiel #1
0
/******************************************************************************
* ID : 31.0
* Outline : ST7579_Write
* Include : ST7579_LCD.h
* Function Name: ST7579_Write
* Description : Write to the LCD using a Glyph Register value, to the Glyph
* data storage or run an LCD Glyph Command.
* Argument : aHandle - the Glyph handle setup by the LCD and Communications.
*          : aRegister - specifies what to do.
*          : aValue - data if required
* Return Value : 0=success, not 0= error
* Calling Functions : GlyphWrite
******************************************************************************/
T_glyphError ST7579_Write(T_glyphHandle aHandle, uint32_t aRegister, uint32_t aValue)
{
    uint32_t pCounter;
    uint32_t column;
    uint32_t line;
    const uint8_t *p_char;
    uint8_t width;
    uint8_t height;
    const uint8_t *p_charData;
    uint32_t page;
    T_glyphError error = GLYPH_ERROR_ILLEGAL_OPERATION ;
    T_glyphWorkspace *p_gw = (T_glyphWorkspace *)aHandle;

    p_gw->iLCDAPI->iStatusRegister = GLYPH_STATUS_BUSY ;

    switch (aRegister) {
        case GLYPH_CHAR_X:
            p_gw->iLCDAPI->iCharX_Position = aValue ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CHAR_Y:
            p_gw->iLCDAPI->iCharY_Position = aValue ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_FONT:
            p_gw->iLCDAPI->iCharFont = aValue;
            switch (aValue) {
            #ifdef USE_GLYPH_FONT_BITMAP
                case GLYPH_FONT_BITMAP:
                    p_gw->iLCDAPI->iFont = Bitmaps_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_HELVR10
                case GLYPH_FONT_HELVR10:
                    p_gw->iLCDAPI->iFont = FontHelvr10_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_8_BY_16
                case GLYPH_FONT_8_BY_16:
                    p_gw->iLCDAPI->iFont = Font8x16_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_8_BY_8
                case GLYPH_FONT_8_BY_8:
                    p_gw->iLCDAPI->iFont = Font8x8_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_WINFREE
                case GLYPH_FONT_WINFREESYSTEM14_BY_16:
                    p_gw->iLCDAPI->iFont = FontWinFreeSystem14x16_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_5_BY_7
                case GLYPH_FONT_5_BY_7:
                    p_gw->iLCDAPI->iFont = Fontx5x7_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_6_BY_13
                case GLYPH_FONT_6_BY_13:
                    p_gw->iLCDAPI->iFont = Fontx6x13_table ;
                    break ;
            #endif
            }
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_DRAW_CMD:
            switch (aValue)  {
                case 1:
                    ST7579_SetLine(p_gw, 0);
                    for (pCounter=0;pCounter<8;pCounter++)  {
                        ST7579_SetPage(aHandle, pCounter);
                        ST7579_SetChar(aHandle, 0);
                        for (column=0; column<128; column++)    {
                            p_gw->iCommAPI->iDataSend(0x00);
                        }
                    }
                    ST7579_SetPage(aHandle, 0);
                    ST7579_SetChar(aHandle, 0);
                    break;
                case 2:
                    /* use reverse video to detect pixel changes */
                    ST7579_Send16bitsCommand(aHandle, LCD_DISPLAY_REVERSE);
                    break;
                case 3:
                    /* use normal video to detect pixel changes */
                    ST7579_Send16bitsCommand(aHandle, LCD_DISPLAY_NORMAL);
                    break;
                case 6:
                    for (pCounter=0;pCounter<8;pCounter++)  {
                        ST7579_SetLine(aHandle, 0);
                        ST7579_SetChar(aHandle, 0);              
                        ST7579_SetPage(aHandle, pCounter);
                        for (column=0;column<16;column++)   {
                            p_gw->iCommAPI->iDataSend(0xFF);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                        }
                    }                                       
                    break;
                case 7:
                    for (line=p_gw->iLCDAPI->iCharY_Position; line<=p_gw->iLCDAPI->iCharY2_Position; line+=8) {
                        ST7579_SetPage(aHandle, line/8);
                        ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                        for (column=p_gw->iLCDAPI->iCharX_Position; column<=p_gw->iLCDAPI->iCharX2_Position; column++)    {
                            p_gw->iCommAPI->iDataSend(0xFF);
                        }
                    }
                    break;
                case 8:
                    for (line=p_gw->iLCDAPI->iCharY_Position; line<=p_gw->iLCDAPI->iCharY2_Position; line+=8) {
                        ST7579_SetPage(aHandle, line/8);
                        ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                        for (column=p_gw->iLCDAPI->iCharX_Position; column<=p_gw->iLCDAPI->iCharX2_Position; column++)    {
                            p_gw->iCommAPI->iDataSend(0x00);
                        }
                    }
                    break;
            }
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_DRAW_CHAR:
            p_char = p_gw->iLCDAPI->iFont[aValue];
            width = p_char[0];
            height = p_char[1];
            p_charData = &p_char[2];
            for (page=0; page<height; page+=8)  {
                ST7579_SetPage(aHandle, (p_gw->iLCDAPI->iCharY_Position+page)>>3);
                ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                for (column=0; column<width; column++, p_charData++)    {
                    p_gw->iCommAPI->iDataSend(*p_charData);
                }
            }
			p_gw->iLCDAPI->iCharX_Position += width;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CHAR_ERASE:
            p_char = p_gw->iLCDAPI->iFont[aValue];
            width = p_char[0];
            height = p_char[1];
            for (page=0; page<height; page+=8)  {
                ST7579_SetPage(aHandle, (p_gw->iLCDAPI->iCharY_Position+page)>>3);
                ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                for (column=0; column<width; column++, p_charData++)    {
                    p_gw->iCommAPI->iDataSend(0x00);
                }
            }
			p_gw->iLCDAPI->iCharX_Position += width;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_INVERT_CHAR:
            p_char = (uint8_t *)p_gw->iLCDAPI->iFont[aValue];
            width = p_char[0];
            height = p_char[1];
            p_charData = &p_char[2];
            for (page=0; page<height; page+=8)  {
                ST7579_SetPage(aHandle, (p_gw->iLCDAPI->iCharY_Position+page)>>3);
                ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                for (column=0; column<width; column++, p_charData++)    {
					// Output the inverted values to invert character
                    p_gw->iCommAPI->iDataSend(*p_charData ^ 0xFF);
                }
            }
			p_gw->iLCDAPI->iCharX_Position += width;
            error = GLYPH_ERROR_NONE;
            break;
        case GLYPH_CHAR_X2:
            p_gw->iLCDAPI->iCharX2_Position = aValue ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CHAR_Y2:
            p_gw->iLCDAPI->iCharY2_Position = aValue ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_FRAME_RATE:
            p_gw->iLCDAPI->iFrameRate = (int32_t)aValue ;
            ST7579_SetFrameRate(aHandle, p_gw->iLCDAPI->iFrameRate) ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CONTRAST:
            p_gw->iLCDAPI->iContrast = (int32_t)aValue ;
            ST7579_SetVO_Range(aHandle, p_gw->iLCDAPI->iContrast) ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CONTRAST_BOOST:
            p_gw->iLCDAPI->iContrastBoost = (int8_t)aValue ;
            ST7579_SetSystemBiasBooster(aHandle, p_gw->iLCDAPI->iContrastBoost) ;
            error = GLYPH_ERROR_NONE ;
            break ;
    }

    p_gw->iLCDAPI->iStatusRegister = GLYPH_STATUS_READY ;
    return error ;
}
Beispiel #2
0
/******************************************************************************
* ID : 31.0
* Outline : ST7579_Write
* Include : ST7579_LCD.h
* Function Name: ST7579_Write
* Description : Write to the LCD using a Glyph Register value, to the Glyph
* data storage or run an LCD Glyph Command.
* Argument : aHandle - the Glyph handle setup by the LCD and Communications.
*          : aRegister - specifies what to do.
*          : aValue - data if required
* Return Value : 0=success, not 0= error
* Calling Functions : GlyphWrite
******************************************************************************/
T_glyphError ST7579_Write(T_glyphHandle aHandle, uint16_t aRegister, uint16_t aValue)
{
    uint16_t pCounter;
    uint16_t column;
    uint16_t line;
    const uint8_t *p_char;
    uint8_t width;
    uint8_t height;
    const uint8_t *p_charData;
    uint16_t page;
    T_glyphError error = GLYPH_ERROR_ILLEGAL_OPERATION ;
    T_glyphWorkspace *p_gw = (T_glyphWorkspace *)aHandle;
    uint8_t cmd = 0xFF;

    p_gw->iLCDAPI->iStatusRegister = GLYPH_STATUS_BUSY ;

    switch (aRegister) {
        case GLYPH_CHAR_X:
            p_gw->iLCDAPI->iCharX_Position = aValue ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CHAR_Y:
            p_gw->iLCDAPI->iCharY_Position = aValue ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_FONT:
            p_gw->iLCDAPI->iCharFont = aValue;
            switch (aValue) {
            #ifdef USE_GLYPH_FONT_BITMAP
                case GLYPH_FONT_BITMAP:
                    p_gw->iLCDAPI->iFont = Bitmaps_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_HELVR10
                case GLYPH_FONT_HELVR10:
                    p_gw->iLCDAPI->iFont = FontHelvr10_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_8_BY_16
                case GLYPH_FONT_8_BY_16:
                    p_gw->iLCDAPI->iFont = Font8x16_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_8_BY_8
                case GLYPH_FONT_8_BY_8:
                    p_gw->iLCDAPI->iFont = Font8x8_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_WINFREE
                case GLYPH_FONT_WINFREESYSTEM14_BY_16:
                    p_gw->iLCDAPI->iFont = FontWinFreeSystem14x16_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_5_BY_7
                case GLYPH_FONT_5_BY_7:
                    p_gw->iLCDAPI->iFont = Fontx5x7_table ;
                    break ;
            #endif
            #ifdef USE_GLYPH_FONT_6_BY_13
                case GLYPH_FONT_6_BY_13:
                    p_gw->iLCDAPI->iFont = Fontx6x13_table ;
                    break ;
            #endif
			#ifdef USE_GLYPH_FONT_LOGOS
                case GLYPH_FONT_LOGOS:
                    p_gw->iLCDAPI->iFont = Logos_table ;
                    break ;
            #endif
            }
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_DRAW_CMD:
            switch (aValue)  {
                case 1:
                    ST7579_SetLine(p_gw, 0);
                    for (pCounter=0;pCounter<8;pCounter++)  {
                        ST7579_SetPage(aHandle, pCounter);
                        ST7579_SetChar(aHandle, 0);
                        for (column=0; column<128; column++)    {
                            p_gw->iCommAPI->iDataSend(0x00);
                        }
                    }
                    ST7579_SetPage(aHandle, 0);
                    ST7579_SetChar(aHandle, 0);
                    break;
                case 2:
                    /* use reverse video to detect pixel changes */
                    ST7579_Send16bitsCommand(aHandle, LCD_DISPLAY_REVERSE);
                    break;
                case 3:
                    /* use normal video to detect pixel changes */
                    ST7579_Send16bitsCommand(aHandle, LCD_DISPLAY_NORMAL);
                    break;
                case 6:
                    for (pCounter=0;pCounter<8;pCounter++)  {
                        ST7579_SetLine(aHandle, 0);
                        ST7579_SetChar(aHandle, 0);              
                        ST7579_SetPage(aHandle, pCounter);
                        for (column=0;column<16;column++)   {
                            p_gw->iCommAPI->iDataSend(0xFF);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                            p_gw->iCommAPI->iDataSend(0x01);
                        }
                    }                                       
                    break;
                    
                case 7: // Draw block
                    line = p_gw->iLCDAPI->iCharY_Position - (p_gw->iLCDAPI->iCharY_Position % 8);   // Gets the nearest block boundary
                    cmd = 0xFF;
                    
                    if (p_gw->iLCDAPI->iCharY_Position < (line + 8))
                            cmd &= (0xFF << (p_gw->iLCDAPI->iCharY_Position - line));
                    
                    for ( ; line<=p_gw->iLCDAPI->iCharY2_Position; line+=8) {
                        
                        ST7579_SetPage(aHandle, line/8);
                        ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                       
                        if ((line+8) > p_gw->iLCDAPI->iCharY2_Position) /* If we're ending midway through a line */
                            cmd &= (0xFF >> ((line+7) - p_gw->iLCDAPI->iCharY2_Position));
                        
                        /* This code fills in the row column by column, one px at a time */
                        for (column=p_gw->iLCDAPI->iCharX_Position; column<=p_gw->iLCDAPI->iCharX2_Position; column++)    {
                            p_gw->iCommAPI->iDataSend(cmd); // No_Clobber_Axes(cmd, column, line));
                        }
                        
                        cmd = 0xFF;
                    }
                    break;
                    
                case 8: // Erase block
                    line = p_gw->iLCDAPI->iCharY_Position - (p_gw->iLCDAPI->iCharY_Position % 8);
                    cmd = 0x00;
                    
                    if (p_gw->iLCDAPI->iCharY_Position < (line + 8))
                            cmd &= (0xFF << (p_gw->iLCDAPI->iCharY_Position - line));
                    
                    for ( ; line<=p_gw->iLCDAPI->iCharY2_Position; line+=8) {
                        ST7579_SetPage(aHandle, line/8);
                        ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                        for (column=p_gw->iLCDAPI->iCharX_Position; column<=p_gw->iLCDAPI->iCharX2_Position; column++)    {
                            p_gw->iCommAPI->iDataSend(cmd); // No_Clobber_Axes(cmd, column, line));
                        }
                    }
                    break;
            }
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_DRAW_CHAR:
            p_char = p_gw->iLCDAPI->iFont[aValue];
            width = p_char[0];
            height = p_char[1];
            p_charData = &p_char[2];
            for (page=0; page<height; page+=8)  {
                ST7579_SetPage(aHandle, (p_gw->iLCDAPI->iCharY_Position+page)>>3);
                ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                for (column=0; column<width; column++, p_charData++)    {
                    p_gw->iCommAPI->iDataSend(*p_charData);
                }
            }
						p_gw->iLCDAPI->iCharX_Position += width;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CHAR_ERASE:
            p_char = p_gw->iLCDAPI->iFont[aValue];
            width = p_char[0];
            height = p_char[1];
            for (page=0; page<height; page+=8)  {
                ST7579_SetPage(aHandle, (p_gw->iLCDAPI->iCharY_Position+page)>>3);
                ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                for (column=0; column<width; column++, p_charData++)    {
                    p_gw->iCommAPI->iDataSend(0x00);
                }
            }
						p_gw->iLCDAPI->iCharX_Position += width;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_INVERT_CHAR:
            p_char = (uint8_t *)p_gw->iLCDAPI->iFont[aValue];
            width = p_char[0];
            height = p_char[1];
            p_charData = &p_char[2];
            for (page=0; page<height; page+=8)  {
                ST7579_SetPage(aHandle, (p_gw->iLCDAPI->iCharY_Position+page)>>3);
                ST7579_SetChar(aHandle, p_gw->iLCDAPI->iCharX_Position);
                for (column=0; column<width; column++, p_charData++)    {
									// Output the inverted values to invert character
                    p_gw->iCommAPI->iDataSend(*p_charData ^ 0xFF);
                }
            }
						p_gw->iLCDAPI->iCharX_Position += width;
            error = GLYPH_ERROR_NONE;
            break;
        case GLYPH_CHAR_X2:
            p_gw->iLCDAPI->iCharX2_Position = aValue ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CHAR_Y2:
            p_gw->iLCDAPI->iCharY2_Position = aValue ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_FRAME_RATE:
            p_gw->iLCDAPI->iFrameRate = (int8_t)aValue ;
            ST7579_SetFrameRate(aHandle, p_gw->iLCDAPI->iFrameRate) ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CONTRAST:
            p_gw->iLCDAPI->iContrast = (int8_t)aValue ;
            ST7579_SetVO_Range(aHandle, p_gw->iLCDAPI->iContrast) ;
            error = GLYPH_ERROR_NONE ;
            break ;
        case GLYPH_CONTRAST_BOOST:
            p_gw->iLCDAPI->iContrastBoost = (int8_t)aValue ;
            ST7579_SetSystemBiasBooster(aHandle, p_gw->iLCDAPI->iContrastBoost) ;
            error = GLYPH_ERROR_NONE ;
            break ;
    }

    p_gw->iLCDAPI->iStatusRegister = GLYPH_STATUS_READY ;
    return error ;
}