From 9903ca7087736b79dbfa0877e5ea3460ba71a07b Mon Sep 17 00:00:00 2001 From: Daniele Caltabiano <34002251+caltabid@users.noreply.github.com> Date: Sat, 5 Jun 2021 19:27:28 +0200 Subject: [PATCH] Implemented stateless looping buttons (second page, front buttons); Reduced anti-bouncing filter. --- Documents/Disc407.bin | Bin 21136 -> 21184 bytes README.md | 1 + stm32/Core/Inc/CStompBtn.h | 3 ++- stm32/Core/Src/CAllDevices.cpp | 38 ++++++++++++++++----------------- stm32/Core/Src/CStompBtn.cpp | 17 +++++++++++---- 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/Documents/Disc407.bin b/Documents/Disc407.bin index 93a388146c91f39217e5897809fe6e3a92816ebf..0bef58e54d6663c7bdf5f020b0e7c8cf1d54b98e 100755 GIT binary patch delta 2958 zcmbtW4Qx}_6~6cRIeB&neXykU;v_u(gqRYj69R+~g5$)`F%RPWC_o_6KW)Q&MFm`t!WO&Oz$HlcN8ILr!Jzps0=1Z(l2>jTEFIc{G0Br3`Av z{1)yGU)m(nTxZ+>_Ko5WXLJxOJ(9Po+Oehu2B>sx;qJ7TBH6FjLgwCh*9zWW=SM-S zcN96f6PoiSV*jwFs(%<)osfRxK|e?GCvo8X3oQM^Xs1)OC-`4V$34tGB%cE=w5FJH z+e#D65$Omp+L0!N2sqZPjl32>a!cGR3%VsR zIo%E--}k&MG5dI64*|Og*wSesy0kLL2v!B8tx&uIBsvB3YM_@+hed3IgmT)#FKq_i z0p)$bi}7W&6!f56v-GSd^#IkQG+s{QlUl5onxIA-8HI{@@#U16)S*#oOfXttgt%jN zkV*mcqNENrKtIqS!b4hm9Os8DUb%vUDcz7;;_|p)N2Rc2Bk*Z zQ(09kAo(vOpPTiJ|H)dB9cx;G4XJ(k^IqF7T##j5F4o{Q7&iRbD2m8bkCABKCOr%E+3LxW0#bsrSLYbMnAki z`vEt7omUiizobHE3|@UH?BoVIMhe&lrJzg@js62}i#R$&-~N&R$=Gs`tXFMfpoa>? zceCO|^!F2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6mT`2=#{u4O__;X_e6mdVa{STxDiLw`WxLpNue)%4FEa!?9b* zF)1B%XQST_q;jwmYpG{VZMud=(o1nkOX_Qz67yghLlHS!`)9_lB|oS;x6u!!{}oU) z6jz6=tiTJ|t^WzxBIOy(Shia=Xl*STmW}f_Lwx~_C<`_lwaKpfwe2g^h(8I4{b2Ng zJ+x#V)F3`FevvnWZCx@?On_gYfLQznuuGQAk0m0$pUl)hnd*OQ&VxaA79;*Tc)MZz zTO#>Z!xM%5a2vWQ;O4{@+Ox!t`C7nN2WSU8OJ*8g$Te0Xex_nEiYm{*{DTL47h!(U iH`v&W%|im>4*|YYjrivP(|{BaXc!$Z){)GnStompLooper.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; }