Subversion Repositories svn.mios32

Compare Revisions

Ignore whitespace Rev 1913 → Rev 1914

/trunk/apps/processing/midibox_cv_v2/src/mbcv_file_p.cpp
296,6 → 296,17
}
}
 
} else if( strcasecmp(parameter, "CV_UpdateRateFactor") == 0 ) {
s32 factor;
char *word = remove_quotes(strtok_r(NULL, separators, &brkt));
if( (factor=get_dec(word)) < 1 || factor > APP_CV_UPDATE_RATE_FACTOR_MAX ) {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[MBCV_FILE_P] ERROR '%s' should be between 1..%d\n", parameter, APP_CV_UPDATE_RATE_FACTOR_MAX);
#endif
} else {
APP_CvUpdateRateFactorSet(factor);
}
 
} else if( strcasecmp(parameter, "EXTCLK_Divider") == 0 ) {
s32 clk;
char *word = remove_quotes(strtok_r(NULL, separators, &brkt));
604,6 → 615,11
sprintf(line_buffer, "\n\n# CV Configuration\n");
FLUSH_BUFFER;
 
sprintf(line_buffer, "\n# CV Update Rate (500 Hz * factor)\n");
FLUSH_BUFFER;
sprintf(line_buffer, "CV_UpdateRateFactor %d\n", APP_CvUpdateRateFactorGet());
FLUSH_BUFFER;
 
sprintf(line_buffer, "\n\n# External Clock Outputs (available at DOUT_DinSyncSR D1..D7)\n");
FLUSH_BUFFER;
{
/trunk/apps/processing/midibox_cv_v2/src/terminal.cpp
272,6 → 272,7
MIDIMON_TerminalHelp(_output_function);
MIDI_ROUTER_TerminalHelp(_output_function);
out(" set dout <pin> <0|1>: directly sets DOUT (all or 0..%d) to given level (1 or 0)", MIOS32_SRIO_NUM_SR*8 - 1);
out(" set update_rate <1..%d>: sets update rate of sound engine (factor*500 Hz), current: %d\n", APP_CV_UPDATE_RATE_FACTOR_MAX, APP_CvUpdateRateFactorGet());
AOUT_TerminalHelp(_output_function);
#ifdef MIOS32_LCD_universal
APP_LCD_TerminalHelp(_output_function);
409,6 → 410,18
}
}
}
} else if( strcmp(parameter, "update_rate") == 0 ) {
s32 factor = -1;
if( (parameter = strtok_r(NULL, separators, &brkt)) ) {
factor = get_dec(parameter);
}
 
if( (factor < 1 || factor > APP_CV_UPDATE_RATE_FACTOR_MAX) ) {
out("Update Rate should be between 1..%d!", APP_CV_UPDATE_RATE_FACTOR_MAX);
} else {
APP_CvUpdateRateFactorSet(factor);
out("Update Rate set to %d Hz (factor %d)", 500*APP_CvUpdateRateFactorGet(), APP_CvUpdateRateFactorGet());
}
} else {
out("Unknown set parameter: '%s'!", parameter);
}
/trunk/apps/processing/midibox_cv_v2/src/scs_config.cpp
80,6 → 80,16
static void stringOnOff(u32 ix, u16 value, char *label) { sprintf(label, " [%c] ", value ? 'x' : ' '); }
static void stringCurve(u32 ix, u16 value, char *label) { sprintf(label, value ? "Exp. " : "Lin. "); }
 
static void stringCvUpdateRate(u32 ix, u16 value, char *label) {
u32 updateRate = (value+1) * 500; // Hz
if( value < 10000 ) {
sprintf(label, "%d.%dk", updateRate / 1000, (updateRate % 1000) / 100);
} else {
sprintf(label, "%3dk", updateRate / 1000);
}
}
 
 
static void stringNote(u32 ix, u16 value, char *label)
{
const char noteTab[12][3] = { "C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-" };
693,6 → 703,9
static u16 aoutIfGet(u32 ix) { return MBCV_MAP_IfGet(); }
static void aoutIfSet(u32 ix, u16 value) { MBCV_MAP_IfSet((aout_if_t)value); }
 
static u16 cvUpdateRateGet(u32 ix) { return APP_CvUpdateRateFactorGet() - 1; }
static void cvUpdateRateSet(u32 ix, u16 value) { APP_CvUpdateRateFactorSet(value+1); }
 
static u16 cvScopeGet(u32 ix) { return env->mbCv[selectedCv].scopeSelect; }
static void cvScopeSet(u32 ix, u16 value) { env->mbCv[selectedCv].scopeSelect = value; env->updateScopeParameters(); }
 
894,6 → 907,7
SCS_ITEM(" Cali", 0, MBCV_MAP_NUM_CALI_MODES-1, cvCaliModeGet, cvCaliModeSet, selectNOP, stringCvCaliMode, NULL),
SCS_ITEM(" Modu", 0, AOUT_NUM_IF-1, aoutIfGet, aoutIfSet, selectNOP, stringAoutIf, NULL),
SCS_ITEM("le ", 1, AOUT_NUM_IF-1, aoutIfGet, aoutIfSet, selectNOP, stringAoutIf, NULL),
SCS_ITEM("UpdR", 0, APP_CV_UPDATE_RATE_FACTOR_MAX-1, cvUpdateRateGet, cvUpdateRateSet, selectNOP, stringCvUpdateRate, NULL),
};
 
const scs_menu_item_t pageScpe[] = {
976,6 → 990,12
return 1;
}
 
// overlay on overload
if( APP_CvUpdateOverloadStatusGet() ) {
if( (MIOS32_TIMESTAMP_Get() % 100) > 50 )
sprintf(line1, "[-! CV OVERLOAD !-]");
}
 
// overlay in MSD mode (user should disable soon since this sucks performance)
if( TASK_MSD_EnableGet() ) {
char msdStr[5];
/trunk/apps/processing/midibox_cv_v2/src/app.cpp
81,8 → 81,12
static u32 stopwatch_value_accumulated;
static u32 stopwatch_value_accumulated_ctr;
 
static u32 cv_se_speed_factor;
static u8 cv_se_speed_factor;
static u8 cv_se_overloaded;
static u32 cv_se_overload_check_ctr = 0;
static u32 cv_se_last_mios32_timestamp = 0;
 
 
/////////////////////////////////////////////////////////////////////////////
// C++ objects
/////////////////////////////////////////////////////////////////////////////
195,16 → 199,11
MIDIMON_Init(0);
MBCV_FILE_Init(0);
 
// initialize MbCvEnvironment
cv_se_speed_factor = 10;
mbCvEnvironment.updateSpeedFactorSet(cv_se_speed_factor);
 
// initialize tasks
TASKS_Init(0);
 
// start timer
// TODO: increase once performance has been evaluated
MIOS32_TIMER_Init(2, 2000 / cv_se_speed_factor, CV_TIMER_SE_Update, MIOS32_IRQ_PRIO_MID);
// initialize MbCvEnvironment
APP_CvUpdateRateFactorSet(5);
 
#if MIOS32_DONT_SERVICE_SRIO_SCAN
//MIOS32_SRIO_ScanNumSet(4);
339,12 → 338,29
extern void CV_TIMER_SE_Update(void)
{
// ignore as long as hardware config hasn't been read
if( !MBCV_FILE_HW_ConfigLocked() )
return -1;
if( !MBCV_FILE_HW_ConfigLocked() ) {
cv_se_last_mios32_timestamp = MIOS32_TIMESTAMP_Get();
return;
}
 
// check MIOS32 timestamp each second
if( ++cv_se_overload_check_ctr >= (cv_se_speed_factor*500) ) {
u32 timestamp = MIOS32_TIMESTAMP_Get();
u32 delay = timestamp - cv_se_last_mios32_timestamp;
cv_se_overload_check_ctr = 0;
cv_se_last_mios32_timestamp = timestamp;
 
// actually 1000, allow some margin
cv_se_overloaded = (delay < 950 );
}
 
// don't process CV if engine overloaded
if( cv_se_overloaded )
return;
 
#if J5_DEBUG_PINS
MIOS32_BOARD_J5_PinSet(4, 0);
MIOS32_BOARD_J5_PinSet(5, 0);
MIOS32_BOARD_J5_PinSet(4, 0);
MIOS32_BOARD_J5_PinSet(5, 0);
#endif
 
#if STOPWATCH_PERFORMANCE_MEASURING == 1 || STOPWATCH_PERFORMANCE_MEASURING == 2
603,6 → 619,46
 
 
/////////////////////////////////////////////////////////////////////////////
// Speed Factor (engine will be updated at factor * 500 Hz)
/////////////////////////////////////////////////////////////////////////////
s32 APP_CvUpdateRateFactorSet(u8 factor)
{
if( factor < 1 || factor > APP_CV_UPDATE_RATE_FACTOR_MAX )
return -1; // invalid factor
 
MIOS32_IRQ_Disable();
 
cv_se_speed_factor = factor;
mbCvEnvironment.updateSpeedFactorSet(cv_se_speed_factor);
 
// start timer
MIOS32_TIMER_Init(2, 2000 / cv_se_speed_factor, CV_TIMER_SE_Update, MIOS32_IRQ_PRIO_MID);
 
// clear overload indicators
cv_se_overloaded = 0;
cv_se_overload_check_ctr = 0;
cv_se_last_mios32_timestamp = MIOS32_TIMESTAMP_Get();
 
MIOS32_IRQ_Enable();
 
return 0; // no error
}
 
s32 APP_CvUpdateRateFactorGet(void)
{
return cv_se_speed_factor;
}
 
/////////////////////////////////////////////////////////////////////////////
// Returns 1 if engine overloaded
/////////////////////////////////////////////////////////////////////////////
s32 APP_CvUpdateOverloadStatusGet(void)
{
return cv_se_overloaded;
}
 
 
/////////////////////////////////////////////////////////////////////////////
// For performance Measurements
/////////////////////////////////////////////////////////////////////////////
s32 APP_StopwatchInit(void)
/trunk/apps/processing/midibox_cv_v2/src/app.h
19,7 → 19,9
// Global definitions
/////////////////////////////////////////////////////////////////////////////
 
#define APP_CV_UPDATE_RATE_FACTOR_MAX 20
 
 
/////////////////////////////////////////////////////////////////////////////
// Global Types
/////////////////////////////////////////////////////////////////////////////
63,7 → 65,11
extern s32 APP_SelectScopeLCDs(void);
extern s32 APP_SelectMainLCD(void);
 
extern s32 APP_CvUpdateRateFactorSet(u8 factor);
extern s32 APP_CvUpdateRateFactorGet(void);
extern s32 APP_CvUpdateOverloadStatusGet(void);
 
 
/////////////////////////////////////////////////////////////////////////////
// Export global variables
/////////////////////////////////////////////////////////////////////////////