<?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=4&amp;t=12336&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2015-07-15T17:11:45+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=12336&amp;mode</id>
<entry>
<author><name><![CDATA[xtreme69]]></name></author>
<updated>2015-07-15T17:11:45+01:00</updated>
<published>2015-07-15T17:11:45+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12336&amp;p=134616#p134616</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12336&amp;p=134616#p134616"/>
<title type="html"><![CDATA[Re: Mini problem z gradientem i ws2812b]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12336&amp;p=134616#p134616"><![CDATA[
Dzięki Mirku  <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> <br />Teraz wszystko pięknie działa , nie wiem jak mogłem być tak ślepy i na to nie wpaść  <img src="https://forum.atnel.pl/images/smilies/icon_redface.gif" alt=":oops:" title="Zawstydzony" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=8203">xtreme69</a> — 15 lip 2015, o 17:11</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2015-07-15T06:35:22+01:00</updated>
<published>2015-07-15T06:35:22+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12336&amp;p=134575#p134575</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12336&amp;p=134575#p134575"/>
<title type="html"><![CDATA[Re: Mini problem z gradientem i ws2812b]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12336&amp;p=134575#p134575"><![CDATA[
<div class="quotetitle">xtreme69 napisał(a):</div><div class="quotecontent"><br />int main(void){<br /> <br />        TCCR0 = (1&lt;&lt;CS01);<br />        TCCR2 = (1&lt;&lt;CS21)|(1&lt;&lt;CS20);  //timery<br /> <br />        gradient2c(pasek, 1, 4, 0x1f, 0x001f00);<br /> <br />        //sei<br />        while(1){<br /> <br /> <br />        }<br /> <br />        ws281x_asm_send(pasek, WS_LED_CNT, WS_PIN);<br />        _delay_ms(10);<br /> <br />}<br /></div><br /><br />no ten przykładowy gradient nie ma szansy się pojawić na pasku LED bo jak ? odpalasz pętlę główną która się nigdy nie kończy ... a dopiero po niej dałeś wysłanie danych (gradientu na pasek LED) ..... daj to przed pętlą główną <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> — 15 lip 2015, o 06:35</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xtreme69]]></name></author>
<updated>2015-07-14T21:53:40+01:00</updated>
<published>2015-07-14T21:53:40+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12336&amp;p=134566#p134566</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12336&amp;p=134566#p134566"/>
<title type="html"><![CDATA[Mini problem z gradientem i ws2812b]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12336&amp;p=134566#p134566"><![CDATA[
Jeżeli piszę nie w tym dziale co trzeba to proszę o przeniesienie do właściwego działu.<br /><br />Witam mam mini problemik z odpaleniem gradientu na mojej lampce<br /><!-- l --><a class="postlink-local" href="http://forum.atnel.pl/topic12279.html" >topic12279.html</a><!-- l --><br /><br />Procek Mega32 16Mhz.<br /><br />te funkcje działają bez problemu:<br />void ws_line(void * line, int x, uint16_t len, uint32_t color);<br />void ws_set_pixel(void * line, int x, uint32_t color);<br />void ws_cls(void * line, uint32_t color);<br /><br /><br /><br />wszystko pięknie działa, jednak przy próbie użycia gradientu już nie jest tak fajnie, mianowicie nie działa<br /><br />[syntax=c]/*<br /> * main.c<br /> *<br /> *  Created on: 10 lip 2015<br /> *      Author: Michał Maszka XTREME69<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 />#include &lt;string.h&gt;<br />#include &lt;stdlib.h&gt;<br /><br />//#include &quot;WS2812/ws2812.h&quot;<br />#include &quot;WS2812/ws281x.h&quot;<br /><br />TWSRGB ws_rgb_leds&#91;WS_LED_CNT&#93;;<br /><br />uint8_t * pasek = (uint8_t*)ws_rgb_leds;<br /><br />void mk_delay(uint16_t ms);<br /><br />int main(void){<br /><br />TCCR0 = (1&lt;&lt;CS01);<br />TCCR2 = (1&lt;&lt;CS21)|(1&lt;&lt;CS20);  //timery<br /><br />gradient2c(pasek, 1, 4, 0x1f, 0x001f00);<br /><br />//sei<br />while(1){<br /><br /><br />}<br /><br />ws281x_asm_send(pasek, WS_LED_CNT, WS_PIN);<br />_delay_ms(10);<br /><br />}<br /><br /><br /><br />void mk_delay(uint16_t ms){<br />while(ms--){<br />_delay_ms(2);<br />}<br />}[/syntax]<br /><br /><br /><br />[syntax=c]/*<br /> * ws281x.c<br /> *<br /> *  Created on: 30-06-2014<br /> *      Author: 123<br /> *      F_CPU = 16 MHz<br /> */<br />#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br /><br />#include &quot;ws281x.h&quot;<br /><br />// ------ gamma  RED   = 1,4<br />const uint8_t gamma_correctionR&#91;&#93; PROGMEM = {<br />  1,  5,  9, 13, 18, 24, 30, 36, 43, 50, 57, 64, 72, 80, 88, 96,105,113,<br />122,132,141,150,160,170,180,190,201,211,222,232,243,255<br />};<br /><br />// ------ gamma  GREEN = 1,6<br />const uint8_t gamma_correctionG&#91;&#93; PROGMEM = {<br />  0,  3,  5,  9, 13, 17, 22, 27, 33, 39, 46, 53, 60, 67, 75, 84, 92,101,<br />110,120,129,140,150,160,171,182,194,205,217,229,242,255<br />};<br /><br />// ------ gamma  BLUE  = 1,9<br />const uint8_t gamma_correctionB&#91;&#93; PROGMEM = {<br />  0,  1,  2,  4,  7, 10, 14, 18, 22, 27, 33, 39, 46, 53, 60, 68, 76, 85,<br /> 94,104,114,125,136,147,159,171,184,197,211,225,240,255<br />};<br /><br />#define GAMMAR(a) (pgm_read_byte(&amp;gamma_correctionR&#91;a&#93;))  // macro for RED<br />#define GAMMAG(a) (pgm_read_byte(&amp;gamma_correctionG&#91;a&#93;))  // macro for GREEN<br />#define GAMMAB(a) (pgm_read_byte(&amp;gamma_correctionB&#91;a&#93;))  // macro for BLUE<br /><br />//     bit = 0    bit = 1<br />//  +----+        |        +--------+    |<br />//  |    |        |        |        |    |<br />//  |    |        |        |        |    |<br />//  |    |        |        |        |    |<br />//  |    |        |        |        |    |<br />//  |    +--------+        |        +----+<br />//  400ns   800ns 800ns   400ns<br /><br /><br />#if DEBUG_ON==1<br /><br />void debug_test( void * line, uint32_t color){<br />if(!color){<br />*((uint8_t*)line ) = 0x0f;<br />*((uint8_t*)line + 1) = 0x0f;<br />*((uint8_t*)line + 2) = 0x0f;<br />}<br />else{<br />*((uint8_t*)line ) = color &gt;&gt; 8;<br />*((uint8_t*)line + 1) = color &gt;&gt; 16;<br />*((uint8_t*)line + 2) = color;<br />}<br />}<br /><br />#endif<br /><br /><br />//czyszczenie     pasek , color<br />void ws_cls(void * line, uint32_t color){<br /><br />if(!color) memset(line, 0, WS_LED_CNT*3);<br />else{<br />uint16_t x,i;<br />for(i=0; i&lt;WS_LED_CNT; i++){<br />x=i*3;<br />*((uint8_t*)line + x) = color &gt;&gt; 8;<br />*((uint8_t*)line + x+1) = color &gt;&gt; 16;<br />*((uint8_t*)line + x+2) = color;<br />}<br />}<br />ws281x_asm_send((uint8_t*)line, WS_LED_CNT, WS_PIN);<br />}<br /><br /><br /><br />// zapalanie pixela pasek, ktury piksel, color<br />void ws_set_pixel(void * line, int x, uint32_t color){<br /><br />if(x&lt;0) return;<br />if(x&gt;=WS_LED_CNT ) return;<br /><br />*((uint8_t*)line + x*3) = color &gt;&gt; 8;<br />*((uint8_t*)line + x*3+1) = color &gt;&gt; 16;<br />*((uint8_t*)line + x*3+2) = color;<br /><br />}<br /><br />// wyświetlanie lini      pasek, na jakiej pozycji, dlugosc paska, color<br />void ws_line(void * line, int x, uint16_t len, uint32_t color){<br /><br />int i;<br />for( i=x; i&lt;(int)(x+len); i++){<br />ws_set_pixel(line, i, color);<br />}<br /><br />}<br />//ws281x_asm_send(pasek, WS_LED_CNT, WS_PIN)  wysylanie bufora<br />void ws281x_asm_send( void *data, uint16_t datlen, uint8_t pin ) {<br /><br />uint8_t databyte=0, cnt, pinLO=~pin;<br />WS_DIR |= pin;<br />datlen *= 3;<br /><br />#if F_CPU == 16000000<br /><br />asm volatile(<br />&quot;lds%&#91;cnt&#93;,%&#91;ws_port&#93;\n\t&quot;<br />&quot;or%&#91;pinHI&#93;,%&#91;cnt&#93;\n\t&quot;<br />&quot;and%&#91;pinLO&#93;,%&#91;cnt&#93;\n\t&quot;<br />&quot;mPTL%=:subi%A6,1\n\t&quot;<br />&quot;sbci%B6,0\n\t&quot;<br />&quot;brcsexit%=\n\t&quot;<br />&quot;ld%&#91;databyte&#93;,X+\n\t&quot;<br />&quot;ldi%&#91;cnt&#93;,8\n\t&quot;<br /><br />&quot;oPTL%=:sts%&#91;ws_port&#93;,%&#91;pinHI&#93;\n\t&quot;<br />&quot;rjmp .+0\n\t&quot;<br /><br />&quot;lsl%&#91;databyte&#93;\n\t&quot;<br />&quot;brcs.+2\n\t&quot;<br />&quot;sts%&#91;ws_port&#93;,%&#91;pinLO&#93;\n\t&quot;<br />&quot;rjmp .+0\n\t&quot;<br />&quot;rjmp .+0\n\t&quot;<br /><br />&quot;dec%&#91;cnt&#93;\n\t&quot;<br />&quot;sts%&#91;ws_port&#93;,%&#91;pinLO&#93;\n\t&quot;<br />&quot;breqmPTL%=\n\t&quot;<br />&quot;rjmp .+0\n\t&quot;<br /><br />&quot;rjmpoPTL%=\n\t&quot;<br />&quot;exit%=:\n\t&quot;<br />:&#91;cnt&#93;&quot;=&amp;d&quot; (cnt)<br />:&#91;databyte&#93;&quot;r&quot; (databyte), &#91;ws_port&#93;&quot;M&quot; (_SFR_MEM_ADDR(WS_PORT)),<br /> &#91;pinHI&#93;&quot;r&quot; (pin), &#91;pinLO&#93;&quot;r&quot; (pinLO), &#91;data&#93;&quot;x&quot; (data), &#91;datlen&#93;&quot;r&quot; (datlen)<br />);<br /><br />#endif<br /><br />}<br /><br /><br />static uint32_t Interpolate2Colors(uint32_t A, uint32_t B, uint16_t pos, uint16_t max){<br /><br />TCLU AA, AB, AC;<br />AA.color =A;<br />AB.color =B;<br /><br />//interpolujemy wartości na kanałach<br />AC.cl&#91;cr&#93; =((((int32_t)AB.cl&#91;cr&#93; - AA.cl&#91;cr&#93;)*(int32_t)pos)/(int32_t)max + AA.cl&#91;cr&#93;); // &amp; 0xff;<br />AC.cl&#91;cg&#93; =((((int32_t)AB.cl&#91;cg&#93; - AA.cl&#91;cg&#93;)*(int32_t)pos)/(int32_t)max + AA.cl&#91;cg&#93;); // &amp; 0xff;<br />AC.cl&#91;cb&#93; =((((int32_t)AB.cl&#91;cb&#93; - AA.cl&#91;cb&#93;)*(int32_t)pos)/(int32_t)max + AA.cl&#91;cb&#93;); // &amp; 0xff;<br /><br /><br />return AC.color;<br />}<br />// pasek, pozycja na pasku, ilośc led, color a, color b<br />void gradient2c(void * line, int x, int len, uint32_t A, uint32_t B ){<br /><br />int i;<br />int alen = (int)(x+len);<br /><br />TCLU col;<br />TWSRGB * aline = line;<br /><br />for(i = x; i &lt; alen; i++){<br /><br />if(i &lt; 0 ) continue;<br />if(i &gt;= WS_LED_CNT+1 ) continue;<br /><br />col.color = Interpolate2Colors(A, B, i-x, len);<br /><br />aline&#91;i&#93;.r = GAMMAR(col.cl&#91;cr&#93;);<br />aline&#91;i&#93;.g = GAMMAG(col.cl&#91;cg&#93;);<br />aline&#91;i&#93;.b = GAMMAB(col.cl&#91;cb&#93;);<br /><br />}<br /><br />}[/syntax]<br /><br /><br />Pewnie mam gdzieś babola, ale puki co nie mogę go znaleźć.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=8203">xtreme69</a> — 14 lip 2015, o 21:53</p><hr />
]]></content>
</entry>
</feed>