Jump to content

Set of controler names + BankStick


goule
 Share

Recommended Posts

Hi all, back in the midibox universe  ;) just have to finish my OS ...

I have several MIDI sensors and until now every name was saved like this :

const char CTL_NAME[17][16] = 
{
 "Joystick 1 X    ",
 "Joystick 1 Y    ",
 "Joystick 2 X    ",
 "Joystick 2 Y    ",
 "Joystick 3 X    ",
 "Joystick 3 Y    ",
 "Joystick 4 X    ",
 "Joystick 4 Y    ",
 "Pitch Bend Wheel",
 "Modulation Wheel",
 "DBeam Left      ",
 "DBeam Right     ",
 "Basic Knob 1    ",
 "Basic Knob 2    ",
 "Ribbon Ctrl V   ",
 "Ribbon Ctrl H   ",
 "Expression Pedal"
};
Now I want to be able to edit/store/read those names in the BankStick. The problem is when I want to create the structure that will be receiving the data from the bankstick : if I create that kind of things ...
unsigned char CTL_NAME2[17][17];

... I get the error message "no target memory available", even with this simple command.

I can easily manipulate BankStick but do I have to read it every time I want to display the name of the controller that has been touched ??  :-\ :-X

Thanks for helping !

Link to comment
Share on other sites

Ok, what I'm gonna do is split each controller name into 2 parts, something like this :

unsigned char NAME_PART1[17][8];

unsigned char NAME_PART2[17][8];

Much more simplier than to split into 2 groups of controllers, as the process is mostly the same for each controller.

BTW, if anyone gotta better idea ...  :P ;D

Peace,

Goule

Link to comment
Share on other sites

Hi Goule,

welcome back! Just added you to the programmers group ;)

If you reduce the strings to 15 characters + terminator (CTL_NAME[16][8]), it will fit into 256 bytes, and it will also be easier to integrate this into a BankStick structure (2^n bytes should always be prefered)

Best Regards, Thorsten.

Link to comment
Share on other sites

Unfortunately, 17 is my number of controllers ... gotta keep this one  :-\

But I could choose to go with CTL_NAME[17][15] as 17*15=255 ...

This would let me 14 characters (+1 term.) for the name.

But I already coded the read/write stuff for the splited name structure :

Reading :

for (ctl=0; ctl<17; ctl++)
{
    for (cpt=0; cpt<16; cpt++)
    {
        octet = MIOS_BANKSTICK_Read((ctl << 4)+cpt);
        if (cpt<8)
            CTL_NAME_PART1[ctl][cpt] = octet;
        else
            CTL_NAME_PART2[ctl][cpt-8] = octet;
    }
    CTL_NAME_PART1[ctl][8] = '\0'; // On insère les bons terminateurs
    CTL_NAME_PART2[ctl][8] = '\0'; // de string sur les fins des 2 tableaux
}

// 3) CTL_CC[] :
for (ctl=0; ctl<17; ctl++)
{
    CTL_CC[ctl] = MIOS_BANKSTICK_Read(272+ctl);
}
and writing :
for (ctl=0; ctl<17; ctl++)
{
    for (cpt=0; cpt<16; cpt++)
    {
        if (cpt<8)
            error |= MIOS_BANKSTICK_Write((ctl << 4)+cpt,CTL_NAME_PART1[ctl][cpt]); // << 4 = *16
        else
            error |= MIOS_BANKSTICK_Write((ctl << 4)+cpt,CTL_NAME_PART2[ctl][cpt-8]); // << 4 = *16
    }
}

// Ecriture des n° de CC
for (ctl=0; ctl<17; ctl++)
{
    error |= MIOS_BANKSTICK_Write(272+ctl,CTL_CC[ctl]);
}

MIOS_LCD_Clear();
if (error) 
{
    MIOS_LCD_PrintCString("Erreur BankStick");
    MIOS_LCD_PrintBCD3(error);
}
else
    MIOS_LCD_PrintCString("BankStick OK    ");

Any comments appreciated to get things even better  ::) ;D

Btw I hope it is not too  :-X for you ...  ;D

Cheerz

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...