///////////////////////////////////////////////////////////////////////////// // Local exit function ///////////////////////////////////////////////////////////////////////////// static s32 EXIT_Handler(void) { s32 status = 0; if( store_file_required ) { // write config files MUTEX_SDCARD_TAKE; if( (status=SEQ_FILE_C_Write(seq_file_session_name)) < 0 ) SEQ_UI_SDCardErrMsg(2000, status); MUTEX_SDCARD_GIVE; MUTEX_SDCARD_TAKE; if( (status=SEQ_FILE_GC_Write()) < 0 ) SEQ_UI_SDCardErrMsg(2000, status); MUTEX_SDCARD_GIVE; } return status; }
///////////////////////////////////////////////////////////////////////////// // 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 // reset tap tempo if any button != GP16 has been pressed if( button != SEQ_UI_BUTTON_GP16 ) resetTapTempo(); #if 0 // leads to: comparison is always true due to limited range of data type if( button >= SEQ_UI_BUTTON_GP1 && button <= SEQ_UI_BUTTON_GP16 ) { #else if( button <= SEQ_UI_BUTTON_GP16 ) { #endif switch( button ) { case SEQ_UI_BUTTON_GP6: case SEQ_UI_BUTTON_GP7: // fire preset SEQ_CORE_BPM_Update(seq_core_bpm_preset_tempo[seq_core_bpm_preset_num], seq_core_bpm_preset_ramp[seq_core_bpm_preset_num]); return 1; case SEQ_UI_BUTTON_GP8: // enter preset selection page SEQ_UI_PageSet(SEQ_UI_PAGE_BPM_PRESETS); return 1; } // re-use encoder handler - only select UI item, don't increment return Encoder_Handler((int)button, 0); } // remaining buttons: switch( button ) { case SEQ_UI_BUTTON_Select: case SEQ_UI_BUTTON_Right: if( ++ui_selected_item >= NUM_OF_ITEMS ) ui_selected_item = 0; return 1; // value always changed case SEQ_UI_BUTTON_Left: if( ui_selected_item == 0 ) ui_selected_item = NUM_OF_ITEMS-1; else --ui_selected_item; return 1; // value always changed case SEQ_UI_BUTTON_Up: return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, 1); case SEQ_UI_BUTTON_Down: return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, -1); } return -1; // invalid or unsupported button } ///////////////////////////////////////////////////////////////////////////// // Local Display Handler function // IN: <high_prio>: if set, a high-priority LCD update is requested ///////////////////////////////////////////////////////////////////////////// static s32 LCD_Handler(u8 high_prio) { if( high_prio ) return 0; // there are no high-priority updates // layout: // 00000000001111111111222222222233333333330000000000111111111122222222223333333333 // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 // <--------------------------------------><--------------------------------------> // Mode Preset Tempo Ramp Fire Preset MClk In/Out Ext. Tap // Master 1 140.0 1s Preset Page USB1 I:on O:off Restart Tempo /////////////////////////////////////////////////////////////////////////// SEQ_LCD_CursorSet(0, 0); SEQ_LCD_PrintString(" Mode Preset Tempo Ramp Fire Preset MClk In/Out "); SEQ_LCD_PrintString(seq_core_state.EXT_RESTART_REQ ? "Ongoing" : " Ext. "); SEQ_LCD_PrintString(" Tap "); /////////////////////////////////////////////////////////////////////////// SEQ_LCD_CursorSet(0, 1); if( ui_selected_item == ITEM_MODE && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(6); } else { const char mode_str[3][7] = { " Auto ", "Master", "Slave "}; SEQ_LCD_PrintString((char *)mode_str[SEQ_BPM_ModeGet()]); } SEQ_LCD_PrintSpaces(2); /////////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_PRESET && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(2); } else { SEQ_LCD_PrintFormattedString("%2d", seq_core_bpm_preset_num+1); } SEQ_LCD_PrintSpaces(3); /////////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_BPM && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(5); } else { float bpm = seq_core_bpm_preset_tempo[seq_core_bpm_preset_num]; SEQ_LCD_PrintFormattedString("%3d.%d", (int)bpm, (int)(10*bpm)%10); } SEQ_LCD_PrintSpaces(2); /////////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_RAMP && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { float ramp = seq_core_bpm_preset_ramp[seq_core_bpm_preset_num]; SEQ_LCD_PrintFormattedString("%2ds", (int)ramp); } /////////////////////////////////////////////////////////////////////////// SEQ_LCD_PrintString(" Preset Page "); /////////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_MCLK_PORT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { SEQ_LCD_PrintString(SEQ_MIDI_PORT_ClkNameGet(SEQ_MIDI_PORT_ClkIxGet(selected_mclk_port))); } SEQ_LCD_PrintSpaces(1); /////////////////////////////////////////////////////////////////////////// SEQ_LCD_PrintString("I:"); if( ui_selected_item == ITEM_MCLK_IN && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { s32 status = SEQ_MIDI_ROUTER_MIDIClockInGet(selected_mclk_port); if( !SEQ_MIDI_PORT_ClkCheckAvailable(selected_mclk_port) ) status = -1; // MIDI In port not available switch( status ) { case 0: SEQ_LCD_PrintString("off"); break; case 1: SEQ_LCD_PrintString("on "); break; default: SEQ_LCD_PrintString("---"); } } SEQ_LCD_PrintSpaces(1); /////////////////////////////////////////////////////////////////////////// SEQ_LCD_PrintString("O:"); if( ui_selected_item == ITEM_MCLK_OUT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { s32 status = SEQ_MIDI_ROUTER_MIDIClockOutGet(selected_mclk_port); if( !SEQ_MIDI_PORT_ClkCheckAvailable(selected_mclk_port) ) status = -1; // MIDI Out port not available switch( status ) { case 0: SEQ_LCD_PrintString("off"); break; case 1: SEQ_LCD_PrintString("on "); break; default: SEQ_LCD_PrintString("---"); } } SEQ_LCD_PrintSpaces(3); // DIN Sync moved to CV configuration SEQ_LCD_PrintSpaces(3+4); /////////////////////////////////////////////////////////////////////////// SEQ_LCD_PrintString("Restart Tempo"); return 0; // no error } ///////////////////////////////////////////////////////////////////////////// // Local exit function ///////////////////////////////////////////////////////////////////////////// static s32 EXIT_Handler(void) { s32 status = 0; if( store_file_required ) { // write config file MUTEX_SDCARD_TAKE; if( (status=SEQ_FILE_C_Write(seq_file_session_name)) < 0 ) SEQ_UI_SDCardErrMsg(2000, status); MUTEX_SDCARD_GIVE; store_file_required = 0; } return status; }
///////////////////////////////////////////////////////////////////////////// // 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 0 // leads to: comparison is always true due to limited range of data type if( button >= SEQ_UI_BUTTON_GP1 && button <= SEQ_UI_BUTTON_GP16 ) { #else if( button <= SEQ_UI_BUTTON_GP16 ) { #endif // re-use encoder handler - only select UI item, don't increment, flags will be toggled return Encoder_Handler((int)button, 0); } // remaining buttons: switch( button ) { case SEQ_UI_BUTTON_Select: case SEQ_UI_BUTTON_Right: if( ++ui_selected_item >= NUM_OF_ITEMS ) ui_selected_item = 0; SetSubpageBasedOnItem(ui_selected_item); return 1; // value always changed case SEQ_UI_BUTTON_Left: if( ui_selected_item == 0 ) ui_selected_item = NUM_OF_ITEMS-1; else --ui_selected_item; SetSubpageBasedOnItem(ui_selected_item); return 1; // value always changed case SEQ_UI_BUTTON_Up: return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, 1); case SEQ_UI_BUTTON_Down: return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, -1); } return -1; // invalid or unsupported button } ///////////////////////////////////////////////////////////////////////////// // Local Display Handler function // IN: <high_prio>: if set, a high-priority LCD update is requested ///////////////////////////////////////////////////////////////////////////// static s32 LCD_Handler(u8 high_prio) { if( high_prio ) return 0; // there are no high-priority updates // layout: // 00000000001111111111222222222233333333330000000000111111111122222222223333333333 // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 // <--------------------------------------><--------------------------------------> // Transposer Section MIDI Ext. Bus Port Chn. Lower/Upper Mode Reset // and Arp. Control Router Ctrl Misc. 1 IN1 #16 --- --- T&A Stacks // Transposer Section MIDI Ext. Port Chn. G1 G2 G3 G4 Fwd Reset // and Arp. Control Router Ctrl Misc. All #16 C-1 C-2 C-3 C-4 USB1 Stcks // Transposer Section MIDI Ext. Node IN P/Chn OUT P/Chn | DefaultPort // and Arp. Control Router Ctrl Misc. #1 Def. All Def. # 1 | USB1 // Transposer Section MIDI Ext. Port Chn. Function CC# // Transposer Section MIDI Ext. IN OUT Chn.| Function CC# // and Arp. Control Router Ctrl Misc. All off --- | Morph Value 1 // Transposer Section MIDI Ext. BLM_SCALAR MIDI // and Arp. Control Router Ctrl Misc.Port: OUT2 Monitor seq_midi_router_node_t *n = &seq_midi_router_node[selected_router_node]; /////////////////////////////////////////////////////////////////////////// //<<<<<<< .mine /* const char leftpage[2][41] = { "Transposer Section MIDI ", " and Arp. Control Router Misc. " }; ======= */ SEQ_LCD_CursorSet(0, 0); SEQ_LCD_PrintString("Transposer Section MIDI Ext. "); SEQ_LCD_CursorSet(0, 1); SEQ_LCD_PrintString(" and Arp. Control Router Ctrl Misc."); //>>>>>>> .r1826 if( ui_cursor_flash && selected_subpage <= 5 ) { const u8 select_pos1[5] = { 0, 10, 20, 30, 35 }; const u8 select_width[5] = { 10, 10, 10, 5, 5 }; int line; for(line=0; line<2; ++line) { SEQ_LCD_CursorSet(select_pos1[selected_subpage], line); SEQ_LCD_PrintSpaces(select_width[selected_subpage]); } } /* SEQ_LCD_CursorSet(0, 0); if (selected_subpage == SUBPAGE_TRANSPOSE && ui_cursor_flash) { SEQ_LCD_PrintSpaces(21); } else { SEQ_LCD_PrintString(" Transposer and Arp "); } SEQ_LCD_CursorSet(0, 1); if (selected_subpage == SUBPAGE_SECTIONS && ui_cursor_flash) { SEQ_LCD_PrintSpaces(21); } else { SEQ_LCD_PrintString(" Section control "); } SEQ_LCD_CursorSet(0, 2); if (selected_subpage == SUBPAGE_ROUTER && ui_cursor_flash) { SEQ_LCD_PrintSpaces(21); } else { SEQ_LCD_PrintString(" MIDI router "); } SEQ_LCD_CursorSet(0, 3); if (selected_subpage == SUBPAGE_MISC && ui_cursor_flash) { SEQ_LCD_PrintSpaces(21); } else { SEQ_LCD_PrintString(" Miscilenious "); } */ SEQ_LCD_CursorSet(0, 4); switch( selected_subpage ) { /////////////////////////////////////////////////////////////////////////// case SUBPAGE_TRANSPOSE: { //SEQ_LCD_CursorSet(40, 0); SEQ_LCD_PrintString(" Bus Port Chn. Mode "); SEQ_LCD_CursorSet(0, 6); SEQ_LCD_PrintString(" Lower/Upper Reset "); SEQ_LCD_CursorSet(0, 5); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_IN_BUS && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(5); } else { SEQ_LCD_PrintFormattedString(" %d ", selected_bus+1); } /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_IN_PORT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { if( seq_midi_in_port[selected_bus] ) SEQ_LCD_PrintString(SEQ_MIDI_PORT_InNameGet(SEQ_MIDI_PORT_InIxGet(seq_midi_in_port[selected_bus]))); else SEQ_LCD_PrintString(" All"); } SEQ_LCD_PrintSpaces(1); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_IN_CHN && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { if( seq_midi_in_channel[selected_bus] ) SEQ_LCD_PrintFormattedString("#%2d", seq_midi_in_channel[selected_bus]); else SEQ_LCD_PrintString("---"); } SEQ_LCD_PrintSpaces(3); /* /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_IN_MODE && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { SEQ_LCD_PrintString(seq_midi_in_options[selected_bus].MODE_PLAY ? "Play" : "T&A "); } SEQ_LCD_PrintSpaces(3); SEQ_LCD_CursorSet(0, 7); */ /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_IN_LOWER && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { SEQ_LCD_PrintNote(seq_midi_in_lower[selected_bus]); } SEQ_LCD_PrintSpaces(3); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_IN_UPPER && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { SEQ_LCD_PrintNote(seq_midi_in_upper[selected_bus]); } SEQ_LCD_PrintSpaces(2); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_IN_MODE && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { SEQ_LCD_PrintString(seq_midi_in_options[selected_bus].MODE_PLAY ? "Play" : "T&A "); } SEQ_LCD_PrintSpaces(3); SEQ_LCD_PrintString("Stacks"); } break; /////////////////////////////////////////////////////////////////////////// case SUBPAGE_SECTIONS: { //SEQ_LCD_CursorSet(40, 0); SEQ_LCD_PrintString(" Port Chn. G1 G2 "); SEQ_LCD_CursorSet(0, 6); SEQ_LCD_PrintString(" G3 G4 Fwd Reset "); SEQ_LCD_CursorSet(0, 5); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_S_PORT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { if( seq_midi_in_sect_port ) SEQ_LCD_PrintString(SEQ_MIDI_PORT_InNameGet(SEQ_MIDI_PORT_InIxGet(seq_midi_in_sect_port))); else SEQ_LCD_PrintString(" All"); } SEQ_LCD_PrintSpaces(1); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_S_CHN && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { if( seq_midi_in_sect_channel ) SEQ_LCD_PrintFormattedString("#%2d", seq_midi_in_sect_channel); else SEQ_LCD_PrintString("---"); } SEQ_LCD_PrintSpaces(2); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_S_OCT_G1 && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { SEQ_LCD_PrintNote(seq_midi_in_sect_note[0]); } SEQ_LCD_PrintSpaces(2); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_S_OCT_G2 && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { SEQ_LCD_PrintNote(seq_midi_in_sect_note[1]); } SEQ_LCD_PrintSpaces(2); SEQ_LCD_CursorSet(0, 5); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_S_OCT_G3 && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { SEQ_LCD_PrintNote(seq_midi_in_sect_note[2]); } SEQ_LCD_PrintSpaces(2); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_S_OCT_G4 && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { SEQ_LCD_PrintNote(seq_midi_in_sect_note[3]); } SEQ_LCD_PrintSpaces(2); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_S_FWD_PORT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { if( seq_midi_in_sect_fwd_port == 0 ) SEQ_LCD_PrintString("----"); else SEQ_LCD_PrintString(SEQ_MIDI_PORT_OutNameGet(SEQ_MIDI_PORT_OutIxGet(seq_midi_in_sect_fwd_port))); } SEQ_LCD_PrintSpaces(1); SEQ_LCD_PrintString("Stcks"); } break; /////////////////////////////////////////////////////////////////////////// case SUBPAGE_ROUTER: { //<<<<<<< .mine //SEQ_LCD_CursorSet(40, 0); SEQ_LCD_PrintString(" Node IN Port/Chn "); SEQ_LCD_CursorSet(0, 6); SEQ_LCD_PrintString("OUT Port/Chn Def.Port"); SEQ_LCD_CursorSet(0, 5); /* ======= SEQ_LCD_CursorSet(40, 0); SEQ_LCD_PrintString("Node IN P/Chn OUT P/Chn | DefaultPort"); SEQ_LCD_CursorSet(40, 1); >>>>>>> .r1826 */ /////////////////////////////////////////////////////////////////////// SEQ_LCD_PrintSpaces(1); if( ui_selected_item == ITEM_R_NODE && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { SEQ_LCD_PrintFormattedString("#%2d", selected_router_node+1); } SEQ_LCD_PrintSpaces(1); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_R_SRC_PORT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { SEQ_LCD_PrintString(SEQ_MIDI_PORT_InNameGet(SEQ_MIDI_PORT_InIxGet(n->src_port))); } SEQ_LCD_PrintSpaces(1); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_R_SRC_CHN && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { if( !n->src_chn ) { SEQ_LCD_PrintString("---"); } else if( n->src_chn > 16 ) { SEQ_LCD_PrintString("All"); } else { SEQ_LCD_PrintFormattedString("#%2d", n->src_chn); } } SEQ_LCD_PrintSpaces(2); SEQ_LCD_CursorSet(0, 7); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_R_DST_PORT && ui_cursor_flash ) { if( n->dst_chn >= 18 ) { SEQ_LCD_PrintSpaces(2); } else { SEQ_LCD_PrintSpaces(4); } } else { if( n->dst_chn >= 18 ) { SEQ_LCD_PrintSpaces(2); } else { SEQ_LCD_PrintString(SEQ_MIDI_PORT_OutNameGet(SEQ_MIDI_PORT_OutIxGet(n->dst_port))); } } /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_R_DST_CHN && ui_cursor_flash ) { if( n->dst_chn >= 18 ) { SEQ_LCD_PrintSpaces(7); } else { SEQ_LCD_PrintSpaces(5); } } else { if( !n->dst_chn ) { SEQ_LCD_PrintString(" --- "); } else if( n->dst_chn == 17 ) { SEQ_LCD_PrintString(" All "); } else if( n->dst_chn == 18 ) { SEQ_LCD_PrintString(" Track"); } else if( n->dst_chn >= 19 ) { SEQ_LCD_PrintString("Sel.Trk"); } else { SEQ_LCD_PrintFormattedString(" #%2d ", n->dst_chn); } } SEQ_LCD_PrintSpaces(3); /////////////////////////////////////////////////////////////////////// SEQ_LCD_PrintChar('|'); SEQ_LCD_PrintSpaces(4); if( ui_selected_item == ITEM_DEF_PORT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { SEQ_LCD_PrintString(SEQ_MIDI_PORT_OutNameGet(SEQ_MIDI_PORT_OutIxGet(MIOS32_MIDI_DefaultPortGet()))); } SEQ_LCD_PrintSpaces(4); } break; /////////////////////////////////////////////////////////////////////////// case SUBPAGE_EXT_CTRL: { SEQ_LCD_CursorSet(40, 0); SEQ_LCD_PrintString(" IN OUT Chn.|Function "); if( selected_ext_ctrl < SEQ_MIDI_IN_EXT_CTRL_NUM_IX_CC ) { SEQ_LCD_PrintString("CC# "); } else { SEQ_LCD_PrintSpaces(10); } SEQ_LCD_CursorSet(40, 1); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_EXT_PORT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { if( seq_midi_in_ext_ctrl_port == 0xff ) SEQ_LCD_PrintString(" All"); else if( !seq_midi_in_ext_ctrl_port ) SEQ_LCD_PrintString(" off"); else SEQ_LCD_PrintString(SEQ_MIDI_PORT_InNameGet(SEQ_MIDI_PORT_InIxGet(seq_midi_in_ext_ctrl_port))); } SEQ_LCD_PrintSpaces(1); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_EXT_PORT_OUT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { if( seq_midi_in_ext_ctrl_out_port ) SEQ_LCD_PrintString(SEQ_MIDI_PORT_OutNameGet(SEQ_MIDI_PORT_OutIxGet(seq_midi_in_ext_ctrl_out_port))); else SEQ_LCD_PrintString("off "); } SEQ_LCD_PrintSpaces(1); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_EXT_CHN && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(3); } else { if( seq_midi_in_ext_ctrl_channel ) SEQ_LCD_PrintFormattedString("#%2d", seq_midi_in_ext_ctrl_channel); else SEQ_LCD_PrintString("---"); } SEQ_LCD_PrintString(" |"); /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_EXT_CTRL && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(15); } else { SEQ_LCD_PrintStringPadded((char *)SEQ_MIDI_IN_ExtCtrlStr(selected_ext_ctrl), 15); } /////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_EXT_VALUE && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(10); } else { SEQ_LCD_PrintSpaces(1); if( selected_ext_ctrl == SEQ_MIDI_IN_EXT_CTRL_NRPN_ENABLED ) { SEQ_LCD_PrintStringPadded(seq_midi_in_ext_ctrl_asg[selected_ext_ctrl] ? "enabled" : "disabled", 9); } else if( selected_ext_ctrl == SEQ_MIDI_IN_EXT_CTRL_PC_MODE ) { SEQ_LCD_PrintStringPadded((char *)SEQ_MIDI_IN_ExtCtrlPcModeStr(seq_midi_in_ext_ctrl_asg[selected_ext_ctrl]), 9); } else { u8 cc = seq_midi_in_ext_ctrl_asg[selected_ext_ctrl]; if( cc >= 0x80 ) SEQ_LCD_PrintString("off"); else SEQ_LCD_PrintFormattedString("%3d", cc); SEQ_LCD_PrintSpaces(7); } } } break; /////////////////////////////////////////////////////////////////////////// case SUBPAGE_MISC: { //SEQ_LCD_CursorSet(40, 0); //<<<<<<< .mine SEQ_LCD_PrintString("BLM_SCALAR "); SEQ_LCD_PrintString(blm_timeout_ctr ? "connected " : "not found "); SEQ_LCD_CursorSet(0, 6); SEQ_LCD_PrintString(" MIDI "); SEQ_LCD_CursorSet(0, 5); /* ======= SEQ_LCD_PrintString("BLM_SCALAR MIDI "); SEQ_LCD_CursorSet(40, 1); >>>>>>> .r1826 */ /////////////////////////////////////////////////////////////////////// SEQ_LCD_PrintString("Port: "); if( ui_selected_item == ITEM_BLM_SCALAR_PORT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { if( !seq_blm_port ) SEQ_LCD_PrintString(" off"); else SEQ_LCD_PrintString(SEQ_MIDI_PORT_InNameGet(SEQ_MIDI_PORT_InIxGet(seq_blm_port))); } //<<<<<<< .mine SEQ_LCD_CursorSet(0, 7); //======= SEQ_LCD_PrintString(blm_timeout_ctr ? " (found) " : " "); // free for new parameters SEQ_LCD_PrintSpaces(12); //>>>>>>> .r1826 /////////////////////////////////////////////////////////////////////// SEQ_LCD_PrintString("Monitor "); } break; } return 0; // no error } ///////////////////////////////////////////////////////////////////////////// // Local exit function ///////////////////////////////////////////////////////////////////////////// static s32 EXIT_Handler(void) { s32 status = 0; if( store_file_required ) { // write config files MUTEX_SDCARD_TAKE; if( (status=SEQ_FILE_C_Write(seq_file_session_name)) < 0 ) SEQ_UI_SDCardErrMsg(2000, status); MUTEX_SDCARD_GIVE; MUTEX_SDCARD_TAKE; if( (status=SEQ_FILE_GC_Write()) < 0 ) SEQ_UI_SDCardErrMsg(2000, status); MUTEX_SDCARD_GIVE; } return status; }
///////////////////////////////////////////////////////////////////////////// // 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 0 // leads to: comparison is always true due to limited range of data type if( button >= SEQ_UI_BUTTON_GP1 && button <= SEQ_UI_BUTTON_GP16 ) { #else if( button <= SEQ_UI_BUTTON_GP16 ) { #endif // re-use encoder handler - only select UI item, don't increment, flags will be toggled return Encoder_Handler((int)button, 0); } // remaining buttons: switch( button ) { case SEQ_UI_BUTTON_Select: case SEQ_UI_BUTTON_Right: if( depressed ) return -1; if( ++ui_selected_item >= NUM_OF_ITEMS ) ui_selected_item = 0; return 1; // value always changed case SEQ_UI_BUTTON_Left: if( depressed ) return -1; if( ui_selected_item == 0 ) ui_selected_item = NUM_OF_ITEMS-1; else --ui_selected_item; return 1; // value always changed case SEQ_UI_BUTTON_Up: if( depressed ) return -1; return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, 1); case SEQ_UI_BUTTON_Down: if( depressed ) return -1; return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, -1); } return -1; // invalid or unsupported button } ///////////////////////////////////////////////////////////////////////////// // Local Display Handler function // IN: <high_prio>: if set, a high-priority LCD update is requested ///////////////////////////////////////////////////////////////////////////// static s32 LCD_Handler(u8 high_prio) { if( high_prio ) return 0; // there are no high-priority updates // layout: // 00000000001111111111222222222233333333330000000000111111111122222222223333333333 // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 // <--------------------------------------><--------------------------------------> // Control Root Selected Scale // Global Keyb 50:Hungarian Gypsy /////////////////////////////////////////////////////////////////////////// SEQ_LCD_CursorSet(0, 0); SEQ_LCD_PrintString(" Control Root Selected Scale "); SEQ_LCD_PrintSpaces(40); /////////////////////////////////////////////////////////////////////////// SEQ_LCD_CursorSet(0, 1); SEQ_LCD_PrintSpaces(1); if( ui_selected_item == ITEM_SCALE_CTRL && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(8); } else { if( seq_core_global_scale_ctrl ) SEQ_LCD_PrintFormattedString("Group G%d", seq_core_global_scale_ctrl); else SEQ_LCD_PrintString("Global "); } SEQ_LCD_PrintSpaces(1); /////////////////////////////////////////////////////////////////////////// // determine the selected scale and root note selection depending on // global/group specific settings u8 scale, root_selection, root; SEQ_CORE_FTS_GetScaleAndRoot(&scale, &root_selection, &root); if( ui_selected_item == ITEM_SCALE_ROOT && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(4); } else { const char root_str[13][5] = { "Keyb", " C ", " C# ", " D ", " D# ", " E ", " F ", " F# ", " G ", " G# ", " A ", " A# ", " B " }; SEQ_LCD_PrintString((char *)root_str[root_selection]); } SEQ_LCD_PrintSpaces(2); if( ui_selected_item == ITEM_SCALE && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(24); } else { SEQ_LCD_PrintFormattedString("%3d:", scale); SEQ_LCD_PrintString(SEQ_SCALE_NameGet(scale)); } /////////////////////////////////////////////////////////////////////////// SEQ_LCD_PrintSpaces(40); return 0; // no error } ///////////////////////////////////////////////////////////////////////////// // Local exit function ///////////////////////////////////////////////////////////////////////////// static s32 EXIT_Handler(void) { s32 status = 0; if( ui_store_file_required ) { // write config file MUTEX_SDCARD_TAKE; if( (status=SEQ_FILE_C_Write(seq_file_session_name)) < 0 ) SEQ_UI_SDCardErrMsg(2000, status); MUTEX_SDCARD_GIVE; ui_store_file_required = 0; } return status; }
///////////////////////////////////////////////////////////////////////////// // This task is called periodically each second ///////////////////////////////////////////////////////////////////////////// void SEQ_TASK_Period1S(void) { static s8 wait_boot_ctr = 3; // wait 3 seconds before loading from SD Card - this is to increase the time where the boot screen is print! u8 load_sd_content = 0; // poll for IIC modules as long as HW config hasn't been locked (read from SD card) // TODO: use proper mutex handling here #ifndef MIOS32_FAMILY_EMULATION if( !SEQ_FILE_HW_ConfigLocked() ) { MIOS32_IIC_MIDI_ScanInterfaces(); } #endif // boot phase of 2 seconds finished? if( wait_boot_ctr > 0 ) { --wait_boot_ctr; if( wait_boot_ctr ) return; } // BLM timeout counter MIOS32_IRQ_Disable(); if( seq_blm_timeout_ctr ) --seq_blm_timeout_ctr; MIOS32_IRQ_Enable(); // check if SD Card connected MUTEX_SDCARD_TAKE; s32 status = FILE_CheckSDCard(); if( status == 1 ) { if( wait_boot_ctr != 0 ) { // don't print message if we just booted char str[21]; sprintf(str, "Label: %s", FILE_VolumeLabel()); #ifndef MBSEQV4L SEQ_UI_Msg(SEQ_UI_MSG_SDCARD, 2000, " SD Card connected", " :-D"); #endif DEBUG_MSG("SD Card connected: %s\n", FILE_VolumeLabel()); } SEQ_FILE_LoadSessionName(); DEBUG_MSG("Loading session %s\n", seq_file_session_name); SEQ_FILE_LoadAllFiles(1); } else if( status == 2 ) { #ifndef MBSEQV4L SEQ_UI_Msg(SEQ_UI_MSG_SDCARD, 2000, "SD Card disconnected", " :-/"); #endif DEBUG_MSG("SD Card disconnected\n"); SEQ_FILE_UnloadAllFiles(); wait_boot_ctr = -1; } else if( status == 3 ) { if( !FILE_SDCardAvailable() ) { #ifndef MBSEQV4L SEQ_UI_Msg(SEQ_UI_MSG_SDCARD, 2000, " No SD Card found ", " :-("); #endif DEBUG_MSG("SD Card not found\n"); SEQ_FILE_HW_LockConfig(); // lock configuration wait_boot_ctr = -1; } else if( !FILE_VolumeAvailable() ) { #ifndef MBSEQV4L SEQ_UI_Msg(SEQ_UI_MSG_SDCARD, 2000, "!! SD Card Error !!!", "!! Invalid FAT !!!!!"); #endif DEBUG_MSG("ERROR: SD Card contains invalid FAT!\n"); SEQ_FILE_HW_LockConfig(); // lock configuration wait_boot_ctr = -1; } else { #ifndef MBSEQV4L if( wait_boot_ctr != 0 ) { // don't print message if we just booted char str1[30]; sprintf(str1, "Banks: ...."); u8 bank; for(bank=0; bank<4; ++bank) str1[7+bank] = SEQ_FILE_B_NumPatterns(bank) ? ('1'+bank) : '-'; char str2[30]; sprintf(str2, "M:%c S:%c G:%c C:%c%c HW:%c", SEQ_FILE_M_NumMaps() ? '*':'-', SEQ_FILE_S_NumSongs() ? '*':'-', SEQ_FILE_G_Valid() ? '*':'-', SEQ_FILE_C_Valid() ? 'S':'-', SEQ_FILE_GC_Valid() ? 'G':'-', SEQ_FILE_HW_Valid() ? '*':'-'); SEQ_UI_Msg(SEQ_UI_MSG_SDCARD, 2000, str1, str2); } #endif #if MBSEQV4L // auto-format // check if formatting is required if( SEQ_FILE_FormattingRequired() ) { strcpy(seq_file_new_session_name, "DEF_V4L"); DEBUG_MSG("Creating initial session '%s'... this can take some seconds!\n", seq_file_new_session_name); if( (status=SEQ_FILE_Format()) < 0 ) { DEBUG_MSG("Failed to create session! (status: %d)\n", status); } else { SEQ_FILE_StoreSessionName(); DEBUG_MSG("Done!\n"); } } #endif // request to load content of SD card load_sd_content = 1; // notify that boot finished wait_boot_ctr = -1; } } else if( status < 0 ) { wait_boot_ctr = -1; #ifndef MBSEQV4L SEQ_UI_SDCardErrMsg(2000, status); #endif DEBUG_MSG("ERROR: SD Card Error %d (FatFs: D%3d)\n", status, file_dfs_errno); } // check for format request // this is running with low priority, so that LCD is updated in parallel! if( seq_ui_format_req ) { // note: request should be cleared at the end of this process to avoid double-triggers! if( (status = SEQ_FILE_Format()) < 0 ) { #ifndef MBSEQV4L SEQ_UI_SDCardErrMsg(2000, status); #endif DEBUG_MSG("ERROR: SD Card Error %d (FatFs: D%3d)\n", status, file_dfs_errno); } else { #ifndef MBSEQV4L SEQ_UI_Msg(SEQ_UI_MSG_USER, 1000, "Files created", "successfully!"); #endif DEBUG_MSG("Files created successfully!\n"); // store session name status |= SEQ_FILE_StoreSessionName(); } // request to load content of SD card load_sd_content = 1; // finally clear request seq_ui_format_req = 0; } // check for backup request // this is running with low priority, so that LCD is updated in parallel! if( seq_ui_backup_req ) { // note: request should be cleared at the end of this process to avoid double-triggers! status = SEQ_FILE_CreateBackup(); if( status < 0 ) { if( status == FILE_ERR_COPY ) { #ifndef MBSEQV4L SEQ_UI_Msg(SEQ_UI_MSG_USER, 2000, "COPY FAILED!", "ERROR :-("); #endif DEBUG_MSG("ERROR: copy failed!\n"); } else { #ifndef MBSEQV4L SEQ_UI_SDCardErrMsg(2000, status); #endif DEBUG_MSG("ERROR: SD Card Error %d (FatFs: D%3d)\n", status, file_dfs_errno); } } else { #ifndef MBSEQV4L SEQ_UI_Msg(SEQ_UI_MSG_USER, 1000, "Files copied", "successfully!"); #endif DEBUG_MSG("Files copied successfully!\n"); // store session name status |= SEQ_FILE_StoreSessionName(); } // finally clear request seq_ui_backup_req = 0; } // check for save all request // this is running with low priority, so that LCD is updated in parallel! if( seq_ui_saveall_req ) { s32 status = 0; // store all patterns int group; for(group=0; group<SEQ_CORE_NUM_GROUPS; ++group) status |= SEQ_FILE_B_PatternWrite(seq_file_session_name, seq_pattern[group].bank, seq_pattern[group].pattern, group, 1); // store config (e.g. to store current song/mixermap/pattern numbers SEQ_FILE_C_Write(seq_file_session_name); // store global config SEQ_FILE_GC_Write(); // store mixer map SEQ_MIXER_Save(SEQ_MIXER_NumGet()); // store session name if( status >= 0 ) status |= SEQ_FILE_StoreSessionName(); if( status < 0 ) { #ifndef MBSEQV4L SEQ_UI_SDCardErrMsg(2000, status); #endif DEBUG_MSG("ERROR: SD Card Error %d (FatFs: D%3d)\n", status, file_dfs_errno); } // finally clear request seq_ui_saveall_req = 0; } MUTEX_SDCARD_GIVE; // load content of SD card if requested ((re-)connection detected) if( load_sd_content && !SEQ_FILE_FormattingRequired() ) { // send layout request to MBHP_BLM_SCALAR MUTEX_MIDIOUT_TAKE; SEQ_BLM_SYSEX_SendRequest(0x00); MUTEX_MIDIOUT_GIVE; // TODO: should we load the patterns when SD Card has been detected? // disadvantage: current edit patterns are destroyed - this could be fatal during a live session if there is a bad contact! SEQ_MIXER_Load(SEQ_MIXER_NumGet()); SEQ_SONG_Load(SEQ_SONG_NumGet()); } #ifndef MBSEQV4L SEQ_LCD_LOGO_ScreenSaver_Period1S(); #endif }