<?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; Термометр на DS18B20 с большими цифрами]]></title>
		<link>http://forum.rcl-radio.ru/viewtopic.php?id=487</link>
		<atom:link href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=487&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Термометр на DS18B20 с большими цифрами».]]></description>
		<lastBuildDate>Thu, 09 Jan 2025 07:37:41 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=11261#p11261</link>
			<description><![CDATA[<p>Мой вариант термометра с автоотключением через 30с. от ип. <br /></p><div class="codebox"><pre><code>#include &lt;avr/io.h&gt;
#include &lt;util/delay.h&gt;
unsigned long Alarm =30000; // 30с. индикации 
#define I2C_SDA         PB3                   
#define I2C_SCL         PB4                  
#define TEMP            PB0
     
#define I2C_SDA_HIGH()  DDRB &amp;= ~(1&lt;&lt;I2C_SDA) 
#define I2C_SDA_LOW()   DDRB |=  (1&lt;&lt;I2C_SDA) 
#define I2C_SCL_HIGH()  DDRB &amp;= ~(1&lt;&lt;I2C_SCL) 
#define I2C_SCL_LOW()   DDRB |=  (1&lt;&lt;I2C_SCL) 
 
int main(void) {
 pinMode(1, OUTPUT);                      
 digitalWrite(1,HIGH);
    OLED_init();
    OLED_clear();
  
while(1) { 
  byte a0,a1,a2,a3,z;
  while ( millis()&lt; Alarm){ 
  int temp = read_temp();
  if(temp&lt;0){temp=-temp;
     z = 18;
    }
    else{
     z=19;}
     a0 = temp/1000%10;
     a1 = temp/100%10;
     if(a0==1)a0=1;
     else {a0=19;
     if(a1==0)a1=19;}
     a2 = temp/10%10;
     a3 = temp%10;
     uint8_t buffer[8] = {z, a0, a1, a2, 16,a3 , 20, 12};
    OLED_printB(buffer);
    _delay_ms(1000); }
    OLED_clear();
   digitalWrite(1,LOW);
 
                     
}}
 
///// I2C ///////////////////////////////////////////////////////
void I2C_init(void) {DDRB  &amp;= ~((1&lt;&lt;I2C_SDA)|(1&lt;&lt;I2C_SCL)); PORTB &amp;= ~((1&lt;&lt;I2C_SDA)|(1&lt;&lt;I2C_SCL));}
void I2C_write(uint8_t data) {
  for(uint8_t i = 8; i; i--) {I2C_SDA_LOW();                        
    if (data &amp; 0x80) I2C_SDA_HIGH();I2C_SCL_HIGH();data&lt;&lt;=1;I2C_SCL_LOW();}
  I2C_SDA_HIGH();I2C_SCL_HIGH();asm(&quot;nop&quot;);I2C_SCL_LOW();                         
}
void I2C_start(uint8_t addr) {I2C_SDA_LOW();I2C_SCL_LOW();I2C_write(addr);}
void I2C_stop(void) {I2C_SDA_LOW();I2C_SCL_HIGH();I2C_SDA_HIGH();}
 
///// OLED ///////////////////////////////////
#define OLED_ADDR       0x78                  
#define OLED_CMD_MODE   0x00                  
#define OLED_DAT_MODE   0x40                  
#define OLED_INIT_LEN   15 
 
// OLED init settings
const uint8_t OLED_INIT_CMD[] PROGMEM = {
  0xA8, 0x1F,       
  0x22, 0x00, 0x03, 
  0x20, 0x01,       
  0xDA, 0x02,       
  0x8D, 0x14,       
  0xAF,             
  0x00, 0x10, 0xB0, 
  0xA1, 0xC8        
};
 
// Simple reduced 3x8 font
const uint8_t OLED_FONT[] PROGMEM = {
  0x7F, 0x41, 0x7F, // 0  
  0x00, 0x02, 0x7F, // 1  1
  0x79, 0x49, 0x4F, // 2  2
  0x41, 0x49, 0x7F, // 3  3
  0x0F, 0x08, 0x7F, // 4  4
  0x4F, 0x49, 0x79, // 5  5
  0x7F, 0x49, 0x79, // 6  6
  0x03, 0x01, 0x7F, // 7  7
  0x7F, 0x49, 0x7F, // 8  8
  0x4F, 0x49, 0x7F, // 9  9
  0x7F, 0x09, 0x7F, // A 10
  0x7F, 0x48, 0x78, // b 11
  0x7F, 0x41, 0x63, // C 12
  0x78, 0x48, 0x7F, // d 13
  0x7F, 0x49, 0x41, // E 14
  0x7F, 0x09, 0x01, // F 15
  0x00, 0x60, 0x00, // . 16
  0x00, 0x36, 0x00, // : 17
  0x08, 0x08, 0x08, // - 18
  0x00, 0x00, 0x00,  //   19
  0x02, 0x05, 0x02,  //  degrees
};
 
void OLED_cursor(uint8_t xpos, uint8_t ypos) {
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  I2C_write(xpos &amp; 0x0F);                 
  I2C_write(0x10 | (xpos &gt;&gt; 4));     
  I2C_write(0xB0 | (ypos &amp; 0x07));    
  I2C_stop();                           
}
 
void OLED_clear(void) {
  OLED_cursor(0, 0);                      
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_DAT_MODE);              
  for(uint16_t i=512; i; i--) I2C_write(0x00); 
  I2C_stop();  
}
 
void OLED_init(void) {
  I2C_init();                             
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  for (uint8_t i = 0; i &lt; OLED_INIT_LEN; i++) I2C_write(pgm_read_byte(&amp;OLED_INIT_CMD[i])); 
  I2C_stop();                            
}
 
uint8_t OLED_stretch(uint8_t b){b=((b &amp; 2)&lt;&lt;3)|(b&amp;1);b|=b&lt;&lt;1;b|=b&lt;&lt;2;return b;}
 
void OLED_printD(uint8_t ch) {
  uint8_t i, j, k, b;                     
  uint8_t sb[4];                          
  ch += ch &lt;&lt; 1;                          
  for(i=8; i; i--) I2C_write(0x00);       
  for(i=3; i; i--) {                      
    b = pgm_read_byte(&amp;OLED_FONT[ch++]);  
    for(j=0; j&lt;4; j++, b &gt;&gt;= 2) sb[j] = OLED_stretch(b);  
    j=4; if(i==2) j=6;               
    while(j--) {                    
      for(k=0; k&lt;4; k++) I2C_write(sb[k]);
}}}
 
void OLED_printB(uint8_t *buffer) {
  I2C_start(OLED_ADDR);      
  I2C_write(OLED_DAT_MODE);              
  for(uint8_t i=0; i&lt;8; i++) OLED_printD(buffer[i]); 
  I2C_stop();                            
}
 void DisplayOnOff (byte On) {
  I2C_start(OLED_ADDR);      
  I2C_write(OLED_DAT_MODE); 
  I2C_write(0xAE + On);
  I2C_stop();
}
//// DS18B20 //////////////////////////////////////
uint8_t therm_reset(){
    uint8_t i;
    PORTB &amp;= ~(1 &lt;&lt; TEMP);
    DDRB |= (1 &lt;&lt; TEMP);
    _delay_us(480);  
    DDRB &amp;= ~(1 &lt;&lt; TEMP);
    _delay_us(60);
    i=((PINB &gt;&gt; TEMP) &amp; 1);
    _delay_us(420);
    return i;
}
void therm_write_bit(uint8_t bit){
    DDRB |= (1 &lt;&lt; TEMP);
    if(bit) DDRB &amp;= ~(1 &lt;&lt; TEMP);
    _delay_us(60);
    DDRB &amp;= ~(1 &lt;&lt; TEMP);
}
uint8_t therm_read_bit(void){
    uint8_t bit=0;
    DDRB |= (1 &lt;&lt; TEMP);
    DDRB &amp;= ~(1 &lt;&lt; TEMP);
    _delay_us(14);
    if(PINB &amp; (1 &lt;&lt; TEMP)) bit=1;
    _delay_us(45);
    return bit;
}
uint8_t therm_read_byte(void){
    uint8_t i=8, n=0;
    while(i--){n&gt;&gt;=1;n|=(therm_read_bit()&lt;&lt;7);}
    return n;
}
void therm_write_byte(uint8_t byte){
    uint8_t i=8;
    while(i--){therm_write_bit(byte&amp;1);byte &gt;&gt;= 1;
    }}
int read_temp(){
    uint8_t temperature[2];
    int temper;
    therm_reset();
    therm_write_byte(0xCC);
    therm_write_byte(0x44);
    while(!therm_read_bit());
    therm_reset();
    therm_write_byte(0xCC);
    therm_write_byte(0xBE);
    temperature[0]=therm_read_byte();
    temperature[1]=therm_read_byte();
    therm_reset();
    return temper = (temperature[1] &lt;&lt; 8 | temperature[0])*10/16;
}</code></pre></div><p>Работает совместно с транзисторным ключом с выходом PB1 attiny.<br /><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2025/01/59d518b57a25e9ccbbe8ed6e07be363a.bmp" alt="http://forum.rcl-radio.ru/uploads/images/2025/01/59d518b57a25e9ccbbe8ed6e07be363a.bmp" /></span></p>]]></description>
			<author><![CDATA[null@example.com (klause)]]></author>
			<pubDate>Thu, 09 Jan 2025 07:37:41 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=11261#p11261</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10634#p10634</link>
			<description><![CDATA[<p>Урааа, заработало как хотел. Спасибо огромное .</p>]]></description>
			<author><![CDATA[null@example.com (vit)]]></author>
			<pubDate>Thu, 15 Aug 2024 09:46:47 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10634#p10634</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10628#p10628</link>
			<description><![CDATA[<div class="codebox"><pre><code>#include &lt;avr/io.h&gt;
#include &lt;util/delay.h&gt;
 
// Project Files (Github):  https://github.com/wagiminator/ATtiny13-TinyOLEDdemo
// License: http://creativecommons.org/licenses/by-sa/3.0/
 
#define I2C_SDA         PB3                   
#define I2C_SCL         PB4                  
#define TEMP            PB0
#define BUTTON          PB2
 
#define I2C_SDA_HIGH()  DDRB &amp;= ~(1&lt;&lt;I2C_SDA) 
#define I2C_SDA_LOW()   DDRB |=  (1&lt;&lt;I2C_SDA) 
#define I2C_SCL_HIGH()  DDRB &amp;= ~(1&lt;&lt;I2C_SCL) 
#define I2C_SCL_LOW()   DDRB |=  (1&lt;&lt;I2C_SCL) 

bool minus;
uint8_t buffer[8];
 
int main(void) {
    PORTB |=(1 &lt;&lt; BUTTON);
    OLED_init();
    OLED_clear();                    
 
while(1) { 
    if(((PINB &gt;&gt; BUTTON) &amp; 1) == 0){   
    int temp = read_temp();
    if(temp&lt;0){minus=1;temp=-temp;}else{minus=0;}
    byte a0 = temp/1000%10;
    byte a1 = temp/100%10;
    byte a2 = temp/10%10;
    byte a3 = temp%10;
    if(minus==0){uint8_t buffer0[8] = {19, a0, a1, 16, a2, a3, 19, 12};OLED_printB(buffer0);}
     else{uint8_t buffer1[8] = {18, a0, a1, 16, a2, a3, 19, 12};OLED_printB(buffer1); }                                              
    _delay_ms(1000);}
    OLED_clear();                   
}}
 
///// I2C ///////////////////////////////////////////////////////
void I2C_init(void) {DDRB  &amp;= ~((1&lt;&lt;I2C_SDA)|(1&lt;&lt;I2C_SCL)); PORTB &amp;= ~((1&lt;&lt;I2C_SDA)|(1&lt;&lt;I2C_SCL));}
void I2C_write(uint8_t data) {
  for(uint8_t i = 8; i; i--) {I2C_SDA_LOW();                        
    if (data &amp; 0x80) I2C_SDA_HIGH();I2C_SCL_HIGH();data&lt;&lt;=1;I2C_SCL_LOW();}
  I2C_SDA_HIGH();I2C_SCL_HIGH();asm(&quot;nop&quot;);I2C_SCL_LOW();                         
}
void I2C_start(uint8_t addr) {I2C_SDA_LOW();I2C_SCL_LOW();I2C_write(addr);}
void I2C_stop(void) {I2C_SDA_LOW();I2C_SCL_HIGH();I2C_SDA_HIGH();}
 
///// OLED ///////////////////////////////////
#define OLED_ADDR       0x78                  
#define OLED_CMD_MODE   0x00                  
#define OLED_DAT_MODE   0x40                  
#define OLED_INIT_LEN   15 
 
// OLED init settings
const uint8_t OLED_INIT_CMD[] PROGMEM = {
  0xA8, 0x1F,       
  0x22, 0x00, 0x03, 
  0x20, 0x01,       
  0xDA, 0x02,       
  0x8D, 0x14,       
  0xAF,             
  0x00, 0x10, 0xB0, 
  0xA1, 0xC8        
};
 
// Simple reduced 3x8 font
const uint8_t OLED_FONT[] PROGMEM = {
  0x7F, 0x41, 0x7F, // 0  0
  0x00, 0x00, 0x7F, // 1  1
  0x79, 0x49, 0x4F, // 2  2
  0x41, 0x49, 0x7F, // 3  3
  0x0F, 0x08, 0x7E, // 4  4
  0x4F, 0x49, 0x79, // 5  5
  0x7F, 0x49, 0x79, // 6  6
  0x03, 0x01, 0x7F, // 7  7
  0x7F, 0x49, 0x7F, // 8  8
  0x4F, 0x49, 0x7F, // 9  9
  0x7F, 0x09, 0x7F, // A 10
  0x7F, 0x48, 0x78, // b 11
  0x7F, 0x41, 0x63, // C 12
  0x78, 0x48, 0x7F, // d 13
  0x7F, 0x49, 0x41, // E 14
  0x7F, 0x09, 0x01, // F 15
  0x00, 0x60, 0x00, // . 16
  0x00, 0x36, 0x00, // : 17
  0x08, 0x08, 0x08, // - 18
  0x00, 0x00, 0x00  //   19
};
 
void OLED_cursor(uint8_t xpos, uint8_t ypos) {
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  I2C_write(xpos &amp; 0x0F);                 
  I2C_write(0x10 | (xpos &gt;&gt; 4));     
  I2C_write(0xB0 | (ypos &amp; 0x07));    
  I2C_stop();                           
}
 
void OLED_clear(void) {
  OLED_cursor(0, 0);                      
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_DAT_MODE);              
  for(uint16_t i=512; i; i--) I2C_write(0x00); 
  I2C_stop();  
}
 
void OLED_init(void) {
  I2C_init();                             
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  for (uint8_t i = 0; i &lt; OLED_INIT_LEN; i++) I2C_write(pgm_read_byte(&amp;OLED_INIT_CMD[i])); 
  I2C_stop();                            
}
 
uint8_t OLED_stretch(uint8_t b){b=((b &amp; 2)&lt;&lt;3)|(b&amp;1);b|=b&lt;&lt;1;b|=b&lt;&lt;2;return b;}
 
void OLED_printD(uint8_t ch) {
  uint8_t i, j, k, b;                     
  uint8_t sb[4];                          
  ch += ch &lt;&lt; 1;                          
  for(i=8; i; i--) I2C_write(0x00);       
  for(i=3; i; i--) {                      
    b = pgm_read_byte(&amp;OLED_FONT[ch++]);  
    for(j=0; j&lt;4; j++, b &gt;&gt;= 2) sb[j] = OLED_stretch(b);  
    j=4; if(i==2) j=6;               
    while(j--) {                    
      for(k=0; k&lt;4; k++) I2C_write(sb[k]);
}}}
 
void OLED_printB(uint8_t *buffer) {
  I2C_start(OLED_ADDR);      
  I2C_write(OLED_DAT_MODE);              
  for(uint8_t i=0; i&lt;8; i++) OLED_printD(buffer[i]); 
  I2C_stop();                            
}
 
//// DS18B20 //////////////////////////////////////
uint8_t therm_reset(){
    uint8_t i;
    PORTB &amp;= ~(1 &lt;&lt; TEMP);
    DDRB |= (1 &lt;&lt; TEMP);
    _delay_us(480);  
    DDRB &amp;= ~(1 &lt;&lt; TEMP);
    _delay_us(60);
    i=((PINB &gt;&gt; TEMP) &amp; 1);
    _delay_us(420);
    return i;
}
void therm_write_bit(uint8_t bit){
    DDRB |= (1 &lt;&lt; TEMP);
    if(bit) DDRB &amp;= ~(1 &lt;&lt; TEMP);
    _delay_us(60);
    DDRB &amp;= ~(1 &lt;&lt; TEMP);
}
uint8_t therm_read_bit(void){
    uint8_t bit=0;
    DDRB |= (1 &lt;&lt; TEMP);
    DDRB &amp;= ~(1 &lt;&lt; TEMP);
    _delay_us(14);
    if(PINB &amp; (1 &lt;&lt; TEMP)) bit=1;
    _delay_us(45);
    return bit;
}
uint8_t therm_read_byte(void){
    uint8_t i=8, n=0;
    while(i--){n&gt;&gt;=1;n|=(therm_read_bit()&lt;&lt;7);}
    return n;
}
void therm_write_byte(uint8_t byte){
    uint8_t i=8;
    while(i--){therm_write_bit(byte&amp;1);byte &gt;&gt;= 1;
    }}
int read_temp(){
    uint8_t temperature[2];
    int temper;
    therm_reset();
    therm_write_byte(0xCC);
    therm_write_byte(0x44);
    while(!therm_read_bit());
    therm_reset();
    therm_write_byte(0xCC);
    therm_write_byte(0xBE);
    temperature[0]=therm_read_byte();
    temperature[1]=therm_read_byte();
    therm_reset();
    return temper = (temperature[1] &lt;&lt; 8 | temperature[0])*6;
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Thu, 15 Aug 2024 01:51:25 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10628#p10628</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10627#p10627</link>
			<description><![CDATA[<p>Здравствуйте , Я вписал код который Вы мне дали , на экране отображается не правильные цифры <span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2024/08/0d9cd16cf6ba428fc681ef00a027db10.jpg" alt="http://forum.rcl-radio.ru/uploads/images/2024/08/0d9cd16cf6ba428fc681ef00a027db10.jpg" /></span></p>]]></description>
			<author><![CDATA[null@example.com (vit)]]></author>
			<pubDate>Wed, 14 Aug 2024 06:11:44 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10627#p10627</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10626#p10626</link>
			<description><![CDATA[<p>Спасибо большое , неожиданно быстро помогли , спасибо большое.</p>]]></description>
			<author><![CDATA[null@example.com (vit)]]></author>
			<pubDate>Tue, 13 Aug 2024 08:14:01 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10626#p10626</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10624#p10624</link>
			<description><![CDATA[<p>return temper = (temperature[1] &lt;&lt; 8 | temperature[0])*10/16;</p><p>&gt;&gt;&gt;</p><p>return temper = (temperature[1] &lt;&lt; 8 | temperature[0])*100/16;</p><p>////////////////////////////////</p><p>byte a0 = temp/100;<br />&nbsp; &nbsp; byte a1 = temp/10%10;<br />&nbsp; &nbsp; byte a2 = temp%10;<br />&nbsp; &nbsp; byte a3 = temp%1;&nbsp; &nbsp;</p><p>&gt;&gt;&gt;</p><p>byte a0 = temp/1000;<br />&nbsp; &nbsp; byte a1 = temp/100%10;<br />&nbsp; &nbsp; byte a2 = temp/10%10;<br />&nbsp; &nbsp; byte a3 = temp%10;</p>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Mon, 12 Aug 2024 17:22:45 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10624#p10624</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=10623#p10623</link>
			<description><![CDATA[<p>Здравствуйте . Собрал все работает отлично , спасибо . Я хотел попросить Вас чтобы Вы помогли мне добавить вторую цифру после запятой, как добавить вторую цифру после запятой я разобрался но там показывает ноль или непонятное значение . <br />&nbsp; &nbsp; byte a0 = temp/100;<br />&nbsp; &nbsp; byte a1 = temp/10%10;<br />&nbsp; &nbsp; byte a2 = temp%10;<br />&nbsp; &nbsp; byte a3 = temp%1;&nbsp; &nbsp; &nbsp; &nbsp;как с этим бороться, показывает всегда ноль.&nbsp; <br />&nbsp; &nbsp; uint8_t buffer[8] = {19, a0, a1, 16, a2, a3, 19, 12 }; <br />Может сюда нужно что то дописать я в этом не селён. Помогите пожалуйста. Спасибо.</p>]]></description>
			<author><![CDATA[null@example.com (vit)]]></author>
			<pubDate>Mon, 12 Aug 2024 17:19:08 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=10623#p10623</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=7747#p7747</link>
			<description><![CDATA[<p>уважаемый liman324 огромное СПАСИБО !!!<br />если честно не ожидал за такую оперативность, попробовал собрал и всё чудно заработало ! ниже минуса не охлаждал что бы минус проверить но надеюсь всё высветит. единственное что моргает, ну хоть так, всё равно вам большое спасибо!!!!</p>]]></description>
			<author><![CDATA[null@example.com (alf-35)]]></author>
			<pubDate>Sat, 15 Apr 2023 17:39:24 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=7747#p7747</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=7742#p7742</link>
			<description><![CDATA[<p>Заменить </p><div class="codebox"><pre><code>    if(((PINB &gt;&gt; BUTTON) &amp; 1) == 0){   
    int temp = read_temp();
    if(temp&lt;0){minus=1;temp=-temp;}else{minus=0;}
    byte a0 = temp/100;
    byte a1 = temp/10%10;
    byte a2 = temp%10;
    if(minus==0){uint8_t buffer0[8] = {19, a0, a1, 16, a2, 19, 12, 19};OLED_printB(buffer0);}
     else{uint8_t buffer1[8] = {18, a0, a1, 16, a2, 19, 12, 19};OLED_printB(buffer1); }                                              
    _delay_ms(10000);}</code></pre></div><p>на</p><div class="codebox"><pre><code> 
    int temp = read_temp();
    if(temp&lt;0){minus=1;temp=-temp;}else{minus=0;}
    byte a0 = temp/100;
    byte a1 = temp/10%10;
    byte a2 = temp%10;
    if(minus==0){uint8_t buffer0[8] = {19, a0, a1, 16, a2, 19, 12, 19};OLED_printB(buffer0);}
     else{uint8_t buffer1[8] = {18, a0, a1, 16, a2, 19, 12, 19};OLED_printB(buffer1); }                                              
    _delay_ms(10000);</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Fri, 14 Apr 2023 12:11:53 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=7742#p7742</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=7738#p7738</link>
			<description><![CDATA[<p>доброе время суток!<br />уважаемый liman324 был бы вам очень признателен если вы могли помочь разобраться как и на что нужно изменить в коде<br />чтоб избавиться от кнопки. схема идеальная для моих нужд, даже удалось собрать и она заработала не смотря на мои познания в этом деле которые практически равны нулю. но нужно чтобы меряло постоянно и бес кнопки</p>]]></description>
			<author><![CDATA[null@example.com (alf-35)]]></author>
			<pubDate>Fri, 14 Apr 2023 09:17:08 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=7738#p7738</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=5743#p5743</link>
			<description><![CDATA[<p>Не получилось убрать незначащий ноль и добавить вторую цифру после запятой. <img src="http://forum.rcl-radio.ru/img/smilies/sad.png" width="15" height="15" alt="sad" />&nbsp; оставлю так. На днях выложу фото готового устройства.<br />Ещё раз спасибо за труд! <img src="http://forum.rcl-radio.ru/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Karl2233)]]></author>
			<pubDate>Thu, 07 Apr 2022 12:47:02 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=5743#p5743</guid>
		</item>
		<item>
			<title><![CDATA[Re: Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=5717#p5717</link>
			<description><![CDATA[<p>Спасибо! <br />Всё работает изумительно! <br />Сейчас буду пытаться убрать незначащий ноль и добавить вторую цифру после запятой - а то точность хорошая, хочется видеть&nbsp; две цифры, не знаю зачем <img src="http://forum.rcl-radio.ru/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Karl2233)]]></author>
			<pubDate>Tue, 05 Apr 2022 12:13:18 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=5717#p5717</guid>
		</item>
		<item>
			<title><![CDATA[Термометр на DS18B20 с большими цифрами]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=5710#p5710</link>
			<description><![CDATA[<p>Основная статья - <a href="http://rcl-radio.ru/?p=112955">http://rcl-radio.ru/?p=112955</a></p><div class="codebox"><pre><code>#include &lt;avr/io.h&gt;
#include &lt;util/delay.h&gt;
 
// Project Files (Github):  https://github.com/wagiminator/ATtiny13-TinyOLEDdemo
// License: http://creativecommons.org/licenses/by-sa/3.0/
 
#define I2C_SDA         PB3                   
#define I2C_SCL         PB4                  
#define TEMP            PB0
#define BUTTON          PB2
 
#define I2C_SDA_HIGH()  DDRB &amp;= ~(1&lt;&lt;I2C_SDA) 
#define I2C_SDA_LOW()   DDRB |=  (1&lt;&lt;I2C_SDA) 
#define I2C_SCL_HIGH()  DDRB &amp;= ~(1&lt;&lt;I2C_SCL) 
#define I2C_SCL_LOW()   DDRB |=  (1&lt;&lt;I2C_SCL) 

bool minus;
uint8_t buffer[8];
 
int main(void) {
    PORTB |=(1 &lt;&lt; BUTTON);
    OLED_init();
    OLED_clear();                    
 
while(1) { 
    if(((PINB &gt;&gt; BUTTON) &amp; 1) == 0){   
    int temp = read_temp();
    if(temp&lt;0){minus=1;temp=-temp;}else{minus=0;}
    byte a0 = temp/100;
    byte a1 = temp/10%10;
    byte a2 = temp%10;
    if(minus==0){uint8_t buffer0[8] = {19, a0, a1, 16, a2, 19, 12, 19};OLED_printB(buffer0);}
     else{uint8_t buffer1[8] = {18, a0, a1, 16, a2, 19, 12, 19};OLED_printB(buffer1); }                                              
    _delay_ms(10000);}
    OLED_clear();                   
}}
 
///// I2C ///////////////////////////////////////////////////////
void I2C_init(void) {DDRB  &amp;= ~((1&lt;&lt;I2C_SDA)|(1&lt;&lt;I2C_SCL)); PORTB &amp;= ~((1&lt;&lt;I2C_SDA)|(1&lt;&lt;I2C_SCL));}
void I2C_write(uint8_t data) {
  for(uint8_t i = 8; i; i--) {I2C_SDA_LOW();                        
    if (data &amp; 0x80) I2C_SDA_HIGH();I2C_SCL_HIGH();data&lt;&lt;=1;I2C_SCL_LOW();}
  I2C_SDA_HIGH();I2C_SCL_HIGH();asm(&quot;nop&quot;);I2C_SCL_LOW();                         
}
void I2C_start(uint8_t addr) {I2C_SDA_LOW();I2C_SCL_LOW();I2C_write(addr);}
void I2C_stop(void) {I2C_SDA_LOW();I2C_SCL_HIGH();I2C_SDA_HIGH();}
 
///// OLED ///////////////////////////////////
#define OLED_ADDR       0x78                  
#define OLED_CMD_MODE   0x00                  
#define OLED_DAT_MODE   0x40                  
#define OLED_INIT_LEN   15 
 
// OLED init settings
const uint8_t OLED_INIT_CMD[] PROGMEM = {
  0xA8, 0x1F,       
  0x22, 0x00, 0x03, 
  0x20, 0x01,       
  0xDA, 0x02,       
  0x8D, 0x14,       
  0xAF,             
  0x00, 0x10, 0xB0, 
  0xA1, 0xC8        
};
 
// Simple reduced 3x8 font
const uint8_t OLED_FONT[] PROGMEM = {
  0x7F, 0x41, 0x7F, // 0  0
  0x00, 0x00, 0x7F, // 1  1
  0x79, 0x49, 0x4F, // 2  2
  0x41, 0x49, 0x7F, // 3  3
  0x0F, 0x08, 0x7E, // 4  4
  0x4F, 0x49, 0x79, // 5  5
  0x7F, 0x49, 0x79, // 6  6
  0x03, 0x01, 0x7F, // 7  7
  0x7F, 0x49, 0x7F, // 8  8
  0x4F, 0x49, 0x7F, // 9  9
  0x7F, 0x09, 0x7F, // A 10
  0x7F, 0x48, 0x78, // b 11
  0x7F, 0x41, 0x63, // C 12
  0x78, 0x48, 0x7F, // d 13
  0x7F, 0x49, 0x41, // E 14
  0x7F, 0x09, 0x01, // F 15
  0x00, 0x60, 0x00, // . 16
  0x00, 0x36, 0x00, // : 17
  0x08, 0x08, 0x08, // - 18
  0x00, 0x00, 0x00  //   19
};
 
void OLED_cursor(uint8_t xpos, uint8_t ypos) {
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  I2C_write(xpos &amp; 0x0F);                 
  I2C_write(0x10 | (xpos &gt;&gt; 4));     
  I2C_write(0xB0 | (ypos &amp; 0x07));    
  I2C_stop();                           
}
 
void OLED_clear(void) {
  OLED_cursor(0, 0);                      
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_DAT_MODE);              
  for(uint16_t i=512; i; i--) I2C_write(0x00); 
  I2C_stop();  
}
 
void OLED_init(void) {
  I2C_init();                             
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  for (uint8_t i = 0; i &lt; OLED_INIT_LEN; i++) I2C_write(pgm_read_byte(&amp;OLED_INIT_CMD[i])); 
  I2C_stop();                            
}
 
uint8_t OLED_stretch(uint8_t b){b=((b &amp; 2)&lt;&lt;3)|(b&amp;1);b|=b&lt;&lt;1;b|=b&lt;&lt;2;return b;}
 
void OLED_printD(uint8_t ch) {
  uint8_t i, j, k, b;                     
  uint8_t sb[4];                          
  ch += ch &lt;&lt; 1;                          
  for(i=8; i; i--) I2C_write(0x00);       
  for(i=3; i; i--) {                      
    b = pgm_read_byte(&amp;OLED_FONT[ch++]);  
    for(j=0; j&lt;4; j++, b &gt;&gt;= 2) sb[j] = OLED_stretch(b);  
    j=4; if(i==2) j=6;               
    while(j--) {                    
      for(k=0; k&lt;4; k++) I2C_write(sb[k]);
}}}
 
void OLED_printB(uint8_t *buffer) {
  I2C_start(OLED_ADDR);      
  I2C_write(OLED_DAT_MODE);              
  for(uint8_t i=0; i&lt;8; i++) OLED_printD(buffer[i]); 
  I2C_stop();                            
}
 
//// DS18B20 //////////////////////////////////////
uint8_t therm_reset(){
    uint8_t i;
    PORTB &amp;= ~(1 &lt;&lt; TEMP);
    DDRB |= (1 &lt;&lt; TEMP);
    _delay_us(480);  
    DDRB &amp;= ~(1 &lt;&lt; TEMP);
    _delay_us(60);
    i=((PINB &gt;&gt; TEMP) &amp; 1);
    _delay_us(420);
    return i;
}
void therm_write_bit(uint8_t bit){
    DDRB |= (1 &lt;&lt; TEMP);
    if(bit) DDRB &amp;= ~(1 &lt;&lt; TEMP);
    _delay_us(60);
    DDRB &amp;= ~(1 &lt;&lt; TEMP);
}
uint8_t therm_read_bit(void){
    uint8_t bit=0;
    DDRB |= (1 &lt;&lt; TEMP);
    DDRB &amp;= ~(1 &lt;&lt; TEMP);
    _delay_us(14);
    if(PINB &amp; (1 &lt;&lt; TEMP)) bit=1;
    _delay_us(45);
    return bit;
}
uint8_t therm_read_byte(void){
    uint8_t i=8, n=0;
    while(i--){n&gt;&gt;=1;n|=(therm_read_bit()&lt;&lt;7);}
    return n;
}
void therm_write_byte(uint8_t byte){
    uint8_t i=8;
    while(i--){therm_write_bit(byte&amp;1);byte &gt;&gt;= 1;
    }}
int read_temp(){
    uint8_t temperature[2];
    int temper;
    therm_reset();
    therm_write_byte(0xCC);
    therm_write_byte(0x44);
    while(!therm_read_bit());
    therm_reset();
    therm_write_byte(0xCC);
    therm_write_byte(0xBE);
    temperature[0]=therm_read_byte();
    temperature[1]=therm_read_byte();
    therm_reset();
    return temper = (temperature[1] &lt;&lt; 8 | temperature[0])*10/16;
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Mon, 04 Apr 2022 12:25:21 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=5710#p5710</guid>
		</item>
	</channel>
</rss>
