GLCD 128x64 Darstellungsproblem

Gast #1852559
Lesenswert?

Hier ist die Funktion (ist aus dem Forum) habe unten versucht die Pixel 
zu drehen die nicht gesetzt werden, geht auch schon besser hat aber 
immer noch fehldarstellugen.

void lcd_putc(uint8_t* font,uint8_t chr)
{
  uint8_t x,page,bit,data,cnt=0;

  if (font_char_present(font,chr)==1)  // print only if letter is 
present in font
  {
    if ( ( (cursor_x + font_char_width(font,chr)) <128)  && 
((cursor_y+font_char_height(font))<=64))  // only print leeter if it 
fits in screen
    {
      uint16_t offset= font_start_offset(font,chr);  // get the position 
of the first byte in font-array

      for(page=0;page<=(font_char_height(font)-1)/8;page++)  // write 
all pages(rows)
      {
        lcd_write_cmd(LCD_SET_PAGE|((cursor_y/8)+page),CHIP1|CHIP2);  // 
calc the current page

        if (cursor_x<64)  // set cursor to its poition (0 on the 
inactive controller so it can start directly on chip change)
        {
          lcd_write_cmd(LCD_SET_ADD|cursor_x,CHIP1);
          lcd_write_cmd(LCD_SET_ADD|0,CHIP2);
        }
        else
        {
          lcd_write_cmd(LCD_SET_ADD|(cursor_x-64),CHIP2);
        }

        for (x=cursor_x;x<cursor_x + font_char_width(font,chr);x++) 
//fill "pages"
        {
          data= pgm_read_byte(font+offset+cnt++);

          if ( page==font_char_height(font)/8)
            data>>=8-(font_char_height(font)%8);  // if char height is 
bigger than 8 we have to remove some leading zeros

          #ifdef FASTTEXT                // this is much much faster 
than using set_pixel (see discription in header file)

          if (cursor_y%8==0 )
          {
            if (x<64)
              lcd_write_data(data,CHIP1);
            else
              lcd_write_data(data,CHIP2);
          }
          else
          #endif
          {

        //  if ((data&(1<<bit))==0)
          //  lcd_fill_rect(x,cursor_y,5,10,WHITE);
            for(bit=0;bit<8;bit++)
          {

              // lcd_set_pixel(x,cursor_y+page*30+bit,WHITE);
            //lcd_set_pixel(x,cursor_y+page*8+bit,WHITE);
            //else
              if ((data&(1<<bit))!=0)
               lcd_set_pixel(x,cursor_y+page*8+bit,BLACK);
            else
            lcd_set_pixel(x,cursor_y+page*8+bit,WHITE);
        //  lcd_fill_rect(x,cursor_y+page*8+bit,5,10,WHITE);
            }

          }
        }

        #ifdef FASTTEXT
        if(cursor_y%8==0)
        {
          if (x<64)
            lcd_write_data(0,CHIP1);
          else
            lcd_write_data(0,CHIP2);
        }
        #endif
      }
      cursor_x += font_char_width(font,chr)+1;


    }
  }
}

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren