پاسخ : چرا syntax highlighter نداریم؟
من با C# یه highlighter نوشتم :mrgreen:
ولی این راهش نیست. سایت باید پدیت بشه.
void adc_init ( void )
{
//BYTE i;
// ADC enable, Prescaler divide by 128, ADC clock = 16MHz/128 = 125kHz
ADCSRA = _BV(ADEN) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0);
// Select Vref, internal Vref 2.56V and external capacitor
ADMUX = _BV(REFS1) | _BV(REFS0);
// reading temparature
//for ( i=0; i<32; i++ )
// adc_read_temp ();
}
//************************************************** ******************************************
//
// Function : adc_read_temp
// Description : read temparature from ADC1 and convert to real temparature
//
//************************************************** ******************************************
uint8_t adc_read_temp ( void )
{
static uint16_t temp_buf[ ADC_TEMP_BUFFER ];
static uint8_t buf_index=0;
uint16_t result=0,data;
uint8_t loop;
// Store each sample to buffer
temp_buf[ buf_index ] = adc_read ( ADC_TEMP_CHANNEL );
// Low pass filter 8 samples by default.
for ( loop=0; loop<ADC_TEMP_BUFFER; loop++ )
{
result += temp_buf [ loop ];
}
// reset index
if( ++buf_index == ADC_TEMP_BUFFER )
{
buf_index = 0;
}
// average result
result = result / ADC_TEMP_BUFFER;
// look-up for temparature, convert to real temparature
for ( loop=0; loop<100; loop++ )
{
data = pgm_read_word ( temp_list + loop );
if( result <= data)
break;
}
return loop;
}
من با C# یه highlighter نوشتم :mrgreen:
ولی این راهش نیست. سایت باید پدیت بشه.
void adc_init ( void )
{
//BYTE i;
// ADC enable, Prescaler divide by 128, ADC clock = 16MHz/128 = 125kHz
ADCSRA = _BV(ADEN) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0);
// Select Vref, internal Vref 2.56V and external capacitor
ADMUX = _BV(REFS1) | _BV(REFS0);
// reading temparature
//for ( i=0; i<32; i++ )
// adc_read_temp ();
}
//************************************************** ******************************************
//
// Function : adc_read_temp
// Description : read temparature from ADC1 and convert to real temparature
//
//************************************************** ******************************************
uint8_t adc_read_temp ( void )
{
static uint16_t temp_buf[ ADC_TEMP_BUFFER ];
static uint8_t buf_index=0;
uint16_t result=0,data;
uint8_t loop;
// Store each sample to buffer
temp_buf[ buf_index ] = adc_read ( ADC_TEMP_CHANNEL );
// Low pass filter 8 samples by default.
for ( loop=0; loop<ADC_TEMP_BUFFER; loop++ )
{
result += temp_buf [ loop ];
}
// reset index
if( ++buf_index == ADC_TEMP_BUFFER )
{
buf_index = 0;
}
// average result
result = result / ADC_TEMP_BUFFER;
// look-up for temparature, convert to real temparature
for ( loop=0; loop<100; loop++ )
{
data = pgm_read_word ( temp_list + loop );
if( result <= data)
break;
}
return loop;
}
دیدگاه