Skip to content

Instantly share code, notes, and snippets.

@volodymyrlut
Last active August 29, 2015 14:22
Show Gist options
  • Save volodymyrlut/e90708bb7e9d15738896 to your computer and use it in GitHub Desktop.
Save volodymyrlut/e90708bb7e9d15738896 to your computer and use it in GitHub Desktop.
while (1)
{
if(PINC.0==0){
lcd_init(16);
lcd_gotoxy(0,0);
i = 0;
if(mode==0){
lcd_putsf("set temp");
} else {
lcd_putsf("set time");
}
delay_ms(500);
}
if(PINC.1==0){
lcd_init(16);
lcd_gotoxy(0,0);
i+=5;
if(mode==0){
sprintf(buff ,"temp : %i", i);
} else {
sprintf(buff ,"time : %i", i);
}
lcd_puts(buff);
delay_ms(500);
}
if(PINC.2==0){
lcd_init(16);
lcd_gotoxy(0,0);
i-=5;
if(mode==0){
sprintf(buff ,"temp : %i", i);
} else {
sprintf(buff ,"time : %i", i);
}
lcd_puts(buff);
delay_ms(500);
}
if(PINC.3==0){
lcd_init(16);
lcd_gotoxy(0,0);
if(mode==0){
mem_temp = i;
mode = 1;
} else {
mem_time = i;
mode = 0;
}
i = 0;
lcd_puts("saved");
delay_ms(500);
}
if((mem_time>0)&&(mem_temp>0)){
lcd_init(16);
lcd_gotoxy(0,0);
PORTB.2=1;
most_sig_byte=spi(0x00);
delay_ms(10);
least_sig_byte=spi(0x00);
PORTB.2=0;
temperature=(most_sig_byte«8) | least_sig_byte;
temperature=temperature &0x7FF8;
temperature=temperature»4;
temperature -=24;
sprintf(Temp,"%d", temperature);
lcd_puts(Temp);
if(temperature < mem_temp){
PINC.5 = 1;
} else {
PINC.5 = 0;
}
delay_ms(500);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment