Beispiel #1
0
void lcd_clear()
{
    lcd_set_address(0, 0);
    int c = 0;
    while(c < PCD8544_MAXBYTES) {
        lcd_write_byte(LCD_WRITE_DATA, 0);
        c++;
    }
    lcd_set_address(0, 0);
}
Beispiel #2
0
void lcd_clear_char_columns(unsigned char x, unsigned char y, unsigned short number)
{
    lcd_set_address(x, y);
    unsigned short i;
    for (i = 0; i < number; i++)
    {
        lcd_write_byte(LCD_WRITE_DATA, 0x00);
    }
}
Beispiel #3
0
void lcd_write_graphic(unsigned char x, unsigned char y, const unsigned char graphic[], unsigned short size)
{
    lcd_set_address(x, y);

    unsigned short i;
    for (i = 0; i < size; i++)
    {
        lcd_write_byte(LCD_WRITE_DATA, graphic[i]);
    }
}
Beispiel #4
0
/*! \brief Clears the LCD screen.
 *
 *  The LCD screen is completely cleared by writing the given color to each
 *  pixel.
 */
void lcd_clear(uint16 color)
{
    int i,j;
    lcd_set_address(0,d_width_x-1,0,d_width_y-1);

    for (i=1;i<d_width_y;i++){
        for (j=0;j<d_width_x;j++){
            writedata16_cont(color);
        }
    }
    for (j=1;j<d_width_x;j++){
        writedata16_cont(color);
    }
    writedata16_last(color);
}
Beispiel #5
0
void lcd_draw_rect(uint16 x1, uint16 x2, uint16 y1, uint16 y2, uint16 color, uint8 fill)
{
    uint16 i;

    if(fill) {                          // if the rectangle has to be filled
        lcd_set_address(x1,x2,y1,y2);
        for(i=0; i<(((x2-x1+1)*(y2-y1+1)+1))-1; i++) {
            writedata16_cont(color);
        }
        writedata16_last(color);
    }
    else {                              // if not to be filled
        lcd_draw_rect(x1,x1,y1,y2,color,1); // draw left line
        lcd_draw_rect(x2,x2,y1,y2,color,1); // draw right line
        lcd_draw_rect(x1,x2,y1,y1,color,1); // draw bottom line
        lcd_draw_rect(x1,x2,y2,y2,color,1); // draw top line
    }
}
Beispiel #6
0
void lcd_draw_bitmap(int16 x, int16 y, const LCD_BITMAP *bitmap)
{
    uint16_t used;
    uint8_t index, mask;

    lcd_set_address(x,x+bitmap->width-1,y,y+bitmap->height-1);

    index = 0;
    mask = 0x80;
    for(used=1; used<(bitmap->width*bitmap->height); used++) {
        if(bitmap->data[index] & mask) { // if pixel value is one
            writedata16_cont(d_theme.Font_Color.Word);
        }
        else {                      // or pixel value is zero
            writedata16_cont(d_theme.BG_Color.Word);
        }
        // increment counters
        if(mask>1) {
            mask >>= 1;
        }
        else {
Beispiel #7
0
/*! \brief Write a character with small font.
 *
 *  This function writes a single character at the given position.
 *
 *  @param x Offset to the left.
 *  @param y Offset to the top.
 *  @param c ASCII character.
 *  @return The function returns the width of the character written.
 */
uint16 lcd_write_char(uint16 x, uint16 y, char c)
{
    uint16_t pixels_used=0;
    uint16_t pixels_to_use;
    uint16_t index;
    uint16_t font_byte;
    uint8_t font_mask;


    // if not a printable character
    if((c < d_font->first_char) || (c > d_font->last_char)) {
        return 0;                       // width=0, abort
    }
    index = c-d_font->first_char;       // get character index in font
    if(d_use_monospace) {
        lcd_set_address(x,x+d_font->width-1,y,y+d_font->height-1);
    }
    else {
        lcd_set_address(x,x+d_font->char_width[index],y,y+d_font->height-1);
    }
    // add half of the space columns in front of the character to balance the spacing
    if(d_use_monospace) {
        // one or more space columns at the beginning
        pixels_to_use = d_font->height*((d_font->width - d_font->char_width[index])/2);
        for(pixels_used=0; pixels_used < pixels_to_use; pixels_used++) {
            writedata16_cont(d_theme.BG_Color.Word);
        }
    }

    // add number of pixels occupied by the current character
    pixels_to_use = pixels_used
                    + d_font->pixel_offset[index+1]
                    - d_font->pixel_offset[index];

    // byte offset in data array
    font_byte = d_font->pixel_offset[index]>>3;
    // bit offset in current data byte
    font_mask = 1u << (d_font->pixel_offset[index]&0x07);

    // loop on all pixels to draw
    for( ; pixels_used<pixels_to_use; pixels_used++) {
        if(d_font->data[font_byte] & font_mask) { // if pixel value is one
            writedata16_cont(d_theme.Font_Color.Word);
        }
        else {                      // or pixel value is zero
            writedata16_cont(d_theme.BG_Color.Word);
        }
        // increment font counters
        if(font_mask<128) {
            font_mask <<= 1;
        }
        else {
            font_mask = 1;
            font_byte++;
        }
    }

    if(d_use_monospace) {
        pixels_to_use = d_font->height*d_font->width; // fixed width
    }
    else {
        pixels_to_use += d_font->height; // add one space column
    }

    // one or more space columns at the end
    for(; pixels_used<pixels_to_use-1; pixels_used++) {
        writedata16_cont(d_theme.BG_Color.Word);
    }
    writedata16_last(d_theme.BG_Color.Word);

    if(d_use_monospace) {
        return d_font->width;
    }
    else {
        return d_font->char_width[index] + 1;
    }
}
Beispiel #8
0
void lcd_set_pixel(uint16 x, uint16 y, uint16 color)
{
    lcd_set_address(x,x,y,y);
    writedata16_last(color);
}