BaseMachine UI Controllerに分離
Dependencies: AverageAnalogIn PinDetect RotaryEncoder Sequence SequencerDisplay mbed-rtos mbed st7567LCD BaseMachineComon
Fork of BaseMachine_Sequencer by
Diff: main.cpp
- Revision:
- 26:fbf48a178aeb
- Parent:
- 25:7382bc0a0329
- Child:
- 27:c382689e652b
--- a/main.cpp Fri Aug 26 05:11:17 2016 +0000 +++ b/main.cpp Fri Aug 26 07:24:48 2016 +0000 @@ -31,15 +31,14 @@ const int envelopeLength = (60 * 1000 / (bpm * 4)) / samplingPeriod; const int waveShape = SpiSequenceSender::WAVESHAPE_SQUARE; const int baseNoteNumber = 36; -const int pitchMax = 12; const int bpmMax = 240; const int bpmMin = 60; // Initial Sequence -const int noteOn[SEQUENCE_N] = { 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0 }; -const int octave[SEQUENCE_N] = {-1,-1,-1, 0, 0,-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }; -const int pitch[SEQUENCE_N] = { 9, 7, 3, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 }; -const int tie[SEQUENCE_N] = { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0 }; +const int noteOn[SEQUENCE_N] = { 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0 }; +const int pitch[SEQUENCE_N] = {36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36 }; +const int tie[SEQUENCE_N] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const int accent[SEQUENCE_N] = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 }; // Devices // @@ -58,9 +57,9 @@ AverageAnalogIn AinDecay(PA_1); AverageAnalogIn AinSustain(PA_0); -RotaryEncoder RotEncStep(D2, D3, 0, SEQUENCE_N - 1, 0); -RotaryEncoder RotEncPitch(D4, D5, 0, pitchMax, 0); -RotaryEncoder RotEncBpm(D14, D15, bpmMin, bpmMax, 120); +RotaryEncoder RotEncStep(PA_10, PB_3, 0, SEQUENCE_N - 1, 0); +RotaryEncoder RotEncPitch(PB_5, PB_4, 0, Sequence::getMaxPitch() - 1, 0); +RotaryEncoder RotEncBpm(PB_9, PB_8, bpmMin, bpmMax, 120); PinDetect PinWaveShape(PD_2, PullUp); PinDetect PinModNumber(PC_11, PullUp); @@ -86,7 +85,7 @@ volatile int currentStep = 0; volatile bool isRunning = false; -volatile bool isDirty = false; +volatile bool isDirty = true; volatile uint8_t pinFlag = 0x00; enum PinBit { @@ -314,7 +313,7 @@ gLCD.drawstring(0, col++, buff); sprintf(buff, "Oct:%-2d Tie:%d Acc:%d", - sequences[currentStep].getOctave(), sequences[currentStep].isTie(),sequences[currentStep].isAccent()); + sequencerDisplay.getOctave(), sequences[currentStep].isTie(),sequences[currentStep].isAccent()); gLCD.drawstring(0, col++, buff); sprintf(buff, "Wsp:%d Mdn:%d", sequenceSender.getWaveShape(), modNumber); @@ -401,16 +400,16 @@ for (int i = 0; i < SEQUENCE_N; i++) { Sequence& seq = sequenceSender.getSequences()[i]; seq.setPitch(pitch[i]); - seq.setOctave(octave[i]); seq.setNoteOn(noteOn[i]); seq.setTie(tie[i]); + seq.setAccent(accent[i]); } + RotEncPitch.setVal(sequences[0].getPitch()); envelopeGenerator.init(envelope); sequenceSender.attachUpdate(&updateFunction); sequenceSender.setWaveShape(waveShape); - //sequenceSender.run(0); //-------------------------------------------------------------------- // Main loop @@ -422,8 +421,8 @@ if (!isRunning) { if (isDirty) { sequencerDisplay.update(SequencerDisplay::stop, currentStep); + //dumpToLCD(); } - //dumpToLCD(); } } }