示例#1
0
void handle_switch_frame(uint8_t *frame)
{
	if (frame[1] == REQUEST_MSG)
	{
		switch((switch_cmd_t) frame[2])
		{
			case SWITCH_ON:
				LIGHT_ON();
				break;
			case SWITCH_OFF:
				LIGHT_OFF();
				break;
			case SWITCH_TOGGLE:
				LIGHT_TOGGLE();
				break;
		}
	}
}
示例#2
0
文件: uart.c 项目: DCLMonk/Pennyworth
int main(int argc, char* argv[]) {

	DDRD |= (1 << LIGHT);
	LIGHT_OFF();
	serial_init();

	FILE s=FDEV_SETUP_STREAM(send_char_serial,NULL,_FDEV_SETUP_WRITE);
	stdout=&s;

	printf("Test String\n");

	while (1) {
		send_char_serial(receive_char_serial());
		LIGHT_ON();
	}

	return 0;
}
示例#3
0
void *fn_showFastPorts(int init){
    // display the application screen
    lcd_puts("Digi 1   Digit 2");
    lcd_gotoxy(0, 2);
    sprintf(buf_fdi_values, "%3d       %3d", value_1, value_2);
    lcd_puts(buf_fdi_values);
    
    if(opt_send_data_via_uart){
        LIGHT_ON(LED_RED);
        sprintf(buf_fdi_values, "%d,%d;\n", value_1, value_2);
        uart_puts( buf_fdi_values );
        uart_puts("\n");
        LIGHT_OFF(LED_RED);
    }
    
    // count the ports
    value_1 = DIGITAL_IN_1_READ;
    value_2 = DIGITAL_IN_2_READ;
    return (void *) NULL;
}
示例#4
0
void *fn_sayHello(int init){
    lcd_gotoxy(0, 0);
    lcd_puts(("hello world."));
    lcd_gotoxy(0, 2);
    lcd_puts(("                "));
    lcd_gotoxy(hello_position, 2);
    lcd_puts(" -");
    ++hello_position;
    if(hello_position > 15){
        hello_position = 0;
    }
    if(opt_send_data_via_uart){
        LIGHT_ON(LED_RED);
        itoa(hello_position, buf, 10);
        uart_puts( buf );
        uart_puts( "\n" );
        LIGHT_OFF(LED_RED);
    }
    _delay_ms(200);
    return (void *) NULL;
}
示例#5
0
void *opt_uartonoff_init(int init){
    frontbuttoncontrol_read();
    if(opt_send_data_via_uart_lastvalue != opt_send_data_via_uart){
        lcd_gotoxy(0, 2);
        if(opt_send_data_via_uart == false){
            lcd_puts("Uart turned off");
        } else {
            lcd_puts("Uart turned on ");
        }
    }
    
    if(frontbuttoncontrol_get_button() == BUTTON_BLUE){
        LIGHT_ON(LED_RED);
        opt_send_data_via_uart = !(opt_send_data_via_uart);
        if(opt_send_data_via_uart){
            _delay_ms(300);
            uart_puts("Starts to send data:\n");
            LIGHT_OFF(LED_RED);
        }
        _delay_ms(500);
        LIGHT_OFF(LED_RED);
    }
    return ((void*)NULL);
}