Example #1
0
int16_t main(void)
{
    char c = 'g';
    
    /* Configure the oscillator for the device */
    ConfigureOscillator();

    /* Initialize IO ports and peripherals */
    InitApp();

    hd44780_init(N_2LINE,FONT_8);
    //hd44780_setCursorPosition(0, 0);
    hd44780_write_char(' ');
    hd44780_write_char('G');
    hd44780_write_char('K');
    hd44780_write_string("hat DE Lieb");

    while(1)
    {
        if(UART1RXRdy()==1){//check for data waiting
			c=UART1RX();//get the character
			if(c=='0')
            {
                T1CONbits.TON = ~T1CONbits.TON;  /* enable Timer 1 and start the count */
                if(!T1CONbits.TON) //if timer is off, turn off LED
                {
                    UART1TX('T');
                    UART1TX('1');
                    UART1TX('-');
                    UART1TX('O');
                    UART1TX('F');
                    UART1TX('F');
                    UART1TX('\n');
                    UART1TX('\r');
                    MSLED_O = 0;
                }
                else
                {
                    UART1TX('T');
                    UART1TX('1');
                    UART1TX('-');
                    UART1TX('O');
                    UART1TX('N');
                    UART1TX('\n');
                    UART1TX('\r');
                    MSLED_O=1;
                }
			}
            else
            {
                UART1TX(c);//echo the character back
                hd44780_write_char(c);
            }
  		}
    }
}
Example #2
0
void hd44780_load_symbol(uint8_t addr, const uint8_t * data) {
//	hd44780_wr_cmd((addr<<3)+0b10000000);
	hd44780_cgram_addr(addr);
	for (uint8_t i = 0; i < 8; i++)
		hd44780_write_char(data[i]);
//	hd44780_ddram_addr(0);
}
void hd44780_write_string(char *str)
{
    while (*str != '\0')
    {
        hd44780_write_char(*str++);
    }
}
Example #4
0
static void hd44780_init_char_gen(void)
{
	int i;

	hd44780_instruction(HD44780_SET_CGRAM_ADDR);

	for (i = 0; i < sizeof(char_gen_chars); i++)
		hd44780_write_char(char_gen_chars[i]);

	hd44780_instruction(HD44780_SET_DDRAM_ADDR);
}
Example #5
0
static int do_hd44780(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
	char *cmd;

	if (argc != 3)
		return CMD_RET_USAGE;

	cmd = argv[1];

	if (strcasecmp(cmd, "cmd") == 0)
		hd44780_instruction(simple_strtol(argv[2], NULL, 0));
	else if (strcasecmp(cmd, "data") == 0)
		hd44780_write_char(simple_strtol(argv[2], NULL, 0));
	else if (strcasecmp(cmd, "str") == 0)
		hd44780_write_str(argv[2]);
	return 0;
}
Example #6
0
void hd44780_write_string(const char *s) {
	for (uint8_t i = 0; (s[i] != '\0') && (i < HD44780_DISP_LENGTH); i++)
		hd44780_write_char(s[i]);
}