ExtDisplay.cpp
/**
 * Vytiskne UTF-8 text na displej vcetne korektniho word-wrapu.
 * Tiskne se na nastavenou pozici X,Y, ktera je LEVY DOLNI roh prvniho pismene.
 * x_offset se pouzije jen pro prvni radek.
 * 
 * Tisk je omezeny nastavenym bounding boxem.
 * 
 * Vraci aktualni pozici X.
 * necha posX = puvodni posX; nastavi posY = posledni radek s textem
 */
Vytiskne UTF-8 text na displej vcetne korektniho word-wrapu.
Tiskne se na nastavenou pozici X,Y, ktera je LEVY DOLNI roh prvniho pismene.
x_offset se pouzije jen pro prvni radek.

Tisk je omezeny nastavenym bounding boxem.

Vraci aktualni pozici X.
necha posX = puvodni posX; nastavi posY = posledni radek s textem
Vytiskne UTF - 8 text na displej vcetne korektniho word - wrapu . Tiskne se na nastavenou pozici X Y ktera je LEVY DOLNI roh prvniho pismene . x_offset se pouzije jen pro prvni radek . Tisk je omezeny nastavenym bounding boxem . Vraci aktualni pozici X . necha posX = puvodni posX ; nastavi posY = posledni radek s textem
int ExtDisplay::printUTF8( const char * text, int x_offset  ) {
    char buffer[BUFFER_SIZE];
    strncpy( buffer, text, BUFFER_SIZE );
    buffer[BUFFER_SIZE-1] = 0;
    utf8tocp( buffer );  
    if( DUMP_DEBUG_INFO ) this->logger->log( "[%s]", buffer );
    if( DUMP_DEBUG_INFO ) this->logger->log( "  pos=%d,%d bbW=%d xo=%d", this->posX, this->posY, this->boundingBoxWidth, x_offset );
    int x,y;
    x = this->posX + x_offset;
    y = this->posY;
    initParser( buffer );
    while( true ) {
        if( ! getNextWord() ) break;
        if( DUMP_DEBUG_INFO ) this->logger->log( "  # '%s'", oneWord );
        int16_t x1, y1;
        uint16_t w, h;
        this->display->getTextBounds( (const char*)oneWord, x, y, &x1, &y1, &w, &h );
        if( DUMP_DEBUG_INFO )  this->logger->log( "  max pos %d,%d size %d,%d", x1,y1, w,h );
        if( ( x + w ) <= ( this->posX + this->boundingBoxWidth ) ) {
            this->display->setCursor( x, y );     
            this->display->print( oneWord );
            x += w;
            if( DUMP_DEBUG_INFO )  this->logger->log( "  pokracuju, nova souradnice %d,%d", x,y );
        } else {
            if( DUMP_DEBUG_INFO )  this->logger->log( "  @ %d,%d, w=%d", x,y, w );
            x = this->posX;
            y += this->vyskaRadku;
            this->display->getTextBounds( (const char*)oneWord, x, y, &x1, &y1, &w, &h );
            if( DUMP_DEBUG_INFO )  this->logger->log( "  @ %d,%d, w=%d", x,y, w );
            this->display->setCursor( x, y );     
            this->display->print( oneWord );
            x += w;
            if( DUMP_DEBUG_INFO ) this->logger->log( "  novy radek, nova souradnice %d,%d", x,y );
        }
        if( delimiter==' ' ) {
            x += this->sirkaMezery;
        }
    }
    this->posY = y;
    return x - this->posX;
}
int ExtDisplay :: printUTF8 ( const char * text , int x_offset ) { char buffer [ BUFFER_SIZE ] ; strncpy ( buffer , text , BUFFER_SIZE ) ; buffer [ BUFFER_SIZE - 1 ] = 0 ; utf8tocp ( buffer ) ; if ( DUMP_DEBUG_INFO ) this -> logger -> log ( " " , buffer ) ; if ( DUMP_DEBUG_INFO ) this -> logger -> log ( " " , this -> posX , this -> posY , this -> boundingBoxWidth , x_offset ) ; int x , y ; x = this -> posX + x_offset ; y = this -> posY ; initParser ( buffer ) ; while ( true ) { if ( ! getNextWord ( ) ) break ; if ( DUMP_DEBUG_INFO ) this -> logger -> log ( " " , oneWord ) ; int16_t x1 , y1 ; uint16_t w , h ; this -> display -> getTextBounds ( ( const char * ) oneWord , x , y , & x1 , & y1 , & w , & h ) ; if ( DUMP_DEBUG_INFO ) this -> logger -> log ( " " , x1 , y1 , w , h ) ; if ( ( x + w ) <= ( this -> posX + this -> boundingBoxWidth ) ) { this -> display -> setCursor ( x , y ) ; this -> display -> print ( oneWord ) ; x += w ; if ( DUMP_DEBUG_INFO ) this -> logger -> log ( " " , x , y ) ; } else { if ( DUMP_DEBUG_INFO ) this -> logger -> log ( " " , x , y , w ) ; x = this -> posX ; y += this -> vyskaRadku ; this -> display -> getTextBounds ( ( const char * ) oneWord , x , y , & x1 , & y1 , & w , & h ) ; if ( DUMP_DEBUG_INFO ) this -> logger -> log ( " " , x , y , w ) ; this -> display -> setCursor ( x , y ) ; this -> display -> print ( oneWord ) ; x += w ; if ( DUMP_DEBUG_INFO ) this -> logger -> log ( " " , x , y ) ; } if ( delimiter == ' ' ) { x += this -> sirkaMezery ; } } this -> posY = y ; return x - this -> posX ; }
Vytiskne UTF-8 text na displej vcetne korektniho word-wrapu.
Vytiskne UTF - 8 text na displej vcetne korektniho word - wrapu .
// musime znovu, protoze ve vyjimecnem pripade to zalomi text samo a vrati to w treba 392 bodu