BaseMachine UI Controllerに分離
Dependencies: AverageAnalogIn PinDetect RotaryEncoder Sequence SequencerDisplay mbed-rtos mbed st7567LCD BaseMachineComon
Fork of BaseMachine_Sequencer by
Diff: main.cpp
- Revision:
- 43:12d11507c077
- Parent:
- 42:3c71f925a47b
- Child:
- 44:b1bdccdbf67e
--- a/main.cpp Fri Oct 07 07:12:00 2016 +0000 +++ b/main.cpp Fri Oct 07 07:48:22 2016 +0000 @@ -89,11 +89,11 @@ } filterParam; struct EnvelopeParam { - int8_t level; - int8_t length; - int8_t duration; - int8_t decay; - int8_t sustain; + uint8_t level; + uint8_t length; + uint8_t duration; + uint8_t decay; + uint8_t sustain; } envelopeParam; uint8_t bpm = 120; @@ -175,15 +175,53 @@ //------------------------------------------------------------------------ void pollingPots() { - oscillatorParam.pulseWidth = AinPulseWidth.read_u16() >> 8; + uint8_t pulseWidth = AinPulseWidth.read_u16() >> (16 - POT_RESOLUTION); + if (pulseWidth != oscillatorParam.pulseWidth) { + oscillatorParam.pulseWidth = pulseWidth; + isDirty = true; + } + + uint8_t cutoff = AinCutOff.read_u16() >> (16 - POT_RESOLUTION); + if (cutoff != filterParam.cutoff) { + filterParam.cutoff = cutoff; + isDirty = true; + } - filterParam.cutoff = AinCutOff.read_u16() >> 8; - filterParam.resonance = AinResonance.read_u16() >> 8; + uint8_t resonance = AinResonance.read_u16() >> (16 - POT_RESOLUTION); + if (resonance != filterParam.resonance) { + filterParam.resonance = resonance; + isDirty = true; + } - envelopeParam.level = AinLevel.read_u16() >> 8; - envelopeParam.duration = AinDuration.read_u16() >> 8; - envelopeParam.decay = AinDecay.read_u16() >> 8; - envelopeParam.sustain = AinSustain.read_u16() >> 8; + uint8_t level = AinLevel.read_u16() >> (16 - POT_RESOLUTION); + if (level != envelopeParam.level) { + envelopeParam.level = level; + isDirty = true; + } + + uint8_t duration = AinDuration.read_u16() >> (16 - POT_RESOLUTION); + if (duration != envelopeParam.level) { + envelopeParam.duration = duration; + isDirty = true; + } + + uint8_t decay = AinDecay.read_u16() >> (16 - POT_RESOLUTION); + if (decay != envelopeParam.decay) { + envelopeParam.decay = decay; + isDirty = true; + } + + uint8_t sustain = AinSustain.read_u16() >> (16 - POT_RESOLUTION); + if (sustain != envelopeParam.sustain) { + envelopeParam.sustain = sustain; + isDirty = true; + } + + uint8_t _accentLevel = AinAccentLevel.read_u16() >> (16 - POT_RESOLUTION); + if (_accentLevel != accentLevel) { + accentLevel = _accentLevel; + isDirty = true; + } } void pollingRotEncs() @@ -243,7 +281,7 @@ #if (UART_TRACE) printf("PinOctaveUp Pushed\r\n"); #endif - if (sequencerDisplay.getOctave() < octaveMax ) { + if (sequencerDisplay.getOctave() < octaveMax) { sequencerDisplay.setOctave(sequencerDisplay.getOctave() + 1); isDirty = true; }