コード例 #1
0
ファイル: seq_terminal.c プロジェクト: gillspice/mios32
/////////////////////////////////////////////////////////////////////////////
// Parser
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_TERMINAL_Parse(mios32_midi_port_t port, u8 byte)
{
  // temporary change debug port (will be restored at the end of this function)
  mios32_midi_port_t prev_debug_port = MIOS32_MIDI_DebugPortGet();
  MIOS32_MIDI_DebugPortSet(port);

  if( byte == '\r' ) {
    // ignore
  } else if( byte == '\n' ) {
    // example for parsing the command:
    char *separators = " \t";
    char *brkt;
    char *parameter;

    if( (parameter = strtok_r(line_buffer, separators, &brkt)) ) {
      if( strcmp(parameter, "help") == 0 ) {
	SEQ_TERMINAL_PrintHelp(DEBUG_MSG);
      } else if( strcmp(parameter, "system") == 0 ) {
	SEQ_TERMINAL_PrintSystem(DEBUG_MSG);
      } else if( strcmp(parameter, "global") == 0 ) {
	SEQ_TERMINAL_PrintGlobalConfig(DEBUG_MSG);
      } else if( strcmp(parameter, "bookmarks") == 0 ) {
	SEQ_TERMINAL_PrintBookmarks(DEBUG_MSG);
      } else if( strcmp(parameter, "config") == 0 ) {
	SEQ_TERMINAL_PrintSessionConfig(DEBUG_MSG);
      } else if( strcmp(parameter, "tracks") == 0 ) {
	SEQ_TERMINAL_PrintTracks(DEBUG_MSG);
      } else if( strcmp(parameter, "track") == 0 ) {
	  char *arg;
	  if( (arg = strtok_r(NULL, separators, &brkt)) ) {
	    int track = get_dec(arg);
	    if( track < 1 || track > SEQ_CORE_NUM_TRACKS ) {
	      MUTEX_MIDIOUT_TAKE;
	      DEBUG_MSG("Wrong track number %d - expected track 1..%d\n", track, SEQ_CORE_NUM_TRACKS);
	      MUTEX_MIDIOUT_GIVE;
	    } else {
	      SEQ_TERMINAL_PrintTrack(DEBUG_MSG, track-1);
	    }
	  } else {
	    MUTEX_MIDIOUT_TAKE;
	    DEBUG_MSG("Please specify track, e.g. \"track 1\"\n");
	    MUTEX_MIDIOUT_GIVE;
	  }
      } else if( strcmp(parameter, "mixer") == 0 ) {
	SEQ_TERMINAL_PrintCurrentMixerMap(DEBUG_MSG);
      } else if( strcmp(parameter, "song") == 0 ) {
	SEQ_TERMINAL_PrintCurrentSong(DEBUG_MSG);
      } else if( strcmp(parameter, "grooves") == 0 ) {
	SEQ_TERMINAL_PrintGrooveTemplates(DEBUG_MSG);
      } else if( strcmp(parameter, "memory") == 0 ) {
	SEQ_TERMINAL_PrintMemoryInfo(DEBUG_MSG);
#if !defined(MIOS32_FAMILY_EMULATION)
      } else if( strcmp(parameter, "network") == 0 ) {
	SEQ_TERMINAL_PrintNetworkInfo(DEBUG_MSG);
      } else if( strcmp(parameter, "udpmon") == 0 ) {
	MUTEX_MIDIOUT_TAKE;
	char *arg;
	if( (arg = strtok_r(NULL, separators, &brkt)) ) {
	  int level = get_dec(arg);
	  switch( level ) {
	  case UDP_MONITOR_LEVEL_0_OFF:
	    DEBUG_MSG("Set UDP monitor level to %d (off)\n", level);
	    break;
	  case UDP_MONITOR_LEVEL_1_OSC_REC:
	    DEBUG_MSG("Set UDP monitor level to %d (received packets assigned to a OSC1..4 port)\n", level);
	    break;
	  case UDP_MONITOR_LEVEL_2_OSC_REC_AND_SEND:
	    DEBUG_MSG("Set UDP monitor level to %d (received and sent packets assigned to a OSC1..4 port)\n", level);
	    break;
	  case UDP_MONITOR_LEVEL_3_ALL_GEQ_1024:
	    DEBUG_MSG("Set UDP monitor level to %d (all received and sent packets with port number >= 1024)\n", level);
	    break;
	  case UDP_MONITOR_LEVEL_4_ALL:
	    DEBUG_MSG("Set UDP monitor level to %d (all received and sent packets)\n", level);
	    break;
	  default:
	    DEBUG_MSG("Invalid level %d - please specify monitor level 0..4\n", level);
	    level = -1; // invalidate level for next if() check
	  }

	  if( level >= 0 )
	    UIP_TASK_UDP_MonitorLevelSet(level);
	} else {
	  DEBUG_MSG("Please specify monitor level (0..4)\n");
	}
	MUTEX_MIDIOUT_GIVE;
#endif
      } else if( strcmp(parameter, "sdcard") == 0 ) {
	SEQ_TERMINAL_PrintSdCardInfo(DEBUG_MSG);
      } else if( strcmp(parameter, "testaoutpin") == 0 ) {
	char *arg;
	int pin_number = -1;
	int level = -1;

	if( (arg = strtok_r(NULL, separators, &brkt)) ) {
	  if( strcmp(arg, "cs") == 0 )
	    pin_number = 1;
	  else if( strcmp(arg, "si") == 0 )
	    pin_number = 2;
	  else if( strcmp(arg, "sc") == 0 )
	    pin_number = 3;
	  else if( strcmp(arg, "reset") == 0 ) {
	    pin_number = 0;
	    level = 0; // dummy
	  }
	}

	if( pin_number < 0 ) {
	  MUTEX_MIDIOUT_TAKE;
	  DEBUG_MSG("Please specifiy valid AOUT pin name: cs, si or sc\n");
	  MUTEX_MIDIOUT_GIVE;
	} else {
	  if( (arg = strtok_r(NULL, separators, &brkt)) )
	    level = get_dec(arg);

	  if( level != 0 && level != 1 ) {
	    MUTEX_MIDIOUT_TAKE;
	    DEBUG_MSG("Please specifiy valid logic level for AOUT pin: 0 or 1\n");
	    MUTEX_MIDIOUT_GIVE;
	  }
	}

	if( pin_number >= 0 && level >= 0 ) {
	  SEQ_TERMINAL_TestAoutPin(DEBUG_MSG, pin_number, level);
	} else {
	  MUTEX_MIDIOUT_TAKE;
	  DEBUG_MSG("Following commands are supported:\n");
	  DEBUG_MSG("testaoutpin cs 0  -> sets AOUT:CS to 0.4V");
	  DEBUG_MSG("testaoutpin cs 1  -> sets AOUT:CS to ca. 4V");
	  DEBUG_MSG("testaoutpin si 0  -> sets AOUT:SI to ca. 0.4V");
	  DEBUG_MSG("testaoutpin si 1  -> sets AOUT:SI to ca. 4V");
	  DEBUG_MSG("testaoutpin sc 0  -> sets AOUT:SC to ca. 0.4V");
	  DEBUG_MSG("testaoutpin sc 1  -> sets AOUT:SC to ca. 4V");
	  DEBUG_MSG("testaoutpin reset -> re-initializes AOUT module so that it can be used again.");
	  MUTEX_MIDIOUT_GIVE;
	}
      } else if( strcmp(parameter, "play") == 0 ) {
	SEQ_UI_Button_Play(0);
	MUTEX_MIDIOUT_TAKE;
	DEBUG_MSG("Sequencer started...\n");
	MUTEX_MIDIOUT_GIVE;
      } else if( strcmp(parameter, "stop") == 0 ) {
	SEQ_UI_Button_Stop(0);
	MUTEX_MIDIOUT_TAKE;
	DEBUG_MSG("Sequencer stopped...\n");
	MUTEX_MIDIOUT_GIVE;
      } else if( strcmp(parameter, "reset") == 0 ) {
	MIOS32_SYS_Reset();
      } else {
	MUTEX_MIDIOUT_TAKE;
	DEBUG_MSG("Unknown command - type 'help' to list available commands!\n");
	MUTEX_MIDIOUT_GIVE;
      }
    }

    line_ix = 0;

  } else if( line_ix < (STRING_MAX-1) ) {
    line_buffer[line_ix++] = byte;
    line_buffer[line_ix] = 0;
  }

  // restore debug port
  MIOS32_MIDI_DebugPortSet(prev_debug_port);

  return 0; // no error
}
コード例 #2
0
ファイル: seq_ui_info.c プロジェクト: glocklueng/MIOS32
/////////////////////////////////////////////////////////////////////////////
// Local button callback function
// Should return:
//   1 if value has been changed
//   0 if value hasn't been changed
//  -1 if invalid or unsupported button
/////////////////////////////////////////////////////////////////////////////
static s32 Button_Handler(seq_ui_button_t button, s32 depressed)
{
  if( depressed ) return 0; // ignore when button depressed

  if( button <= SEQ_UI_BUTTON_GP8 || button == SEQ_UI_BUTTON_Select ) {
    if( button != SEQ_UI_BUTTON_Select )
      ui_selected_item = button / 2;

    SEQ_UI_Msg(SEQ_UI_MSG_USER_R, 10000, "Sending Informations", "to MIOS Terminal!");

    switch( ui_selected_item + list_view_offset ) {

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_SYSTEM:
	SEQ_TERMINAL_PrintSystem(DEBUG_MSG);
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_GLOBALS:
	SEQ_TERMINAL_PrintGlobalConfig(DEBUG_MSG);
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_CONFIG:
	SEQ_TERMINAL_PrintSessionConfig(DEBUG_MSG);
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_TRACKS:
	SEQ_TERMINAL_PrintTracks(DEBUG_MSG);
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_TRACK_INFO:
	SEQ_TERMINAL_PrintTrack(DEBUG_MSG, SEQ_UI_VisibleTrackGet());
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_MIXER_MAP:
	SEQ_TERMINAL_PrintCurrentMixerMap(DEBUG_MSG);
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_SONG:
	SEQ_TERMINAL_PrintCurrentSong(DEBUG_MSG);
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_GROOVES:
	SEQ_TERMINAL_PrintGrooveTemplates(DEBUG_MSG);
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_BOOKMARKS:
	SEQ_TERMINAL_PrintBookmarks(DEBUG_MSG);
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_SD_CARD:
	SEQ_TERMINAL_PrintSdCardInfo(DEBUG_MSG);
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      case LIST_ITEM_NETWORK:
#if !defined(MIOS32_FAMILY_EMULATION)
	UIP_TERMINAL_PrintNetwork(DEBUG_MSG);
#endif
	break;

      //////////////////////////////////////////////////////////////////////////////////////////////
      default:
	DEBUG_MSG("No informations available.");
    }

    SEQ_UI_Msg(SEQ_UI_MSG_USER_R, 1000, "Sent Informations", "to MIOS Terminal!");

    return 1;
  }

  if( button >= SEQ_UI_BUTTON_GP9 && button <= SEQ_UI_BUTTON_GP16 ) {
    // re-using encoder handler
    return Encoder_Handler(button, 0);
  }

  switch( button ) {
    case SEQ_UI_BUTTON_Right:
    case SEQ_UI_BUTTON_Up:
      return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, 1);

    case SEQ_UI_BUTTON_Left:
    case SEQ_UI_BUTTON_Down:
      return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, -1);
  }

  return -1; // invalid or unsupported button
}