SetupHardware();
init_plate_timer();
- touchpad_init(); // you need to call this to setup the I/O pin!
+// touchpad_init(); // you need to call this to setup the I/O pin!
_delay_ms(500);
sei();
- touchpad_set_rel_mode_100dpi();// use touchpad in relative mode
+// touchpad_set_abs_mode();// use touchpad in relative mode
while (1) {
Usb2SerialTask();
// touchpad_read(); // read data from touchpad
// inc_target_plate_pos_x(4*delta_x());
// inc_target_plate_pos_y(-4*delta_y());
+// uart_print_number(x_abs(),5);
+// uart_puts("\n\r");
+// _delay_ms(200);
if(plate_ready()){
pos_report();
}
// plate stuff
-int32_t plate_pos_x = 0,plate_pos_y = 0;
-int32_t target_plate_pos_x = 0,target_plate_pos_y = 0;
+volatile int32_t plate_pos_x = 0,plate_pos_y = 0;
+volatile int32_t target_plate_pos_x = 0,target_plate_pos_y = 0;
uint8_t ready = 0;
- _delay_us(PHASE_DELAY_US);
+// _delay_us(PHASE_DELAY_US);
if( busy && (todo_x==0) && (todo_y==0) ){
busy=0;
}
-
+// the following is only needed if used with interrupt
void init_plate_timer(void){
TCCR1B |= (1<<CS10) | (1<<CS12) | (1<<WGM12);
TCCR1C |= (1<<FOC1A);
- OCR1A = 32;
+ OCR1A = TIMER_SETTING;
TIMSK1 |= (1<<OCIE1A);
}
-#define PHASE_DELAY_US 0
+#define PHASE_DELAY_US 1500
+#define TIMER_STEP 6.4e-5
+
+#define TIMER_SETTING PHASE_DELAY_US*1e-6/TIMER_STEP