Exemplo n.º 1
0
void print_at(uint8_t x, uint8_t y, uint8_t channel){
	char buff[17];
	buff[16]=0;

	uint64_t threshold=1000000ULL; //1s

	LCD_goto(x,y);
	LCD_putc(time_us()-last_updated_at[channel]<threshold ? 'v' : 'x');
	LCD_puts(itoa((int)channels[channel],buff,10));
	LCD_putc(' ');
	LCD_putc(' ');
}
Exemplo n.º 2
0
int main ( void ) {

    LCD lcd = { &PORTC, 2, 3, 4, 5, 6, 7 }; // PORT, RS, EN, D4, D5, D6, D7

    LCD_Init(lcd);

    for ( ;; ) {

        LCD_Clear();
        LCD_Set_Cursor(1,0);
        LCD_putrs("  HELLO WORLD!  ");

		LCD_Set_Cursor(1,0);
		for ( char c = 'A'; c < 'Q'; ++c ) { // Print characters A-P
			 LCD_putc(c);
			 for ( unsigned char i = 0; i < 30; ++i ) { // 300ms Delay
			 	__delay_ms(10);
			 }
		}
		
		for ( unsigned char i = 0; i < 100; ++i ) { // 1s Delay
		 	__delay_ms(10);
		 }

	}

    return (EXIT_SUCCESS);
}
Exemplo n.º 3
0
void LCD_putrs ( const char *a ) {

    for ( int i = 0; a[i] != '\0'; ++i ) {
        LCD_putc(a[i]);
    }

}
Exemplo n.º 4
0
void LCD_puts(const __flash char *s, uint8_t type) {
    lcd_wasnl = 0;
    while (*s) {
        LCD_putc(*s, type | LCD_TYP_CKNL); // force new-line check here
        s++;
    }
    // if the function ended before it had the chance to goto next line when it had to:
    if (lcd_wasnl == 1)
        LCD_goto(0, ++cursor_row); // we will do it
    lcd_wasnl = 0;
}
Exemplo n.º 5
0
//	PUTC,digit,character
//	Call LCD_putc(digit, character);
//	Send "Called LCD_putc" to PC.
void OnPUTC(char *PUTCstr)
{
	uint8_t digit;

	sendFString(PUTC_msg);
	
	digit = (uint8_t)(PUTCstr[4] - 48);// convert to integer
	
	if(digit <= 6)
	{
		LCD_putc(digit,PUTCstr[5]);
		LCD_UpdateRequired(1,0);
	}
	
}
Exemplo n.º 6
0
void LCD_puts(char *str, int fd)
{
  int i;
  for (i = 0; i < 16; i++)
    {
      if (str[i] == 0x00)
        {
	  break;
        }
      else
        {
	  LCD_putc((unsigned int)str[i], fd);
        }
    }
}
Exemplo n.º 7
0
/*****************************************************************************
*
*   Function name : EnterName
*
*   Returns :       char ST_state (to the state-machine)
*
*   Parameters :    char input (from joystick)
*
*   Purpose :       Lets the user enter a name using the joystick. Pressing the
*                   joystick UP/DOWN will browse the alphabet and NEXT/PREV 
*                   will shift between the characters in the name.
*
*****************************************************************************/
char EnterName(char input)
{
    static char enter = 1;

    static char temp_index = 0;
    static char temp_name[6];
    
    char i;

    if (enter)
    {
        LoadEEPROM(Name, index, EEPROM_START + 1);  // Load name from EEPROM
                
        if(index)
            index -= 1;         //make the last character in name blink

        enter = 0;        
    }
    else
    {
        temp_index = index;
                
        for(i = 5; (i != 255); i--, temp_index--)
        {
            if ((Name[temp_index] >= ' ') && (Name[temp_index] <= 'z') && (temp_index != 255)) //check if it's legal character
                temp_name[i] = Name[temp_index];
            else
                temp_name[i] = ' '; // if not, put in a space
        }       
        
        LCD_putc(0, temp_name[0]);
        LCD_putc(1, temp_name[1]);
        LCD_putc(2, temp_name[2]);
        LCD_putc(3, temp_name[3]);
        LCD_putc(4, temp_name[4]);
        LCD_putc(5, temp_name[5] | 0x80);   //Make this digit blink
        LCD_putc(6, '\0');

        if (input != KEY_NULL)
            LCD_FlashReset();
     
        LCD_UpdateRequired(TRUE, 0);
    }
    
    if (input != KEY_NULL)
        LCD_FlashReset();

    if (input == KEY_PLUS)
    {
       
        Name[index]--;

        if( (('!' <= Name[index]) && (Name[index] <= '/')) && (Name[index] != ' '))
            Name[index] = ' ';
        else if( (':' <= Name[index]) && (Name[index] <= '@'))
            Name[index] = '9';
        else if(Name[index] >= '[')
            Name[index] = 'Z';
        else if(Name[index] < ' ')
            Name[index] = 'Z';

    }
    else if (input == KEY_MINUS)
    {
        Name[index]++;

        if( (('!' <= Name[index]) && (Name[index] <= '/')) && (Name[index] != ' '))
            Name[index] = '0';
        else if( (':' <= Name[index]) && (Name[index] <= '@'))
            Name[index] = 'A';
        else if(Name[index] >= '[')
            Name[index] = ' ';
        else if(Name[index] < ' ')
            Name[index] = ' ';
    }
    else if (input == KEY_PREV)
    {
        if(index)
        {
            index--;
        }
    }
    else if (input == KEY_NEXT)
    {
        if(index < STRLENGHT)
        {
            index++;
            Name[index] = 'A';            
        }
    }
    else if (input == KEY_ENTER)
    {
        index++;
        
        Name[index] = '\0';
        
        __EEPUT(EEPROM_START, index);   //store the length of name in EEPROM
    
        StoreEEPROM(Name, index, EEPROM_START + 1);  //store the Name in EEPROM
        
        enter = 1;
        return ST_VCARD_FUNC;
    }

    return ST_VCARD_ENTER_NAME_FUNC;
}
Exemplo n.º 8
0
void LCD_puts(char *s){
	while(*s != '\0'){
		LCD_putc(*s);
		s++;
	}
}
Exemplo n.º 9
0
void show_dig(void)
{
    if(tech_fl&DIG_MINUS) LCD_putc('-',10);

    LCD_float(pm2, pm_dot, 0);
    LCD_abc((char*)show_dig_str[0],6);
    LCD_float(pm_minv, pm_dot, 10);

    LCD_float(*pm_val, pm_dot, 16);
    LCD_abc((char*)show_dig_str[1],22);
    LCD_float(pm_maxv, pm_dot, 26);

    if(KEY_OK)
    {
        if((pm2<=pm_maxv)&&(pm2>=pm_minv))
            *pm_val=pm2;
        tech_fl&=~DIG_INPUT;
    }
    if(KEY_NO)
    {
        if(pm2) {pm2=0;tech_fl&=~DIG_MINUS;}
        else tech_fl&=~DIG_INPUT;
    }
    if(!(tech_fl&DIG_MINUS))
    {
        if(KEY_1) {if(((pm2*10+1)<=pm_maxv)//&&((pm2*10+1)>=pm_minv)
                &&((pm2*10+1)>0)) pm2=(pm2*10+1);}
        if(KEY_2) {if(((pm2*10+2)<=pm_maxv)//&&((pm2*10+2)>=pm_minv)
                &&((pm2*10+2)>0)) pm2=(pm2*10+2);}
        if(KEY_3) {if(((pm2*10+3)<=pm_maxv)//&&((pm2*10+3)>=pm_minv)
                &&((pm2*10+3)>0)) pm2=(pm2*10+3);}
        if(KEY_4) {if(((pm2*10+4)<=pm_maxv)//&&((pm2*10+4)>=pm_minv)
                &&((pm2*10+4)>0)) pm2=(pm2*10+4);}
        if(KEY_5) {if(((pm2*10+5)<=pm_maxv)//&&((pm2*10+5)>=pm_minv)
                &&((pm2*10+5)>0)) pm2=(pm2*10+5);}
        if(KEY_6) {if(((pm2*10+6)<=pm_maxv)//&&((pm2*10+6)>=pm_minv)
                &&((pm2*10+6)>0)) pm2=(pm2*10+6);}
        if(KEY_7) {if(((pm2*10+7)<=pm_maxv)//&&((pm2*10+7)>=pm_minv)
                &&((pm2*10+7)>0)) pm2=(pm2*10+7);}
        if(KEY_8) {if(((pm2*10+8)<=pm_maxv)//&&((pm2*10+8)>=pm_minv)
                &&((pm2*10+8)>0)) pm2=(pm2*10+8);}
        if(KEY_9) {if(((pm2*10+9)<=pm_maxv)//&&((pm2*10+9)>=pm_minv)
                &&((pm2*10+9)>0)) pm2=(pm2*10+9);}
        if(KEY_0) { if(!pm2)
                {
                    if(pm_minv<0)
                        tech_fl|=DIG_MINUS;
                }
                if(((pm2*10+0)<=pm_maxv)//&&((pm2*10+0)>=pm_minv)
                    &&((pm2*10+0)>0)) pm2=(pm2*10+0);}
    }
    else
    {
        if(KEY_1) {if(((pm2*10-1)>=pm_minv)//&&((pm2*10-1)<=pm_maxv)
                &&((pm2*10-1)<0)) pm2=(pm2*10-1);}
        if(KEY_2) {if(((pm2*10-2)>=pm_minv)//&&((pm2*10-2)<=pm_maxv)
                  &&((pm2*10-2)<0)) pm2=(pm2*10-2);}
        if(KEY_3) {if(((pm2*10-3)>=pm_minv)//&&((pm2*10-3)<=pm_maxv)
                  &&((pm2*10-3)<0)) pm2=(pm2*10-3);}
        if(KEY_4) {if(((pm2*10-4)>=pm_minv)//&&((pm2*10-4)<=pm_maxv)
                  &&((pm2*10-4)<0)) pm2=(pm2*10-4);}
        if(KEY_5) {if(((pm2*10-5)>=pm_minv)//&&((pm2*10-5)<=pm_maxv)
                  &&((pm2*10-5)<0)) pm2=(pm2*10-5);}
        if(KEY_6) {if(((pm2*10-6)>=pm_minv)//&&((pm2*10-6)<=pm_maxv)
                  &&((pm2*10-6)<0)) pm2=(pm2*10-6);}
        if(KEY_7) {if(((pm2*10-7)>=pm_minv)//&&((pm2*10-7)<=pm_maxv)
                  &&((pm2*10-7)<0)) pm2=(pm2*10-7);}
        if(KEY_8) {if(((pm2*10-8)>=pm_minv)//&&((pm2*10-8)<=pm_maxv)
                  &&((pm2*10-8)<0)) pm2=(pm2*10-8);}
        if(KEY_9) {if(((pm2*10-9)>=pm_minv)//&&((pm2*10-9)<=pm_maxv)
                  &&((pm2*10-9)<0)) pm2=(pm2*10-9);}
        if(KEY_0) {if(((pm2*10-0)>=pm_minv)//&&((pm2*10-0)<=pm_maxv)
                  &&((pm2*10-0)<0)) pm2=(pm2*10-0);}
    }
}