Exemplo n.º 1
0
int
main (int argc, char **argv)
{
  const char *typestr = NULL;

  program_init (argc, argv);
  program_getoptuint ('i', &iterations);
  program_getoptuint ('l', &layer);
  program_getoptuint ('v', &vector);
  program_getoptuint ('w', &window);
  program_getoptstr ('t', &typestr);

  if (typestr) {
    for (type = 0; type < NUM_MODELS; type++) {
      if (strcasecmp (typestr, model_name[type]) == 0)
        break;
    }
    if (type == NUM_MODELS)
      fatal ("unkown model %s", typestr);
  }

  b = bundle_open (program_poparg ());
  if (b == NULL)
    fatal ("bundle_open");
  program_run ();
  bundle_save (b);
  bundle_free (b);
  return 0;
}
Exemplo n.º 2
0
int
main (int argc, char **argv)
{
  program_init (argc, argv);
  program_getoptuint ('m', &min);

  b = bundle_open (program_poparg ());
  if (b == NULL)
    fatal ("bundle_open");
  program_run ();
  bundle_save (b);
  bundle_free (b);
  return 0;
}
Exemplo n.º 3
0
void remote_decode ( uint16_t ircode)
{ 

  uint8_t set_speed = 8 ;
  switch ( ircode)
	   {
	    case IR_TV_1:	
 			set_speed = 0;
			 break;
		case IR_TV_2:
			set_speed =1;
			break;
	    case IR_TV_3:
 			set_speed =2;			
			break;
		case IR_TV_4:
 			set_speed =3;			
			 break;
	    case IR_TV_5:
 			set_speed =4;			
			 break;
		case IR_TV_6:
 			set_speed = 5;			
			 break;
	    case IR_TV_7:
 			set_speed = 6;			
			break;
		case IR_TV_8:
 			set_speed = 7;			
			break;
	    case IR_TV_9:
 			set_speed =8;			
			break;
		case IR_TV_0:
			set_motor_parameter (MOTOR_STOP);
			uart_puts ("Voltage SUM 1");
			debug_lvalue(g_pos[0],10);
			g_pos[0] =0;
			uart_puts ("Voltage SUM 2");
			debug_lvalue(g_pos[1],10);
			g_pos[1] =0;
			break;
		case IR_TV_CHUP:
			set_motor_parameter(MOTOR_FORWARD);
			break;
		case IR_TV_CHDOWN:							
			set_motor_parameter(MOTOR_BACKWARD);
			break;
		case IR_TV_TVMUTE:
			break;
		case  IR_TV_TVPOWER:
		  	break;
		case   IR_TV_TVAV:
		    program_run();
		    break;
		case  IR_TV_VOLUP:
            set_motor_parameter(MOTOR_TURN_LEFT);
			break;
		case  IR_TV_VOLDOWN:                 			
		    set_motor_parameter(MOTOR_TURN_RIGHT);
			break;
 		default:
			break;
 	   }
	   g_speed[1] = g_speed_table[set_speed]; 
	   g_speed[0] = g_speed[1];

}
Exemplo n.º 4
0
int16_t cmd_decode (uint8_t *buffer_ptr)
{

 uint8_t  cmd_no =0;
 uint8_t  *cmd_argument;
 uint8_t   i,j ;
 
// Should repeat until end of buffer
 
// Loop until end of text

   cmd_argument = buffer_ptr;
     
   while ( cmd_no !=  CMD_LINE_END)     // Until end of line which mean g_motor will change
   {
 		cmd_no =  text_decode (buffer_ptr,cmd_argument);
#ifdef DEBUG		
		uart_puts("Command :");
 		uart_putc(0x30+cmd_no);
 		uart_putc('*');
 		uart_puts(cmd_argument);
#endif        
 		switch (cmd_no)
		{
			case MOTOR_CMD: 
				g_motor = (uint8_t)atoi(cmd_argument);
				if (g_motor > 0)
				   g_motor--;                //  > 0 Start from 0 need -1
				else
				   g_motor = 0;
 				break;
			case  SPEED_CMD:	
				i = (uint8_t)atoi(cmd_argument);
				if ( i >=  MOTOR_MAX_SPEED)
						i = MOTOR_MAX_SPEED;    // Start from 0
				if (i)   // i > 0; 		
					i--;   //Start from 0;		
				g_speed[g_motor] =  g_speed_table[i];
				if (g_speed[g_motor] == 0)
				        g_mode[g_motor] = MOTOR_STOP;
  				break;
			case  ANGLE_CMD:   // Can be - 	             			 
     			g_angle[g_motor] = atoi(cmd_argument);
				if (g_angle[g_motor] < 0)
				{   
						g_mode[g_motor] = MOTOR_BACKWARD;
 
// Set g_angle to positive value by invert all bit and +1                
                        g_angle[g_motor] = (~(g_angle[g_motor])+1);
                        if  (g_angle[g_motor] > 1)
						{
 						   g_angle[g_motor] *= MOTOR_ANGLE_COEF;
						   g_status[g_motor] = 1;
 						   g_speed[g_motor] = g_speed_table[MOTOR_ANGLE_SPEED] ;
						}		
				}	
				else  if (g_angle[g_motor] == 0)
				       {  	
							g_mode[g_motor] = MOTOR_STOP;
 					   }
				else	  
				{
					if ((g_angle[g_motor] > 0))   //  +
					{
						g_mode[g_motor] = MOTOR_FORWARD;
 					}
					if  (g_angle[g_motor] > 1)
					{
 						g_angle[g_motor] *=  MOTOR_ANGLE_COEF;	
						g_status[g_motor] = 1;
  						g_speed[g_motor]  = g_speed_table[MOTOR_ANGLE_SPEED] ;
					}
 				}
                g_pos[g_motor] = 0;
				break;	
			case PROGRAM_CMD:
				g_program_flag = (uint8_t)atoi(cmd_argument);
				if (g_program_flag)   // Start  program save in buffer
				{
					uart_puts ("Program Start to save : ");
				     g_program_index = 0;
				}
				else
				{  
					uart_puts ("Program End : ");
				}
				break;
 			case SAVE_CMD:
				j = (uint8_t)atoi(cmd_argument);
				if ( j > 0)    // Save commmand to eeprom
                {
					g_program_buff[g_program_index] = 0x00 ;  // Put null at the end
                    g_program_index++;   
                    for ( i =0; i < g_program_index; i++)
                    {
						while (!eeprom_is_ready());
							eeprom_write_byte(&g_program_eeprom[i],g_program_buff[i]);
					}
					debug_value( g_program_index,10);
					uart_puts ("Save complete ");
					g_program_index = 0;	
				}
				break;
		    case RUN_CMD:
			    program_run();
			    break;
 			default:
			    uart_putc(0x0D);
				uart_putc(0x0A);
 		        break;	  
		}		
    }
 
 return 0; 
}