sajt u izradi..
English French German Italian Portuguese Russian Spanish
Created: Saturday, 16.November.2013. 14:24
/*
 * @copyright	Copyright (C) 2013 Branislav Kešelj . All rights reserved.
 * @license		GNU/GPLv2
 * v.1.1 - 17.11.2013
 */

var tl = function() {
    var R=[]; 
    var C = ['а','б','в','г','д','џ','ђ','е','ж','з','и','ј','к','л','љ','м','н','њ','о','п','р','с','т','ћ','у','ф','х','ц','ч','ш','А','Б','В','Г','Д','Џ','Ђ','Е','Ж','З','И','Ј','К','Л','Љ','М','Н','Њ','О','П','Р','С','Т','Ћ','У','Ф','Х','Ц','Ч','Ш'];
    var L = ['a','b','v','g','d','dž','đ','e','ž','z','i','j','k','l','lj','m','n','nj','o','p','r','s','t','ć','u','f','h','c','č','š','A','B','V','G','D','Dž','Đ','E','Ž','Z','I','J','K','L','Lj','M','N','Nj','O','P','R','S','T','Ć','U','F','H','C','Č','Š'];

    var T = [/(<script[^>]*?>[\s\S]*?<\/script>)/ig,/(<style[^>]*?>[\s\S]*?<\/style>)/ig,/\{#x\}([\s\S]*?)\{\/#x\}/ig,/(<[^>]*>)/ig,
         /(&quot;)/g, /(&apos;)/g, /(&amp;)/g, /(&lt;)/g, /(&gt;)/g, /(&nbsp;)/g, /(&iexcl;)/g, /(&cent;)/g, /(&pound;)/g,
         /(&curren;)/g, /(&yen;)/g, /(&brvbar;)/g, /(&sect;)/g, /(&uml;)/g, /(&copy;)/g, /(&ordf;)/g, /(&laquo;)/g, /(&not;)/g, /(&shy;)/g,
         /(&reg;)/g, /(&macr;)/g, /(&deg;)/g, /(&plusmn;)/g, /(&sup2;)/g, /(&sup3;)/g, /(&acute;)/g, /(&micro;)/g, /(&para;)/g, /(&middot;)/g,
         /(&cedil;)/g, /(&sup1;)/g, /(&ordm;)/g, /(&raquo;)/g, /(&frac14;)/g, /(&frac12;)/g, /(&frac34;)/g, /(&iquest;)/g, /(&times;)/g, /(&divide;)/g,
         /(&Oslash;)/g, /(&oslash;)/g, /(&forall;)/g, /(&part;)/g, /(&exists;)/g, /(&empty;)/g, /(&nabla;)/g, /(&isin;)/g, /(&notin;)/g, /(&ni;)/g,
         /(&prod;)/g, /(&sum;)/g, /(&minus;)/ig, /(&lowast;)/ig, /(&radic;)/ig, /(&prop;)/ig, /(&infin;)/ig, /(&ang;)/ig, /(&and;)/ig, /(&or;)/ig,
         /(&cap;)/g, /(&cup;)/g, /(&int;)/g, /(&there4;)/g, /(&sim;)/g, /(&cong;)/g, /(&asymp;)/g, /(&ne;)/g, /(&equiv;)/g, /(&le;)/g,
         /(&ge;)/g, /(&sub;)/g, /(&sup;)/g, /(&nsub;)/g, /(&sube;)/g, /(&supe;)/g, /(&oplus;)/g, /(&otimes;)/g, /(&perp;)/g, /(&sdot;)/g,
         /(&Alpha;)/g, /(&Beta;)/g, /(&Gamma;)/g, /(&Delta;)/g, /(&Epsilon;)/g, /(&Zeta;)/g, /(&Eta;)/g, /(&Theta;)/g, /(&Iota;)/g, /(&Kappa;)/g,
         /(&Lambda;)/g, /(&Mu;)/g, /(&Nu;)/g, /(&Xi;)/g, /(&Omicron;)/g, /(&Pi;)/g, /(&Rho;)/g, /(&Sigma;)/g, /(&Tau;)/g, /(&Upsilon;)/g, /(&Phi;)/g,
         /(&Chi;)/g, /(&Psi;)/g, /(&Omega;)/g, /(&alpha;)/g, /(&beta;)/g, /(&gamma;)/g, /(&delta;)/g, /(&epsilon;)/g, /(&zeta;)/g, /(&eta;)/g, /(&theta;)/g,
         /(&iota;)/g, /(&kappa;)/g, /(&lambda;)/g, /(&mu;)/g, /(&nu;)/g, /(&xi;)/g, /(&omicron;)/g, /(&pi;)/g, /(&rho;)/g, /(&sigmaf;)/g, /(&sigma;)/g,
         /(&tau;)/g, /(&upsilon;)/g, /(&phi;)/g, /(&chi;)/g, /(&psi;)/g, /(&omega;)/g, /(&thetasym;)/g, /(&upsih;)/g, /(&piv;)/g, /(&OElig;)/g, /(&oelig;)/g,
         /(&Scaron;)/g,  /(&scaron;)/g, /(&Yuml;)/g, /(&fnof;)/g, /(&circ;)/g, /(&tilde;)/g, /(&ensp;)/g, /(&emsp;)/g, /(&thinsp;)/g, /(&zwnj;)/g, /(&zwj;)/g,
         /(&lrm;)/g, /(&rlm;)/g, /(&ndash;)/ig, /(&mdash;)/ig, /(&lsquo;)/ig, /(&rsquo;)/ig, /(&sbquo;)/ig, /(&ldquo;)/ig, /(&rdquo;)/ig, /(&bdquo;)/ig, /(&dagger;)/ig,
         /(&Dagger;)/g, /(&bull;)/g, /(&hellip;)/g, /(&permil;)/g, /(&prime;)/g, /(&Prime;)/g, /(&lsaquo;)/g, /(&rsaquo;)/g, /(&oline;)/g, /(&euro;)/g, /(&trade;)/g,
         /(&larr;)/g, /(&uarr;)/g, /(&rarr;)/g, /(&darr;)/g, /(&harr;)/g, /(&crarr;)/g, /(&lceil;)/g, /(&rceil;)/g, /(&lfloor;)/g, /(&rfloor;)/g, /(&loz;)/g,
         /(&spades;)/g, /(&clubs;)/g, /(&hearts;)/g, /(&diams;)/g];

    var S=[/konju[^avjrshš][a-z]*/ig,3,/injek[a-z]*/ig,2,/nadživ[a-z]*/ig,3,/tanjug[a-z]*/ig,3,/panjeliniz[a-z]*/ig,3,/injunkt[a-z]*/ig,2,/nadžet[a-z]*/ig,3,/nadžnj[a-z]*/ig,3,
             /nadžanj[a-z]*/ig,3,/nadždrel[a-z]*/ig,3,/nadžup[a-z]*/ig,3,/odžal[^j][a-z]*/ig,2,/odžaljen/ig,2,/podžupan[a-z]*/ig,3];

    var I=[/<input[^>]*type="submit"[^>]*>/gi,/<input[^>]*type="button"[^>]*>/gi];

    Array.prototype.count = function ()
        {
        var c = 0;
        for(i in this)
        { if(typeof this[i] != "undefined") c++; }
        return c-1;
        };

    return {
        encode:function(w)
            {
			var n=1000;
            function c($1,$2)
                {
                n++; R.push('##'+n+'###'); R.push($2);
                return '##'+n+'###';
                }
            for(var i=0; i< T.count();i++)
                { w=w.replace(T[i], c); }
            return w;
            },

        encode_:function(w)
            {
            function c($1)
                { return $1.substr(0, S[i+1])+'#q#q##'+$1.substr(S[i+1]); }
            for(var i=0; i< S.count();i+=2)
                { w=w.replace(S[i], c); }
            return w;
            },

        decode:function(w)
            {
            for(var i=0; i< R.count();i+=2)
                { w=w.replace(R[i],R[i+1]); }
            R=[];
            return w;
            },

        decode_:function(w)
            { return w.replace(/#q#q##/g,''); },

        convertInputTag:function(w,l)
            {
            function c($1)
                {
                function f($1,$2)
                    { return 'value="'+tl.convert($2,l)+'"'; }
                return $1.replace(/value="([\s\S]*?)"/,f);
                }
            for(var i=0;i< I.count();i++)
                { w=w.replace(I[i], c); }
            return w;
            },

        lang:function(w)
            {
            var l= 0, c=0 ;
            for (var i=0;i<w.length;i++)
                {
                if(L.indexOf(w.charAt(i))!=-1) l++;
                    else if(C.indexOf(w.charAt(i))!=-1) c++;
                if(c>10) return 'l';
                if(l>10) return 'c';
                }
            return false ;
            },
        convert:function(w,l)
            {
            var c, d, n, u, t='';
            for (var i=0;i<w.length;i++)
                {
                c=w.charAt(i) ;
                if (l=='c')
                    {
                    d=L.indexOf(c);
                    if(d!=-1)
                        {
                        n=w.charAt(i+1);
                        if (((c=='l' || c=='n') && n=='j') || (c=='d' && n=='ž') || ((c=='L' || c=='N') && (n=='j' || n=='J')) || (c=='D' &&  (n=='ž' || n=='Ž')))
                            { d++ ; i++ ; }
                        t+=C[d];
                        }
                        else t+=c;
                    }
                    else
                        {
                        d=C.indexOf(c);
                        if (d!=-1)
                            {
                            u=0;
                            if (c=='Љ' || c=='Њ' || c=='Џ')
                                {
                                n=w.charAt(i+1) ;
                                u=C.indexOf(n);
                                }
                            t+=(u>29) ? L[d].toUpperCase():L[d] ;
                            }
                            else t+=c;
                        }
                }
            return t;
            }
        };
    }();

 

Comment (0) Hits: 280
Created: Monday, 26.August.2013. 18:16
/*
 * Created: 05.06.13. 08:22PM
 * Author: Branislav Kešelj / http://kbblog.net
 * 	   
 * ATMEGA 8
 * 
 *FUSE
 *------------------ 
 * H-> 0xC9
 * L-> 0x6f
 *------------------
 *
 */ 
#define F_CPU 8000000UL //Define the clock speed
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/eeprom.h>
uint32_t display; 
uint8_t digit=0;
uint8_t error_flag=0x00;
uint8_t alarm_flag=0x00;
uint16_t menu_flag=0x00;
int16_t ALx_data[5];
char eedata[] EEMEM = {0x20,0x00,0x00,0x00,0x00,0x00,0x64,0x00,0x03,0x00,
						0x21,0x00,0x00,0x00,0x00,0x00,0x64,0x00,0x00,0x00,
						0x22,0x00,0x00,0x00,0x00,0x00,0x64,0x00,0x00,0x00,
						0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
						0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
						0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
						
// ----------------------------------------------------------------------------------------------------------------
						
#define PROG 0x38
#define DOWN 0x34
#define UP 0x2C
#define SET 0x1C
#define UP_DOWN_TIME 0x190 // after 2.5ms*400
#define UP_DOWN_SPEED 0x05 // 5*2.5ms+2.5ms, 1+ || 1-
#define RESET_TIME 0x1F40 //8000*2.5 = 20s
#define BLINK_TIME 0x64  // 2.5ms*100
uint8_t key_flag=0x00;
uint16_t up_down_time = 0x00;
uint8_t up_down_speed =0x00;
uint16_t reset_time = 0x00; //  20s
uint8_t blink_time_ = 0x00;
uint8_t scan_key()
	{
	uint8_t key_status;
	key_status = PINB & 0x3C;
	
	if(key_status != 0x3C)
		{
		if(key_status == PROG || key_status == DOWN || key_status == UP || key_status == SET)
			{ // one key press
			if(key_flag != 0x80)
				{
				if(key_flag==key_status)
					{
					reset_time=RESET_TIME; //8000*2.5 = 20s
					blink_time_=0x01;
					key_flag++;
					return key_status;
					}
					else if(!key_flag) key_flag=key_status;
					
				if(up_down_time && (key_status == UP || key_status == DOWN) )
					{
					if(up_down_time == UP_DOWN_TIME)
						{
						if(up_down_speed == UP_DOWN_SPEED)
							{
							key_flag=0x00;
							up_down_speed=0x00;	
							}	
							else up_down_speed++;
						}
						else up_down_time++;				
					}	
				}
			}
			else key_flag=0x80;
		}
		else 
			{
			key_flag=0;
			up_down_time=(up_down_time) ? 1:0;
			up_down_speed=0x00;
			}			
	return 0;
	}
// ----------------------------------------------------------------------------------------------------------------
	
void reset()
	{
	if(reset_time)	
		{
		reset_time--;
		if(!reset_time)
			{
			menu_flag =0 ;
			alarm_flag =(alarm_flag & 0x01) ? 0:alarm_flag;	
			}
		}	
	}
// ----------------------------------------------------------------------------------------------------------------
void blink_time()
	{
	if(blink_time_)
		{
		blink_time_++;
		if((blink_time_ & 0x7F)==BLINK_TIME)
			{
			if(blink_time_ & 0x80) blink_time_=0x01;
				else blink_time_=0x81;   	
			}
		}	
	}
// ----------------------------------------------------------------------------------------------------------------
	
#define LED_OUT_ON PD6
#define LED_OUT_OFF PD7
#define OUT_ PB0
#define OUT_INVERT PB1	
	
void alarm_out_on()
	{
	PORTB |= (1<<OUT_);
	PORTB &= ~ (1<<OUT_INVERT);
	PORTD |= (1<<LED_OUT_ON);
	PORTD &= ~ (1<<LED_OUT_OFF);
	}
void alarm_out_off()
	{	
	PORTB &= ~ (1<<OUT_);
	PORTD &= ~ (1<<LED_OUT_ON);
	if(alarm_flag & 0x80) 
		{
		PORTB |= (1<<OUT_INVERT);
		PORTD |= (1<<LED_OUT_OFF); 
		}
		else 
			{
			PORTB &= ~ (1<<OUT_INVERT);
			PORTD &= ~ (1<<LED_OUT_OFF);
			}
	}
	
// ----------------------------------------------------------------------------------------------------------------
#define DS PD3 // Serial Data
#define SCL PD4 // Shift Clock
#define E PD5 // Latch Clock
void bin2display(int16_t v)
	{
	display=0;	
	uint16_t d[]={1000,100,10,1};
	for(uint8_t i=0;i<4;i++)
		{
		display+=v/d[i]; // 
		display<<=5;
		v-=(v/d[i])*d[i];			
		}
	}
void wrt_595(uint8_t output)
	{
	for(uint8_t i=0;i<8;i++)
		{
		if(output & 0x80) PORTD |= (1 << DS); // send 1
			else PORTD &= ~(1 << DS); // send 0
		PORTD |= (1 << SCL); // Shift Clock HI
		PORTD &= ~(1 << SCL); // Shift Clock LOW
		output<<=1;
		}
	PORTD |= (1 << E); // Latch Clock HI
	PORTD &= ~(1 << E); // Latch Clock LOW
	}
	
void wrt_display()
	{	
	uint8_t digit_num[]={0x20,0x10,0x08,0x04,0x02};
	uint8_t char_[]={0xED,0x28,0xB5,0xB9,0x78,0xD9,0xDD,0xA8,0xFD,0xF8,
					0xD5,0x00,0x10,0xD5,0x14,0xC5,0x3E,0xBE,0xBC,0x9B,0x08,0x22,0x9B,0xAB};	//  0-9, .C,None,-,E,r,C,.A,.H,.P,.S,.-,.1,.2,.3
					
	PORTC &=0x01; // display turn off	
	wrt_595(char_[(display>>(digit*5)) & 0x1f]);
	PORTC=(PORTC & 0x01)+digit_num[digit]; // display turn on
	digit++;	
	if(digit == 0x05) digit=0; 	
	}	
// ----------------------------------------------------------------------------------------------------------------
#define READ_TIME 0x64 // 100*2.5ms
#define ERROR_TIME 0x04 // 
#define SCK PD0 // Serial Data
#define CS PD1 // Shift Clock
#define SO PD2 // Latch Clock
uint16_t temp;
uint8_t read_time = 0; 
uint16_t error_time=0;
void read_max31855()
	{	
	uint16_t dataH;
	uint16_t dataL;
	
	if (!(read_time)) 
		{
		read_time=READ_TIME;
		dataH=0;
		dataL=0;
		PORTD &= ~(1<<CS);
		_delay_us(1);
		PORTD &= ~(1<<SCK);
		_delay_us(1);
		for (int i=31; i>=0; i--)
			{
			PORTD |= (1<<SCK);
			_delay_us(1);
			if(i>15 && PIND & (1<<SO)) dataH |= (1 << (i-16));
				else if (i<16 && PIND & (1<<SO)) dataL |= (1 << i);
			PORTD &= ~(1<<SCK);
			_delay_us(1);
			}
		PORTD |= (1<<CS); // new conversion enable ... ~0.25s
		if(dataH & 0x01)
			{
			//Err-1 - thermocouple is open (no connections)
			//Err-2 - thermocouple is short-circuited to GND
			//Err-3	- thermocouple is short-circuited to VCC
				
			error_time=ERROR_TIME;
			error_flag=((dataL & 0x07)/2+1)+0x14;
			display=0xD73980+error_flag; // Err-X, X-> 1,2,3
			}
			else
				{
				if(!error_time)
					{
					error_flag=0x00;
					temp=dataH>>4;	//
					if(!menu_flag && !(alarm_flag&0x03))
						{
						bin2display(temp);
						display+=0x0A; // .C
						if(temp<=0x384) display+= 0xb00000; // temp>=900.C = leading digit ON
						}	
					}
					else error_time--;		
				}								
		}
		else read_time--;
	}
	
void int_max31855()
	{
	PORTD |= (1<<CS); // conversion enable ... ~0.25s	
	_delay_ms(250);
	read_max31855();			
	}
// ----------------------------------------------------------------------------------------------------------------
#define Cx_min 0x01
#define Cx_max 0x03
#define Cx_step 0x0A // 
#define temp_min 0xFF38 // -200 .C
#define temp_max 0x546 // 1350 .C
#define hist_min 0x00 // 0 .C
#define hist_max 0x64 // 100 .C
#define activ_min 0x00 // 0.1s 
#define activ_max 0x3C // 60s
#define ALARM_FLAG_EE 0x32 // 50
int16_t Cx_data[5];
uint8_t Cx=0x01; // program num
uint8_t pass=0x00;
void alx_save()
	{
	if(blink_time_ & 0x80)
		{
		pass=(!pass) ? 0x01:pass;
		if(pass==1) 
			{
			if(!(alarm_flag & 0x80))  display=0xC63194; // -----
				else  
					{
					if(ALx_data[0]<0)
						{
						bin2display(ALx_data[0]*-1);
						display+=0xC00000;
						}
					else bin2display(ALx_data[0]);
					display+=0x0A;
					}
			}			
			else
				{
				alarm_flag^=0x03; // 
				pass=0;
				}
		}
		else
			{
			if(pass==1) pass=0x02;
			display=0xB5AD6B; // NNNNN N->NONE
			}	
	}
void set_alarm(uint8_t key)
	{
	blink_time();	
	if(!(alarm_flag & 0x02))
		{
		uint8_t ALx;
		ALx=((alarm_flag & 0x1C)>>2)/2+1;
		if(!(alarm_flag & 0x80))
			{ // alarm is OFF
			display=ALx;
			display=display*0x8000+0xF03171; // Cx-NA , N->NONE
			}
		if(key)
			{
			if(key==PROG && !(alarm_flag & 0x80)) alarm_flag =0x00 ;
				else 
					{
					if((((alarm_flag & 0x1C)>>2) ^ 0x07) == key>>3)
						{ // alarm ON || OFF
						if(alarm_flag & 0x80)
							{ // turn OFF alarm
							alarm_flag=0x03;
							eeprom_write_byte((uint8_t*)ALARM_FLAG_EE , 0x00);	
							alarm_out_off();
							}
							else
								{ // turn ON alarm
								alarm_flag+=0x80; // 0x80 ->AL ON,
								eeprom_write_byte((uint8_t*)ALARM_FLAG_EE , alarm_flag);
								eeprom_read_block ((void*) ALx_data , (const void*) ((ALx -1) * Cx_step) , Cx_step) ;	
								alarm_flag+=0x02; //  0x02 -> alx_save()								
								}
						PORTC &=0x01; // display off
						blink_time_=0x01; // reset blink time
						}
						else alarm_flag^=0x01;
					}					
			}	
		}
		else alx_save();		
	}
void cx_save()
	{
	if(!(menu_flag & 0x20))
		{
		PORTC &=0x01; // display off 
		menu_flag=0x3F;
		blink_time_=0x01; // reset blink time
		eeprom_update_block((const void*) Cx_data,(void*) ((Cx-1) * Cx_step) ,Cx_step);
		}
	if(blink_time_ & 0x80)
		{
		pass=(!pass) ? 0x01:pass;
		if(pass==1) display=0xC63194; // -----	
			else
			{
			menu_flag=0; // menu out
			pass=0; 
			}			 
		}
		else
			{
			if(pass==1) pass=0x02;	
			display=0xB5AD6B; // NNNNN N->NONE	
			}
	}
void set_act_time(uint8_t key)
	{
	if(!(menu_flag & 0x10))
		{
		if(key)
			{
			if(key==PROG) menu_flag =0x07 ;
				else if (key==UP)
					{
					Cx_data[2]++;
					if(Cx_data[2]==(activ_max+1)) Cx_data[2]=activ_min;
					}
					else if(key==DOWN)
						{
						Cx_data[2]--;
						if(Cx_data[2]==(activ_min-1)) Cx_data[2]=activ_max;
						}
						else menu_flag=0x1F; // SET
			}
		bin2display(Cx_data[2]);
		display+=0xB58000;
		display+=(blink_time_ & 0x80) ? 0x0B:0x11;
		}
		else cx_save();
	}
	
void set_hist(uint8_t key )
	{
	if(!(menu_flag & 0x08))
		{
		if(key)
			{
			if(key==PROG) menu_flag =0x03 ;
				else if (key==UP)
					{
					Cx_data[1]++;
					if(Cx_data[1]==(hist_max+1)) Cx_data[1]=hist_min;
					}
					else if(key==DOWN)
						{
						Cx_data[1]--;
						if(Cx_data[1]==(hist_min-1)) Cx_data[1]=hist_max;
						}
						else menu_flag=0x0F; // SET
			}
		bin2display(Cx_data[1]);
		display+=0xB00000;
		display+=(blink_time_ & 0x80) ? 0x0B:0x10;
		}
		else set_act_time(key);		
	}
	
void set_temp(uint8_t key )
	{
	if(!(menu_flag & 0x04))
		{
		if(key)
			{
			if(key==PROG)
				{
				menu_flag =0x01 ; // one step back
				up_down_time=0x00; // off UP DOWN speed
				}
				else if (key==UP)
					{
					Cx_data[0]++;
					if(Cx_data[0]==(temp_max+1)) Cx_data[0]=temp_min;
					}
					else if(key==DOWN)
						{
						Cx_data[0]--;
						if(Cx_data[0]==(temp_min-1)) Cx_data[0]=temp_max;
						}
						else menu_flag=0x07; // SET
			}
		if(Cx_data[0]<0)
			{
			bin2display(Cx_data[0]*-1);
			display+=0xC00000;
			}
			else bin2display(Cx_data[0]); 
		display+=(blink_time_ & 0x80) ? 0x0B:0x0A;
		}
		else set_hist(key);		
	}
void set_prog(uint8_t key)
	{
	blink_time();
	if(!(menu_flag & 0x02))
		{
		if(key)
			{
			if(key==PROG) menu_flag =0 ;
				else if (key==UP)
					{
					Cx++;
					if(Cx==(Cx_max+1)) Cx=Cx_min;	
					}	
					else if(key==DOWN)
						{
						Cx--;
						if(Cx==(Cx_min-1)) Cx=Cx_max;
						}
						else
							{ // SET
							menu_flag=0x03;
							up_down_time=0x01; // enable speed UP DOWN 
							eeprom_read_block ((void*) Cx_data , (const void*) ((Cx -1) * Cx_step) , Cx_step) ;	
							}	
			}
		display=Cx;
		display=display*0x8000 + 0xF02D6B; // CxNNN  N-NONE		
		}	
		else set_temp(key); 
	}
void menu()
	{
	uint8_t key=scan_key();
	
	if(menu_flag) set_prog(key);
		else if(alarm_flag & 0x03)	set_alarm(key);		
			else if(key)
				{
				if(key==PROG && (!(alarm_flag & 0x80))) menu_flag = 0x01 ;
					else 
						{
						if(!(error_flag))
							{
							if(alarm_flag & 0x80)
								{
								alarm_flag+=0x01;
								key_flag=0; // reset key press	
								}
								else alarm_flag=(key>>1)^0x1F;
							}													
						}						 						
				blink_time_ = 0x01; // reset blink time
				}
	}
// ----------------------------------------------------------------------------------------------------------------
#define AL_ACTIV_TIME 0x190;
uint16_t activ_time = AL_ACTIV_TIME // 2.5ms*400= 1s
void alarm()
	{
	if(alarm_flag & 0x80)
		{
		if(!(error_flag))
			{				
			if(!(alarm_flag & 0x40))
				{ // 
				activ_time=ALx_data[2]*AL_ACTIV_TIME;
				alarm_flag^=0x40;
				if(temp<ALx_data[0]) 
					{
					alarm_out_on();
					alarm_flag^=0x20;
					}				
					else alarm_out_off();
				}
			if(alarm_flag & 0x20)
				{
				if(temp>=ALx_data[0])
					{
					if(!(activ_time))
						{
						alarm_flag^=0x20;
						alarm_out_off();	
						}
						else activ_time--;	
					}
					else activ_time=ALx_data[2]*AL_ACTIV_TIME;	
				}
				else
					{
					if(temp<=(ALx_data[0]-ALx_data[1])) // (temp-hist)
						{
						if(!(activ_time))
							{
							alarm_flag^=0x20;
							alarm_out_on();
							}
							else activ_time--;	
						}
						else activ_time=ALx_data[2]*AL_ACTIV_TIME;	
				}
			}
			else
				{
				alarm_flag=0x00;
				alarm_out_off();
				}
		}
	}
	
void int_alarm()
	{
	uint8_t ALx;
	
	alarm_flag=eeprom_read_byte((const uint8_t*) ALARM_FLAG_EE);
	ALx=((alarm_flag & 0x1C)>>2)/2+1;
	if(alarm_flag) eeprom_read_block ((void*) ALx_data , (const void*) ((ALx -1) * Cx_step) , Cx_step) ;
	}
// ----------------------------------------------------------------------------------------------------------------
	
ISR(TIMER0_OVF_vect ) 
    { // ~2.5ms		
	TCNT0=0xEB;
	read_max31855();
	menu();	
	alarm();
	reset();
	wrt_display();	
	}
int main (void)
    {
    DDRC = 0b00111111;
    PORTC = 0b00000000;
    DDRB = 0b00000011;
    PORTB = 0b00111100;
    DDRD = 0b11111011;
    PORTD = 0b00000100;
	_delay_ms(100);
	EEARH = 0x00;
	TCCR0 = (1 << CS00) | (1 << CS02);
	TIMSK = (1<<TOIE0);
	int_max31855();
	int_alarm();
    TCNT0=0xEB;
	sei();
    while(1)
        {
			
						
        }
    }
	
// END

 

Comment (0) Hits: 590
Created: Monday, 19.August.2013. 17:33
'
'Kešelj Branislav 2010
'
'
Sub a____blank_price()
    Dim t As Integer
    t = InputBox(Prompt:="Page 1 -> 24 price", _
          Title:="BLANK PRICE", Default:="1")
    If t > 0 Then Call engine(0, 0, 0, t * 24, 1)
End Sub
Private Sub engine(item_num, item_name, item_price, t, b)
        Dim c As Double
        Dim r_min As Integer
        Dim r_max As Integer
        Dim limit As Integer
        Dim row As Integer
        Dim col As String
        Dim item_price_  As Variant
        limit = 240
        c = t / limit
        If (c > Int(c)) Then c = Int(c) + 1
        For p = 1 To c
            If p = 1 Then
                Range("E1:G3").Select
                Selection.Copy
            End If
            Sheets.Add
            Range("A:A,D:D,G:G").ColumnWidth = 4.43
            Range("B:B,E:E,H:H").ColumnWidth = 17.14
            Range("C:C,F:F,I:I").ColumnWidth = 8.72
            Rows(1).RowHeight = 26.25
            Rows(2).RowHeight = 30
            Rows(3).RowHeight = 36
            If p = 1 Then
                Range("A1,D1,G1").Select
            Else
                Range("A1").Select
            End If
            ActiveSheet.Paste
            If p * limit <= t Then
                r_max = limit
                r_min = p * limit - limit
            Else
                r_min = (p - 1) * limit
                r_max = t - r_min
            End If
            row = 1
            For i = 1 To r_max
                Select Case i Mod 3
                    Case Is = 1
                        col = "C"
                        If (i + 3) Mod 3 = 1 And (i + 3) <= r_max Then
                            Rows(i & ":" & i + 2).Select
                            Selection.Copy
                            Rows(i + 3 & ":" & i + 3).Select
                            ActiveSheet.Paste
                        End If
                        row = row + 3
                    Case Is = 2
                        col = "F"
                    Case Else
                        col = "I"
                End Select
                If b = 0 Then
                    If t > 1 Then
                        Range(col & row - 3).Value = item_num(i + r_min, 1)
                        Range(col & row - 3).Offset(1, -2).Value = item_name(i + r_min, 1)
                        item_price_ = Split(item_price(i + r_min, 1), ".")
                    Else
                        Range(col & row - 3).Value = item_num
                        Range(col & row - 3).Offset(1, -2).Value = item_name
                        item_price_ = Split(item_price, ".")
                    End If
                    Range(col & row - 3).Offset(2, -1).Value = Range(col & row - 3).Offset(2, -1).Value & item_price_(0)
                    If (UBound(item_price_) - LBound(item_price_) + 1) = 2 Then
                        If Len(item_price_(1)) = 1 Then
                            Range(col & row - 3).Offset(2, 0).Value = "." & item_price_(1) & "0 " & Range(col & row - 3).Offset(2, 0).Value
                        Else
                            Range(col & row - 3).Offset(2, 0).Value = "." & item_price_(1) & " " & Range(col & row - 3).Offset(2, 0).Value
                        End If
                    Else
                        Range(col & row - 3).Offset(2, 0).Value = ".00 " & Range(col & row - 3).Offset(2, 0).Value
                    End If
                End If
             Next i
        Next p

    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.53)
        .RightMargin = Application.InchesToPoints(0.23)
        .TopMargin = Application.InchesToPoints(0.18)
        .BottomMargin = Application.InchesToPoints(0.67)
        .HeaderMargin = Application.InchesToPoints(0.17)
        .FooterMargin = Application.InchesToPoints(0.5)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .FitToPagesWide = False
        .FitToPagesTall = False
    End With
End Sub

 

Comment (0) Hits: 464
Created: Monday, 19.August.2013. 17:28
'
'Kešelj Branislav 2012
'
'
Sub a____load_file()
Dim Filter As String
Dim FilterIndex As Integer
Dim Filename As Variant
    Filter = "Excel Files (*.xls),*.xls," & _
    "Excel Files (*.xlsx),*.xlsx,"
    With Application
        Filename = .GetOpenFilename(Filter, 0, "Select a File to Open")
    End With
    If Filename = False Then
        MsgBox "No file was selected."
        Exit Sub
    End If
    Workbooks.Open Filename
    t = Application.WorksheetFunction.CountA(Columns("A:A"))
    If t > 0 Then
        Range("A1:C" & t).Select
        Selection.Copy
        ActiveWindow.Close
        Range("A5").Select
        ActiveSheet.Paste
        Range("A5").Select
    Else
        MsgBox "EMPTY file"
        ActiveWindow.Close
    End If
End Sub
Sub b____all_price()
Dim t As Integer
Dim naziv As Variant
Dim sifra As Variant
Dim cena As Variant
    t = Application.WorksheetFunction.CountA(Columns("A:A"))
    If t > 0 Then
        item_num = Range("A5:A" & t + 4).Value
        item_name = Range("B5:B" & t + 4).Value
        item_price = Range("C5:C" & t + 4).Value
        Call engine(item_num, item_name, item_price, t, 0)
    End If
End Sub
Private Sub engine(item_num, item_name, item_price, t, b)
        Dim c As Double
        Dim r_min As Integer
        Dim r_max As Integer
        Dim limit As Integer
        Dim row As Integer
        Dim col As String
        Dim item_price_  As Variant
        limit = 240
        c = t / limit
        If (c > Int(c)) Then c = Int(c) + 1
        For p = 1 To c
            Sheets("Main").Select
            Range("E1:G3").Select
            Selection.Copy
            Sheets.Add
            Range("A:A,D:D,G:G").ColumnWidth = 4.43
            Range("B:B,E:E,H:H").ColumnWidth = 17.14
            Range("C:C,F:F,I:I").ColumnWidth = 8.72
            Rows(1).RowHeight = 26.25
            Rows(2).RowHeight = 30
            Rows(3).RowHeight = 36
            Range("A1,D1,G1").Select
            ActiveSheet.Paste
            If p * limit <= t Then
            r_max = limit
            r_min = p * limit - limit
            Else
            r_min = (p - 1) * limit
            r_max = t - r_min
            End If
            row = 1
            For i = 1 To r_max
                Select Case i Mod 3
                    Case Is = 1
                        col = "C"
                        If (i + 3) Mod 3 = 1 And (i + 3) <= r_max Then
                            Rows(i & ":" & i + 2).Select
                            Selection.Copy
                            Rows(i + 3 & ":" & i + 3).Select
                            ActiveSheet.Paste
                        End If
                        row = row + 3
                    Case Is = 2
                        col = "F"
                    Case Else
                        col = "I"
                End Select
                If b = 0 Then
                    If t > 1 Then
                        Range(col & row - 3).Value = item_num(i + r_min, 1)
                        Range(col & row - 3).Offset(1, -2).Value = item_name(i + r_min, 1)
                        item_price_ = Split(item_price(i + r_min, 1), ".")
                    Else
                        Range(col & row - 3).Value = item_num
                        Range(col & row - 3).Offset(1, -2).Value = item_name
                        item_price_ = Split(item_price, ".")
                    End If
                    Range(col & row - 3).Offset(2, -1).Value = Range(col & row - 3).Offset(2, -1).Value & item_price_(0)
                    If (UBound(item_price_) - LBound(item_price_) + 1) = 2 Then
                        If Len(item_price_(1)) = 1 Then
                            Range(col & row - 3).Offset(2, 0).Value = "." & item_price_(1) & "0 " & Range(col & row - 3).Offset(2, 0).Value
                        Else
                            Range(col & row - 3).Offset(2, 0).Value = "." & item_price_(1) & " " & Range(col & row - 3).Offset(2, 0).Value
                        End If
                    Else
                        Range(col & row - 3).Offset(2, 0).Value = ".00 " & Range(col & row - 3).Offset(2, 0).Value
                    End If
                End If
             Next i
        Next p

    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.53)
        .RightMargin = Application.InchesToPoints(0.23)
        .TopMargin = Application.InchesToPoints(0.18)
        .BottomMargin = Application.InchesToPoints(0.67)
        .HeaderMargin = Application.InchesToPoints(0.17)
        .FooterMargin = Application.InchesToPoints(0.5)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .FitToPagesWide = False
        .FitToPagesTall = False
    End With
End Sub


 

Comment (0) Hits: 590
Created: Monday, 19.August.2013. 17:17
'
'Kešelj Branislav 2010
'
'
Sub load_file()
    Dim t As Integer
    Dim db As Variant
    t = Application.WorksheetFunction.CountA(Columns("A:A"))
    Range("A5:C" & (t + 5)).Select
    Selection.ClearContents
    db = Range("B4").Value
    If (db = "") Then
        With Application
            db = .GetOpenFilename("Excel Files (*.csv),*.csv,", 0, "Select a File to Open")
        End With
        If db = False Then
            MsgBox "No file was selected."
            Exit Sub
        Else
            Range("B4").Value = db
            ActiveWorkbook.Save
        End If
    End If
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & db, Destination:=Range("$A$5"))
        .Name = ""
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 932
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = True
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
    Range("C:C,D:D,F:F,G:G,H:H").Select
    Selection.Delete Shift:=xlToLeft
    Rows("5:5").Select
    Selection.Delete Shift:=xlUp
    Range("A:A").ColumnWidth = 7
    Range("B:B").ColumnWidth = 70
    Range("C:C").ColumnWidth = 15
    Range("D5").Select
End Sub
Sub mp_select()
Dim t As Integer
Dim naziv As Variant
Dim sifra As Variant
Dim cena As Variant
    Selection.Copy
    Sheets("template").Select
    Range("A5").Select
    ActiveSheet.Paste
    t = Application.WorksheetFunction.CountA(Columns("A:A"))
    If t > 0 Then
        sifra = Range("A5:A" & (t + 5)).Value
        naziv = Range("B5:B" & (t + 5)).Value
        cena = Range("C5:C" & (t + 5)).Value
        Selection.Clear
        Call engine(sifra, naziv, cena, t, 0)
    Else
        Sheets("main").Select
    End If
End Sub
Sub clear_all()
    Dim t As Integer
    t = Application.WorksheetFunction.CountA(Columns("A:A"))
    Range("A5:C" & (t + 5)).Select
    Selection.ClearContents
    Range("B4").Value = ""
    Range("A1").Select
End Sub
Private Sub engine(item_num, item_name, item_price, t, b)
        Dim c As Double
        Dim r_min As Integer
        Dim r_max As Integer
        Dim limit As Integer
        Dim row As Integer
        Dim col As String
        Dim item_price_  As Variant
        limit = 240
        c = t / limit
        If (c > Int(c)) Then c = Int(c) + 1
        
        For p = 1 To c
            If p = 1 Then
                Range("E1:G3").Select
                Selection.Copy
            End If
            Sheets.Add
            Range("A:A,D:D,G:G").ColumnWidth = 4.43
            Range("B:B,E:E,H:H").ColumnWidth = 17.14
            Range("C:C,F:F,I:I").ColumnWidth = 8.72
            Rows(1).RowHeight = 26.25
            Rows(2).RowHeight = 30
            Rows(3).RowHeight = 36
            If p = 1 Then
                Range("A1,D1,G1").Select
            Else
                Range("A1").Select
            End If
            ActiveSheet.Paste
            If p * limit <= t Then
            r_max = limit
            r_min = p * limit - limit
            Else
            r_min = (p - 1) * limit
            r_max = t - r_min
            End If
            row = 1
            For i = 1 To r_max
                Select Case i Mod 3
                    Case Is = 1
                        col = "C"
                        If (i + 3) Mod 3 = 1 And (i + 3) <= r_max Then
                            Rows(i & ":" & i + 2).Select
                            Selection.Copy
                            Rows(i + 3 & ":" & i + 3).Select
                            ActiveSheet.Paste
                        End If
                        row = row + 3
                    Case Is = 2
                        col = "F"
                    Case Else
                        col = "I"
                End Select
                If b = 0 Then
                    If t > 1 Then
                        Range(col & row - 3).Value = item_num(i + r_min, 1)
                        Range(col & row - 3).Offset(1, -2).Value = item_name(i + r_min, 1)
                        item_price_ = Split(item_price(i + r_min, 1), ".")
                    Else
                        Range(col & row - 3).Value = item_num
                        Range(col & row - 3).Offset(1, -2).Value = item_name
                        item_price_ = Split(item_price, ".")
                    End If
                    Range(col & row - 3).Offset(2, -1).Value = Range(col & row - 3).Offset(2, -1).Value & item_price_(0)
                    If (UBound(item_price_) - LBound(item_price_) + 1) = 2 Then
                        If Len(item_price_(1)) = 1 Then
                            Range(col & row - 3).Offset(2, 0).Value = "." & item_price_(1) & "0 " & Range(col & row - 3).Offset(2, 0).Value
                        Else
                            Range(col & row - 3).Offset(2, 0).Value = "." & item_price_(1) & " " & Range(col & row - 3).Offset(2, 0).Value
                        End If
                    Else
                        Range(col & row - 3).Offset(2, 0).Value = ".00 " & Range(col & row - 3).Offset(2, 0).Value
                    End If
                End If
             Next i
        Next p

    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.53)
        .RightMargin = Application.InchesToPoints(0.23)
        .TopMargin = Application.InchesToPoints(0.18)
        .BottomMargin = Application.InchesToPoints(0.67)
        .HeaderMargin = Application.InchesToPoints(0.17)
        .FooterMargin = Application.InchesToPoints(0.5)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .FitToPagesWide = False
        .FitToPagesTall = False
    End With
End Sub

 

 

 

Comment (0) Hits: 479
Free visitor tracking, live stats, counter, conversions for Joomla, Wordpress, Drupal, Magento and Prestashop