merci pour le Core, je te renvoie les timbres
regarde la fonction Toggle de la midibox 64
sinon les boutons que tu cherches sont des TOGGLE SWITCH, ou inverseurs. Hong Kong super seller en vend pas cher sur ebay, des modeles qui coute une blinde en france en boutique
autrement, tu peux coder ça de la façon suivante, en partant d'une appli ain64din128dout128 :
si le bouton mute est appuyé (1ere fois) , l'état mute est ON, j'envoie le msg 0
si le bouton mute est appuyé (2eme fois), l'état mute est OFF, j'envoie le msg 127, je lis la valeur du slider
l'état mute doit etre défini comme un char boolean, il ne peut donc avoir que deux état, 0 ou 1. quand j'appuie mute, j'ajoute +1 à la valeur du char mute ; du coup il oscille entre 0 et un. j'ai coder une appli dans le genre pour une télécommande multicanal
/////////////////////////////////////////////////////////////////////////////
// Variables
/////////////////////////////////////////////////////////////////////////////
unsigned char level;
//signed char level_mute;
unsigned char levelJ5A0;
unsigned char levelJ5A1;
/////////////////////////////////////////////////////////////////////////////
// Global variables
/////////////////////////////////////////////////////////////////////////////
// status of application (see bitfield declaration in main.h) :
app_flags_t app_flags; // display state
button_L_state_t button_L_state;
button_C_state_t button_C_state;
button_R_state_t button_R_state;
button_Ls_state_t button_Ls_state;
button_Sw_state_t button_Sw_state;
button_Rs_state_t button_Rs_state;
button_MUTE_state_t button_MUTE_state;
button_CAL_state_t button_CAL_state;
led_L_pin_state_t led_L_pin_state;
led_C_pin_state_t led_C_pin_state;
led_R_pin_state_t led_R_pin_state;
led_Ls_pin_state_t led_Ls_pin_state;
led_Sw_pin_state_t led_Sw_pin_state;
led_Rs_pin_state_t led_Rs_pin_state;
led_MUTE_pin_state_t led_MUTE_pin_state;
led_CAL_pin_state_t led_CAL_pin_state;
/////////////////////////////////////////////////////////////////////////////
// Gestion des LEDS et Relais
/////////////////////////////////////////////////////////////////////////////
void LED(void)
{
// 7eme LED MUTE reliÈe ‡ SR3-D1 (note midi 0x06 = F-1#)
// DOUT pin in evnt1, value ON OFF in evnt2
if (led_MUTE_pin_state.led_MUTE==1)
{
// allumage de la LED MUTE :
MIOS_DOUT_PinSet(0x11, 1); // allumÈ SR3D1
MIOS_DOUT_PinSet(0x01, 0); // allumÈ SR1D1
MIOS_DOUT_PinSet(0x09, 1); // Èteint SR2D1
// muter TOUS les inter 4066 :
MIOS_DOUT_PinSet(0x07, 1); // canal L (muted)
MIOS_DOUT_PinSet(0x0f, 0);
MIOS_DOUT_PinSet(0x06, 1); // canal C
MIOS_DOUT_PinSet(0x0e, 0);
MIOS_DOUT_PinSet(0x05, 1); // canal R
MIOS_DOUT_PinSet(0x0d, 0);
MIOS_DOUT_PinSet(0x04, 1); // canal Ls
MIOS_DOUT_PinSet(0x0c, 0);
MIOS_DOUT_PinSet(0x02, 1); // canal Sw
MIOS_DOUT_PinSet(0x0a, 0);
MIOS_DOUT_PinSet(0x03, 1); // canal Rs
MIOS_DOUT_PinSet(0x0b, 0);
// Gestion des LEDS de canaux :
// 1ere LED L reliÈe ‡ SR3-D7 (note midi 0x00 = C-1)
if (led_L_pin_state.led_L==0){ // ALLUMÈ = ACTIVÈ
MIOS_DOUT_PinSet(0x17, 1); // allumÈe SR3D7
}else{//if (led_pin_state.led_L==0)
MIOS_DOUT_PinSet(0x17,0); // Èteint SR3D7
}
// 2eme LED C reliÈe ‡ SR3-D6 (note midi 0x01 = C-1#)
if (led_C_pin_state.led_C==0){
MIOS_DOUT_PinSet(0x16, 1); // allumÈ SR3D6
}else{
MIOS_DOUT_PinSet(0x16,0); // Èteint SR3D6
}
// 3eme LED R reliÈe ‡ SR3-D5 (note midi 0x02 = D-1)
if (led_R_pin_state.led_R==0){
MIOS_DOUT_PinSet(0x15, 1); // allumÈ SR3D5
}else{
MIOS_DOUT_PinSet(0x15,0); // Èteint SR3D5
}
// 4eme LED Ls reliÈe ‡ SR3-D4 (note midi 0x03 = D-1#)
if (led_Ls_pin_state.led_Ls==0){
MIOS_DOUT_PinSet(0x14, 1); // allumÈ SR3D4
}else{
MIOS_DOUT_PinSet(0x14,0); // Èteint SR3D4
}
// 5eme LED Sw reliÈe ‡ SR3-D3 (note midi 0x04 = E-1)
if (led_Sw_pin_state.led_Sw==0){
MIOS_DOUT_PinSet(0x13, 1); // allumÈ SR3D3
}else{
MIOS_DOUT_PinSet(0x13,0); // Èteint SR3D3
}
// 6eme LED Rs reliÈe ‡ SR3-D2 (note midi 0x05 = F-1)
if (led_Rs_pin_state.led_Rs==0){
MIOS_DOUT_PinSet(0x12, 1); // allumÈ SR3D5
}else{
MIOS_DOUT_PinSet(0x12,0); // Èteint SR3D5
}
}else{
// extinction de la LED MUTE :
MIOS_DOUT_PinSet(0x11,0); // Èteint SR3D6
MIOS_DOUT_PinSet(0x01,1); // Èteint SR1D6
MIOS_DOUT_PinSet(0x09,0); // allumÈ SR2D6
// mise en place du fonctionnement des interrupteurs :
led_L_pin_state.led_L=button_L_state.L; // retour Ètat prÈcÈdent
led_C_pin_state.led_C=button_C_state.C;
led_R_pin_state.led_R=button_R_state.R;
led_Ls_pin_state.led_Ls=button_Ls_state.Ls;
led_Sw_pin_state.led_Sw=button_Sw_state.Sw;
led_Rs_pin_state.led_Rs=button_Rs_state.Rs;
// 1ere LED L reliÈe ‡ SR3-D7 (note midi 0x00 = C-1)
if (led_L_pin_state.led_L==0){
MIOS_DOUT_PinSet(0x17, 1); // allumÈe SR3D7
MIOS_DOUT_PinSet(0x07, 0); // allumÈe SR1D6
MIOS_DOUT_PinSet(0x0f, 1); // Èteint SR2D6
}else{
MIOS_DOUT_PinSet(0x17, 0); // Èteinte SR3D7
MIOS_DOUT_PinSet(0x07, 1); // Èteint SR1D6
MIOS_DOUT_PinSet(0x0f, 0); // allumÈ SR2D6
}
// 2eme LED C reliÈe ‡ SR3-D6 (note midi 0x01 = C-1#)
if (led_C_pin_state.led_C==0){
MIOS_DOUT_PinSet(0x16, 1); // allumÈ SR3D6
MIOS_DOUT_PinSet(0x06, 0); // allumÈ SR1D6
MIOS_DOUT_PinSet(0x0e, 1); // Èteint SR2D6
}else{
MIOS_DOUT_PinSet(0x16,0); // Èteint SR1D6
MIOS_DOUT_PinSet(0x06,1); // Èteint SR3D6
MIOS_DOUT_PinSet(0x0e,0); // allumÈ SR3D6
}
// 3eme LED R reliÈe ‡ SR3-D5 (note midi 0x02 = D-1)
if (led_R_pin_state.led_R==0){
MIOS_DOUT_PinSet(0x15, 1); // allumÈ SR3D5
MIOS_DOUT_PinSet(0x05, 0); // allumÈ SR1D5
MIOS_DOUT_PinSet(0x0d, 1); // Èteint SR2D5
}else{
MIOS_DOUT_PinSet(0x15,0); // Èteint SR3D5
MIOS_DOUT_PinSet(0x05,1); // Èteint SR1D5
MIOS_DOUT_PinSet(0x0d,0); // allumÈ SR2D5
}
// 4eme LED Ls reliÈe ‡ SR3-D4 (note midi 0x03 = D-1#)
if (led_Ls_pin_state.led_Ls==0){
MIOS_DOUT_PinSet(0x14, 1); // allumÈ SR3D4
MIOS_DOUT_PinSet(0x04, 0); // allumÈ SR1D4
MIOS_DOUT_PinSet(0x0c, 1); // Èteint SR2D4
}else{
MIOS_DOUT_PinSet(0x14,0); // Èteint SR3D4
MIOS_DOUT_PinSet(0x04,1); // Èteint SR1D4
MIOS_DOUT_PinSet(0x0c,0); // allumÈ SR2D4
}
// 5eme LED Sw reliÈe ‡ SR3-D3 (note midi 0x04 = E-1)
if (led_Sw_pin_state.led_Sw==0){
MIOS_DOUT_PinSet(0x13, 1); // allumÈ SR3D3
MIOS_DOUT_PinSet(0x02, 0); // allumÈ SR1D4
MIOS_DOUT_PinSet(0x0a, 1); // Èteint SR2D4
}else{
MIOS_DOUT_PinSet(0x13,0); // Èteint SR3D3
MIOS_DOUT_PinSet(0x02,1); // Èteint SR1D4
MIOS_DOUT_PinSet(0x0a,0); // allumÈ SR2D4
}
// 6eme LED Rs reliÈe ‡ SR3-D2 (note midi 0x05 = F-1)
if (led_Rs_pin_state.led_Rs==0){
MIOS_DOUT_PinSet(0x12, 1); // allumÈ SR3D5
MIOS_DOUT_PinSet(0x03, 0); // allumÈ SR1D5
MIOS_DOUT_PinSet(0x0b, 1); // Èteint SR2D5
}else{
MIOS_DOUT_PinSet(0x12,0); // Èteint SR3D5
MIOS_DOUT_PinSet(0x03,1); // Èteint SR1D5
MIOS_DOUT_PinSet(0x0b,0); // allumÈ SR2D5
}
}
// gestion de CALIBRATE :
// 8eme LED CAL reliÈe ‡ SR3-D0 (note midi 0x07 = G-1)
if (led_CAL_pin_state.led_CAL==1){
MIOS_DOUT_PinSet(0x10, 1); // allumÈ SR3D0
MIOS_DOUT_PinSet(0x08, 1); // allumÈ SR1D0
MIOS_DOUT_PinSet(0x00, 0); // Èteint SR2D0
}else{
MIOS_DOUT_PinSet(0x10,0); // Èteint SR3D0
MIOS_DOUT_PinSet(0x08,0); // Èteint SR1D0
MIOS_DOUT_PinSet(0x00,1); // allumÈ SR2D0
}
}
/////////////////////////////////////////////////////////////////////////////
// Fonction LEVEL
/////////////////////////////////////////////////////////////////////////////
void LEVEL(void)
{
levelJ5A0 = (MIOS_AIN_Pin7bitGet(0)); // lecture des potard au dÈmarrage (Èvite "0")
levelJ5A1 = (MIOS_AIN_Pin7bitGet(1)); // lecture des potard au dÈmarrage (Èvite "0")
// remettre les lignes suivantes de code pour proto avec 2 potards :
// level = ((levelJ5A0)+((128+levelJ5A1+1)>>1)+128)+0; // ancienne formule OK pour proto julien
// level = potard 0 - potard1
level = ((levelJ5A0)-(levelJ5A1)+15); // nlle formule OK pour proto julien
// rules return to zero s:
if (level>(127+15))
level=0;
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when an button has been toggled
// pin_value is 1 when button released, and 0 when button pressed
/////////////////////////////////////////////////////////////////////////////
void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam
{
// send pin number and value as Note On Event
MIOS_MIDI_BeginStream(); // Bit start
switch( pin )
{
case 5: // 1ere touche L reliÈ ‡ SR1-D5
if (pin_value==0 ){
(button_L_state.L ++);
(led_L_pin_state.led_L++);
// MIOS_DOUT_PinSet(0x01, 1);
}
// RxTx command
MIOS_MIDI_TxBufferPut(0x90);
MIOS_MIDI_TxBufferPut(0x00);
MIOS_MIDI_TxBufferPut(pin_value ? 0x00 : 0x7f);
break;
case 4: // 2eme touche C reliÈ ‡ SR1-D4
if (pin_value==0 ){
(button_C_state.C ++);
(led_C_pin_state.led_C++);
// MIOS_DOUT_PinSet(0x01, 1);
}
MIOS_MIDI_TxBufferPut(0x90);
MIOS_MIDI_TxBufferPut(0x01);
MIOS_MIDI_TxBufferPut(pin_value ? 0x00 : 0x7f);
break;
etc ...