/* ------------------------------------------------------------------ */ uint8_t topMenu(uint8_t key) { static int enter = 1; if (enter) { LCD_WriteLine(0, 16, "Beat The Buzzer "); LCD_WriteLine(1, 16, "Press Start "); enter = 0; } if (key == KEY_START) { enter = 1; return ST_GAME_RUNNING; } return ST_TOP_MENU; }
/* ------------------------------------------------------------------ */ uint8_t gameRunning(uint8_t key) { static int enter = 1; if (enter) { LCD_WriteLine(0, 16, "Beat The Buzzer "); LCD_WriteLine(1, 16, "Lives Left: "); enter = 0; } if (key == KEY_RESET) { enter = 1; return ST_TOP_MENU; } else if (key == KEY_LOOP) { // TODO: Sound buzzer } return ST_GAME_RUNNING; }
int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop WDT BCSCTL1 = XT2OFF | CALBC1_1MHZ;//turn off XT2, SET ACLK to divide by 8, set MCLK (CPU) to 1, 8, 12, or 16 MHz DCOCTL = CALDCO_1MHZ; ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; // ADC10ON, interrupt enabled ADC10CTL1 = A2DKNOBCHANNEL; // input A1 ADC10AE0 |= BIT1 | BIT3 | BIT4; // PA.1 ADC option select P1DIR |= GREEN_LED; // Set P1.0 to output direction RED LED P1DIR |= BIT2 | RED_LED; // P1.2 to output P1SEL |= BIT2; // P1.2 to TA0.1 //setup timer A0, which runs the pulse width modulator and data sampling //counter counts from 0 to TACCR0 and then starts over TA0CCR0 = 32768-1; // PWM Period TA0CCTL1 = OUTMOD_7; // CCR1 reset/set TA0CTL = TASSEL_2 + MC_1 + ID_0; // SMCLK divide by 1, up mode TA0CCTL0 = CCIS_2 | CCIE; // compare mode CCIS_2 sets GND as input => less current?; enable interrupt //setup timer A1, which runs the display TA1CCR0 = 0x800; // PWM Period TA1CCTL0 = OUTMOD_3; // TA1CTL = TASSEL_2 + MC_2 + ID_3; // SMCLK divide by 8, counts up continues mode TA1CCTL0 = CCIE; // compare mode CCIS_2 sets GND as input => less current?; enable interrupt /* //int power[20]; unsigned int power[5]; char * temp; int i ; for( i = 0; i <= 4; i++ ){ power[i] = i; sprintf(temp, "%d", power[i] ); LCD_Intialize(); LCD_WriteLine(temp, LCD_FIRST_LINE);// \0 inserts 0 value (not 0 character) into string=c convention for end of line if( i == 1){ LCD_WriteLine(temp, LCD_FIRST_LINE);// \0 inserts 0 value (not 0 character) into string=c convention for end of line } else if( i == 2 ){ LCD_WriteLine( temp, LCD_SECOND_LINE); } else if( i == 3 ){ LCD_WriteLine(temp, LCD_THIRD_LINE); } else{ LCD_WriteLine(temp, LCD_FOURTH_LINE); } } */ LCD_Intialize(); sprintf(topstring,"TIME VOLTAGE\0"); LCD_WriteLine(topstring, LCD_FIRST_LINE); for (;;) { __bis_SR_register(CPUOFF + GIE);// Turn off CPU pending interrupt=LPM0 this line is only necessary to save power if(tst_flag(TIMER1_FLAG)){ //4 high is some event ex. 0x4 -> 0x00100 clr_flag(TIMER1_FLAG); voltage_count = voltage_count>>3; voltage_value = voltage_count<<4; voltage_value += voltage_count<<3; voltage_value += voltage_count<<2; sprintf(voltage,"%d", voltage_value); sprintf(scdstring," %c.%cV\0", voltage[0],voltage[1]); LCD_WriteLine(scdstring, LCD_SECOND_LINE); } if(tst_flag(A2D_FLAG)){ clr_flag(A2D_FLAG); knob_count_low_pass_filter+= (knob_count - (knob_count_low_pass_filter>>5)); CCR1 = knob_count_low_pass_filter; // sprintf(topstring,"Testing = %d\0", CCR1); //LCD_WriteLine(topstring, LCD_SECOND_LINE); } } }