Example #1
0
__interrupt void USCIAB0RX_ISR()
{
    P1OUT |= BIT0;  // red led
    char cmd[CMDLEN];
    uint i;

    /*
     *  UCA0RXIFG is high when UCA0RXBUF has received a complete character.
     *  However, it rarely stays high more than one byte at a time.  Perhaps
     *  because I type too slow on my keyboard.  Because of this all the
     *  commands are a single character for now.
     */
    for (i = 0; (IFG2 & UCA0RXIFG) && i < CMDLEN; i++) {
        cmd[i] = UCA0RXBUF; // get it out of the buffer before it is overwritten with new traffic
    } // keep checking the buffer until it is clear or we have 79 characters

    cmd[i] = '\0';  // last character always terminates the string

    P1OUT &= ~BIT0;

    /*
     * Parse command
     */
    if (strcmp(cmd, "h") == 0)          // help
        serial_log("\r\nHelp?  There is only one commmand: 'v'\r\n");
    else if (strcmp(cmd, "v") == 0)     // version
        serial_log("\r\nUart Debug 1.0 by Matthew Cashdollar <*****@*****.**>\r\n");
    else {
        serial_log("\r\nBad command: ");
        serial_log(cmd);
        serial_log("\r\nType 'h' for help.\r\n");
    }
}
void loop()
{
	int raw_temp = analogRead(TEMP_SENSOR);
	int magnify = digitalRead(TEMP_MAGNIFY_BTN);

	float deg_temp = 37.3 / 1024 * raw_temp;

	if (magnify == HIGH) {					// magnifying mode button ON/OFF
		ref_deg_temp = deg_temp; 			// setting up the reference value
		set_led_rgb(ref_deg_temp);
	}
	else {
		ref_deg_temp = 0;					// reset the temperature value
		set_led_rgb(0);
	}

	serial_log();
	delay(250);
}