Ejemplo n.º 1
0
Archivo: hw_com.c Proyecto: 5kg/gdb
static unsigned
hw_com_io_read_buffer_callback(device *me,
			       void *dest,
			       int space,
			       unsigned_word addr,
			       unsigned nr_bytes,
			       cpu *processor,
			       unsigned_word cia)
{
  hw_com_device *com = device_data(me);
  int i;
  for (i = 0; i < nr_bytes; i++) {
    read_com(me, com, addr + i, &((char*)dest)[i]);
  }
  return nr_bytes;
}
Ejemplo n.º 2
0
int main() {
	char chout='\n';
	int action=1;
	time_t last_time_action, current_time, last_time;
	
	if ( init_mpc () == 0) {
		printf("Error init mpc\n");
		exit (-1);
	}

	output_t * output_st = init_output_st ();

	while (init_display(output_st)) {
		printf("Error display\n");
		sleep (1);
	}

	set_cirilic ();
	clear_scr();
	
	int encoder_fd = 0;
	if (cfileexists(ENCODER_COM_PORT)) {
		encoder_fd = init_comport(ENCODER_COM_PORT, ENCODER_COM_SPEED);
	} else {
		encoder_fd = init_comport(DEFAULT_ENCODER_COM_PORT, ENCODER_COM_SPEED);
	}

	init_term();
	last_time = time(NULL); 

	int count_click = 0;
	struct timeval t_start, t_end;
	int show_time = 0;
	while (1) {
		get_all (output_st);
		int ret_read = read_com(encoder_fd, 1 , 100, &chout);
		if ((chout=='R') || (chout=='L') ||(chout=='a') || (chout=='d')) {
				action=0;
				last_time_action = time(NULL);
				set_play_list_position(tuning_movement(chout)); 
				get_cur_position (); 
				show_current_cursor_pos ();
		}
		if ((chout=='P') ||(chout=='s') ) {
			gettimeofday(&t_end, NULL);
			if(!count_click) {
				t_start = t_end;
				count_click++;
			} else {
				if (usec_used (&t_start, &t_end) <= 500000) {
					double_click_button();
					if (show_time) {
						show_time--;
					} else {
						show_time++;
					}
				} 
				count_click = 0;
			}
		}

		if (count_click) {
			gettimeofday(&t_end, NULL);
			if (usec_used (&t_start, &t_end) > 500000) 	{
				print_button_pressed();
				music_pause();
				count_click = 0;
			}
		}

		chout = '\0';
		current_time = time(NULL); 
		if (action==0) {
			if ((current_time-last_time_action)>3) {
				action++;
			}
		}
		if ((action) && ((current_time-last_time)>0)) {
			if (!show_time) {
				show_current_track(output_st);
			} else {
				show_current_time_and_date();
			}
			last_time = current_time; 
		}
	}
}