Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** MenuStructure.h
- * Provides the structure of the menu system. It uses a system of #define statements to create
- * a menu structure. This system is based on the menu system found in the Marlin firmware in
- * ultralcd.h file.
- *
- * Written by Andrew Glick (12/31/2018).
- *
- *
- */
- #ifndef menustructure_h_
- #define menustructure_h_
- #include "Menus.h"
- #include "Display.h"
- #include "lang.h"
- #include "config.h"
- #include <Adafruit_GFX.h>
- #include <Adafruit_SSD1306.h>
- #include "SerialDebug.h"
- #define ROW_SELECTED '>'
- #define ROW_NORMAL ' '
- typedef __uint8_t uint8_t;
- typedef void (*menuFunc_t)(); //Function pointer to menu functions.
- uint8_t cursorPos;
- // uint8_t lastCursorPos;
- bool cvFwd;
- bool redrawMenu;
- uint8_t currentViewOffset;
- static char str[16];
- const int strLen = 16;
- static char buffer[8];
- inline int numDigits8(uint8_t n) { return ((n < 10) ? 1 : (n < 100) ? 2 : 3); } // Returns the number of digits in an 8-bit number
- //*******************************************************************
- // Function to draw a standard menu line with a value on the right
- void draw_menu_generic(uint8_t row, const char* label, char preChar, const char* value, uint8_t valCharOffset, bool cv)
- {
- oled.setCursor(0, row * CHAR_HEIGHT);
- if (!cv) oled.print(preChar);
- else oled.print(" ");
- oled.print(" ");
- oled.print(label);
- oled.print(":");
- //Serial.print(label);
- oled.setCursor(valCharOffset * CHAR_WIDTH, row * CHAR_HEIGHT);
- if (cv) oled.print(preChar);
- else oled.print(" ");
- oled.print(value);
- }
- //*******************************************************************
- // Function to draw a menu line with a specific character on the right
- void draw_menu_char(uint8_t row, const char* label, char preChar, int value, uint8_t valCharOffset)
- {
- oled.setCursor(0, row * CHAR_HEIGHT);
- oled.print(preChar);
- oled.print(" ");
- oled.print(label);
- //oled.print(":");
- oled.setCursor(valCharOffset * CHAR_WIDTH, row * CHAR_HEIGHT);
- oled.write(value);
- }
- //*******************************************************************//
- // Get string functions //
- //*******************************************************************//
- // Clear the str buffer by filling it with spaces
- void clrStr() { for(int i = 0; i < strLen - 1; i++) str[i] = 0; }
- char* uiToStr(uint8_t x) // unsigned int to string
- {
- clrStr();
- (x >= 100) ? str[0] = (x / 100) % 10 + '0' : str[0] = ' '; // set the 100's place if x >= 100
- (x >= 10) ? str[1] = (x / 10) % 10 + '0' : str[1] = ' '; // set the 10's place if x >= 10
- str[2] = (x % 10) + '0'; // set the 1's place
- str[3] = ' ';
- return str;
- }
- char* siToStr(int8_t x) // signed int to string
- {
- clrStr();
- int xx = abs(x);
- int digits = numDigits8(xx); // Get the number of digits to place the negative sign
- str[0] = ' '; // Clear the first character
- (xx >= 100) ? str[1] = (char) ((xx / 100) % 10) + '0' : str[1] = ' '; // set the 100's place if x >= 100
- (xx >= 10) ? str[2] = (char) ((xx / 10) % 10) + '0' : str[2] = ' '; // set the 10's place if x >= 10
- str[3] = (char) (xx % 10) + '0'; // set the 1's place
- if (x < 0) str[3 - digits] = '-'; // set the appropriate character to '-' if the number is negative
- return str;
- }
- char* cuiToStr(uint8_t x, const char* c) // character + unsigned int to char
- {
- clrStr();
- strcpy(buffer, c);
- if (x == 0) return buffer;
- else return uiToStr(x);
- }
- char* percentToStr(uint8_t x) // unsigned int (as percent) to string
- {
- clrStr();
- (x >= 100) ? str[0] = (x / 100) % 10 + '0' : str[0] = ' '; // set the 100's place if x >= 100
- (x >= 10) ? str[1] = (x / 10) % 10 + '0' : str[1] = ' '; // set the 10's place if x >= 10
- str[2] = (x % 10) + '0'; // set the 1's place
- str[3] = '%';
- return str;
- }
- char* noteToStr(uint8_t note)
- {
- static const char* noNote = " None";
- if (note >= 128) return (char*) noNote; // If the note is too large, return "None";
- clrStr();
- strcpy(str, note_table[note % 12]); // Copy over the note name
- str[6] = ' '; // Add a space
- str[7] = (note / 12) + 1 + '0'; // Set the octave
- return str;
- }
- // Definitions for each row type
- #define draw_menu(row, label, value, cursor) draw_menu_generic(row, label, cursor, value, 10, cvFwd)
- #define draw_menu_submenu(row, label, value, cursor) draw_menu_char(row, label, cursor, 26, DISPLAY_MENU_OFFSET)
- #define draw_menu_back(row, label, value, cursor) draw_menu_char(row, label, cursor, 27, DISPLAY_MENU_OFFSET)
- #define draw_menu_toggle(row, label, value, cursor) draw_menu_char(row, label, cursor, ' ', 17)
- #define draw_menu_function(row, label, value, cursor) draw_menu_char(row, label, cursor, '*', DISPLAY_MENU_OFFSET)
- #define draw_menu_value(row, label, value, cursor) draw_menu_generic(row, label, cursor, uiToStr(value), DISPLAY_VALUE_OFFSET, cvFwd)
- #define draw_menu_tf(row, label, value, cursor) draw_menu_generic(row, label, cursor, tf_table[value], DISPLAY_TF_OFFSET, cvFwd)
- #define draw_menu_percent(row, label, value, cursor) draw_menu_generic(row, label, cursor, percentToStr(value), DISPLAY_PERCENT_OFFSET, cvFwd)
- #define draw_menu_off8(row, label, value, cursor) draw_menu_generic(row, label, cursor, cuiToStr(value, str_off), DISPLAY_OFF8_OFFSET, cvFwd)
- #define draw_menu_off24(row, label, value, cursor) draw_menu_generic(row, label, cursor, cuiToStr(value, str_off), DISPLAY_OFF24_OFFSET, cvFwd)
- #define draw_menu_u64(row, label, value, cursor) draw_menu_generic(row, label, cursor, uiToStr(value), DISPLAY_U6_OFFSET, cvFwd)
- #define draw_menu_u127(row, label, value, cursor) draw_menu_generic(row, label, cursor, uiToStr(value), DISPLAY_U6_OFFSET, cvFwd)
- #define draw_menu_u255(row, label, value, cursor) draw_menu_generic(row, label, cursor, uiToStr(value), DISPLAY_U8_OFFSET, cvFwd)
- #define draw_menu_s127(row, label, value, cursor) draw_menu_generic(row, label, cursor, siToStr(value), DISPLAY_S8_OFFSET, cvFwd)
- #define draw_menu_note(row, label, value, cursor) draw_menu_generic(row, label, cursor, note_table[value], DISPLAY_NOTE_OFFSET, cvFwd)
- #define draw_menu_noteVal(row, label, value, cursor) draw_menu_generic(row, label, cursor, noteToStr(value), DISPLAY_NOTE_OFFSET - 2, cvFwd)
- #define draw_menu_noteDiv(row, label, value, cursor) draw_menu_generic(row, label, cursor, noteDiv_table[value], DISPLAY_NOTEDIV_OFFSET, cvFwd)
- #define draw_menu_mode(row, label, value, cursor) draw_menu_generic(row, label, cursor, mode_table[value], DISPLAY_MODE_OFFSET, cvFwd)
- #define draw_menu_wave(row, label, value, cursor) draw_menu_generic(row, label, cursor, wave_table[value], DISPLAY_WAVE_OFFSET, cvFwd)
- // Menu Type declerations for MENU_ITEM_EDIT_NEW
- // -------- display --------
- // min, max, rate, display, type, width
- #define __value_t 0, 255, 1, uiToStr, func, 3
- #define __tf_t 0, 1 1, tf_table, array, 6
- #define __off8_t 0, 8, 1, uiToStr, func, 3
- #define __off24_t 0, 24, 1, uiToStr, func, 3
- #define __percent_t 0, 100, 5, percentToStr, func, 4
- #define __u64_t 0, 64, 1, uiToStr, func, 3
- #define __u127_t 0, 127, 4, uiToStr, func, 3
- #define __u255_t 0, 255, 5, uiToStr, func, 3
- #define __s127_t -128, 127, 5, siToStr, func, 4
- #define __noteVal_t 0, 127, 1, noteToStr, func, 8
- #define __noteDiv_t 0, 7, 1, noteDiv_table, array, noteDivLen
- #define __note_t 0, 11, 1, note_table, array, 6
- #define __mode_t 0, numModes-1, 1, mode_table, array, 11
- #define __wave_t 0, 6, 1, wave_table, array, 7
- // For off8: (x == 0) ? "Off" : uiToStr(x);
- /* Types of menu actions */
- #define toggle_cvFwd cvFwd = !cvFwd
- #define menu_action_function(function) function();
- void menu_action_toggle(bool b) { b = !b; }
- void menu_action_back(menuFunc_t data);
- void menu_action_submenu(menuFunc_t data);
- // Menu system macros based on menu system macros from Marlin firmware in ultralcd.h
- // Insert at end of 'if(!cvFwd)' for cursorPos debug: Serial.print("cP: "); Serial.print(cursorPos);
- #define START_MENU() do { \
- oled.clearDisplay(); \
- oled.setTextSize(1); \
- oled.setTextColor(WHITE); \
- if (cursorPos < currentViewOffset) { currentViewOffset = cursorPos; } /* Scroll up */ \
- uint8_t lineNr = currentViewOffset, menuItemNr, cursorSkip = 0; \
- bool buttonPressed = re.switchPressed(); \
- redrawMenu |= buttonPressed; \
- if (!cvFwd) { \
- cursorPos += changeValue(cursorPos, range_value);\
- } \
- for(uint8_t drawLineNr = 0; drawLineNr < OLED_HEIGHT; drawLineNr++, lineNr++) { \
- menuItemNr = 0; \
- cursorSkip = 0; /* Disable cursor skip functionality*/ \
- // debugPrint("Start");
- #define MENU_ITEM(type, label, args) do { \
- if(lineNr == menuItemNr) { \
- debugPrint2("Ln#",lineNr);\
- if (lineNr == cursorPos + cursorSkip) { \
- draw_menu_ ## type(drawLineNr, label, value, ROW_SELECTED);\
- } \
- else \
- draw_menu_ ## type(drawLineNr, label, value, ROW_NORMAL); \
- if (buttonPressed && cursorPos + cursorSkip == lineNr) menu_action_ ## type(args); \
- }\
- menuItemNr++; \
- } while (0)
- // New MENU_ITEM_EDIT macro:
- /* Notes:
- * draw_menu_generic(row, value, selected_bool, VALUE, VALUE OFFSET, cv )
- * changeValue(value, min, max, (rate))
- * Maybe have a struct for each type instead of a lot of function arguments
- * Offset should be from right
- */
- // Definitions for types of displays
- // Note: Move these elsewhere when done
- #define disp_array(display, value) display[value]
- #define disp_func(display, value) display(value)
- #define disp_char(display, value) display
- #define MENU_ITEM_EDIT_NEW(min, max, rate, display, displayType, width, label, value) do { \
- if(lineNr == menuItemNr) \
- { \
- /*debugPrint2("Ln#",lineNr);*/\
- /*min + max + rate + display + displayType + width + label + value; */\
- if (lineNr == cursorPos + cursorSkip) \
- { \
- draw_menu_generic(drawLineNr, label, ROW_SELECTED, disp_ ## displayType(display, value), OLED_WIDTH - width, cvFwd); \
- if (cvFwd) value += changeValue(value, min, max, rate);\
- } \
- else \
- draw_menu_generic(drawLineNr, label, ROW_NORMAL, disp_ ## displayType(display, value), OLED_WIDTH - width, cvFwd); \
- if (buttonPressed && cursorPos + cursorSkip == lineNr) toggle_cvFwd; \
- }\
- menuItemNr++; \
- } while (0)
- #define MENU_ITEM_EDIT(type, label, value) do { \
- if(lineNr == menuItemNr) { \
- /*debugPrint2("Ln#",lineNr);*/\
- if (lineNr == cursorPos + cursorSkip) { \
- draw_menu_ ## type(drawLineNr, label, value, ROW_SELECTED);\
- if (cvFwd) value += changeValue(value, range_ ## type);\
- } \
- else \
- draw_menu_ ## type(drawLineNr, label, value, ROW_NORMAL); \
- if (buttonPressed && cursorPos + cursorSkip == lineNr) toggle_cvFwd; \
- }\
- menuItemNr++; \
- } while (0)
- // Need to remove eventually
- #define MENU_ITEM_EDITS(type, label, value) do { \
- if(lineNr == menuItemNr) { \
- /*debugPrint2("Ln#",lineNr);*/\
- if (lineNr == cursorPos + cursorSkip) { \
- draw_menu_ ## type(drawLineNr, label, value, ROW_SELECTED);\
- if (cvFwd) value += changeValueS(value, range_ ## type);\
- } \
- else \
- draw_menu_ ## type(drawLineNr, label, value, ROW_NORMAL); \
- if (buttonPressed && cursorPos + cursorSkip == lineNr) toggle_cvFwd; \
- }\
- menuItemNr++; \
- } while (0)
- #define MENU_ITEM_DUMMY() do { if (lineNr == menuItemNr) { cursorSkip++; } menuItemNr++; } while (0)
- #define END_MENU() \
- if (cursorPos >= menuItemNr) cursorPos = menuItemNr - 1; \
- if (cursorPos + cursorSkip >= currentViewOffset + OLED_HEIGHT) { /* Scroll down */ \
- currentViewOffset = cursorPos + cursorSkip - OLED_HEIGHT + 1; \
- lineNr = currentViewOffset - 1; \
- drawLineNr = -1; \
- } \
- } } while (0); \
- oled.display()
- //if (redrawMenu) { oled.display(); redrawMenu = false; }
- //End of Marlin based menu system macros
- #endif
- /** Menus.cpp
- *
- * Written by Andrew Glick (8/2/2018).
- *
- *
- */
- #include "Menus.h"
- #include "MenuStructure.h"
- #include "MenuVariables.h"
- #include <Wire.h>
- #include <Adafruit_GFX.h>
- #include <Adafruit_SSD1306.h>
- #include "RotaryEncoder.h"
- void (*cMenu)(void); // Pointer to function for active menu
- RotaryEncoder re = RotaryEncoder();
- /* Menus */
- void menu_splash();
- void menu_simple();
- void menu_main();
- void menu_voice1();
- void menu_presets();
- void menu_presets_key();
- void menu_presets_mode();
- void menu_sequence();
- void menu_settings();
- //*******************************************************************
- // Equivalent of void setup() for the menu objects and such
- void beginMenus()
- {
- oled.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); // initialize with the I2C addr 0x3D (for the 128x64)
- bl.attach(BUTTON_L_PIN, INPUT_PULLUP); // attach the lower buttons
- bm.attach(BUTTON_M_PIN, INPUT_PULLUP);
- br.attach(BUTTON_R_PIN, INPUT_PULLUP);
- re.begin(ROTENC_ADDR); // begin the rotarty encoder
- cMenu = menu_main; // set the current menu to menu_main
- menu_splash(); // splash the OLED
- }
- //*******************************************************************
- // Function to change a value in a menu - For unsigned char
- int changeValue(int val, int boundMin, int boundMax, int rate)
- {
- // Change 'val' based on how much the rotary encoder has changed
- int change = re.getEncoderRotation() * rate; // get how much the encoder has changed
- // Constrain "change" to bonuds
- change = max(change, boundMin - val);
- change = min(change, boundMax - val);
- // if (change != 0) redrawMenu = true; // If there is a change, redraw the menu
- // debugPrint(change);
- return change;
- }
- //*******************************************************************
- // Function to change a value in a menu - for signed char
- int8_t changeValueS(int8_t val, int boundMin, int boundMax, int rate)
- {
- // Change 'val' based on how much the rotary encoder has changed
- int change = re.getEncoderRotation(); // get how much the encoder has changed
- // Constrain "change"
- change = max(change, boundMin - val);
- change = min(change, boundMax - val);
- // debugPrint(change);
- return change;
- }
- //*******************************************************************
- // Function to change values | Uses buttons
- uint8_t changeValueB(uint8_t val, int boundMin, int boundMax, int rate)
- {
- // Change 'val' based on button input
- int change = 0;
- if (bl.isPressed()) change -= rate;
- if (br.isPressed()) change += rate;
- if (val + change < boundMin || val + change > boundMax) change = 0; // constrain it to bounds
- // debugPrint2("c:", change);
- return change;
- }
- //*******************************************************************
- // MENUS
- //*******************************************************************
- //*******************************************************************
- // Displays the menu
- void displayMenu() { (*cMenu)(); }
- //*******************************************************************
- // Gets the user input from buttons
- void getButtonInput()
- {
- if (bm.isPressed()) seq1.togglePlayback(); // if the middle button is pressed
- }
- //*******************************************************************
- // Splash screen at startup
- void menu_splash()
- {
- // splash the OLED with the adafruit logo
- oled.display();
- delay(1000);
- oled.clearDisplay();
- // spash the screen with the program info
- oled.setTextSize(2);
- oled.setTextColor(WHITE);
- oled.setCursor(4 * CHAR_WIDTH, 2 * CHAR_HEIGHT);
- oled.print("Modutar");
- oled.setCursor(7 * CHAR_WIDTH, 4 * CHAR_HEIGHT);
- oled.print(VERSION_NUMBER);
- oled.display();
- delay(750);
- }
- //*******************************************************************
- // Simple view of the menu
- void menu_simple()
- {
- START_MENU();
- MENU_ITEM_EDIT(note, "Key:", cKey);
- MENU_ITEM_EDIT(mode, "Mode:", cMode);
- END_MENU();
- }
- //*******************************************************************
- // Main menu
- void menu_main()
- {
- START_MENU();
- //Serial.print(" :) ");
- MENU_ITEM_EDIT(note, "Key", cKey);
- MENU_ITEM_EDIT(mode, "Mode", cMode);
- MENU_ITEM_EDIT(value,"Octave", cOctave);
- MENU_ITEM_EDIT(off8, "Pressure", cPressure);
- MENU_ITEM_EDIT(tf, "Slide Enable", slideEnabled);
- MENU_ITEM_DUMMY();
- MENU_ITEM(submenu, "Voice 1", menu_voice1);
- MENU_ITEM(submenu, "Presets", menu_presets);
- MENU_ITEM(submenu, "Sequencer", menu_sequence);
- MENU_ITEM(submenu, "Settings", menu_settings);
- END_MENU();
- //blink.refresh();
- }
- //*******************************************************************
- // Menu for voice 1
- void menu_voice1()
- {
- START_MENU();
- // MENU_ITEM_EDIT(u255, "Current Voice", currentVoice); // Uncomment when multiple voices are a thing
- // Oscillators
- MENU_ITEM_EDIT(wave, "o1-Wave", voice1.osc[0].wave);
- if (voice1.osc[0].wave == 6) // Show PWM option if the wave is set to "Pulse"
- MENU_ITEM_EDIT(u255,"o1-PWM", voice1.osc[0].pwm);
- MENU_ITEM_EDIT(off8, "o1-Voume", voice1.osc[0].volume);
- MENU_ITEM_EDIT(wave, "o2-Wave", voice1.osc[1].wave);
- if (voice1.osc[1].wave == 6) // Show PWM option if the wave is set to "Pulse"
- MENU_ITEM_EDIT(u255,"o2-PWM", voice1.osc[1].pwm);
- MENU_ITEM_EDIT(value, "o2-Octave", voice1.osc[1].octave);
- MENU_ITEM_EDITS(s127, "o2-Detune", voice1.osc[1].detune);
- MENU_ITEM_EDITS(s127, "o2-Offset", voice1.osc[1].offset);
- MENU_ITEM_EDIT(off8, "o2-Volume", voice1.osc[1].volume);
- MENU_ITEM_EDIT(wave, "o3-Wave", voice1.osc[2].wave);
- if (voice1.osc[2].wave == 6) // Show PWM option if the wave is set to "Pulse"
- MENU_ITEM_EDIT(u255,"o3-PWM", voice1.osc[2].pwm);
- MENU_ITEM_EDIT(value, "o3-Octave", voice1.osc[2].octave);
- MENU_ITEM_EDITS(s127, "o3-Detune", voice1.osc[2].detune);
- MENU_ITEM_EDITS(s127, "o3-Offset", voice1.osc[2].offset);
- MENU_ITEM_EDIT(off8, "o3-Volume", voice1.osc[2].volume);
- MENU_ITEM_EDIT(off8, "Noise Volume", voice1.noiseVolume);
- MENU_ITEM_DUMMY();
- // LFO
- MENU_ITEM_EDIT(wave, "LFO-Wave", voice1.lfoWave);
- MENU_ITEM_EDIT(u255, "LFO-Rate", voice1.lfoRate);
- MENU_ITEM_EDIT(u255, "LFO-Delay", voice1.lfoDelay);
- MENU_ITEM_EDIT(u255, "LFO-Depth", voice1.lfoDepth);
- MENU_ITEM_DUMMY();
- // ADSR EG
- MENU_ITEM_EDIT(u255, "Attack", voice1.egAttack);
- MENU_ITEM_EDIT(u255, "Decay", voice1.egDecay);
- MENU_ITEM_EDIT(u255, "Sustain", voice1.egSustain);
- MENU_ITEM_EDIT(u255, "Release", voice1.egRelease);
- MENU_ITEM_DUMMY();
- // Filter
- MENU_ITEM_EDIT(off8, "Filter Mix", voice1.filterMix);
- MENU_ITEM_EDIT(u255, "Filter Cutoff", voice1.filterCutoff);
- MENU_ITEM_EDIT(u255, "Filter Resonance", voice1.filterResonance);
- // Add: Glide
- // Back
- MENU_ITEM(back, "Back", menu_main);
- END_MENU();
- }
- /* This doesn't work yet
- void menu_voice1_new()
- {
- START_MENU();
- // Oscillators
- MENU_ITEM_EDIT_NEW(__wave_t, "o1-Wave", voice1.osc[0].wave);
- if (voice1.osc[0].wave == 6) // Show PWM option if the wave is set to "Pulse"
- MENU_ITEM_EDIT_NEW(__u255_t,"o1-PWM", voice1.osc[0].pwm);
- MENU_ITEM_EDIT_NEW(__off8_t, "o1-Voume", voice1.osc[0].volume);
- MENU_ITEM_EDIT_NEW(off8, "Noise Volume", voice1.noiseVolume);
- MENU_ITEM_DUMMY();
- // Back
- MENU_ITEM(back, "Back", menu_main);
- END_MENU();
- }//*/
- //*******************************************************************
- // Menu for changing presets
- void menu_presets()
- {
- START_MENU();
- MENU_ITEM(submenu, "Keys", menu_presets_key);
- MENU_ITEM(submenu, "Modes", menu_presets_mode);
- MENU_ITEM_EDIT(off8, "Current Preset", cPreset);
- MENU_ITEM_EDIT(off8, "Preset Count", presetCount);
- MENU_ITEM(back, "Back", menu_main);
- END_MENU();
- }
- // Changes the presets' key
- void menu_presets_key()
- {
- START_MENU();
- MENU_ITEM_EDIT(note, "Key 1", presetKeys[0]);
- MENU_ITEM_EDIT(note, "Key 2", presetKeys[1]);
- MENU_ITEM_EDIT(note, "Key 3", presetKeys[2]);
- MENU_ITEM_EDIT(note, "Key 4", presetKeys[3]);
- MENU_ITEM_EDIT(note, "Key 5", presetKeys[4]);
- MENU_ITEM_EDIT(note, "Key 6", presetKeys[5]);
- MENU_ITEM_EDIT(note, "Key 7", presetKeys[6]);
- MENU_ITEM_EDIT(note, "Key 8", presetKeys[7]);
- MENU_ITEM(back, "Back", menu_presets);
- END_MENU();
- }
- // Changes the presets' mode
- void menu_presets_mode()
- {
- START_MENU();
- MENU_ITEM_EDIT(note, "Mode 1", presetMode[0]);
- MENU_ITEM_EDIT(note, "Mode 2", presetMode[1]);
- MENU_ITEM_EDIT(note, "Mode 3", presetMode[2]);
- MENU_ITEM_EDIT(note, "Mode 4", presetMode[3]);
- MENU_ITEM_EDIT(note, "Mode 5", presetMode[4]);
- MENU_ITEM_EDIT(note, "Mode 6", presetMode[5]);
- MENU_ITEM_EDIT(note, "Mode 7", presetMode[6]);
- MENU_ITEM_EDIT(note, "Mode 8", presetMode[7]);
- MENU_ITEM(back, "Back", menu_presets);
- END_MENU();
- }
- //*******************************************************************
- // Menu for adjusting the sequence
- void menu_sequence()
- {
- // Note: Consider changing first argument in MENU_ITEM_EDIT(<THIS ONE> , <Tag>, <Value>) to be: ( (min, max, displayString), , )
- START_MENU();
- MENU_ITEM_EDIT(u64, "Edit Sequence", seq1.seqPos);
- MENU_ITEM_EDIT(noteVal, "Note", seq1.notes[seq1.seqPos][0]);
- MENU_ITEM_EDIT(u64, "Seq-Length", seq1.seqLen);
- MENU_ITEM_EDIT(u255, "BPM", seq1.bpm);
- MENU_ITEM_EDIT(noteDiv, "Beat Unit", seq1.noteType); // Crashes when value decreases
- // MENU_ITEM_EDIT(percent, "Swing", seq1.swing); // To-do
- MENU_ITEM(function, "Trim", seq1.trim);
- MENU_ITEM(function, "Clear", seq1.clearSequence);
- MENU_ITEM(back, "Back", menu_main);
- // Additional lines to be run when the menu is active
- seqEdit = (cvFwd && cursorPos == 0); // If the user is editing the sequence (in the menu)
- seqCursorView = (cvFwd && cursorPos == 2) ? 1 : 0; // Get the view mode for the cursor on the 8x8 LED matrix
- if (br.isPressed() && bl.isPressed()) seq1.eraseNote(); // If button L and R are pressed, erase current note
- END_MENU();
- }
- //*******************************************************************
- // Menu for settings
- void menu_settings()
- {
- START_MENU();
- MENU_ITEM_EDIT(u255, "Volume", displayVolume);
- MENU_ITEM_EDIT(off24, "Ribbon Overide", ribbonOveride);
- MENU_ITEM_EDIT(tf, "Flip Control", invertRibbonController);
- MENU_ITEM(back, "Back", menu_main);
- END_MENU();
- }
- //*******************************************************************
- // MENU ACTIONS
- //*******************************************************************
- // Goes back a menu
- void menu_action_back(menuFunc_t data)
- {
- cMenu = data;
- // cursorPos = lastCursorPos;
- cursorPos = 0;
- }
- // Goes to a sub menu
- void menu_action_submenu(menuFunc_t data)
- {
- cMenu = data;
- // lastCursorPos = cursorPos;
- cursorPos = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement