connornishijima / Pixie_Chroma

Arduino library and documentation for Pixie Chroma displays!
https://lixielabs.com/chroma/
MIT License
53 stars 9 forks source link

write_pix( char* ) should never modify cursor position #24

Closed github-actions[bot] closed 2 years ago

github-actions[bot] commented 2 years ago

write_pix( char* ) should never modify cursor position

Use an internal offset ( +user offset ) to place chars instead

https://github.com/connornishijima/Pixie_Chroma/blob/53296056cbd58874dbf103f998b0f856d540037e/src/pixie_chroma_internal.cpp#L744


    @param    x_pos    X pixel position of write **[optional]**
    @param    y_pos    Y pixel position of write **[optional]**
*///............................................................................
void PixieChroma::write_pix( char* message, int16_t x_offset, int16_t y_offset ){
    uint8_t len = strlen( message );
    for( uint8_t i = 0; i < len; i++ ){
        if( message[i] == '\n' ){ // Newline, force line break
            // TODO: write_pix( char* ) should never modify cursor position
            // Use an internal offset ( +user offset ) to place chars instead
            cursor_x =  display_padding_x;
            cursor_y += display_height;
        }
        else if( line_wrap == true && cursor_x >= ( display_width * chars_x ) ){ // End of line reached, wrap to new line if line_wrap enabled
            cursor_x =  display_padding_x;
            cursor_y += display_height;

            add_char(
                message[i],
                cursor_x + x_offset,
                cursor_y + y_offset
            );
            cursor_x += display_width;
        }
        else if( message[i] == 0 || message[i] == '\0' ){ // end of string
            return;
        }
        else{ // Normal
            add_char(
                message[i],
                cursor_x + x_offset,
                cursor_y + y_offset
            );
            cursor_x += display_width;
        }       
    }

b80daf9a86325d81ea4cfc81f1abac6dfc586df3

github-actions[bot] commented 2 years ago

Closed in eae2ce6d4a6d4209c50756221ff1db39bc5a7766