diff --git a/Documents/Disc407.bin b/Documents/Disc407.bin index 93a3881..0bef58e 100755 Binary files a/Documents/Disc407.bin and b/Documents/Disc407.bin differ diff --git a/README.md b/README.md index 3be3019..97c9354 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ I got great inspiration from 2 open source projects: * Button CC values (excluded Looper/Page2 Btn) * {51, 52, 53, 54, 55, 56, 57, 58, 59} * {61, 62, 63, 64, 65, 66, 67, 68, 69} + * Buttons 65 to 69 (Second page, front buttons) are stateless and only send value=127, this is better for some looping commands * Potentiometers CC values (excluded Mode Pot) * {18, 19, 20, 21, 22, 23, 24}; * Expression pedal CC values diff --git a/stm32/Core/Inc/CStompBtn.h b/stm32/Core/Inc/CStompBtn.h index 3ab00d6..c8fbbc8 100755 --- a/stm32/Core/Inc/CStompBtn.h +++ b/stm32/Core/Inc/CStompBtn.h @@ -22,10 +22,11 @@ class CStompBtn uint16_t LedPin; uint8_t CC; uint8_t OldValue, State; + int Mode; public: CStompBtn(); virtual ~CStompBtn(); - void Init(GPIO_TypeDef *BtnPort, uint16_t BtnPin, GPIO_TypeDef *LedPort, uint16_t LedPin, uint8_t CC, uint8_t OldValue, uint8_t State); + void Init(GPIO_TypeDef *BtnPort, uint16_t BtnPin, GPIO_TypeDef *LedPort, uint16_t LedPin, uint8_t CC, uint8_t OldValue, uint8_t State, int Mode); int Update(int Polarity); int GetState(void); }; diff --git a/stm32/Core/Src/CAllDevices.cpp b/stm32/Core/Src/CAllDevices.cpp index dab15e3..264dda9 100755 --- a/stm32/Core/Src/CAllDevices.cpp +++ b/stm32/Core/Src/CAllDevices.cpp @@ -21,27 +21,27 @@ CAllDevices::CAllDevices() }; uint8_t ExpCCvalues[2] = {16, 17}; uint8_t PotCCvalues[8] = {18, 19, 20, 21, 22, 23, 24, 0}; - this->StompLooper.Init(StompBtn05_GPIO_Port, StompBtn05_Pin, StompLED05_GPIO_Port, StompLED05_Pin, 0, 0, 0); + this->StompLooper.Init(StompBtn05_GPIO_Port, StompBtn05_Pin, StompLED05_GPIO_Port, StompLED05_Pin, 0, 0, 0, 0); - this->StompsL1[0].Init(StompBtn01_GPIO_Port, StompBtn01_Pin, StompLED01_GPIO_Port, StompLED01_Pin, StompCCvalues[0][0], 0, 0); - this->StompsL1[1].Init(StompBtn02_GPIO_Port, StompBtn02_Pin, StompLED02_GPIO_Port, StompLED02_Pin, StompCCvalues[0][1], 0, 0); - this->StompsL1[2].Init(StompBtn03_GPIO_Port, StompBtn03_Pin, StompLED03_GPIO_Port, StompLED03_Pin, StompCCvalues[0][2], 0, 0); - this->StompsL1[3].Init(StompBtn04_GPIO_Port, StompBtn04_Pin, StompLED04_GPIO_Port, StompLED04_Pin, StompCCvalues[0][3], 0, 0); - this->StompsL1[4].Init(StompBtn06_GPIO_Port, StompBtn06_Pin, StompLED06_GPIO_Port, StompLED06_Pin, StompCCvalues[0][4], 0, 0); - this->StompsL1[5].Init(StompBtn07_GPIO_Port, StompBtn07_Pin, StompLED07_GPIO_Port, StompLED07_Pin, StompCCvalues[0][5], 0, 0); - this->StompsL1[6].Init(StompBtn08_GPIO_Port, StompBtn08_Pin, StompLED08_GPIO_Port, StompLED08_Pin, StompCCvalues[0][6], 0, 0); - this->StompsL1[7].Init(StompBtn09_GPIO_Port, StompBtn09_Pin, StompLED09_GPIO_Port, StompLED09_Pin, StompCCvalues[0][7], 0, 0); - this->StompsL1[8].Init(StompBtn10_GPIO_Port, StompBtn10_Pin, StompLED10_GPIO_Port, StompLED10_Pin, StompCCvalues[0][8], 0, 0); + this->StompsL1[0].Init(StompBtn01_GPIO_Port, StompBtn01_Pin, StompLED01_GPIO_Port, StompLED01_Pin, StompCCvalues[0][0], 0, 0, 0); + this->StompsL1[1].Init(StompBtn02_GPIO_Port, StompBtn02_Pin, StompLED02_GPIO_Port, StompLED02_Pin, StompCCvalues[0][1], 0, 0, 0); + this->StompsL1[2].Init(StompBtn03_GPIO_Port, StompBtn03_Pin, StompLED03_GPIO_Port, StompLED03_Pin, StompCCvalues[0][2], 0, 0, 0); + this->StompsL1[3].Init(StompBtn04_GPIO_Port, StompBtn04_Pin, StompLED04_GPIO_Port, StompLED04_Pin, StompCCvalues[0][3], 0, 0, 0); + this->StompsL1[4].Init(StompBtn06_GPIO_Port, StompBtn06_Pin, StompLED06_GPIO_Port, StompLED06_Pin, StompCCvalues[0][4], 0, 0, 0); + this->StompsL1[5].Init(StompBtn07_GPIO_Port, StompBtn07_Pin, StompLED07_GPIO_Port, StompLED07_Pin, StompCCvalues[0][5], 0, 0, 0); + this->StompsL1[6].Init(StompBtn08_GPIO_Port, StompBtn08_Pin, StompLED08_GPIO_Port, StompLED08_Pin, StompCCvalues[0][6], 0, 0, 0); + this->StompsL1[7].Init(StompBtn09_GPIO_Port, StompBtn09_Pin, StompLED09_GPIO_Port, StompLED09_Pin, StompCCvalues[0][7], 0, 0, 0); + this->StompsL1[8].Init(StompBtn10_GPIO_Port, StompBtn10_Pin, StompLED10_GPIO_Port, StompLED10_Pin, StompCCvalues[0][8], 0, 0, 0); - this->StompsL2[0].Init(StompBtn01_GPIO_Port, StompBtn01_Pin, StompLED01_GPIO_Port, StompLED01_Pin, StompCCvalues[1][0], 0, 0); - this->StompsL2[1].Init(StompBtn02_GPIO_Port, StompBtn02_Pin, StompLED02_GPIO_Port, StompLED02_Pin, StompCCvalues[1][1], 0, 0); - this->StompsL2[2].Init(StompBtn03_GPIO_Port, StompBtn03_Pin, StompLED03_GPIO_Port, StompLED03_Pin, StompCCvalues[1][2], 0, 0); - this->StompsL2[3].Init(StompBtn04_GPIO_Port, StompBtn04_Pin, StompLED04_GPIO_Port, StompLED04_Pin, StompCCvalues[1][3], 0, 0); - this->StompsL2[4].Init(StompBtn06_GPIO_Port, StompBtn06_Pin, StompLED06_GPIO_Port, StompLED06_Pin, StompCCvalues[1][4], 0, 0); - this->StompsL2[5].Init(StompBtn07_GPIO_Port, StompBtn07_Pin, StompLED07_GPIO_Port, StompLED07_Pin, StompCCvalues[1][5], 0, 0); - this->StompsL2[6].Init(StompBtn08_GPIO_Port, StompBtn08_Pin, StompLED08_GPIO_Port, StompLED08_Pin, StompCCvalues[1][6], 0, 0); - this->StompsL2[7].Init(StompBtn09_GPIO_Port, StompBtn09_Pin, StompLED09_GPIO_Port, StompLED09_Pin, StompCCvalues[1][7], 0, 0); - this->StompsL2[8].Init(StompBtn10_GPIO_Port, StompBtn10_Pin, StompLED10_GPIO_Port, StompLED10_Pin, StompCCvalues[1][8], 0, 0); + this->StompsL2[0].Init(StompBtn01_GPIO_Port, StompBtn01_Pin, StompLED01_GPIO_Port, StompLED01_Pin, StompCCvalues[1][0], 0, 0, 0); + this->StompsL2[1].Init(StompBtn02_GPIO_Port, StompBtn02_Pin, StompLED02_GPIO_Port, StompLED02_Pin, StompCCvalues[1][1], 0, 0, 0); + this->StompsL2[2].Init(StompBtn03_GPIO_Port, StompBtn03_Pin, StompLED03_GPIO_Port, StompLED03_Pin, StompCCvalues[1][2], 0, 0, 0); + this->StompsL2[3].Init(StompBtn04_GPIO_Port, StompBtn04_Pin, StompLED04_GPIO_Port, StompLED04_Pin, StompCCvalues[1][3], 0, 0, 0); + this->StompsL2[4].Init(StompBtn06_GPIO_Port, StompBtn06_Pin, StompLED06_GPIO_Port, StompLED06_Pin, StompCCvalues[1][4], 0, 0, 1); + this->StompsL2[5].Init(StompBtn07_GPIO_Port, StompBtn07_Pin, StompLED07_GPIO_Port, StompLED07_Pin, StompCCvalues[1][5], 0, 0, 1); + this->StompsL2[6].Init(StompBtn08_GPIO_Port, StompBtn08_Pin, StompLED08_GPIO_Port, StompLED08_Pin, StompCCvalues[1][6], 0, 0, 1); + this->StompsL2[7].Init(StompBtn09_GPIO_Port, StompBtn09_Pin, StompLED09_GPIO_Port, StompLED09_Pin, StompCCvalues[1][7], 0, 0, 1); + this->StompsL2[8].Init(StompBtn10_GPIO_Port, StompBtn10_Pin, StompLED10_GPIO_Port, StompLED10_Pin, StompCCvalues[1][8], 0, 0, 1); this->LedMain.Init(LD_PWR_GPIO_Port, LD_PWR_Pin); this->LedMain.Set(0, 1000, 200); diff --git a/stm32/Core/Src/CStompBtn.cpp b/stm32/Core/Src/CStompBtn.cpp index 0b6b3db..e0ed3c3 100755 --- a/stm32/Core/Src/CStompBtn.cpp +++ b/stm32/Core/Src/CStompBtn.cpp @@ -16,7 +16,7 @@ CStompBtn::~CStompBtn() { } -void CStompBtn::Init(GPIO_TypeDef *BtnPort, uint16_t BtnPin, GPIO_TypeDef *LedPort, uint16_t LedPin, uint8_t CC, uint8_t OldValue, uint8_t State) +void CStompBtn::Init(GPIO_TypeDef *BtnPort, uint16_t BtnPin, GPIO_TypeDef *LedPort, uint16_t LedPin, uint8_t CC, uint8_t OldValue, uint8_t State, int Mode) { this->BtnPort = BtnPort ; this->BtnPin = BtnPin ; @@ -25,7 +25,8 @@ void CStompBtn::Init(GPIO_TypeDef *BtnPort, uint16_t BtnPin, GPIO_TypeDef *LedPo this->CC = CC ; this->OldValue = OldValue; this->State = State ; - this->Debounce.Init(100, 0); + this->Mode = Mode ; + this->Debounce.Init(50, 0); } int CStompBtn::Update(int Polarity) // 0: active, 1: bypass @@ -38,14 +39,22 @@ int CStompBtn::Update(int Polarity) // 0: active, 1: bypass if (CurrentValue) { // rising edge this->State = !this->State; // toggle state if (this->CC>0) { - Command = Polarity?!this->State:this->State; + if (this->Mode) { + Command = 1; + } else { + Command = Polarity?!this->State:this->State; + } sendMidiCC(0, this->CC, 127*Command); } ret=1; } this->OldValue = CurrentValue; } - HAL_GPIO_WritePin(this->LedPort, this->LedPin, (GPIO_PinState)this->State); // always refresh led status + if (this->Mode) { + HAL_GPIO_WritePin(this->LedPort, this->LedPin, (GPIO_PinState)NewValue); + } else { + HAL_GPIO_WritePin(this->LedPort, this->LedPin, (GPIO_PinState)this->State); + } return ret; }