Mismatch of DaisyPetal.KNOB_X -> POT_X numbers

varlogtim

New member
I just soldered up my Terrarium and have been exploring the inputs. I wrote the following code to verify the hardware inputs:

C++:
#include "daisy_petal.h"
#include "terrarium.h"

using namespace daisy;
using namespace terrarium;

DaisyPetal petal;

void pot_led_flash_control(uint8_t pot_num) {
    bool led_state = true;
    float knob_val;

    while (1) {
        petal.seed.SetLed(led_state);
        led_state = !led_state;

        petal.knob[pot_num].Process();
        knob_val = petal.knob[pot_num].Value();

        uint32_t ms = knob_val * 1000 + 50;
        System::Delay(ms);
    }
}

int main(void)
{

    petal.Init();
    petal.StartAdc();
   
    // petal.KNOB_1 = POT_1
    // petal.KNOB_2 = POT_4
    // petal.KNOB_3 = POT_2
    // petal.KNOB_4 = POT_5
    // petal.KNOB_5 = POT_3
    // petal.KNOB_6 = POT_6

    pot_led_flash_control(petal.KNOB_6);

    return 0;
}

As seen in the comments above, it appears that there is a mismatch between the DaisyPetal.KNOB_X numbers and the POT_X numbers listed on the board.

What do you guys think about making a PedalPCB Github repo for Terrarium which contains a header file with these mappings in it. Basically extending the already existing terrarium.h file that is floating around in forum posts.

Once the file is in a repo, when we create terrarium projects we can add a git submodule for the project and it will automatically pull the header file into the project. This might be overkill as I can't think of anything else that might need to go into this, but, if something does come up, it would be good if we could go to a single place for this information.

I am thinking something like this:

C++:
#include "daisy_petal.h"

#ifndef TERRARIUM
#define TERRARIUM

namespace terrarium
{
    class Terrarium
    {
        public:
            enum Sw
            {
                FOOTSWITCH_1 = 4,
                FOOTSWITCH_2 = 5,
                SWITCH_1 = 2,
                SWITCH_2 = 1,
                SWITCH_3 = 0,
                SWITCH_4 = 6,
            };
            enum Pots
            {
                POT_1 = daisy::DaisyPetal::KNOB_1,
                POT_2 = daisy::DaisyPetal::KNOB_3,
                POT_3 = daisy::DaisyPetal::KNOB_5,
                POT_4 = daisy::DaisyPetal::KNOB_2,
                POT_5 = daisy::DaisyPetal::KNOB_4,
                POT_6 = daisy::DaisyPetal::KNOB_6
            };
    };
}

#endif

Then the knobs can be accessed like so:

C++:
#include <daisy_petal.h>
#include <terrarium.h>

DaisyPetal petal;
petal.knobs[Terrarium::POT_2]

Let me know what you guys think.
 
Back
Top