Engage Turbo Mode!

One of the many quintessential 90s kid experiences is going to your friend's house to play co-op games, maybe some Tekken, just to be handed one of these:

You look confused. Your buddy assures that the controller is "just as good". You pick up the controller and feel that something is rattling inside. This thing is coming apart any time. The only saving grace here, is the often present turbo mode. Turn it on, and now the controller rapid fires, whenever it decides to actually work, so you can pull off one of these:


It doesn't make much of a difference since you still inevitably get wiped out, but hey, maybe we can turn that painful memory into something cool. Let's add a "turbo" rapid fire mode to the BeatBox. Check out how it works!


Ok so first of all, if you are not yet familiar with the firmware flashing process, please refer to our previous blogpost at: https://www.rhythmo.io/post/android-firmware-recall-info-how-to-fix-it-yourself-with-an-arduino-uno

You'll need an Arduino Uno to act as an AVI programmer, and basically, just upload this firmware file that has the updated turbo function.

Download RAR • 4KB

That's it! Now, in mode 1, once you hold down the Shift button, the next note button that you trigger will repeat in 50ms intervals. You can control the repeat speed by using the 4th knob on the BeatBox while holding down Shift.

That's the TL;DR version, but obviously we are not going to end there. Let's briefly talk about the code here so you can perhaps customize the turbo function, or maybe get some ideas on how to put in additional functions. The way that the BeatBox functions is very simple. Once turned on, the chip basically scans every single button and knob constantly to detect movements. You can see this very clearly in the loop function:

The buttons are set up in a 4x6 matrix, hence the keys[j][i] expression.

First of all, we declared a counter for trigger repeat time, and a condition about if turbo mode is on, as you can see on lines 98-99:

Now, we'll go to the keyPressed function to put in the turbo mode activation codes, starting on line 328. Lines 341-413 are behaviors under mode 1, which is the generic midi controller mode. Starting from line 363, we'll look at what the controller does once Shift is held down, and a note button is pressed.

If a note button is detected, and shift is held down, turbo mode gets turned on. Once in turbo mode, the program starts to loop within the turbo mode, until turbo is turned off. As you can see, turbo mode sends a note on, and a note off signal, then counts the entire turboCount duration, which is set to 50 at default, during which it checks for the encoder movement every 1ms to see if the turbo duration is changed.

Lines 390 to 404 detect if the shift button has been released, to turn off the turbo mode. Keys[1][3] means the button on column 2, button 4, which is the shift button. Now, if within the turbo mode, the chip detects a change in the value of the shift button, the keyReleased function gets called. Let's take a look at the function.

Here we can see, if the key released is the shift button, turboOn gets set to false, therefore exiting the turbo loop.

Now, let's talk about encoder behavior. The BeatBox features 360 degree encoders, meaning that there's technically no limit to the value the encoders can count. Under mode 1, the encoders basically stops counting when the value hits less than 0, and above 127, since those are the midi value ranges for a midi cc knob. Here, you can see, if turbo mode isn't engaged, the encoders carries on sending midi signals as normal; once turbo mode is engaged, only the 4th knob (indicated by the if(i==3)) updates the turboCount by the knob value + 20, meaning that if the knob's value is 0, turboCount becomes 20ms, and if the knob's value is 127, turboCount becomes 147ms. You can play around with this section to either change the note repeat time range, or if you play around with math a little, you might be able to make the note repeat to a fraction of a beat.

ANYWAYS, when it comes to flashing the code, sky is the limit. Definitely try to play around with this, show us what you come up with, and don't forget to always keep a copy of the original code so you always have something to fall back on!

37 views0 comments