<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[forum.rcl-radio.ru &mdash; Часы на адресной ленте WS2812 (Разработка)]]></title>
		<link>http://forum.rcl-radio.ru/viewtopic.php?id=651</link>
		<atom:link href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=651&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Часы на адресной ленте WS2812 (Разработка)».]]></description>
		<lastBuildDate>Thu, 13 Jun 2024 16:27:33 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Часы на адресной ленте WS2812 (Разработка)]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10511#p10511</link>
			<description><![CDATA[<p>А может быть это из за того что ардуинка питается от USB компутера, а лента от отдельного БП.?<br />Щас попробую запитать от БП.</p><p>Apd. <br />Нет все так же.<br />Щас впаял датчик темп. загрузил скетч со знаком &quot;t&quot;, все заработало, настройки запоминаются.</p><p>Еще вопросик, можно сделать так что бы при индикации времени мигали точки??<br />Я просто в програмировании полный барабан. Спаять все могу, а вот с кодированием беда.<br />Изучал всякие уроки, но дальше вкл/выкл. светодиод дело не идет. Мозги пенсионерские видно уже старые, входят в ступор.</p>]]></description>
			<author><![CDATA[null@example.com (mic1960)]]></author>
			<pubDate>Thu, 13 Jun 2024 16:27:33 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10511#p10511</guid>
		</item>
		<item>
			<title><![CDATA[Re: Часы на адресной ленте WS2812 (Разработка)]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10509#p10509</link>
			<description><![CDATA[<p>код так и делает, запоминает настройки. Почему у Вас так не происходит я понять не могу</p>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Thu, 13 Jun 2024 05:22:24 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10509#p10509</guid>
		</item>
		<item>
			<title><![CDATA[Re: Часы на адресной ленте WS2812 (Разработка)]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10506#p10506</link>
			<description><![CDATA[<p>Доброе утро.<br />Так я не говорю про ошибки.<br />Суть в том, что при отключении питания МК, и последующим включении яркость устанавливается на минимум.<br />А мне бы хотелось бы наоборот. А ещо лучше что б запоминало установленную яркость.</p>]]></description>
			<author><![CDATA[null@example.com (mic1960)]]></author>
			<pubDate>Thu, 13 Jun 2024 04:28:29 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10506#p10506</guid>
		</item>
		<item>
			<title><![CDATA[Re: Часы на адресной ленте WS2812 (Разработка)]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10505#p10505</link>
			<description><![CDATA[<p>не вижу ошибок.<br />После изменения яркости и цвета подсветки ждете 10 сек прежде чем перезагрузить микроконтроллер?</p>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Thu, 13 Jun 2024 02:46:27 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10505#p10505</guid>
		</item>
		<item>
			<title><![CDATA[Часы на адресной ленте WS2812 (Разработка)]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10504#p10504</link>
			<description><![CDATA[<p>Привет всем.<br />Помогите подправить скетч из этой темы.<br /><a href="http://forum.rcl-radio.ru/viewtopic.php?id=432">http://forum.rcl-radio.ru/viewtopic.php?id=432</a></p><p>При включении устанавливается яркость на минимуме.<br />Цвет красный.<br />Что нужно переписать что бы яркость при включении была на максимуме, а цвет зеленый.</p><p>// Atmega328, Atmega8 16MHz</p><p>#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br />#define ADDR_DS3231&nbsp; &nbsp; 0b1101000<br />#define CPU_F&nbsp; &nbsp;16000000 // Clock Speed <br />#define SCL_F&nbsp; &nbsp;100000 // // I2C Speed<br />#define L_BIT&nbsp; &nbsp; PORTB &amp;= ~(1&lt;&lt;PB0)<br />#define H_BIT&nbsp; &nbsp; PORTB |=&nbsp; (1&lt;&lt;PB0)&nbsp; &nbsp; <br />#define LED_MAX 88</p><p>&nbsp; byte rr[LED_MAX],gg[LED_MAX],bb[LED_MAX],r,g,b;<br />&nbsp; int i,up,down,brig=1,hh,mm;<br />&nbsp; byte sec,min,hour,datat,mont,year,day;<br />&nbsp; byte r_led=0,g_led=1,b_led=0;<br />&nbsp; byte mode;<br />&nbsp; bool sett,w,w1;<br />&nbsp; unsigned long times,times0;</p><p>int main(void){<br />&nbsp; &nbsp; cli();<br />&nbsp; TWBR = (((CPU_F)/(SCL_F)-16 )/2) ;<br />&nbsp; TWSR = 0;<br />&nbsp; DDRD &amp;= ~(1&lt;&lt;PD2);// INPUT SQW DS3231<br />&nbsp; DDRB |= (1&lt;&lt;PB0); // INPUT WS2812B (D8 - ARDUINO)<br />&nbsp; DDRD &amp;= ~(1&lt;&lt;PD3);// INPUT BUTTON MODE<br />&nbsp; DDRD &amp;= ~(1&lt;&lt;PD4);// INPUT BUTTON UP<br />&nbsp; DDRD &amp;= ~(1&lt;&lt;PD5);// INPUT BUTTON DOWN<br />&nbsp; DDRD &amp;= ~(1&lt;&lt;PD6);// INPUT BUTTON SET<br />&nbsp; PORTD |= (1&lt;&lt;PD3);PORTD |= (1&lt;&lt;PD4);PORTD |= (1&lt;&lt;PD5);PORTD |= (1&lt;&lt;PD6);<br />&nbsp; DDRB |= (1&lt;&lt;PB0); // INPUT WS2812B (D8 - ARDUINO)<br />&nbsp; DDRD &amp;= ~(1&lt;&lt;PD2);// BUTTON (D2 - ARDUINO)<br />&nbsp; PORTD |=(1&lt;&lt;PD2); // INPUT_PULLUP<br />&nbsp; /// TIMER 0 = 1ms<br />&nbsp; ADCSRA = 0b10000100; <br />&nbsp; TCCR0A = 0;TCCR0B = 0;TCNT0 = 0;<br />&nbsp; OCR0A = 249;<br />&nbsp; TCCR0A |= (1 &lt;&lt; WGM01);<br />&nbsp; TCCR0B |= (1 &lt;&lt; CS01) | (1 &lt;&lt; CS00);<br />&nbsp; TIMSK0 |= (1 &lt;&lt; OCIE0A);<br />&nbsp; sei();<br />&nbsp; _delay_ms(100);<br />&nbsp; i2c_write(ADDR_DS3231,0x0E,0b00000000);<br />&nbsp; //set_time(21,1,12,26,12,12,0);// год 00-99, ДН 1-7 (1=ВС), месяц 1-12, дата 1-31, час 0-23, минуты 0-59, секунды 0-59<br />&nbsp; if(EEPROM_read(100)!=0){for(int i1=0;i1&lt;101;i1++){EEPROM_write(i1,1);}}// очистка памяти при первом включении&nbsp; &nbsp;<br />&nbsp; mode = EEPROM_read(0);brig = EEPROM_read(1);</p><p>while(1){<br />/////// BUTTON ///////////////////////////////////////////////<br />&nbsp; if(((PIND &gt;&gt; PD3) &amp; 1) == 0){mode++;if(mode&gt;7){mode=0;}_delay_ms(300);w=1;times0=times;}<br />&nbsp; switch(mode){<br />&nbsp; &nbsp; case 0: r_led=1,g_led=1,b_led=1; break;<br />&nbsp; &nbsp; case 1: r_led=1,g_led=0,b_led=0; break;<br />&nbsp; &nbsp; case 2: r_led=0,g_led=1,b_led=0; break;<br />&nbsp; &nbsp; case 3: r_led=0,g_led=0,b_led=1; break;<br />&nbsp; &nbsp; case 4: r_led=1,g_led=1,b_led=0; break;<br />&nbsp; &nbsp; case 5: r_led=1,g_led=0,b_led=1; break;<br />&nbsp; &nbsp; case 6: r_led=0,g_led=1,b_led=1; break;<br />&nbsp; &nbsp; case 7: r_led=0,g_led=0,b_led=0; break;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp;if(((PIND &gt;&gt; PD4) &amp; 1) == 0 &amp;&amp; sett==0){brig++;if(brig&gt;255){brig=255;}_delay_ms(1);w=1;times0=times;} <br />&nbsp; &nbsp;if(((PIND &gt;&gt; PD5) &amp; 1) == 0 &amp;&amp; sett==0){brig--;if(brig&lt;1){brig=1;}_delay_ms(1);w=1;times0=times;} <br />&nbsp; &nbsp;if(((PIND &gt;&gt; PD6) &amp; 1) == 0 &amp;&amp; sett==0){sett=1;_delay_ms(300);}<br />&nbsp; &nbsp;if(((PIND &gt;&gt; PD6) &amp; 1) == 0 &amp;&amp; sett==1){sett=0;_delay_ms(300);}&nbsp; &nbsp;</p><p>/////// READ TIME ////////////////////////////////////////////&nbsp; <br />&nbsp; &nbsp;sec =&nbsp; (i2c_read_1bit(ADDR_DS3231,0) &amp; 0x0F) + (((i2c_read_1bit(ADDR_DS3231,0) &amp; 0x70) &gt;&gt; 4) * 10);<br />&nbsp; &nbsp;min =&nbsp; (i2c_read_1bit(ADDR_DS3231,1) &amp; 0x0F) + (((i2c_read_1bit(ADDR_DS3231,1) &amp; 0x70) &gt;&gt; 4) * 10);<br />&nbsp; &nbsp;hour = ((i2c_read_1bit(ADDR_DS3231,2) &amp; 0x0F) + ((i2c_read_1bit(ADDR_DS3231,2) &amp; 0x70) &gt;&gt; 4) * 10);<br />&nbsp; &nbsp;i = hour*100+min;<br />&nbsp; &nbsp;<br />//////////// SET TIME ////////////////////////////////////////////////////////////////////// <br /> if(sett==1){<br />&nbsp; hh=hour;<br />&nbsp; mm=min;<br />&nbsp; if(((PIND &gt;&gt; PD4) &amp; 1) == 0){hh++;if(hh&gt;23){hh=0;}_delay_ms(100);w1=1;} <br />&nbsp; if(((PIND &gt;&gt; PD5) &amp; 1) == 0){mm++;if(mm&gt;59){mm=1;}_delay_ms(100);w1=1;} <br />&nbsp; if(w1==1){w1=0;set_time(21,1,12,26,hh,mm,0);}<br />&nbsp; i = hh*100+mm;<br />&nbsp; }<br />////////// RGB ////////////////////////////////////////////////<br />&nbsp; switch(i/1000){&nbsp; &nbsp;<br />&nbsp; &nbsp; case 0: ws(0,1);ws(3,1);ws(6,1);ws(9,0);ws(12,1);ws(15,1);ws(18,1);break;<br />&nbsp; &nbsp; case 1: ws(0,0);ws(3,0);ws(6,1);ws(9,0);ws(12,0);ws(15,0);ws(18,1);break;<br />&nbsp; &nbsp; case 2: ws(0,0);ws(3,1);ws(6,1);ws(9,1);ws(12,1);ws(15,1);ws(18,0);break;<br />&nbsp; &nbsp; case 3: ws(0,0);ws(3,1);ws(6,1);ws(9,1);ws(12,0);ws(15,1);ws(18,1);break;<br />&nbsp; &nbsp; case 4: ws(0,1);ws(3,0);ws(6,1);ws(9,1);ws(12,0);ws(15,0);ws(18,1);break;<br />&nbsp; &nbsp; case 5: ws(0,1);ws(3,1);ws(6,0);ws(9,1);ws(12,0);ws(15,1);ws(18,1);break;<br />&nbsp; &nbsp; case 6: ws(0,1);ws(3,1);ws(6,0);ws(9,1);ws(12,1);ws(15,1);ws(18,1);break;<br />&nbsp; &nbsp; case 7: ws(0,0);ws(3,1);ws(6,1);ws(9,0);ws(12,0);ws(15,0);ws(18,1);break;<br />&nbsp; &nbsp; case 8: ws(0,1);ws(3,1);ws(6,1);ws(9,1);ws(12,1);ws(15,1);ws(18,1);break;<br />&nbsp; &nbsp; case 9: ws(0,1);ws(3,1);ws(6,1);ws(9,1);ws(12,0);ws(15,1);ws(18,1);break;<br />&nbsp; &nbsp; } <br />&nbsp; switch(i/100%10){&nbsp; &nbsp;<br />&nbsp; &nbsp; case 0: ws(21,1);ws(24,1);ws(27,1);ws(30,0);ws(33,1);ws(36,1);ws(39,1);break;<br />&nbsp; &nbsp; case 1: ws(21,0);ws(24,0);ws(27,1);ws(30,0);ws(33,0);ws(36,0);ws(39,1);break;<br />&nbsp; &nbsp; case 2: ws(21,0);ws(24,1);ws(27,1);ws(30,1);ws(33,1);ws(36,1);ws(39,0);break;<br />&nbsp; &nbsp; case 3: ws(21,0);ws(24,1);ws(27,1);ws(30,1);ws(33,0);ws(36,1);ws(39,1);break;<br />&nbsp; &nbsp; case 4: ws(21,1);ws(24,0);ws(27,1);ws(30,1);ws(33,0);ws(36,0);ws(39,1);break;<br />&nbsp; &nbsp; case 5: ws(21,1);ws(24,1);ws(27,0);ws(30,1);ws(33,0);ws(36,1);ws(39,1);break;<br />&nbsp; &nbsp; case 6: ws(21,1);ws(24,1);ws(27,0);ws(30,1);ws(33,1);ws(36,1);ws(39,1);break;<br />&nbsp; &nbsp; case 7: ws(21,0);ws(24,1);ws(27,1);ws(30,0);ws(33,0);ws(36,0);ws(39,1);break;<br />&nbsp; &nbsp; case 8: ws(21,1);ws(24,1);ws(27,1);ws(30,1);ws(33,1);ws(36,1);ws(39,1);break;<br />&nbsp; &nbsp; case 9: ws(21,1);ws(24,1);ws(27,1);ws(30,1);ws(33,0);ws(37,1);ws(39,1);break;<br />&nbsp; &nbsp; } <br />&nbsp; &nbsp; <br />&nbsp; &nbsp; if(((PIND &gt;&gt; PD2) &amp; 1) == 0 &amp;&amp; sett==0){data_led(42, r_led*brig, g_led*brig, b_led*brig);data_led(43, r_led*brig, g_led*brig, b_led*brig);<br />&nbsp; &nbsp; data_led(44, r_led*brig, g_led*brig, b_led*brig);data_led(45, r_led*brig, g_led*brig, b_led*brig);}<br />&nbsp; &nbsp; else{data_led(42, 0, 0, 0);data_led(43, 0, 0, 0);data_led(44, 0, 0, 0);data_led(45, 0, 0, 0);}<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; if(sett==1){data_led(42, 0, brig, 0);data_led(43, brig, 0, 0);data_led(44, 0, brig, 0);data_led(45, brig, 0, 0);}<br />&nbsp; &nbsp; &nbsp;<br />&nbsp; switch(i/10%10){&nbsp; &nbsp;<br />&nbsp; &nbsp; case 0: ws(46,1);ws(49,1);ws(52,1);ws(55,0);ws(58,1);ws(61,1);ws(64,1);break;<br />&nbsp; &nbsp; case 1: ws(46,0);ws(49,0);ws(52,1);ws(55,0);ws(58,0);ws(61,0);ws(64,1);break;<br />&nbsp; &nbsp; case 2: ws(46,0);ws(49,1);ws(52,1);ws(55,1);ws(58,1);ws(61,1);ws(64,0);break;<br />&nbsp; &nbsp; case 3: ws(46,0);ws(49,1);ws(52,1);ws(55,1);ws(58,0);ws(61,1);ws(64,1);break;<br />&nbsp; &nbsp; case 4: ws(46,1);ws(49,0);ws(52,1);ws(55,1);ws(58,0);ws(61,0);ws(64,1);break;<br />&nbsp; &nbsp; case 5: ws(46,1);ws(49,1);ws(52,0);ws(55,1);ws(58,0);ws(61,1);ws(64,1);break;<br />&nbsp; &nbsp; case 6: ws(46,1);ws(49,1);ws(52,0);ws(55,1);ws(58,1);ws(61,1);ws(64,1);break;<br />&nbsp; &nbsp; case 7: ws(46,0);ws(49,1);ws(52,1);ws(55,0);ws(58,0);ws(61,0);ws(64,1);break;<br />&nbsp; &nbsp; case 8: ws(46,1);ws(49,1);ws(52,1);ws(55,1);ws(58,1);ws(61,1);ws(64,1);break;<br />&nbsp; &nbsp; case 9: ws(46,1);ws(49,1);ws(52,1);ws(55,1);ws(58,0);ws(61,1);ws(64,1);break;<br />&nbsp; &nbsp; }&nbsp; <br />&nbsp; switch(i%10){&nbsp; &nbsp;<br />&nbsp; &nbsp; case 0: ws(67,1);ws(70,1);ws(73,1);ws(76,0);ws(79,1);ws(82,1);ws(85,1);break;<br />&nbsp; &nbsp; case 1: ws(67,0);ws(70,0);ws(73,1);ws(76,0);ws(79,0);ws(82,0);ws(85,1);break;<br />&nbsp; &nbsp; case 2: ws(67,0);ws(70,1);ws(73,1);ws(76,1);ws(79,1);ws(82,1);ws(85,0);break;<br />&nbsp; &nbsp; case 3: ws(67,0);ws(70,1);ws(73,1);ws(76,1);ws(79,0);ws(82,1);ws(85,1);break;<br />&nbsp; &nbsp; case 4: ws(67,1);ws(70,0);ws(73,1);ws(76,1);ws(79,0);ws(82,0);ws(85,1);break;<br />&nbsp; &nbsp; case 5: ws(67,1);ws(70,1);ws(73,0);ws(76,1);ws(79,0);ws(82,1);ws(85,1);break;<br />&nbsp; &nbsp; case 6: ws(67,1);ws(70,1);ws(73,0);ws(76,1);ws(79,1);ws(82,1);ws(85,1);break;<br />&nbsp; &nbsp; case 7: ws(67,0);ws(70,1);ws(73,1);ws(76,0);ws(79,0);ws(82,0);ws(85,1);break;<br />&nbsp; &nbsp; case 8: ws(67,1);ws(70,1);ws(73,1);ws(76,1);ws(79,1);ws(82,1);ws(85,1);break;<br />&nbsp; &nbsp; case 9: ws(67,1);ws(70,1);ws(73,1);ws(76,1);ws(79,0);ws(82,1);ws(85,1);break;<br />&nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; led_rgb();res();<br />&nbsp; &nbsp; _delay_ms(100);</p><p>////// EEPROM ///////////////////<br /> if(times-times0&gt;10000&amp;&amp;w==1){EEPROM_write(0,mode);EEPROM_write(1,brig);w=0;}&nbsp; <br />}} // end loop</p><p>void ws(int ind, bool datt){<br />&nbsp; if(datt==1){data_led(ind, r_led*brig, g_led*brig, b_led*brig);data_led(ind+1, r_led*brig, g_led*brig, b_led*brig);data_led(ind+2, r_led*brig, g_led*brig, b_led*brig);}<br />&nbsp; if(datt==0){data_led(ind, 0, 0, 0);data_led(ind+1, 0, 0, 0);data_led(ind+2, 0, 0, 0);}}<br />&nbsp; <br />void bit_0(){H_BIT;asm(&quot;nop&quot;);asm(&quot;nop&quot;);&nbsp; &nbsp;L_BIT;asm(&quot;nop&quot;);asm(&quot;nop&quot;);asm(&quot;nop&quot;);&nbsp; &nbsp;asm(&quot;nop&quot;);} <br />void bit_1(){H_BIT;asm(&quot;nop&quot;);asm(&quot;nop&quot;);asm(&quot;nop&quot;);asm(&quot;nop&quot;);asm(&quot;nop&quot;);asm(&quot;nop&quot;);asm(&quot;nop&quot;);asm(&quot;nop&quot;);&nbsp; &nbsp;L_BIT;}<br />void bit_w(bool x){if(x) bit_1(); else bit_0();}<br />void res(){_delay_us(100);}<br />void data_led(int num, byte rrr, byte ggg, byte bbb){bb[num]=bbb;rr[num]=rrr;gg[num]=ggg;}<br />void led_rgb(){<br />&nbsp; for(int num_i=0;num_i&lt;LED_MAX;num_i++){ <br />&nbsp; cli();<br />bit_w((bb[num_i] &amp; 0x80)&gt;&gt;7);<br />bit_w((bb[num_i] &amp; 0x40)&gt;&gt;6);<br />bit_w((bb[num_i] &amp; 0x20)&gt;&gt;5);<br />bit_w((bb[num_i] &amp; 0x10)&gt;&gt;4);<br />bit_w((bb[num_i] &amp; 0x08)&gt;&gt;3);<br />bit_w((bb[num_i] &amp; 0x04)&gt;&gt;2);<br />bit_w((bb[num_i] &amp; 0x02)&gt;&gt;1);<br />bit_w((bb[num_i] &amp; 0x01)&gt;&gt;0);<br />&nbsp; <br />bit_w((rr[num_i] &amp; 0x80)&gt;&gt;7);<br />bit_w((rr[num_i] &amp; 0x40)&gt;&gt;6);<br />bit_w((rr[num_i] &amp; 0x20)&gt;&gt;5);<br />bit_w((rr[num_i] &amp; 0x10)&gt;&gt;4);<br />bit_w((rr[num_i] &amp; 0x08)&gt;&gt;3);<br />bit_w((rr[num_i] &amp; 0x04)&gt;&gt;2);<br />bit_w((rr[num_i] &amp; 0x02)&gt;&gt;1);<br />bit_w((rr[num_i] &amp; 0x01)&gt;&gt;0);</p><p>bit_w((gg[num_i] &amp; 0x80)&gt;&gt;7);<br />bit_w((gg[num_i] &amp; 0x40)&gt;&gt;6);<br />bit_w((gg[num_i] &amp; 0x20)&gt;&gt;5);<br />bit_w((gg[num_i] &amp; 0x10)&gt;&gt;4);<br />bit_w((gg[num_i] &amp; 0x08)&gt;&gt;3);<br />bit_w((gg[num_i] &amp; 0x04)&gt;&gt;2);<br />bit_w((gg[num_i] &amp; 0x02)&gt;&gt;1);<br />bit_w((gg[num_i] &amp; 0x01)&gt;&gt;0);<br />&nbsp; &nbsp;sei(); <br />}}</p><p>void set_time(byte years, byte days, byte monts, byte datas, byte hours ,byte minute, byte second){<br />&nbsp; &nbsp; if(second &lt; 255){i2c_write(ADDR_DS3231,0x00,(second/10&lt;&lt;4)+second%10);}<br />&nbsp; &nbsp; if(minute &lt; 255){i2c_write(ADDR_DS3231,0x01,(minute/10&lt;&lt;4)+minute%10);} <br />&nbsp; &nbsp; if(hours &lt; 255){i2c_write(ADDR_DS3231,0x02,(hours/10&lt;&lt;4)+hours%10);}<br />&nbsp; &nbsp; if(days &lt; 255){i2c_write(ADDR_DS3231,0x03,days);}<br />&nbsp; &nbsp; if(datas &lt; 255){i2c_write(ADDR_DS3231,0x04,(datas/10&lt;&lt;4)+datas%10);}<br />&nbsp; &nbsp; if(monts &lt; 255){i2c_write(ADDR_DS3231,0x05,(monts/10&lt;&lt;4)+monts%10);}<br />&nbsp; &nbsp; if(years &lt; 255){i2c_write(ADDR_DS3231,0x06,(years/10&lt;&lt;4)+years%10);}<br />&nbsp; }&nbsp; &nbsp; </p><br /><p>int i2c_read_1bit(byte i2c_addr, byte i2c_reg){<br />&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWSTA)|(1&lt;&lt;TWEN);&nbsp; // START<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT)));<br />&nbsp; &nbsp;TWDR = i2c_addr &lt;&lt; 1;<br />&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT) | (1&lt;&lt;TWEN);<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT)));<br />&nbsp; &nbsp;TWDR = i2c_reg;<br />&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT) | (1&lt;&lt;TWEN);<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT)));</p><p>&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWSTA)|(1&lt;&lt;TWEN);&nbsp; // START<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT))); <br />&nbsp; &nbsp;TWDR = (i2c_addr &lt;&lt; 1) | 1;<br />&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT) | (1&lt;&lt;TWEN);<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT)));</p><p>&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWEN)|(1&lt;&lt;TWEA); <br />&nbsp; while(~TWCR&amp;(1&lt;&lt;TWINT));<br />&nbsp; &nbsp; byte i2c_data = TWDR; <br />&nbsp; TWCR = (1&lt;&lt;TWINT) | (1&lt;&lt;TWEN);<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT)));</p><p>&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWEN)|(1&lt;&lt;TWSTO); // СТОП<br />&nbsp; return i2c_data;<br />&nbsp; } <br />&nbsp; &nbsp;<br /> void i2c_write(byte i2c_addr, byte i2c_reg, byte i2c_dat){<br />&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWSTA)|(1&lt;&lt;TWEN);&nbsp; // START<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT)));<br />&nbsp; &nbsp;TWDR = i2c_addr &lt;&lt; 1;<br />&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT) | (1&lt;&lt;TWEN);<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT)));<br />&nbsp; &nbsp;TWDR = i2c_reg;<br />&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT) | (1&lt;&lt;TWEN);<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT)));<br />&nbsp; &nbsp;TWDR = i2c_dat;<br />&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT) | (1&lt;&lt;TWEN);<br />&nbsp; while (!(TWCR &amp; (1&lt;&lt;TWINT)));<br />&nbsp; &nbsp;TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWEN)|(1&lt;&lt;TWSTO); // СТОП<br />&nbsp; } </p><p>ISR(TIMER0_COMPA_vect) {times++;}// millis = 1 ms&nbsp; &nbsp; &nbsp;</p><p>unsigned char EEPROM_read(unsigned int uiAddress){<br />&nbsp; while(EECR &amp; (1&lt;&lt;EEPE));&nbsp; // проверка готовности EEPROM <br />&nbsp; &nbsp; EEARH = ((uiAddress &amp; 0xF0) &lt;&lt; 2); // регистр адреса H<br />&nbsp; &nbsp; EEARL = uiAddress &amp; 0x0F; // регистр адреса L<br />&nbsp; &nbsp; EECR |= (1&lt;&lt;EERE);// чтение EEPROM<br />&nbsp; &nbsp; return EEDR; // вывод значения<br />}</p><p>void EEPROM_write(unsigned int uiAddress, unsigned char ucData){<br />&nbsp; while(EECR &amp; (1&lt;&lt;EEPE)); // проверка готовности EEPROM <br />&nbsp; &nbsp; EEARH = ((uiAddress &amp; 0xF0) &lt;&lt; 2); // регистр адреса H<br />&nbsp; &nbsp; EEARL = uiAddress &amp; 0x0F; // регистр адреса L<br />&nbsp; &nbsp; EEDR = ucData; // регистр данных <br />&nbsp; &nbsp; EECR |= (1&lt;&lt;EEMPE);// Разрешение записи в EEPROM<br />&nbsp; &nbsp; EECR |= (1&lt;&lt;EEPE); // Запись в EEPROM<br />}</p>]]></description>
			<author><![CDATA[null@example.com (mic1960)]]></author>
			<pubDate>Wed, 12 Jun 2024 17:20:32 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10504#p10504</guid>
		</item>
	</channel>
</rss>
