Subversion Repositories svn.mios32

Compare Revisions

Regard whitespace Rev 1270 → Rev 1271

/trunk/apps/examples/speech_synth/scs_config.c
32,6 → 32,8
// Local parameter variables
/////////////////////////////////////////////////////////////////////////////
 
static u8 extraPage;
 
static u8 selectedPatch;
static u8 selectedBank;
static u8 selectedPhrase;
59,9 → 61,9
// String Conversion Functions
/////////////////////////////////////////////////////////////////////////////
static void stringEmpty(u32 ix, u16 value, char *label) { label[0] = 0; }
static void stringDec(u32 ix, u16 value, char *label) { sprintf(label, "%4d ", value); }
static void stringDecP1(u32 ix, u16 value, char *label) { sprintf(label, "%4d ", value+1); }
static void stringDecPM(u32 ix, u16 value, char *label) { sprintf(label, "%4d ", (int)value - 64); }
static void stringDec(u32 ix, u16 value, char *label) { sprintf(label, "%3d ", value); }
static void stringDecP1(u32 ix, u16 value, char *label) { sprintf(label, "%3d ", value+1); }
static void stringDecPM(u32 ix, u16 value, char *label) { sprintf(label, "%3d ", (int)value - 64); }
static void stringDec03(u32 ix, u16 value, char *label) { sprintf(label, " %03d ", value); }
static void stringHex2(u32 ix, u16 value, char *label) { sprintf(label, " %02x ", value); }
static void stringPlay(u32 ix, u16 value, char *label) { sprintf(label, " [%c] ", SYNTH_PhraseIsPlayed(selectedPhrase) ? '*' : 'o'); }
173,29 → 175,49
};
 
const scs_menu_page_t rootMode0[] = {
SCS_PAGE("Disk ", pageDsk, SCS_StringStandardItems, SCS_StringStandardValues),
SCS_PAGE("Glb. ", pageGlb, SCS_StringStandardItems, SCS_StringStandardValues),
SCS_PAGE("Phr. ", pagePhr, SCS_StringStandardItems, SCS_StringStandardValues),
SCS_PAGE("Disk ", pageDsk),
SCS_PAGE("Glb. ", pageGlb),
SCS_PAGE("Phr. ", pagePhr),
};
 
 
/////////////////////////////////////////////////////////////////////////////
// This function returns the two lines of the main page (2x20 chars)
// This function can overrule the display output
// If it returns 0, the original SCS output will be print
// If it returns 1, the output copied into line1 and/or line2 will be print
// If a line is not changed (line[0] = 0 or line[1] = 0), the original output
// will be displayed - this allows to overrule only a single line
/////////////////////////////////////////////////////////////////////////////
static s32 getStringMainPage(char *line1, char *line2)
static s32 displayHook(char *line1, char *line2)
{
if( extraPage ) {
sprintf(line1, "Extra Page");
sprintf(line2, "Msg1 Msg2 Msg3 Msg4 ");
return 1;
} else if( SCS_MenuStateGet() == SCS_MENU_STATE_MAINPAGE ) {
getPatchString(line1);
strcpy(line2, "Press soft button");
sprintf(line2, "Press soft button");
return 1;
} else if( SCS_MenuStateGet() == SCS_MENU_STATE_SELECT_PAGE ) {
getPatchString(line1);
return 1;
}
 
return 0; // no error
return 0;
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This function is called when the rotary encoder is moved in the main page
// This function is called when the rotary encoder is moved
// If it returns 0, the encoder increment will be handled by the SCS
// If it returns 1, the SCS will ignore the encoder
/////////////////////////////////////////////////////////////////////////////
static s32 encMovedInMainPage(s32 incrementer)
static s32 encHook(s32 incrementer)
{
if( extraPage ) {
MIOS32_MIDI_SendDebugMessage("Encoder moved in extra page: %d\n", incrementer);
return 1;
} else if( SCS_MenuStateGet() == SCS_MENU_STATE_MAINPAGE ) {
int newPatch = selectedPatch + incrementer;
if( newPatch < 0 )
newPatch = 0;
217,31 → 239,41
// SCS_Msg(SCS_MSG_L, 1000, buffer, "read!");
}
MUTEX_SDCARD_GIVE;
return 1;
}
 
return 0; // no error
return 0;
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This function is called when a soft button is pressed in the main page
// if a value < 0 is returned, the menu won't be entered
// This function is called when a button has been pressed or depressed
// If it returns 0, the button movement will be handled by the SCS
// If it returns 1, the SCS will ignore the button event
/////////////////////////////////////////////////////////////////////////////
static s32 buttonPressedInMainPage(u8 softButton)
static s32 buttonHook(u8 scsButton, u8 depressed)
{
// here the root table could be changed depending on soft button
 
return 0; // no error
if( extraPage ) {
if( scsButton == SCS_PIN_SOFT5 && depressed ) // selects/deselects extra page
extraPage = 0;
else {
if( !depressed )
switch( scsButton ) {
case SCS_PIN_SOFT1: SCS_Msg(SCS_MSG_L, 1000, "Soft Button", "#1 pressed"); break;
case SCS_PIN_SOFT2: SCS_Msg(SCS_MSG_L, 1000, "Soft Button", "#2 pressed"); break;
case SCS_PIN_SOFT3: SCS_Msg(SCS_MSG_L, 1000, "Soft Button", "#3 pressed"); break;
case SCS_PIN_SOFT4: SCS_Msg(SCS_MSG_L, 1000, "Soft Button", "#4 pressed"); break;
}
}
return 1;
} else {
if( scsButton == SCS_PIN_SOFT5 && !depressed ) { // selects/deselects extra page
extraPage = 1;
return 1;
}
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This function returns the upper line on the page selection (20 chars)
/////////////////////////////////////////////////////////////////////////////
static s32 getStringPageSelection(char *line1)
{
getPatchString(line1);
 
return 0; // no error
return 0;
}
 
 
257,12 → 289,13
 
switch( mode ) {
case 0: {
extraPage = 0;
 
// install table
SCS_INSTALL_ROOT(rootMode0);
SCS_InstallMainPageStringHook(getStringMainPage);
SCS_InstallPageSelectStringHook(getStringPageSelection);
SCS_InstallEncMainPageHook(encMovedInMainPage);
SCS_InstallButtonMainPageHook(buttonPressedInMainPage);
SCS_InstallDisplayHook(displayHook);
SCS_InstallEncHook(encHook);
SCS_InstallButtonHook(buttonHook);
break;
}
default: return -1; // mode not supported