<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=23&amp;t=11103&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2015-03-20T16:59:04+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=23&amp;t=11103&amp;mode</id>
<entry>
<author><name><![CDATA[Intre]]></name></author>
<updated>2015-03-20T16:59:04+01:00</updated>
<published>2015-03-20T16:59:04+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=124027#p124027</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=124027#p124027"/>
<title type="html"><![CDATA[Re: INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=124027#p124027"><![CDATA[
OdeOn Jak najbardziej: <br /><br />np. w Botland<br /><br /><a href="http://botland.com.pl/wyswietlacze-graficzne/2666-wyswietlacz-dotykowy-tft-lcd-35-320-x-480-z-czytnikiem-microsd.html"  class="postlink">http://botland.com.pl/wyswietlacze-graficzne/2666-wyswietlacz-dotykowy-tft-lcd-35-320-x-480-z-czytnikiem-microsd.html</a><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1356">Intre</a> — 20 mar 2015, o 16:59</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[OdeOn]]></name></author>
<updated>2015-03-20T14:32:20+01:00</updated>
<published>2015-03-20T14:32:20+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=124014#p124014</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=124014#p124014"/>
<title type="html"><![CDATA[Re: INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=124014#p124014"><![CDATA[
taki wyświetlacz do kupienia w Polsce?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1407">OdeOn</a> — 20 mar 2015, o 14:32</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Intre]]></name></author>
<updated>2015-03-19T21:25:28+01:00</updated>
<published>2015-03-19T21:25:28+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123958#p123958</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123958#p123958"/>
<title type="html"><![CDATA[Re: INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123958#p123958"><![CDATA[
<div class="quotetitle">majster napisał(a):</div><div class="quotecontent"><br />Biblioteka piękna tylko czy rysowanie nie migło by być z bufora aby każdy piksel zapalił się w tym samym momencie?<br /></div><br /><br />480 * 320 * 2 = 30 7200 <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1356">Intre</a> — 19 mar 2015, o 21:25</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[majster]]></name></author>
<updated>2015-03-19T20:52:05+01:00</updated>
<published>2015-03-19T20:52:05+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123949#p123949</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123949#p123949"/>
<title type="html"><![CDATA[Re: INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123949#p123949"><![CDATA[
Już rano widziałem lecz nie mogłem pisać.<br /><br />Biblioteka piękna tylko czy rysowanie nie migło by być z bufora aby każdy piksel zapalił się w tym samym momencie? <br /><br />Namazane ze smarta.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1628">majster</a> — 19 mar 2015, o 20:52</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[siddawid]]></name></author>
<updated>2015-03-19T11:07:25+01:00</updated>
<published>2015-03-19T11:07:25+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123902#p123902</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123902#p123902"/>
<title type="html"><![CDATA[Re: INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123902#p123902"><![CDATA[
Biedna Atmega się tam poci i daje resztki sił  <img src="https://forum.atnel.pl/images/smilies/icon_e_biggrin.gif" alt=":D" title="Bardzo szczęśliwy" /> A tak na serio KAWAŁEK DOBREGO KODU !<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2604">siddawid</a> — 19 mar 2015, o 11:07</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Grzechu]]></name></author>
<updated>2015-03-19T09:34:23+01:00</updated>
<published>2015-03-19T09:34:23+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123898#p123898</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123898#p123898"/>
<title type="html"><![CDATA[Re: INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123898#p123898"><![CDATA[
<img src="https://forum.atnel.pl/images/smilies/icon_eek.gif" alt=":shock:" title="Zaszokowany" /> Takie efekty na 8-bitowcu?! WOOOWWWW...  <img src="https://forum.atnel.pl/images/smilies/icon_e_surprised.gif" alt=":o" title="Zdziwiony" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=5164">Grzechu</a> — 19 mar 2015, o 09:34</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[anshar]]></name></author>
<updated>2015-03-19T01:37:47+01:00</updated>
<published>2015-03-19T01:37:47+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123884#p123884</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123884#p123884"/>
<title type="html"><![CDATA[Re: INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123884#p123884"><![CDATA[
Super projekt! No to i ja jeszcze dodam, że KAWAŁ DOBREJ ROBOTY <img src="https://forum.atnel.pl/images/smilies/icon_e_biggrin.gif" alt=":D" title="Bardzo szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=7157">anshar</a> — 19 mar 2015, o 01:37</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Intre]]></name></author>
<updated>2015-03-19T01:27:01+01:00</updated>
<published>2015-03-19T01:27:01+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123882#p123882</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123882#p123882"/>
<title type="html"><![CDATA[Re: INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123882#p123882"><![CDATA[
Dambo polecam naprawdę fajnie świeci <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> Sam mam już wizję zrobienia takiej sobie stacji pogodowej jak opanuje inne rozpoczęte projekty.<br /><br /><br /> Mirku dziękuje zmiany w bibliotece naniesione, przetestowane, teraz działa ta funkcja super <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1356">Intre</a> — 19 mar 2015, o 01:27</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2015-03-19T01:06:59+01:00</updated>
<published>2015-03-19T01:06:59+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123880#p123880</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123880#p123880"/>
<title type="html"><![CDATA[Re: INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123880#p123880"><![CDATA[
nie wyświetla ci poprawnie znaków z pamięci Flash bo masz babola:<br /><br />[syntax=c]register char c;<br />        while (*str ) {<br />                c = pgm_read_byte (str++);[/syntax]<br /><br />pętla while próbuje sprawdzać zawartość wskaźnika w pamięci RAM a nie FLASH - więc leci na wariata po całym RAMie aż natrafi na zero a wyświetla znaki czytane z Flash w kolejnej linii <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><br /><br />zrób tak:<br /><br />[syntax=c]register char c;<br />        while ( (c = pgm_read_byte (str++))  ) {[/syntax]<br /><br />Oczywiście jak to mówią KAWAŁ DOBREJ ROBOTY <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><br />                <br /><br />i powinno być ok <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 19 mar 2015, o 01:06</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Intre]]></name></author>
<updated>2015-03-19T01:30:11+01:00</updated>
<published>2015-03-18T23:59:58+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123878#p123878</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123878#p123878"/>
<title type="html"><![CDATA[INTRE 3,5&quot; 480 x 320 TFT LCD HX8357D SPI Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11103&amp;p=123878#p123878"><![CDATA[
Chciałby zaprezentować wstępną bibliotekę po &quot;SPI&quot; do wyświetlacza 3,5&quot; 480 x 320 TFT LCD opartego o sterownik HX8357D firmy Adafruit <a href="https://www.adafruit.com/product/2050"  class="postlink">https://www.adafruit.com/product/2050</a> napisaną przeze mnie na podstawie oryginalnej biblioteki od firmy Adafruit dla Arduino oraz doświadczeń zdobytych podczas nauk Mirka dotyczących wyświetlaczy OLED oraz tzw. Green Booka.<br /><br />Myślę że na początek film z jej pracy na wyświetlaczu, na żywo wygląda to zdecydowanie lepiej niestety kamera, którą posiadam nie oddaje &quot;ładności&quot; świecenia jego jednakże bardziej mam na celu pokazanie pracy i możliwości funkcji jakie posiada biblioteka. <br /><br /><div style="width: 583px; height: 471px; margin: 0 auto; padding-left: 26px; padding-top: 48px; background: url('https://www.atnel.pl/download/atnel_tv.png') no-repeat;"> <strong>iframe</strong> </div><br /><br />A teraz kod <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> Myślę że za specjalnie nie ma co go komentować osobno, albo raczej mi się tak wydaję bo starałem się napisać ją czytelnie i w miarę zrozumiale dodając stosowne komentarze.<br />Nie będę może zupełnie całego programu testowego publikować na stronie ale dodam go całego spakowanego na końcu tematu jako załącznik do obejrzenia i ewentualnych własnych testów jak ktoś w/w wyświetlacz nabędzie.<br /><br />main.c<br />[syntax=c]/*<br /> * main.c<br /> *<br /> *  Created on: 17-03-2015<br /> *      Author: Intre<br /> *<br /> *  Biblioteka i program testowy dla wyświetlacza: Adafruit 3,5&quot; 480 x 320 TFT LCD Breakout Board<br /> *  https://www.adafruit.com/product/2050<br /> *<br /> * Napisana na podstawie oryginalnej biblioteki do w/w wyświetlacza Adafruit<br /> * i doświadczeń nabytych podczas nauki pisania biblioteki do wyświetlacza OLED:<br /> * http://mirekk36.blogspot.com/2014/08/wyswietlacz-oled-c-library-part-01a.html<br /> * https://www.youtube.com/watch?v=IDhnhCp61Ao<br /> * oraz książki JĘZYK C PASJA PROGRAMOWANIA MIKROKONTROLERÓW 8-BITOWYCH<br /> * https://www.sklep.atnel.pl/pl/p/Jezyk-C-Pasja-programowania-mikrokontrolerow-8-bitowych-Wydanie-II-Ksiazka-DVD/104<br /> *      thx mirekk36 :)<br /> *<br /> *      licencja darmowa i jeśli ktoś chce z niej korzystać to proszę zamieszczać w/w preambułe oraz Copyright (c) 2013 Adafruit Industries.<br /> *<br /> *      sterownik: HX8357D<br /> *      komunikacja: SPI<br /> *<br /> */<br /><br /><br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br />#include &quot;INTRE_HX8357D/hx8357D.h&quot;<br />#include &quot;BITMAPS/bitmaps.h&quot;<br />#include &quot;TIMERS/timers.h&quot;<br />#include &quot;INTRE_DEMO/intre_demo.h&quot;<br /><br /><br />int main(void) {<br /><br />//inicjalizacja Timer 2<br />timer2_init();<br /><br />//ustawienie wyświetlanego czasu<br />set_higrometer_time (17,59);<br /><br />//inicjalizacja wyświetlacza, rotacja 0-3<br />hx8357d_init (3);<br /><br />//prezentacja różnych możliwości biblioteki na TFT LCD<br />intre_HX8357D_library_demo ();<br /><br />//inicjalizacja dema Higrometru<br />hx8357d_cls(black);<br />higrometer_colors (0);<br />higrometer_scheme ();<br /><br />//włączenie przerwań<br />sei();<br /><br />while(1) {<br /><br />intre_higrometer_demo ();<br />}<br /><br />}[/syntax]<br /><br />hx8357D.h<br />[syntax=c]/*<br /> * hx8357D.h<br /> *<br /> *  Created on: 16-03-2015<br /> *      Author: Intre<br /> */<br /><br />#ifndef HX8357D_H_<br />#define HX8357D_H_<br /><br /><br />// ### definicje stałych preprocesora ###<br /><br />// hardware SPI<br />#define CLK PB7<br />#define MISO PB6<br />#define MOSI PB5<br />#define CS (1&lt;&lt;PB4)<br />#define DC (1&lt;&lt;PB3)<br /><br />//definicje portów pinów<br />#define CLK_PORT  PORTB<br />#define CLK_DDRDDRB<br /><br />#define CS_PORT  PORTB<br />#define CS_DDRDDRB<br /><br />#define DC_PORT  PORTB<br />#define DC_DDRDDRB<br /><br />// zmiana stanów pinów LOW/HI<br />#define CLK_LOWCLK_PORT &amp;= ~CLK<br />#define CLK_HI CLK_PORT |= CLK<br /><br />#define CS_LOW CS_PORT &amp;= ~CS<br />#define CS_HI CS_PORT |= CS<br /><br />#define DC_LOW DC_PORT &amp;= ~DC<br />#define DC_HI DC_PORT |= DC<br /><br />// komendy dla sterownika HX8357D<br />#define HX8357D 0xD<br />#define HX8357B 0xB<br /><br />#define HX8357_TFTWIDTH  320<br />#define HX8357_TFTHEIGHT 480<br /><br />#define HX8357_NOP     0x00<br />#define HX8357_SWRESET 0x01<br />#define HX8357_RDDID   0x04<br />#define HX8357_RDDST   0x09<br /><br />#define HX8357_RDPOWMODE  0x0A<br />#define HX8357_RDMADCTL  0x0B<br />#define HX8357_RDCOLMOD  0x0C<br />#define HX8357_RDDIM  0x0D<br />#define HX8357_RDDSDR  0x0F<br /><br />#define HX8357_SLPIN   0x10<br />#define HX8357_SLPOUT  0x11<br />#define HX8357B_PTLON   0x12<br />#define HX8357B_NORON   0x13<br /><br />#define HX8357_INVOFF  0x20<br />#define HX8357_INVON   0x21<br />#define HX8357_DISPOFF 0x28<br />#define HX8357_DISPON  0x29<br /><br />#define HX8357_CASET   0x2A<br />#define HX8357_PASET   0x2B<br />#define HX8357_RAMWR   0x2C<br />#define HX8357_RAMRD   0x2E<br /><br />#define HX8357B_PTLAR   0x30<br />#define HX8357_TEON  0x35<br />#define HX8357_TEARLINE  0x44<br />#define HX8357_MADCTL  0x36<br />#define HX8357_COLMOD  0x3A<br /><br />#define HX8357_SETOSC 0xB0<br />#define HX8357_SETPWR1 0xB1<br />#define HX8357B_SETDISPLAY 0xB2<br />#define HX8357_SETRGB 0xB3<br />#define HX8357D_SETCOM  0xB6<br /><br />#define HX8357B_SETDISPMODE  0xB4<br />#define HX8357D_SETCYC  0xB4<br />#define HX8357B_SETOTP 0xB7<br />#define HX8357D_SETC 0xB9<br /><br />#define HX8357B_SET_PANEL_DRIVING 0xC0<br />#define HX8357D_SETSTBA 0xC0<br />#define HX8357B_SETDGC  0xC1<br />#define HX8357B_SETID  0xC3<br />#define HX8357B_SETDDB  0xC4<br />#define HX8357B_SETDISPLAYFRAME 0xC5<br />#define HX8357B_GAMMASET 0xC8<br />#define HX8357B_SETCABC  0xC9<br />#define HX8357_SETPANEL  0xCC<br /><br />#define HX8357B_SETPOWER 0xD0<br />#define HX8357B_SETVCOM 0xD1<br />#define HX8357B_SETPWRNORMAL 0xD2<br /><br />#define HX8357B_RDID1   0xDA<br />#define HX8357B_RDID2   0xDB<br />#define HX8357B_RDID3   0xDC<br />#define HX8357B_RDID4   0xDD<br /><br />#define HX8357D_SETGAMMA 0xE0<br /><br />#define HX8357B_SETGAMMA 0xC8<br />#define HX8357B_SETPANELRELATED  0xE9<br /><br />//kolory<br />#define black           0x0000<br />#define navy            0x000F<br />#define dark_green      0x03E0<br />#define dark_cyan       0x03EF<br />#define maroon          0x7800<br />#define purple          0x780F<br />#define olive           0x7BE0<br />#define light_grey      0xC618<br />#define dark_grey       0x7BEF<br />#define blue            0x001F<br />#define green           0x07E0<br />#define cyan            0x07FF<br />#define red             0xF800<br />#define magenta         0xF81F<br />#define yellow          0xFFE0<br />#define white           0xFFFF<br />#define orange          0xFD20<br />#define green_yellow    0xAFE5<br />#define brown           0x79E0<br /><br />//definicje kierunków<br />#define MADCTL_MY  0x80<br />#define MADCTL_MX  0x40<br />#define MADCTL_MV  0x20<br />#define MADCTL_ML  0x10<br />#define MADCTL_RGB 0x00<br />#define MADCTL_BGR 0x08<br />#define MADCTL_MH  0x04<br /><br />//definicje pomocnicze<br />#define swap(a, b) { int16_t t = a; a = b; b = t; }<br /><br />//deklaracje zmiennych<br />uint16_t _width, _height;<br />extern const uint8_t font&#91;&#93;;<br />extern int crsor_x, cursor_y;<br /><br />// ### deklaracje funkcji ###<br /><br />//funkcje sprzętowe<br />void hx8357d_init_spi(void); //<br />void spi_send( uint8_t bajt ); //<br />void hx8357d_command( uint8_t cmd );//<br />void hx8357d_data( uint8_t dat );//<br />void hx8357d_init (uint8_t rot);//<br />void hx8357d_setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);<br />void hx8357d_cls(uint16_t color); //całyekran kolor<br />void hx8357d_setRotation(uint8_t rotation);<br />uint16_t hx8357d_color565(uint8_t r, uint8_t g, uint8_t b);<br />void hx8357d_pushColor(uint16_t color);<br /><br />//funkcje graficzne<br />void hx8357d_drawPixel(int16_t x, int16_t y, uint16_t color); //podstawowa funkcja zapalająca pixel<br />void hx8357d_drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); //linia pion<br />void hx8357d_drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); //linia poziom<br />void hx8357d_drawLine( int x0, int y0, int x1, int y1, uint16_t color); //linia<br />void hx8357d_drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); //kółko puste<br />void hx8357d_drawCircleHelper( int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);<br />void hx8357d_fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);<br />void hx8357d_fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); // kółko wypełnione<br />void hx8357d_drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); // prostokąt pusty<br />void hx8357d_fillRect(int16_t x, int16_t y, int16_t w, int16_t h,  uint16_t color); //prostokąt wypełniony<br />void hx8357d_drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color); // prostokąt zaokrąglony pusty<br />void hx8357d_fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color); // prostokąt zaokrąglony pełny<br />void hx8357d_drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); // trójkąt pusty<br />void hx8357d_fillTriangle ( int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); //trójkąt wypełniony<br /><br />// % bar<br />void hx8357d_ProgressBar( uint16_t x_begin, uint16_t y, uint8_t h, uint8_t procent, uint8_t x_end, uint16_t color);<br /><br />//funcje wyświetlające napisy i zmienne<br />void hx8357d_drawChar(int x, int y, unsigned char c, uint16_t color, uint16_t bg_color, uint8_t size);<br />void hx8357d_puts (int x, int y, char * str, uint8_t txt_size, uint16_t color, uint16_t bg_color);<br />void hx8357d_puts_P (int x, int y, const char * str, uint8_t txt_size, uint16_t color, uint16_t bg_color);<br />void hx8357d_put_int (int x, int y, int data, uint8_t txt_size, uint16_t color, uint16_t bg_color);<br /><br />//wyświetlanie Bitmap z pamięci Flash<br />void hx8357d_drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);<br />void hx8357d_drawBitmap_bg_color(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg_color);<br />void hx8357d_drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);<br /><br />#endif /* HX8357D_H_ */[/syntax]<br /><br />hx8357D.c<br />[syntax=c]/*<br /> * hx8357D.c<br /> *<br /> *  Created on: 16-03-2015<br /> *      Author: Intre<br /> */<br /><br />/***************************************************<br />  This is our library for the Adafruit HX8357D Breakout<br />  ----&gt; http://www.adafruit.com/products/2050<br /><br />  Check out the links above for our tutorials and wiring diagrams<br />  These displays use SPI to communicate, 4 or 5 pins are required to<br />  interface (RST is optional)<br />  Adafruit invests time and resources providing this open source code,<br />  please support Adafruit and open-source hardware by purchasing<br />  products from Adafruit!<br /><br />  Written by Limor Fried/Ladyada for Adafruit Industries.<br />  MIT license, all text above must be included in any redistribution<br /> ****************************************************/<br /><br />#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br /><br />#include &quot;hx8357D.h&quot;<br /><br />//deklaracje zmiennych<br />uint16_t _width, _height;<br /><br />void hx8357d_init_spi(void) {<br /><br />DC_DDR |= DC;<br />DC_PORT |= DC;<br />DC_LOW;<br /><br />CS_DDR |= CS;<br />CS_PORT |= CS;<br />CS_LOW;<br /><br />DDRB |= (1&lt;&lt;MOSI)|(1&lt;&lt;CLK);<br />PORTB |= (1&lt;&lt;MISO);<br />SPCR |= (1&lt;&lt;SPE)|(1&lt;&lt;MSTR);  // aktywacja  SPI, tryb pracy Master,<br />SPSR |= (1&lt;&lt;SPI2X);  //prędkość zegara Fosc/2<br />}<br /><br />// wysłanie bitu po SPI<br />void spi_send( uint8_t bajt ) {<br />SPDR = bajt;<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />}<br /><br />// wysłanie komendy<br />void hx8357d_command( uint8_t cmd ) {<br />DC_LOW;<br />CLK_LOW;<br />CS_LOW;<br />spi_send(cmd);<br />CS_HI;<br />}<br /><br />//wysładnie danych<br />void hx8357d_data( uint8_t dat ) {<br />DC_HI;<br />CLK_LOW;<br />CS_LOW;<br />spi_send (dat);<br />CS_HI;<br />}<br /><br />// inicjalizacja sterownika HX8357D<br />void hx8357d_init (uint8_t rot) {<br /><br />hx8357d_init_spi();<br />spi_send(0);<br />_delay_ms(200);<br /><br /><br />    hx8357d_command(HX8357_SWRESET);<br /><br />    // setextc<br />    hx8357d_command(HX8357D_SETC);<br />    hx8357d_data(0xFF);<br />    hx8357d_data(0x83);<br />    hx8357d_data(0x57);<br /><br />    _delay_ms(300);<br /><br />    // setRGB which also enables SDO<br />    hx8357d_command(HX8357_SETRGB);<br />    hx8357d_data(0x80);  //enable SDO pin!<br />    // hx8357d_data(0x00);  //disable SDO pin!<br />    hx8357d_data(0x0);<br />    hx8357d_data(0x06);<br />    hx8357d_data(0x06);<br /><br />    hx8357d_command(HX8357D_SETCOM);<br />    hx8357d_data(0x25);  // -1.52V<br /><br />    hx8357d_command(HX8357_SETOSC);<br />    hx8357d_data(0x68);  // Normal mode 70Hz, Idle mode 55 Hz<br /><br />    hx8357d_command(HX8357_SETPANEL); //Set Panel<br />    hx8357d_data(0x05);  // BGR, Gate direction swapped<br /><br />    hx8357d_command(HX8357_SETPWR1);<br />    hx8357d_data(0x00);  // Not deep standby<br />    hx8357d_data(0x15);  //BT<br />    hx8357d_data(0x1C);  //VSPR<br />    hx8357d_data(0x1C);  //VSNR<br />    hx8357d_data(0x83);  //AP<br />    hx8357d_data(0xAA);  //FS<br /><br />    hx8357d_command(HX8357D_SETSTBA);<br />    hx8357d_data(0x50);  //OPON normal<br />    hx8357d_data(0x50);  //OPON idle<br />    hx8357d_data(0x01);  //STBA<br />    hx8357d_data(0x3C);  //STBA<br />    hx8357d_data(0x1E);  //STBA<br />    hx8357d_data(0x08);  //GEN<br /><br />    hx8357d_command(HX8357D_SETCYC);<br />    hx8357d_data(0x02);  //NW 0x02<br />    hx8357d_data(0x40);  //RTN<br />    hx8357d_data(0x00);  //DIV<br />    hx8357d_data(0x2A);  //DUM<br />    hx8357d_data(0x2A);  //DUM<br />    hx8357d_data(0x0D);  //GDON<br />    hx8357d_data(0x78);  //GDOFF<br /><br />    hx8357d_command(HX8357D_SETGAMMA);<br />    hx8357d_data(0x02);<br />    hx8357d_data(0x0A);<br />    hx8357d_data(0x11);<br />    hx8357d_data(0x1d);<br />    hx8357d_data(0x23);<br />    hx8357d_data(0x35);<br />    hx8357d_data(0x41);<br />    hx8357d_data(0x4b);<br />    hx8357d_data(0x4b);<br />    hx8357d_data(0x42);<br />    hx8357d_data(0x3A);<br />    hx8357d_data(0x27);<br />    hx8357d_data(0x1B);<br />    hx8357d_data(0x08);<br />    hx8357d_data(0x09);<br />    hx8357d_data(0x03);<br />    hx8357d_data(0x02);<br />    hx8357d_data(0x0A);<br />    hx8357d_data(0x11);<br />    hx8357d_data(0x1d);<br />    hx8357d_data(0x23);<br />    hx8357d_data(0x35);<br />    hx8357d_data(0x41);<br />    hx8357d_data(0x4b);<br />    hx8357d_data(0x4b);<br />    hx8357d_data(0x42);<br />    hx8357d_data(0x3A);<br />    hx8357d_data(0x27);<br />    hx8357d_data(0x1B);<br />    hx8357d_data(0x08);<br />    hx8357d_data(0x09);<br />    hx8357d_data(0x03);<br />    hx8357d_data(0x00);<br />    hx8357d_data(0x01);<br /><br />    hx8357d_command(HX8357_COLMOD);<br />    hx8357d_data(0x55);  // 16 bit<br /><br />    hx8357d_command(HX8357_MADCTL);<br />    hx8357d_data(0xC0);<br /><br />    hx8357d_command(HX8357_TEON);  // TE off<br />    hx8357d_data(0x00);<br /><br />    hx8357d_command(HX8357_TEARLINE);  // tear line<br />    hx8357d_data(0x00);<br />    hx8357d_data(0x02);<br /><br />    hx8357d_command(HX8357_SLPOUT); //Exit Sleep<br />    _delay_ms(150);<br /><br />    hx8357d_command(HX8357_DISPON);  // display on<br />    _delay_ms(150);<br /><br />    hx8357d_setRotation(rot);<br />    _delay_ms(25);<br /><br />    hx8357d_cls(black);<br />    _delay_ms(25);<br /><br />}<br /><br />void hx8357d_setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {<br /><br />  hx8357d_command(HX8357_CASET); // Column addr set<br />  hx8357d_data(x0 &gt;&gt; 8);<br />  hx8357d_data(x0 &amp; 0xFF);     // XSTART<br />  hx8357d_data(x1 &gt;&gt; 8);<br />  hx8357d_data(x1 &amp; 0xFF);     // XEND<br /><br />  hx8357d_command(HX8357_PASET); // Row addr set<br />  hx8357d_data(y0&gt;&gt;8);<br />  hx8357d_data(y0);     // YSTART<br />  hx8357d_data(y1&gt;&gt;8);<br />  hx8357d_data(y1);     // YEND<br /><br />  hx8357d_command(HX8357_RAMWR); // write to RAM<br />}<br /><br />// obrót ekranu 0-3<br />void hx8357d_setRotation(uint8_t rotation) {<br /><br />  hx8357d_command(HX8357_MADCTL);<br /><br />  if (rotation &gt;=3 ) rotation=3;   // can't be higher than 3<br />  switch (rotation) {<br />   case 0:<br />     hx8357d_data(MADCTL_MX | MADCTL_MY | MADCTL_RGB);<br />     _width  = HX8357_TFTWIDTH;<br />     _height = HX8357_TFTHEIGHT;<br />     break;<br />   case 1:<br />     hx8357d_data(MADCTL_MV | MADCTL_MY | MADCTL_RGB);<br />     _width  = HX8357_TFTHEIGHT;<br />     _height = HX8357_TFTWIDTH;<br />     break;<br />  case 2:<br />    hx8357d_data( MADCTL_RGB);<br />     _width  = HX8357_TFTWIDTH;<br />     _height = HX8357_TFTHEIGHT;<br />    break;<br />   case 3:<br />     hx8357d_data(MADCTL_MX | MADCTL_MV | MADCTL_RGB);<br />     _width  = HX8357_TFTHEIGHT;<br />     _height = HX8357_TFTWIDTH;<br />     break;<br />  }<br />}<br /><br />// fill a rectangle<br />void  hx8357d_fillRect(int16_t x, int16_t y, int16_t w, int16_t h,  uint16_t color) {<br /><br />  // rudimentary clipping (drawChar w/big text requires this)<br />  if((x &gt;= _width) || (y &gt;= _height)) return;<br />  if((x + w - 1) &gt;= _width)  w = _width  - x;<br />  if((y + h - 1) &gt;= _height) h = _height - y;<br /><br />  hx8357d_setAddrWindow (x, y, x+w-1, y+h-1);<br /><br />  uint8_t hi = color &gt;&gt; 8, lo = color;<br /><br />  DC_HI;<br />  CS_LOW;<br /><br />  for(y=h; y&gt;0; y--) {<br />    for(x=w; x&gt;0; x--) {<br />      spi_send(hi);<br />      spi_send(lo);<br />    }<br />  }<br />  CS_HI;<br />}<br /><br />//czyszczenie ekranu kolorem<br />void hx8357d_cls(uint16_t color) {<br />hx8357d_fillRect(0, 0, _width, _height, color);<br />}<br /><br />// Pass 8-bit (each) R,G,B, get back 16-bit packed color<br />uint16_t hx8357d_color565(uint8_t r, uint8_t g, uint8_t b) {<br />  return ((r &amp; 0xF8) &lt;&lt; 8) | ((g &amp; 0xFC) &lt;&lt; 3) | (b &gt;&gt; 3);<br />}<br /><br /><br />void hx8357d_pushColor(uint16_t color) {<br /><br />  DC_HI;<br />  CS_LOW;<br /><br />  spi_send(color &gt;&gt; 8);<br />  spi_send(color);<br /><br />  CS_HI;<br />}[/syntax]<br /><br />hx8357D_graphic.c<br />[syntax=c]/*<br /> * hx8357D_graphic.c<br /> *<br /> *  Created on: 16-03-2015<br /> *      Author: Intre<br /> */<br /><br />/*<br />This is the core graphics library for all our displays, providing a common<br />set of graphics primitives (points, lines, circles, etc.).  It needs to be<br />paired with a hardware-specific library for each display device we carry<br />(to handle the lower-level functions).<br /><br />Adafruit invests time and resources providing this open source code, please<br />support Adafruit &amp; open-source hardware by purchasing products from Adafruit!<br /><br />Copyright (c) 2013 Adafruit Industries.  All rights reserved.<br /><br />Redistribution and use in source and binary forms, with or without<br />modification, are permitted provided that the following conditions are met:<br /><br />- Redistributions of source code must retain the above copyright notice,<br />  this list of conditions and the following disclaimer.<br />- Redistributions in binary form must reproduce the above copyright notice,<br />  this list of conditions and the following disclaimer in the documentation<br />  and/or other materials provided with the distribution.<br /><br />THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;<br />AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br />IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br />ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE<br />LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br />CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br />SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br />INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br />CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br />ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br />POSSIBILITY OF SUCH DAMAGE.<br />*/<br /><br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;stdlib.h&gt;<br /><br />#include &quot;hx8357D.h&quot;<br /><br />int cursor_x, cursor_y;<br /><br />void hx8357d_drawPixel(int16_t x, int16_t y, uint16_t color) {<br /><br />  if((x &lt; 0) ||(x &gt;= _width) || (y &lt; 0) || (y &gt;= _height)) return;<br /><br />  hx8357d_setAddrWindow(x,y,x+1,y+1);<br />  DC_HI;<br />  CS_LOW;<br />  spi_send(color &gt;&gt; 8);<br />  spi_send(color);<br />  CS_HI;<br />}<br /><br />void hx8357d_drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) {<br /><br />  if((x &gt;= _width) || (y &gt;= _height)) return;<br /><br />  if((y+h-1) &gt;= _height)<br />    h = _height-y;<br /><br />  hx8357d_setAddrWindow(x, y, x, y+h-1);<br /><br />  uint8_t hi = color &gt;&gt; 8, lo = color;<br /><br />  DC_HI;<br />  CS_LOW;<br /><br />  while (h--) {<br />    spi_send(hi);<br />    spi_send(lo);<br />  }<br />  CS_HI;<br />}<br /><br />void hx8357d_drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) {<br /><br />  if((x &gt;= _width) || (y &gt;= _height)) return;<br />  if((x+w-1) &gt;= _width)  w = _width-x;<br />  hx8357d_setAddrWindow(x, y, x+w-1, y);<br /><br />  uint8_t hi = color &gt;&gt; 8, lo = color;<br />  DC_HI;<br />  CS_LOW;<br /><br />  while (w--) {<br />    spi_send(hi);<br />    spi_send(lo);<br />  }<br />  CS_HI;<br />}<br /><br />// Bresanham's algorithm - thx wikipedia<br />void hx8357d_drawLine( int x0, int y0, int x1, int y1, uint16_t color) {<br />int steep = abs(y1 - y0) &gt; abs(x1 - x0);<br />if (steep) {<br />swap(x0, y0);<br />swap(x1, y1);<br />}<br /><br />if (x0 &gt; x1) {<br />swap(x0, x1);<br />swap(y0, y1);<br />}<br /><br />int dx, dy;<br />dx = x1 - x0;<br />dy = abs(y1 - y0);<br /><br />int err = dx / 2;<br />int ystep;<br /><br />if (y0 &lt; y1) {<br />ystep = 1;<br />} else {<br />ystep = -1;<br />}<br /><br />for (; x0 &lt;= x1; x0++) {<br />if (steep) {<br />hx8357d_drawPixel(y0, x0, color);<br />} else {<br />hx8357d_drawPixel(x0, y0, color);<br />}<br />err -= dy;<br />if (err &lt; 0) {<br />y0 += ystep;<br />err += dx;<br />}<br />}<br />}<br /><br /><br />// Draw a circle outline<br />void hx8357d_drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color) {<br />  int16_t f = 1 - r;<br />  int16_t ddF_x = 1;<br />  int16_t ddF_y = -2 * r;<br />  int16_t x = 0;<br />  int16_t y = r;<br /><br />  hx8357d_drawPixel(x0  , y0+r, color);<br />  hx8357d_drawPixel(x0  , y0-r, color);<br />  hx8357d_drawPixel(x0+r, y0  , color);<br />  hx8357d_drawPixel(x0-r, y0  , color);<br /><br />  while (x&lt;y) {<br />    if (f &gt;= 0) {<br />      y--;<br />      ddF_y += 2;<br />      f += ddF_y;<br />    }<br />    x++;<br />    ddF_x += 2;<br />    f += ddF_x;<br /><br />    hx8357d_drawPixel(x0 + x, y0 + y, color);<br />    hx8357d_drawPixel(x0 - x, y0 + y, color);<br />    hx8357d_drawPixel(x0 + x, y0 - y, color);<br />    hx8357d_drawPixel(x0 - x, y0 - y, color);<br />    hx8357d_drawPixel(x0 + y, y0 + x, color);<br />    hx8357d_drawPixel(x0 - y, y0 + x, color);<br />    hx8357d_drawPixel(x0 + y, y0 - x, color);<br />    hx8357d_drawPixel(x0 - y, y0 - x, color);<br />  }<br />}<br /><br />void hx8357d_drawCircleHelper( int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color) {<br />  int16_t f     = 1 - r;<br />  int16_t ddF_x = 1;<br />  int16_t ddF_y = -2 * r;<br />  int16_t x     = 0;<br />  int16_t y     = r;<br /><br />  while (x&lt;y) {<br />    if (f &gt;= 0) {<br />      y--;<br />      ddF_y += 2;<br />      f     += ddF_y;<br />    }<br />    x++;<br />    ddF_x += 2;<br />    f     += ddF_x;<br />    if (cornername &amp; 0x4) {<br />      hx8357d_drawPixel(x0 + x, y0 + y, color);<br />      hx8357d_drawPixel(x0 + y, y0 + x, color);<br />    }<br />    if (cornername &amp; 0x2) {<br />      hx8357d_drawPixel(x0 + x, y0 - y, color);<br />      hx8357d_drawPixel(x0 + y, y0 - x, color);<br />    }<br />    if (cornername &amp; 0x8) {<br />      hx8357d_drawPixel(x0 - y, y0 + x, color);<br />      hx8357d_drawPixel(x0 - x, y0 + y, color);<br />    }<br />    if (cornername &amp; 0x1) {<br />      hx8357d_drawPixel(x0 - y, y0 - x, color);<br />      hx8357d_drawPixel(x0 - x, y0 - y, color);<br />    }<br />  }<br />}<br /><br /><br /><br />void hx8357d_fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color) {<br />hx8357d_drawFastVLine(x0, y0-r, 2*r+1, color);<br />hx8357d_fillCircleHelper(x0, y0, r, 3, 0, color);<br />}<br /><br /><br />// Used to do circles and roundrects<br />void hx8357d_fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color) {<br /><br />  int16_t f     = 1 - r;<br />  int16_t ddF_x = 1;<br />  int16_t ddF_y = -2 * r;<br />  int16_t x     = 0;<br />  int16_t y     = r;<br /><br />  while (x&lt;y) {<br />    if (f &gt;= 0) {<br />      y--;<br />      ddF_y += 2;<br />      f     += ddF_y;<br />    }<br />    x++;<br />    ddF_x += 2;<br />    f     += ddF_x;<br /><br />    if (cornername &amp; 0x1) {<br />    hx8357d_drawFastVLine(x0+x, y0-y, 2*y+1+delta, color);<br />    hx8357d_drawFastVLine(x0+y, y0-x, 2*x+1+delta, color);<br />    }<br />    if (cornername &amp; 0x2) {<br />    hx8357d_drawFastVLine(x0-x, y0-y, 2*y+1+delta, color);<br />    hx8357d_drawFastVLine(x0-y, y0-x, 2*x+1+delta, color);<br />    }<br />  }<br />}<br /><br />// Draw a rectangle<br />void hx8357d_drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) {<br />hx8357d_drawFastHLine(x, y, w, color);<br />hx8357d_drawFastHLine(x, y+h-1, w, color);<br />hx8357d_drawFastVLine(x, y, h, color);<br />hx8357d_drawFastVLine(x+w-1, y, h, color);<br />}<br /><br />// Draw a rounded rectangle<br />void hx8357d_drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color) {<br />  // smarter version<br />  hx8357d_drawFastHLine(x+r  , y    , w-2*r, color); // Top<br />  hx8357d_drawFastHLine(x+r  , y+h-1, w-2*r, color); // Bottom<br />  hx8357d_drawFastVLine(x    , y+r  , h-2*r, color); // Left<br />  hx8357d_drawFastVLine(x+w-1, y+r  , h-2*r, color); // Right<br />  // draw four corners<br />  hx8357d_drawCircleHelper(x+r    , y+r    , r, 1, color);<br />  hx8357d_drawCircleHelper(x+w-r-1, y+r    , r, 2, color);<br />  hx8357d_drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);<br />  hx8357d_drawCircleHelper(x+r    , y+h-r-1, r, 8, color);<br />}<br /><br />// Fill a rounded rectangle<br />void hx8357d_fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color) {<br />  // smarter version<br />  hx8357d_fillRect(x+r, y, w-2*r, h, color);<br /><br />  // draw four corners<br />  hx8357d_fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color);<br />  hx8357d_fillCircleHelper(x+r    , y+r, r, 2, h-2*r-1, color);<br />}<br /><br />// Draw a triangle<br />void hx8357d_drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) {<br />hx8357d_drawLine(x0, y0, x1, y1, color);<br />hx8357d_drawLine(x1, y1, x2, y2, color);<br />hx8357d_drawLine(x2, y2, x0, y0, color);<br />}<br /><br />// Fill a triangle<br />void hx8357d_fillTriangle ( int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) {<br /><br />  int16_t a, b, y, last;<br /><br />  // Sort coordinates by Y order (y2 &gt;= y1 &gt;= y0)<br />  if (y0 &gt; y1) {<br />    swap(y0, y1); swap(x0, x1);<br />  }<br />  if (y1 &gt; y2) {<br />    swap(y2, y1); swap(x2, x1);<br />  }<br />  if (y0 &gt; y1) {<br />    swap(y0, y1); swap(x0, x1);<br />  }<br /><br />  if(y0 == y2) { // Handle awkward all-on-same-line case as its own thing<br />    a = b = x0;<br />    if(x1 &lt; a)      a = x1;<br />    else if(x1 &gt; b) b = x1;<br />    if(x2 &lt; a)      a = x2;<br />    else if(x2 &gt; b) b = x2;<br />    hx8357d_drawFastHLine(a, y0, b-a+1, color);<br />    return;<br />  }<br /><br />  int16_t<br />    dx01 = x1 - x0,<br />    dy01 = y1 - y0,<br />    dx02 = x2 - x0,<br />    dy02 = y2 - y0,<br />    dx12 = x2 - x1,<br />    dy12 = y2 - y1;<br />  int32_t<br />    sa   = 0,<br />    sb   = 0;<br /><br />  // For upper part of triangle, find scanline crossings for segments<br />  // 0-1 and 0-2.  If y1=y2 (flat-bottomed triangle), the scanline y1<br />  // is included here (and second loop will be skipped, avoiding a /0<br />  // error there), otherwise scanline y1 is skipped here and handled<br />  // in the second loop...which also avoids a /0 error here if y0=y1<br />  // (flat-topped triangle).<br />  if(y1 == y2) last = y1;   // Include y1 scanline<br />  else         last = y1-1; // Skip it<br /><br />  for(y=y0; y&lt;=last; y++) {<br />    a   = x0 + sa / dy01;<br />    b   = x0 + sb / dy02;<br />    sa += dx01;<br />    sb += dx02;<br />    /* longhand:<br />    a = x0 + (x1 - x0) * (y - y0) / (y1 - y0);<br />    b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);<br />    */<br />    if(a &gt; b) swap(a,b);<br />    hx8357d_drawFastHLine(a, y, b-a+1, color);<br />  }<br /><br />  // For lower part of triangle, find scanline crossings for segments<br />  // 0-2 and 1-2.  This loop is skipped if y1=y2.<br />  sa = dx12 * (y - y1);<br />  sb = dx02 * (y - y0);<br />  for(; y&lt;=y2; y++) {<br />    a   = x1 + sa / dy12;<br />    b   = x0 + sb / dy02;<br />    sa += dx12;<br />    sb += dx02;<br />    /* longhand:<br />    a = x1 + (x2 - x1) * (y - y1) / (y2 - y1);<br />    b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);<br />    */<br />    if(a &gt; b) swap(a,b);<br />    hx8357d_drawFastHLine(a, y, b-a+1, color);<br />  }<br />}<br /><br />// ### % bar ###<br /><br />// x, y lewy górny róg<br />// h wysokosc min. 3<br />// procent wartośc procętowa 0-100<br />// x_koniec pozycja końcowa<br />// colorkolor<br />void hx8357d_ProgressBar( uint16_t x_begin, uint16_t y, uint8_t h, uint8_t procent, uint8_t x_end, uint16_t color){<br /><br />uint8_t i;<br />uint8_t set2 = (x_end*procent)/100;<br /><br />hx8357d_drawRect( x_begin-1, y, x_end+1, h, color);<br /><br />for( i=0; i &lt; set2; i++){<br />hx8357d_drawFastVLine( x_begin+i, y+1, h-2, color);<br />}<br />for( ; i &lt; x_end-1; i++){<br />hx8357d_drawFastVLine( x_begin+i, y+1, h-2, !color);<br />}<br />}<br /><br />// rysuj znak/literę<br />void hx8357d_drawChar(int x, int y, unsigned char c, uint16_t color, uint16_t bg_color, uint8_t size) {<br /><br />  if((x &gt;= _width)            || // Clip right<br />     (y &gt;= _height)           || // Clip bottom<br />     ((x + 6 * size - 1) &lt; 0) || // Clip left<br />     ((y + 8 * size - 1) &lt; 0))   // Clip top<br />    return;<br /><br />  for (int8_t i=0; i&lt;6; i++ ) {<br />    uint8_t line;<br />    if (i == 5)<br />      line = 0x0;<br />    else<br />      line = pgm_read_byte(font+(c*5)+i);<br />    for (int8_t j = 0; j&lt;8; j++) {<br />      if (line &amp; 0x1) {<br />        if (size == 1) // default size<br />        hx8357d_drawPixel(x+i, y+j, color);<br />        else {  // big size<br />        hx8357d_fillRect(x+(i*size), y+(j*size), size, size, color);<br />        }<br />      } else if (bg_color != color) {<br />        if (size == 1) // default size<br />        hx8357d_drawPixel(x+i, y+j, bg_color);<br />        else {  // big size<br />        hx8357d_fillRect(x+i*size, y+j*size, size, size, bg_color);<br />        }<br />      }<br />      line &gt;&gt;= 1;<br />    }<br />  }<br />}<br /><br />// wyświetl tekst z pamięci RAM<br />void hx8357d_puts (int x, int y, char * str, uint8_t txt_size, uint16_t  color, uint16_t bg_color) {<br /><br />cursor_x = x; cursor_y = y;<br /><br />while (*str ) {<br /><br />hx8357d_drawChar (cursor_x, cursor_y, *str++, color, bg_color, txt_size);<br />cursor_x += txt_size*6;<br />}<br />}<br /><br />// wyświetl tekst z pamięci FLASH<br />void hx8357d_puts_P (int x, int y, const char * str, uint8_t txt_size, uint16_t color, uint16_t bg_color) {<br /><br />cursor_x = x; cursor_y = y;<br /><br />register char c;<br />while (*str ) {<br />c = pgm_read_byte (str++);<br />hx8357d_drawChar (cursor_x, cursor_y, c, color, bg_color, txt_size);<br />cursor_x += txt_size*6;<br />}<br />}<br /><br />// wyświetl zmienną<br />void  hx8357d_put_int (int x, int y, int data, uint8_t txt_size, uint16_t color, uint16_t bg_color) {<br />char buf&#91;16&#93;;<br />hx8357d_puts (x, y, itoa (data, buf, 10), txt_size, color, bg_color);<br />}<br /><br /><br />// ### wyświetlanie map bitowych ###<br /><br />//jednokolorowa bez tła<br />void  hx8357d_drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {<br /><br />  int16_t i, j, byteWidth = (w + 7) / 8;<br /><br />  for(j=0; j&lt;h; j++) {<br />    for(i=0; i&lt;w; i++ ) {<br />      if(pgm_read_byte(bitmap + j * byteWidth + i / 8) &amp; (128 &gt;&gt; (i &amp; 7))) {<br />      hx8357d_drawPixel(x+i, y+j, color);<br />      }<br />    }<br />  }<br />}<br /><br /><br />//jednokolorowa z tłem<br />void hx8357d_drawBitmap_bg_color(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg_color) {<br /><br />  int16_t i, j, byteWidth = (w + 7) / 8;<br /><br />  for(j=0; j&lt;h; j++) {<br />    for(i=0; i&lt;w; i++ ) {<br />      if(pgm_read_byte(bitmap + j * byteWidth + i / 8) &amp; (128 &gt;&gt; (i &amp; 7))) {<br />      hx8357d_drawPixel(x+i, y+j, color);<br />      }<br />      else {<br />      hx8357d_drawPixel(x+i, y+j, bg_color);<br />      }<br />    }<br />  }<br />}<br /><br />//Draw XBitMap Files (*.xbm), exported from GIMP,<br />//Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.<br />//C Array can be directly used with this function<br />void hx8357d_drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {<br /><br />  int16_t i, j, byteWidth = (w + 7) / 8;<br /><br />  for(j=0; j&lt;h; j++) {<br />    for(i=0; i&lt;w; i++ ) {<br />      if(pgm_read_byte(bitmap + j * byteWidth + i / 8) &amp; (1 &lt;&lt; (i % 8))) {<br />      hx8357d_drawPixel(x+i, y+j, color);<br />      }<br />    }<br />  }<br />}[/syntax]<br /><br />intre_demo.h<br />[syntax=c]/*<br /> * intre_demo.h<br /> *<br /> *  Created on: 16-03-2015<br /> *      Author: Intre<br /> */<br /><br />#ifndef INTRE_DEMO_H_<br />#define INTRE_DEMO_H_<br /><br /><br />typedef struct {<br />uint16_t term1_color;<br />uint16_t term2_color;<br />uint16_t term1_font_color;<br />uint16_t term1_out_color;<br />uint16_t term2_font_color;<br />uint16_t term2_in_color;<br />uint16_t termo_background_color;<br />uint16_t clock_date_background;<br />uint16_t date_font_color;<br />uint16_t clock_font_color;<br />uint16_t day_of_week_font_color;<br />uint16_t day_of_week_background;<br />uint16_t weather_background;<br />uint16_t weather_font_color;<br />uint16_t cloud_color;<br />uint16_t cloud_background;<br />uint16_t umbrella_color;<br />uint16_t intre_font_color;<br />uint16_t intre_background;<br />uint16_t top_background;<br />uint16_t light_color;<br />uint16_t wifi_color;<br />uint16_t battery_color;<br />uint16_t posts_color;<br />uint16_t higro_font_color;<br /><br />} TCOLOR;<br /><br />extern TCOLOR scheme;<br />extern uint8_t higro;<br />extern char week_tab &#91;7&#93;&#91;13&#93;;<br /><br /><br />void testLines(uint16_t color);<br />void testFastLines(uint16_t color1, uint16_t color2);<br />void testRects(uint16_t color);<br />void testFilledRects(uint16_t color1, uint16_t color2);<br />void testFilledCircles(uint8_t radius, uint16_t color);<br />void testCircles(uint8_t radius, uint16_t color);<br />void testTriangles(uint8_t size);<br />void testFilledTriangles(int size);<br />void testRoundRects(int size);<br />void testFilledRoundRects(int size);<br /><br />void intre_matrix (void);<br />void icons (void);<br />void buttons (void);<br /><br />void intre_HX8357D_library_demo (void);<br />void set_higrometer_time (uint8_t hour, uint8_t minute);<br />void higrometer_colors (uint8_t skin_no);<br />void higrometer_scheme (void);<br />void intre_higrometer_demo (void);<br />void digital_clock (void);<br />void umbrella_on (void);<br />void umbrella_off (void);<br />void procent_higro (void);<br /><br />#endif /* INTRE_DEMO_H_ */[/syntax]<br /><br />intre_demo.c<br />[syntax=c]/*<br /> * intre_demo.c<br /> *<br /> *  Created on: 16-03-2015<br /> *      Author: Intre<br /> */<br /><br /><br />#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br />#include &quot;intre_demo.h&quot;<br /><br />#include &quot;..//INTRE_HX8357D/hx8357D.h&quot;<br />#include &quot;..//BITMAPS/bitmaps.h&quot;<br />#include &quot;..//TIMERS/timers.h&quot;<br /><br /><br />TCOLOR scheme;<br /><br />uint8_t higro, load;<br /><br />char week_tab &#91;7&#93;&#91;13&#93;=  {&quot;poniedziałek&quot;, &quot;wtorek&quot;, &quot;środa&quot;, &quot;czwartek&quot;, &quot;piątek&quot;, &quot;sobota&quot;, &quot;niedziela&quot; };<br /><br /><br />void set_higrometer_time (uint8_t hour, uint8_t minute){<br />clock.hh = hour;<br />clock.min = minute;<br />}<br /><br /><br />void intre_HX8357D_library_demo (void){<br /><br />hx8357d_drawBitmap_bg_color(150, 50, intre, 183, 57, blue, black);<br />hx8357d_puts(180, 120 ,&quot;prezentuje:&quot;, 2, white, black);<br />hx8357d_puts(100, 175 ,&quot;Adafruit 480 x 320 TFT LCD&quot;, 2, yellow, black);<br />hx8357d_puts(160, 210 ,&quot;Breakout Board&quot;, 2, green, black);<br />_delay_ms(3000);<br /><br />hx8357d_cls(black);<br />hx8357d_puts(190, 110 ,&quot;wczytywanie...&quot;, 2, white, black);<br />hx8357d_drawBitmap_bg_color(155, 100, hourglass, 31, 31, white, black);<br /><br />for (load =0; load&lt;100; load++) {<br />hx8357d_ProgressBar( 130, 170, 30, load, 240, orange);<br />_delay_ms(20);<br />}<br /><br />hx8357d_cls(red);<br />_delay_ms(200);<br /><br />hx8357d_cls(green);<br />_delay_ms(200);<br /><br />hx8357d_cls(blue);<br />_delay_ms(200);<br /><br />testLines(yellow);<br />_delay_ms(2000);<br /><br />testLines(white);<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />testFastLines(red, black);<br />_delay_ms(300);<br /><br />testFastLines(navy, black);<br />_delay_ms(300);<br /><br />hx8357d_cls(black);<br />testCircles(30, green_yellow);<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />testFilledCircles(30, blue);<br />_delay_ms(2000);<br />hx8357d_cls(black);<br /><br />    testFilledTriangles(155);<br />_delay_ms(2000);<br /><br />testTriangles(155);<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />testFilledRoundRects(320);<br />_delay_ms(2000);<br /><br />testRoundRects(320);<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />testFilledRects (blue, yellow);<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />intre_matrix ();<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />buttons ();<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />icons ();<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />higrometer_colors (2);<br />higrometer_scheme ();<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />higrometer_colors (1);<br />higrometer_scheme ();<br />_delay_ms(2000);<br /><br />hx8357d_cls(black);<br />higrometer_colors (3);<br />higrometer_scheme ();<br />_delay_ms(2000);<br /><br />hx8357d_cls(white);<br />higrometer_colors (4);<br />higrometer_scheme ();<br />_delay_ms(2000);<br /><br /><br />}<br /><br /><br />void intre_higrometer_demo (void){<br />if(clock.sec_flag) {<br /><br />digital_clock ();<br /><br />if( 0 == (clock.sec%3) ) umbrella_on();<br />if( 1 == (clock.sec%3) ) umbrella_off();<br /><br />clock.sec_flag=0;<br />}<br /><br />if (!clock.Timer1) {<br />clock.Timer1 = 500;<br />procent_higro ();<br />}<br />}<br /><br /><br />void higrometer_scheme (void) {<br /><br />//top<br />hx8357d_drawBitmap_bg_color(0, 0, intre, 183, 57, scheme.intre_font_color, scheme.intre_background);<br />hx8357d_drawBitmap_bg_color(183, 0, light, 69, 57, scheme.light_color, scheme.top_background);<br />hx8357d_drawBitmap_bg_color(240, 0, wi_fi, 32, 57, scheme.wifi_color, scheme.top_background);<br />hx8357d_drawBitmap_bg_color(272, 0, battery, 52, 57, scheme.battery_color, scheme.top_background);<br />hx8357d_fillRect(324, 0, 89, 57,  scheme.top_background);<br />hx8357d_puts(380, 18 , &quot;%&quot;, 3, scheme.higro_font_color, scheme.top_background);<br />hx8357d_drawBitmap_bg_color(413, 0, posts, 67, 57, scheme.posts_color, scheme.top_background);<br /><br />//cloud<br />hx8357d_fillRect(0, 57, 183, 205,  scheme.cloud_background);<br /><br />//termo<br />hx8357d_drawBitmap_bg_color(183, 57, out, 100, 26, scheme.term1_out_color, scheme.termo_background_color);<br />hx8357d_puts(185, 63 ,&quot;out&quot;, 2, scheme.term1_out_color, scheme.termo_background_color);<br />hx8357d_fillRect(183, 83, 100, 73,  scheme.termo_background_color);<br />hx8357d_put_int(215, 95 , 12, 6, scheme.term1_font_color, scheme.termo_background_color);<br />hx8357d_drawBitmap_bg_color(283, 57, term1, 52, 99, scheme.term1_color, scheme.termo_background_color);<br />hx8357d_fillRect(334, 57, 104, 99,  scheme.termo_background_color);<br />hx8357d_puts(350, 63 ,&quot;in&quot;, 2, scheme.term2_in_color, scheme.termo_background_color);<br />hx8357d_put_int(370, 95 , 21, 6, scheme.term2_font_color, scheme.termo_background_color);<br />hx8357d_drawBitmap_bg_color(438, 57, term2, 42, 99, scheme.term2_color, scheme.termo_background_color);<br /><br />//clock date<br />hx8357d_fillRect(183, 156, 298, 106,  scheme.clock_date_background);<br />hx8357d_puts(250, 230 , &quot;15.03.2015&quot;, 3, scheme.date_font_color, scheme.clock_date_background);<br />hx8357d_fillRect(0, 261, 183, 60,  scheme.weather_background);<br />hx8357d_fillRect(183, 261, 298, 60,  scheme.day_of_week_background);<br />hx8357d_puts(245, 280 , week_tab&#91;0&#93;, 3, scheme.day_of_week_font_color, scheme.day_of_week_background);<br />hx8357d_puts (270, 170 , &quot;:&quot;, 6, scheme.clock_font_color, scheme.clock_date_background);<br />hx8357d_puts (370, 170 , &quot;:&quot;, 6, scheme.clock_font_color, scheme.clock_date_background);<br /><br />digital_clock();<br /><br />//weather<br />hx8357d_puts(20, 275 , &quot;deszcz&quot;, 4, scheme.weather_font_color, scheme.weather_background);<br /><br />//cloud<br />hx8357d_drawBitmap_bg_color(0, 57, cloud, 183, 205, scheme.cloud_color, scheme.cloud_background);<br />hx8357d_drawBitmap_bg_color(124, 57, umbrella, 59, 59, scheme.umbrella_color, scheme.cloud_background);<br /><br />}<br /><br /><br />void digital_clock (void){<br /><br /><br />if (clock.hh &lt;10){<br />hx8357d_put_int (200, 170 , 0, 6, scheme.clock_font_color, scheme.clock_date_background);<br />hx8357d_put_int (235, 170 , clock.hh, 6, scheme.clock_font_color, scheme.clock_date_background);<br />}<br />else<br />hx8357d_put_int (200, 170 , clock.hh, 6, scheme.clock_font_color, scheme.clock_date_background);<br /><br />if (clock.min &lt;10){<br />hx8357d_put_int (300, 170 , 0, 6, scheme.clock_font_color, scheme.clock_date_background);<br />hx8357d_put_int (335, 170 , clock.min, 6, scheme.clock_font_color, scheme.clock_date_background);<br />}<br />else<br />hx8357d_put_int (300, 170 , clock.min, 6, scheme.clock_font_color, scheme.clock_date_background);<br /><br />if (clock.sec &lt;10){<br />hx8357d_put_int (400, 170 , 0, 6, scheme.clock_font_color, scheme.clock_date_background);<br />hx8357d_put_int (435, 170 , clock.sec, 6, scheme.clock_font_color, scheme.clock_date_background);<br />}<br />else<br />hx8357d_put_int (400, 170 , clock.sec, 6, scheme.clock_font_color, scheme.clock_date_background);<br /><br />}<br /><br /><br /><br />void umbrella_on (void){<br />hx8357d_drawBitmap_bg_color(124, 57, umbrella, 59, 59, scheme.umbrella_color, scheme.cloud_background);<br />}<br /><br /><br />void umbrella_off (void){<br />hx8357d_fillRect(124, 57, 59, 59,  scheme.cloud_background);<br />}<br /><br />void procent_higro (void){<br />higro++;<br />if (higro &gt;=99) higro=0;<br />if (higro &lt;=9){<br />hx8357d_put_int(340, 18 , 0, 3, scheme.higro_font_color ,  scheme.top_background);<br />hx8357d_put_int(358, 18 , higro, 3, scheme.higro_font_color ,  scheme.top_background);<br />}<br />else<br />hx8357d_put_int(340, 18 , higro, 3, scheme.higro_font_color,  scheme.top_background);<br /><br />}<br /><br /><br />void icons (void){<br />hx8357d_drawBitmap_bg_color(103, 49, watch, 46, 42, blue, black);<br />hx8357d_drawBitmap_bg_color(149, 49, trash, 65, 42, white, black);<br />hx8357d_drawBitmap_bg_color(214, 49, coffee, 62, 42, yellow, black);<br />hx8357d_drawBitmap_bg_color(276, 49, no, 62, 42, red, black);<br />hx8357d_drawBitmap_bg_color(336, 49, arow, 46, 42, green, black);<br />hx8357d_drawBitmap_bg_color(103, 137, anten, 46, 45, magenta, black);<br />hx8357d_drawBitmap_bg_color(149, 137, umbro2, 65, 45, orange, black);<br />hx8357d_drawBitmap_bg_color(214, 137, tank, 62, 45, cyan, black);<br />hx8357d_drawBitmap_bg_color(276, 137, music, 60, 45, blue, black);<br />hx8357d_drawBitmap_bg_color(336, 137, cd, 46, 45, white, black);<br />hx8357d_drawBitmap_bg_color(103, 228, talk, 46, 42, green, black);<br />hx8357d_drawBitmap_bg_color(149, 228, lupe, 65, 42, red, black);<br />hx8357d_drawBitmap_bg_color(214, 228, arow2, 65, 42, yellow, black);<br />hx8357d_drawBitmap_bg_color(279, 228, armchair, 60, 42, magenta, black);<br />hx8357d_drawBitmap_bg_color(336, 228, folder, 46, 42, orange, black);<br />}<br /><br />void intre_matrix (void){<br />hx8357d_drawBitmap_bg_color(40, 20, intre, 183, 57, blue, black);<br />hx8357d_drawBitmap_bg_color(250, 20, intre, 183, 57, red, black);<br />hx8357d_drawBitmap_bg_color(40, 77, intre, 183, 57, white, black);<br />hx8357d_drawBitmap_bg_color(250, 77, intre, 183, 57, yellow, black);<br />hx8357d_drawBitmap_bg_color(40, 134, intre, 183, 57, cyan, black);<br />hx8357d_drawBitmap_bg_color(250, 134, intre, 183, 57, magenta, black);<br />hx8357d_drawBitmap_bg_color(40, 191, intre, 183, 57, green, black);<br />hx8357d_drawBitmap_bg_color(250, 191, intre, 183, 57, blue, black);<br />hx8357d_drawBitmap_bg_color(40, 248, intre, 183, 57, red, black);<br />hx8357d_drawBitmap_bg_color(250, 248, intre, 183, 57, white, black);<br />}<br /><br /><br /><br />void buttons (void){<br />hx8357d_fillRoundRect(25, 15, 230, 90, 45, red);<br />hx8357d_puts (105, 50, &quot;SAVE&quot;, 3, white, red);<br />hx8357d_fillRoundRect(25, 115, 230, 90, 35, blue);<br />hx8357d_puts (105, 150, &quot;LOAD&quot;, 3, yellow, blue);<br />hx8357d_fillRoundRect(25, 215, 230, 90, 20, green);<br />hx8357d_puts (100, 250, &quot;CANEL&quot;, 3, black, green);<br />hx8357d_fillRoundRect(280, 15, 90, 90, 20, green_yellow);<br />hx8357d_fillRoundRect(280, 115, 90, 90, 20, cyan);<br />hx8357d_fillCircle(425, 160, 42, orange);<br />hx8357d_fillRoundRect(280, 215, 190, 90, 25, white);<br />hx8357d_fillRoundRect(290, 225, 170, 70, 25, blue);<br />hx8357d_puts (315, 245, &quot;INTRE&quot;, 4, white, blue);<br />hx8357d_fillTriangle (425, 15, 380, 105, 470, 105, magenta);<br />hx8357d_drawBitmap_bg_color(295, 38, lupe, 65, 42, blue, green_yellow);<br />hx8357d_drawBitmap_bg_color(295, 140, trash, 65, 42, red, cyan);<br />hx8357d_drawBitmap_bg_color(400, 140, folder, 46, 42, black, orange);<br />hx8357d_drawBitmap_bg_color(403, 61, arow, 46, 42, white, magenta);<br />}<br /><br />void testLines(uint16_t color) {<br /><br />  int  x1, y1, x2, y2,<br />       w = _width,<br />       h = _height;<br /><br />  hx8357d_cls(black);<br /><br />  x1 = y1 = 0;<br />  y2    = h - 1;<br /><br />  for(x2=0; x2&lt;w; x2+=6) hx8357d_drawLine(x1, y1, x2, y2, color);<br />  x2    = w - 1;<br />  for(y2=0; y2&lt;h; y2+=6) hx8357d_drawLine(x1, y1, x2, y2, color);<br /><br />}<br /><br /><br />void testFastLines(uint16_t color1, uint16_t color2) {<br /><br />  int x, y, w = _width, h = _height;<br /><br />  hx8357d_cls(black);<br /><br />  for(y=0; y&lt;h; y+=5) hx8357d_drawFastHLine(0, y, w, color1);<br />  for(x=0; x&lt;w; x+=5) hx8357d_drawFastVLine(x, 0, h, color2);<br /><br /><br />}<br /><br />void testRects(uint16_t color) {<br /><br />  int n, i, i2, cx = _width  / 2, cy = _height / 2;<br /><br />  hx8357d_cls(black);<br />  n = HX8357_TFTWIDTH;<br /><br />  for(i=2; i&lt;n; i+=6) {<br />    i2 = i / 2;<br />    hx8357d_drawRect(cx-i2, cy-i2, i, i, color);<br />  }<br />}<br /><br />void testFilledRects(uint16_t color1, uint16_t color2) {<br /><br />  int n, i, i2, cx = _width  / 2 - 1, cy = _height / 2 - 1;<br /><br />  hx8357d_cls(black);<br />  n = HX8357_TFTWIDTH;<br /><br />  for(i=n; i&gt;0; i-=6) {<br />    i2    = i / 2;<br /><br />  hx8357d_fillRect(cx-i2, cy-i2, i, i, color1);<br />  hx8357d_drawRect(cx-i2, cy-i2, i, i, color2);<br />  }<br />}<br /><br />void testFilledCircles(uint8_t radius, uint16_t color) {<br /><br />  int x, y, w = _width, h = _height, r2 = radius * 2;<br /><br /> // hx8357d_cls(black);<br /><br />  for(x=radius; x&lt;w; x+=r2) {<br />    for(y=radius; y&lt;h; y+=r2) {<br />    hx8357d_fillCircle(x, y, radius, color);<br />    }<br />  }<br />}<br /><br />void testCircles(uint8_t radius, uint16_t color) {<br /><br />  int x, y, r2 = radius * 2, w = _width  + radius, h = _height + radius;<br /><br />  // Screen is not cleared for this one -- this is<br />  // intentional and does not affect the reported time.<br /><br />  for(x=0; x&lt;w; x+=r2) {<br />    for(y=0; y&lt;h; y+=r2) {<br />    hx8357d_drawCircle(x, y, radius, color);<br />    }<br />  }<br />}<br /><br />void testTriangles(uint8_t size) {<br /><br />  int   i, cx = _width  / 2 - 1, cy = _height / 2 - 1;<br /><br /> // hx8357d_cls(black);<br />  //n     = size;<br /><br />  for(i=0; i&lt;size; i+=5) {<br />  hx8357d_drawTriangle(<br />      cx    , cy - i, // peak<br />      cx - i, cy + i, // bottom left<br />      cx + i, cy + i, // bottom right<br />      hx8357d_color565(200, 20, i));<br />  }<br />}<br /><br />void testFilledTriangles(int size) {<br /><br />  int i, cx = _width  / 2 - 1, cy = _height / 2 - 1;<br /><br />  hx8357d_cls(black);<br />   i = size;<br /><br />  for(i=170; i&gt;10; i-=5) {<br /><br />  hx8357d_fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,<br />  hx8357d_color565(0, i, i));<br /><br />  hx8357d_drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,<br />  hx8357d_color565(i, i, 0));<br />  }<br />}<br /><br />void testRoundRects(int size) {<br /><br />  int w, i, i2,cx = _width  / 2 , cy = _height / 2 ;<br /><br /> // hx8357d_cls(black);<br />  w     = size;<br /><br />  for(i=0; i&lt;w; i+=8) {<br />    i2 = i / 2 - 2;<br />    hx8357d_drawRoundRect(cx-i2, cy-i2, i, i, i/8, hx8357d_color565(i, 100, 100));<br />  }<br />}<br /><br />void testFilledRoundRects(int size) {<br /><br />  int i, i2, cx = _width  / 2 + 10, cy = _height / 2 + 10;<br /><br />  hx8357d_cls(black);<br />  //i = size;<br /><br />  for(i = size- 20; i&gt;20; i-=6) {<br />    i2 = i / 2;<br />    hx8357d_fillRoundRect(cx-i2, cy-i2, i-20, i-20, i/8,  hx8357d_color565(100, i/2, 100));<br />  }<br />}[/syntax]<br /><br />timers.h<br />[syntax=c]/*<br /> * timers.h<br /> *<br /> *  Created on: 16-03-2015<br /> *      Author: Intre<br /> */<br /><br />#ifndef TIMERS_H_<br />#define TIMERS_H_<br /><br />// ustalamy czy korzystamy z pinu do wł/wył zasilania karty SD<br />#define USE_A32A1<br />#define USE_A644PA0   // ##CAUTION## works properly only 3,3V<br /><br /><br />//zmienne dla odmierzania czasu<br />volatile typedef struct {<br />uint8_t sec_flag;<br />uint8_t cnt;<br />uint8_t sec;<br />uint8_t min;<br />uint8_t hh;<br />uint16_t Timer1;<br />uint16_t Timer2;<br />} TTIME;<br /><br />extern volatile TTIME clock;<br /><br /><br />// funkcja inicjalizująca Taimer 2<br />extern void timer2_init (void);<br /><br /><br />#endif /* TIMERS_H_ */[/syntax]<br /><br />timers.c<br />[syntax=c]/*<br /> * timers.c<br /> *<br /> *  Created on: 16-03-2015<br /> *      Author: Intre<br /> */<br /><br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br /><br />#include &quot;timers.h&quot;<br /><br /><br />volatile TTIME clock;<br /><br />// inicjalizacja TIMER 2<br />// Zoptymalizowane dla F_CPU = 18 432 000 MHz<br />void timer2_init (void) {<br /><br />#if  USE_A32A == 1<br />TCCR2 |= (1&lt;&lt;WGM21);   //tryb CTC<br />    TCCR2 |= (1&lt;&lt;CS22)|(1&lt;&lt;CS21)|(1&lt;&lt;CS20); // preskaler 1024<br />    OCR2  = 179;              //  10 ms thx mkAVRCaclulator http://atnel.pl/mkavrcalculator.html<br />    TIMSK  |= (1&lt;&lt;OCIE2);<br />#endif<br /><br />#if  USE_A644PA == 1<br />TCCR2A |= (1&lt;&lt;WGM21);   //tryb CTC<br />    TCCR2B |= (1&lt;&lt;CS22)|(1&lt;&lt;CS21)|(1&lt;&lt;CS20); // preskaler 1024<br />    OCR2A  = 179;              //  10 ms thx mkAVRCaclulator http://atnel.pl/mkavrcalculator.html<br />    TIMSK2  |= (1&lt;&lt;OCIE2A);<br />#endif<br />}<br /><br />//obsługa przerwania<br />#if  USE_A32A == 1<br />ISR(TIMER2_COMP_vect) {<br />#endif<br /><br /><br />#if  USE_A644PA == 1<br />ISR(TIMER2_COMPA_vect) {<br />#endif<br /><br />clock.cnt++;<br />if(clock.cnt&gt;99) {<br />{<br />clock.sec_flag=1;<br />clock.sec++;<br />          if(clock.sec&gt;59)<br />                  { clock.sec = 0;<br />                  clock.min++;<br />          if(clock.min&gt;59) {<br />          clock.min = 0;<br />          clock.hh++;<br />               }<br />          if(clock.hh&gt;24) {<br />               clock.hh = 0;<br />                }<br />                  }<br />          clock.cnt = 0;<br />  }<br />   }<br />uint16_t n;<br />n = clock.Timer1;<br />if (n) clock.Timer1 = --n;<br />n = clock.Timer2;<br />if (n) clock.Timer2 = --n;<br />}[/syntax]<br /><br />I jak? <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><br />No cóż trochę się naklepałem, jeszcze są pliki z bitmapami i ustawieniami skórki dla dema higrometru ale to zostawiam do obejrzenia w załączniku. Ogólnie nie mam pojęcia czy tą bibliotekę jak również program demonstracyjny napisałem dobrze czy źle, to już pozostawiam do oceny w waszej gestii. <br /><br />Napiszę że na pewno mi ta biblioteka działa i ja osobiście jestem z niej zadowolony, funkcjonalność jaką ja potrzebuje do jakiś swoich projektów mam wystarczającą, rzekłbym aż nad to.<br />Biblioteka w załączniku jest skompilowana na procesor Atmega 32A pracująca z zegarem 18 432 000, z innymi mniejszymi kwarcami też chodzi ale nie zalecałbym niczego niżej niż 16Mhz - już mocno zwalnia. Testowałem ja na różnych procesorach np. A32A, A128 (po odchudzeniu nawet na A8 najmniejszy jaki próbowałem) jak i również na A644PA oraz A1284P i tu mam małe pytanie bo zagadką dla mnie jest to że o ile ze starszymi wymienionymi procesorami komunikacja SPI przy 5V działa idealnie bez zastrzeżeń to jak skompiluje tą bibliotekę na nowsze procesory serii 644 itd. to amen, złe działanie, defakto krzaki na ekranie, niestabilność, masakra. Jednakże jak przestawię tylko napięcie zasilania na 3,3V lub dam dodatkowy dzielnik napięcia to ręka odjoł biblioteka działa tak samo dobrze jak na A32 itp. o co tu chodzi, coś się zmieniło w nowszych procesorach, analizowałem notę jest tam coś o zasilaniu w przypadku używania SPI, coś powiązane z UART że trzeba dać 0 wrejestr PWR, ale domyślnie są 0 no nie jasne to dla mnie, może ktoś z bardziej doświadczonych kolegów wyjaśni o co chodzi, mówię przestawiam na 3,3V i jest ok, a ze starszymi procesorami obojętnie czy na 5V czy na 3,3V jest też ok. <br /><br />Z innych uwag jakie mam albo mi nie wyszły to wyświetlanie zmiennej z pamięci flash, ona się wyświetla na ekranie ale oprócz niej jakieś krzaki, może ktoś obejrzeć funkcje i mi podpowiedzieć jaki mam błąd lub może ficzer trzeba zrobić by było ok <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> <span style="color: #FF4000"> Już nie aktualne bo poprawione - aktualizacja biblioteki w załączniku <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> </span><br /><br />W demie aż się pewnie prosiło o latający napis spoza ekranu na wyświetlacz, ot taka pętelka - no cóż mała masakra z prędkością wyświetlania jakby AVRkowi pary zabrakło jak cały napis wjedzie <img src="https://forum.atnel.pl/images/smilies/icon_lol.gif" alt=":lol:" title="Śmieje się" />  dlatego z prezentacji tego zrezygnowałem ale kto wie może coś źle robię.... <br /><br />Z innych rzeczy jak ktoś bliżej się przyjrzy temu wyświetlaczowi to stwierdzi że ma on dotykowy rezystancjny ekran oraz czytnik kart MicroSD, i to się zgadza wszystko jest. Jeszcze tego nie opanowałem z jednej strony sprzętowo bo chcę dotykowy ekran zrobić na opisanym przez Mirka układzie STMPE811 <a href="https://www.sklep.atnel.pl/pl/searchquery/STMPE811/1/phot/5?url=STMPE811"  class="postlink">https://www.sklep.atnel.pl/pl/searchquery/STMPE811/1/phot/5?url=STMPE811</a> i tutaj walczę z przylutowaniem jego bo jest ciut za duży <img src="https://forum.atnel.pl/images/smilies/icon_lol.gif" alt=":lol:" title="Śmieje się" /> <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> ale myślę że za jakiś czas go opanuje i dodam stosowną aktualizacje biblioteki o funkcjonalność dotyku ale opartą o kod Mirka z zielonej książki więc by go uruchomić będzie wymagane dogranie jej sobie. Czytnik kart SD udało mi się bez większych problemów odpalić w wyświetlaczu również za pomocą biblioteki PetiFS Mirka z zielonej książki jednakże poległem na razie na pisaniu funkcji wyświetlającej zdjęcia z karty, no cóż jest to szerszy problem który opisze w nowym wątku ze stosownymi pytaniami oraz niejasnościami jakie mam i jak to opanuję również dodam zaktualizowaną funkcjonalność. Wyświetlacz ma jeszcze tryb 8-bit ja jednakże raczej nie będę go oprogramowywać - chociaż może kiedyś dla zabawy to też kod zamieszczę. <br /><br />To z grubsza, tyle jak są jakieś pytania czy nie jasności to chętnie odpowiem. Dodam jeszcze że ten wyświetlacz w PL można nabyć np. w sklepie Botland:<br /><a href="http://botland.com.pl/wyswietlacze-graficzne/2666-wyswietlacz-dotykowy-tft-lcd-35-320-x-480-z-czytnikiem-microsd.html"  class="postlink">http://botland.com.pl/wyswietlacze-graficzne/2666-wyswietlacz-dotykowy-tft-lcd-35-320-x-480-z-czytnikiem-microsd.html</a><br /><br />I jeszcze napisze dla malkontentów, powiem wam że jestem przeszczęsliwy, wniebowzięty wręcz że po jakimś tam czasie, w sumie nie długim ja wiem roku-póltorej nauki języka C od 0 z Mirkiem, jego poradnikami oraz książkami opanowałem sobie sam bez niczyjej pomocy obsługę jakiegoś tam przypadkowego wyświetlacza LCD TFT, którego widzę pierwszy raz na oczy w jakiś tydzień wraz z programem demonstracyjnym. I to jest dla mnie najlepsze wręcz bezcenne, a o Mirku świadczy że robotę jaką robi robi ją bardzo dobrze <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1356">Intre</a> — 18 mar 2015, o 23:59</p><hr />
]]></content>
</entry>
</feed>