<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GFX library rotate and inverse text options?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68981/gfx-library-rotate-and-inverse-text-options</link><description>Any idea or example for easiest way to print rotated text (only particular text, not the whole display) and inverse text(only) foreground/background colors? 
 Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Dec 2020 14:54:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68981/gfx-library-rotate-and-inverse-text-options" /><item><title>RE: GFX library rotate and inverse text options?</title><link>https://devzone.nordicsemi.com/thread/283865?ContentTypeID=1</link><pubDate>Tue, 08 Dec 2020 14:54:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4bf6a42-55c6-4521-b6fa-facc76a4e7df</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am happy to hear that the converter worked fine for you, I haven&amp;#39;t tried it in a while &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;It is not critical which answer you select, mostly people select the&amp;nbsp;answer that wraps up the case (which would be mine from 4 days ago I guess).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GFX library rotate and inverse text options?</title><link>https://devzone.nordicsemi.com/thread/283693?ContentTypeID=1</link><pubDate>Tue, 08 Dec 2020 05:24:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7929805c-ba3e-433a-9528-266f848ae148</guid><dc:creator>samsam</dc:creator><description>&lt;p&gt;Thank you very much,&amp;nbsp; this online convertor works perfect (even without casting)&amp;nbsp; - the first so far that works almost &amp;quot;out of the box&amp;quot;, else there are plenty of such convertors for Arduino hobbyists, but the bytes order is swapped (little vs big endian)&amp;nbsp; so for simple example with couple colors is not big deal to change them in any text editor , but for real colorful picture will not work ;)&lt;/p&gt;
&lt;p&gt;Now I&amp;#39;m really confused which of your answers to select as &amp;quot;Verify answers&amp;quot; as all of them were quite useful?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GFX library rotate and inverse text options?</title><link>https://devzone.nordicsemi.com/thread/283251?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2020 08:15:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4db9a41-e941-4d5f-bede-db6d386e9a68</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
[quote user="samsam"]but don’t know why decide (based on scanty description maybe) that this function rotates everything incl. already drawn.[/quote]
&lt;p&gt;To be honest I thought the same, until I discovered that some of the library functions used the rotate functions to only rotate specific elements ;)&lt;/p&gt;
[quote user="samsam"]first will try another approach - with drawing a rectangle for background and then the text with original function and inversed color.[/quote]
&lt;p&gt;That sounds like a better way to do it, definitely&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
[quote user="samsam"]By the way – could you recommend some image convertor that has compatible output with your gfx library?[/quote]
&lt;p&gt;I investigated this some years back when asked the same question, and was able to find an online converter that worked OK.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Essentially you have to use&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://www.digole.com/tools/PicturetoC_Hex_converter.php"&gt;this online generator&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;to&amp;nbsp;load your image, set the &amp;quot;Used for&amp;quot; setting to&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;65K Color(2 bytes/pixel: RRRRRGGG GGGBBBBB, for &amp;quot;EDIM2&amp;quot;)&lt;/em&gt;, and click the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;&amp;quot;Get C String&amp;quot;&lt;/em&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;button.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then you can copy the C array from the&lt;em&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;Image data&lt;/em&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;box into your .c or .h file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that the array will be define as uint8, not uint16, so you will have to cast it back to uint16 before you pass it to the gfx library.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GFX library rotate and inverse text options?</title><link>https://devzone.nordicsemi.com/thread/282969?ContentTypeID=1</link><pubDate>Thu, 03 Dec 2020 02:32:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01fe3e73-e686-4bd4-b31a-5811b76c2841</guid><dc:creator>samsam</dc:creator><description>&lt;p&gt;Hi Torbj&amp;oslash;rn,&lt;/p&gt;
&lt;p&gt;Thanks for the solutions &amp;ndash; the rotation works &amp;ndash; my bad &amp;ndash; I should try it first before ask, but don&amp;rsquo;t know why decide (based on scanty description maybe) that this function rotates everything incl. already drawn.&lt;/p&gt;
&lt;p&gt;Didn&amp;rsquo;t try yet your solution for inverse print, but based on the speed that I monitor how slow the text is printed even with original function that draws only minimum pixels for the glyphs, first will try another approach - with drawing a rectangle for background and then the text with original function and inversed color.&lt;/p&gt;
&lt;p&gt;By the way &amp;ndash; could you recommend some image convertor that has compatible output with your gfx library?&lt;/p&gt;
&lt;p&gt;I tried all 3 from &lt;a href="https://www.14core.com/c-array-generator/"&gt;this link&lt;/a&gt;, but only the last one gives some reasonable result, but colors are awful&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/2639.svg" title="Frowning2"&gt;&amp;#x2639;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thank you and best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GFX library rotate and inverse text options?</title><link>https://devzone.nordicsemi.com/thread/282895?ContentTypeID=1</link><pubDate>Wed, 02 Dec 2020 13:44:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6478996-b55a-4389-8237-31509dbb8b63</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1) Regarding rotating text, can you try to run the nrf_gfx_rotation_set(..) function before and after the calls you want rotated?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I believe this will change the rotation of those prints only:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrf_gfx_rotation_set(p_lcd, NRF_LCD_ROTATE_90);

// Add your draw calls here

nrf_gfx_rotation_set(p_lcd, NRF_LCD_ROTATE_0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;2) Regarding printed inverted text, this is not supported out of the box, but it should be possible to support it by making some changes to the nrf_gfx.c file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you make the following changes in the write_character function I believe it should allow you to write inverted text:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void write_character(nrf_lcd_t const * p_instance,
                            nrf_gfx_font_desc_t const * p_font,
                            uint8_t character,
                            uint16_t * p_x,
                            uint16_t y,
                            uint16_t font_color)
{
    uint8_t char_idx = character - p_font-&amp;gt;startChar;
    uint16_t bytes_in_line = CEIL_DIV(p_font-&amp;gt;charInfo[char_idx].widthBits, 8);

    if (character == &amp;#39; &amp;#39;)
    {
        *p_x += p_font-&amp;gt;height / 2;
        return;
    }

    for (uint16_t i = 0; i &amp;lt; p_font-&amp;gt;height; i++)
    {
        for (uint16_t j = 0; j &amp;lt; bytes_in_line; j++)
        {
            for (uint8_t k = 0; k &amp;lt; 8; k++)
            {
                if ((1 &amp;lt;&amp;lt; (7 - k)) &amp;amp;
                    p_font-&amp;gt;data[p_font-&amp;gt;charInfo[char_idx].offset + i * bytes_in_line + j])
                {
                    pixel_draw(p_instance, *p_x + j * 8 + k, y + i, font_color);
                }
                // This code is added to handle inverted text
                else
                {
                    pixel_draw(p_instance, *p_x + j * 8 + k, y + i, inverted_color);
                }
                // End of modified segment
            }
        }
    }

    *p_x += p_font-&amp;gt;charInfo[char_idx].widthBits + p_font-&amp;gt;spacePixels;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please note that you either have to define the inverted_color value somewhere, or simply use the same font_color and remove the original non-inverted pixel_draw call.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>