/* Timer compare ISR, for ADC reads */ ISR(TIMER1_COMPA_vect, ISR_BLOCK) { switch (currentState) { case STATE_X_READ: currentX = getResult(); #ifdef DEBUG phex16(currentX); #endif #if defined COORD && COORD == 'X' setupX(); currentState = STATE_X_START; move_mouse(); #else setupY(); currentState = STATE_Y_START; #endif break; case STATE_Y_START: ADMUX = (1<< REFS0) | (1 << MUX0); //ADC1 ADCSRA = (1 << ADEN)|(1 << ADSC)|(1<< ADC_PRESCALER_64); currentState = STATE_Y_READ; break; case STATE_Y_READ: currentY = getResult(); #ifdef DEBUG phex16(currentY); print("\t"); #endif move_mouse(); #if defined COORD && COORD == 'Y' setupY(); currentState = STATE_Y_START; #else setupX(); currentState = STATE_X_START; #endif break; case STATE_X_START: ADMUX = (1 << REFS0) | (1 << MUX2); //ADC4 ADCSRA = (1 << ADEN)|(1 << ADSC)|(1<< ADC_PRESCALER_64); currentState = STATE_X_READ; break; } }
void Touch::process() { switch (this->getCycle()) { case 0: setupX(); break; case 1: startX(); break; case 2: setupY(); break; case 3: startY(); break; default: asm("nop"); } }