Beispiel #1
0
void setSpeed (uint8_t level,uint8_t *working,uint8_t *stopping){

	cli();
		switch (level) {
		case HIGH:
			*working=5;
			*stopping=0;
			lcd_pos(4,9);
			lcd_putstring("H");
			break;
		case MED:
			*working=3;
			*stopping=2;
			lcd_pos(4,9);
			lcd_putstring("M");
			break;
		case LOW:
			*working=2;
			*stopping=3;
			lcd_pos(4,9);
			lcd_putstring("L");
			break;
		case OFF:
			*working=0;
			*stopping=5;
			lcd_pos(4,9);
			lcd_putstring("O");
			break;
		}
	sei();
}
Beispiel #2
0
main()
 {
    uchar m;
    P0=0xFF;                    //置P0口
    P1=0xFF;                    //置P1口  
    delay(10);                 //延时
    lcd_init();                //初始化LCD             
        
    lcd_pos(0);                //设置显示位置为第一行的第1个字符
     m = 0;
    while(cdis1[m] != '\0')
     {                         //显示字符
       lcd_wdat(cdis1[m]);
       m++;
     }

    lcd_pos(0x40);             //设置显示位置为第二行第1个字符
     m = 0;
    while(cdis2[m] != '\0')
     {
       lcd_wdat(cdis2[m]);      //显示字符
       m++;
     }       
	  dis_buf = 0x2d;          //显示字符"-"

    while(1)
    { 
       keydown();
	   lcd_pos(0x4c);             
       lcd_wdat(dis_buf);        //第一位数显示   
    }
  }   
Beispiel #3
0
void main(void) {
    int count;
    unsigned int adcValue = 0;
    unsigned int adcValueOld = 0;
    char buffer[16];

    ConfigureOscillator();
    InitApp();

    lcd_init();
    lcd_enable();
    lcd_cursor_off();
    lcd_test();
    lcd_pos(2, 1);
    while (1) {
        ConvertADC();
        while (BusyADC());
        adcValue = ReadADC();
        if (adcValue != adcValueOld) {
            lcd_clear();
            lcd_pos(1, 1);
            memset(&buffer[0], 0, sizeof(buffer));
            sprintf(&buffer[0], "Valor: %.4u %.3u%%", adcValue, (int)(((float)adcValue / 1024) * 100));
            lcd_write_buffer(buffer, strlen(buffer));
            adcValueOld = adcValue;
        }
        __delay_ms(20);
    }
}
main()
{
   uchar m;
    
    IRIN=1;                    //I/O口初始化
    BEEP=1;
	  RELAY=1; 
	
    delay1(10);                 //延时
    lcd_init();                //初始化LCD             
        
    lcd_pos(0);                //设置显示位置为第一行的第1个字符

     m = 0;
    while(cdis1[m] != '\0')
     {                         //显示字符
       lcd_wdat(cdis1[m]);
       m++;
     }

    lcd_pos(0x40);             //设置显示位置为第二行第1个字符
     m = 0;
    while(cdis2[m] != '\0')
     {
       lcd_wdat(cdis2[m]);      //显示字符
       m++;
     }


	IE = 0x81;                 //允许总中断中断,使能 INT0 外部中断
	TCON = 0x01;               //触发方式为脉冲负边沿触发

   while(1)	;

} //end main
main()
{
 uchar m;
    P2=0xff;
    IRIN=1;                    //I/O口初始化
    BEEP=1;
    RELAY=1; 
	
    delay1(10);                 //延时
    lcd_init();                //初始化LCD             
        
    lcd_pos(0);                //设置显示位置为第一行的第1个字符

     m = 0;
    while(cdis1[m] != '\0')
     {                         //显示字符
       lcd_wdat(cdis1[m]);
       m++;
     }

    lcd_pos(0x40);             //设置显示位置为第二行第1个字符
     m = 0;
    while(cdis2[m] != '\0')
     {
       lcd_wdat(cdis2[m]);      //显示字符
       m++;
     }


	IE = 0x81;                 //允许总中断中断,使能 INT0 外部中断
	TCON = 0x01;               //触发方式为脉冲负边沿触发
  while(1)
	{
	
		keyscan();
 
	delay(10);
    	switch(key)								   //读出对应值
		{
					
			case 1:P1= 0x08;break;
			case 2:P1= 0x3f;break;
			case 3:P1= 0x2d;break;
			case 4:P1= 0x08;break;
			case 5:P1= 0x10;break;
			case 6:P1= 0x20;break;
			case 7:P1= 0x40;break;
			case 8:P1= 0x80;break;
			default:break; 
		 
		}  
}
}//end main
Beispiel #6
0
// Show command by index
void ShowCmd(uint8_t cmd_index) {
	if (state.bits.config==1) return;
	_cmd_type Cmd = CmdArray[cmd_index];
	char buf[6];
	int16_to_str(cmd_index+1, buf, 0x30); // bcd convertion
	lcd_pos(0x10);
	lcd_out(buf+2); lcd_out(": "); 
	lcd_dat(Cmd.cmd_name); lcd_hex(Cmd.cmd_data);
	lcd_pos(0x00); lcd_out(GetTimerName(LastTimerDelay));
//	lcd_hexdigit(LastTimerDelay

}
Beispiel #7
0
void main(void) {
    int count;
    int size;
    unsigned int adcValue = 0;
    unsigned int adcValueOld = 0;
    char buffer[16];

    ConfigureOscillator();
    InitApp();

    lcd_init();
    lcd_enable();
    lcd_cursor_off();
    lcd_test();
    lcd_pos(2, 1);
    while (1) {
        ConvertADC();
        while (BusyADC());
        adcValue = ReadADC();
        if (adcValue != adcValueOld) {
            lcd_clear();
            //Linha 1
            lcd_pos(1, 1);
            memset(&buffer[0], 0, sizeof (buffer));
            sprintf(&buffer[0], "Step:%.4u %3.1f%%", adcValue, ((float) adcValue / 1023) * 100);
            size = (strlen(buffer) > sizeof(buffer)) ? sizeof(buffer) : strlen(buffer);
            lcd_write_buffer(buffer, size);
            for(count = 0; count < size; count++){
                while(BusyUSART());
                putcUSART((char)buffer[count]);
            }
            //Linha 2
            lcd_pos(2, 1);
            memset(&buffer[0], 0, sizeof (buffer));
            sprintf(&buffer[0], "Volts:%1.7fV", (float)adcValue * ((float)5 /1023));
            size = (strlen(buffer) > sizeof(buffer)) ? sizeof(buffer) : strlen(buffer);
            lcd_write_buffer(buffer, size);
            //Variável de controle
            adcValueOld = adcValue;
            for(count = 0; count < size; count++){
                while(BusyUSART());
                putcUSART((char)buffer[count]);
            }
        }
        for (count = 0; count < 40; count++) {
            __delay_ms(10);
        }
    }
}
Beispiel #8
0
void main()
{
	unsigned int i,j,k,l,m,n;
	PINSEL0=0X00000000;
	PINSEL1=0X00000000;
	IO0DIR=0XFFFFFFFF;
	lcd_init();
	init_rtc();
	lcd_str("CLOCK:- 24");
	cmd(0xc0);
	lcd_str("00:00:00");
	while(1)
	{ 
	        if(flag)
	        {
			flag=0;
			lcd_pos(2,0);
			lcd_display(HOUR/10 + '0');
			lcd_display(HOUR%10 + '0'); 
			lcd_display(':') ;
			lcd_display(MIN/10 + '0');
			lcd_display(MIN%10 + '0');
			lcd_display(':') ;
			lcd_display(SEC/10 + '0');
		        lcd_display(SEC%10 + '0');
	        }
	}

}
Beispiel #9
0
/**********************************************************

* 主函数

**********************************************************/
void  main()
{
    uchar  m;

    lcd_init();                          //LCD1602初始化

    lcd_pos(0x00);                 //设置显示位置为第一行
    for(m=0;m<16;m++)
    lcd_write(1,cdis1[m]);


     lcd_pos(0x40);                //设置显示位置为第二行     
     for(m=0;m<16;m++) 
     lcd_write(1,cdis2[m]);

      while(1);
}
Beispiel #10
0
// Show seconds counter value 
void ShowTime(uint16_t data) {
	if (state.bits.config==1) return;

	uint16_t mins = data / 60; if (mins>99) mins=99;
	uint16_t secs = data % 60;

	lcd_pos(0x1b);
	char buf[6];
	int16_to_str(mins, buf, 0x30); 
	lcd_out(buf+3);lcd_dat(':');
	int16_to_str(secs, buf, 0x30); 
	lcd_out(buf+3);
}
Beispiel #11
0
/*???*/
main()
{
	uchar i;
	wela=0;
	dula=0;
	delay_1ms(10);
	lcd_init();
	lcd_pos(1,0);
	i=0;
	while(dis2[i]!='\0')
	{
		write_dat(dis2[i]);
		i++;
	}
	lcd_pos(2,0);
	i=0;
	while(dis3[i]!='\0')
	{
		write_dat(dis3[i]);
		i++;
	}
	lcd_pos(3,0);
	i=0;
	while(dis4[i]!='\0')
	{
		write_dat(dis4[i]);
		i++;
	}
	while(1)
	{
		lcd_pos(0,0);
		makerand();
		for(i=0;i<10;i++)
		{
			write_dat(dis1[i]);
		}
	}
}
Beispiel #12
0
  main()
 {
    uchar i;
    delay(10);                 //延时
    lcd_init();                //初始化LCD             
  
    lcd_pos(0,0);             //设置显示位置为第一行的第1个字符
     i = 0;
    while(dis1[i] != '\0')
     {                         //显示字符
       lcd_wdat(dis1[i]);
       i++;
     }
    lcd_pos(1,0);             //设置显示位置为第二行的第1个字符
     i = 0;
    while(dis2[i] != '\0')
     {
       lcd_wdat(dis2[i]);      //显示字符
       i++;
     }
 	 lcd_pos(2,0);             //设置显示位置为第三行的第1个字符
     i = 0;
    while(dis3[i] != '\0')
     {
       lcd_wdat(dis3[i]);      //显示字符
       i++;
     }
	 lcd_pos(3,0);             //设置显示位置为第四行的第1个字符
     i = 0;
    while(dis4[i] != '\0')
     {
       lcd_wdat(dis4[i]);      //显示字符
       i++;
     }
     while(1);
}
Beispiel #13
0
void main(void)
{
    ConfigureOscillator();
    InitApp();

    lcd_init();
    lcd_enable();
    lcd_cursor_off();
    lcd_test();
    lcd_pos(2,1);
    while(1)
    {
        
    }
}
Beispiel #14
0
void main()
{
	lcd_init();
	lcd_pos(0, 0);
	lcd_write_string("Ξ�½ΠΑυξΘ£Ί1234‘ζ");
	UART_Init();
	while (1) 
	{
		LED_ON();
		delay_ms(100);
		LED_OFF();
		delay_ms(100);
		SendData('b');
		SendData('\n');
	}
}
Beispiel #15
0
void ShowError(uint8_t ErrorClass, uint8_t ErrorCode) {
	timer_stop(-1); // stop all timers
	OutDataPort(0); // reset all ports
	state.bits.error=1;
	state.bits.started = 0;
	if (state.bits.config == 1) {
		StopMenu();
		state.bits.config = 0;
	}

	char buf[6];
	int16_to_str(ErrorCode+1, buf, 0x30); // bcd convertion

	lcd_clear();
	ShowCmd(ErrorCode);
	lcd_pos(0x19); lcd_out((char[]){79,193,184,178,186,97,33,0}); // "Ошибка!"
Beispiel #16
0
void
main(void)
{
	char tmpbuf[256];
	int i, f, fpos = 0, block, cur, got, vol = 0xfff;
	char *buf = (void *) 0x80080000;

	fnames = malloc(MAX_FNAMES * 256);

	tmpbuf[0] = 'd';
	tmpbuf[1] = ':';
	tmpbuf[2] = 0;
	f = open(tmpbuf, O_RDONLY);
	if (f > 0)
		close(f);
	scan_files(tmpbuf);
	lcd_init();

next_file:
	f = open(fnames[fpos], O_RDONLY);
	if (f < 0) {
		printf("Open failed\n");
		exit (1);
	}
	printf("Playing %s, vol %d\n", fnames[fpos], vol);
	lcd_pos(0, 0);
	lcd_puts(&fnames[fpos][3]);
	lcd_puts("          ");

	block = 0;
	got = read(f, buf, 0x8000);
	OUTW(IO_PCM_FIRST, buf);
	OUTW(IO_PCM_LAST, buf + 0x7ffe);
	OUTW(IO_PCM_FREQ, 9108); /* 44.1 kHz sample rate */
	OUTW(IO_PCM_VOLUME, vol + (vol << 16));

	while (got > 0) {
		INW(cur, IO_PCM_CUR);
		if ((cur & 0x4000) != block) {
			got = read(f, buf + block, 0x4000);
			block = cur & 0x4000;
			INB(i, IO_PUSHBTN);
			if ((i & BTN_UP) && vol < 0xffff)
				vol = (vol << 1) + 1;
			if ((i & BTN_DOWN) && vol > 0)
				vol = vol >> 1;
			if ((i & (BTN_UP|BTN_DOWN)))
				printf("Playing %s, vol %d\n",
				    fnames[fpos], vol);
			lcd_pos(0, 1);
			sprintf(tmpbuf, "volume %d ", vol);
			lcd_puts(tmpbuf);
			OUTW(IO_PCM_VOLUME, vol + (vol << 16));
			if ((i & BTN_LEFT)) {
				close(f);
				if (fpos == 0)
					fpos = fcnt;
				fpos--;
				goto next_file;
			}
			if ((i & BTN_RIGHT))
				break;
		}
#ifdef __mips__
		/* Wait for an interrupt, but which one? - XXX REVISIT!!! */
		__asm __volatile__("wait");
#endif
	}
Beispiel #17
0
void Set_Control_Byte(uint8_t data) {
	ControlPortState = data; // запоминаем состояние порта
//	OutDataPort(0);		// очищаем значения порта
	OutDataPort(data);	// выставляем значения порта
	lcd_pos(0x0e); lcd_hex(ControlPortState);
}
Beispiel #18
0
void ShowSensors(void)
{
	if (state.bits.config==1) return; 
	lcd_pos(0x1E); lcd_hex(CurSensors);
	lcd_pos(0x10); lcd_hex(ControlPortState);
}