From 891522e34df9c5d5d8b7411d7edaedeef5da783b Mon Sep 17 00:00:00 2001 From: Christophe Date: Fri, 4 Oct 2019 17:43:24 +0200 Subject: [PATCH] modification pour essai lecture des ports --- .../MidiHallSynthChrom/MidiHallSynthChrom.ino | 106 ++++++++++++++++-- 1 file changed, 96 insertions(+), 10 deletions(-) diff --git a/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino b/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino index 3b8512c..7cd29a1 100644 --- a/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino +++ b/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino @@ -17,7 +17,7 @@ */ - + /* bool EtatEntree24 = HIGH ; bool VarSuivi24 = HIGH ; @@ -40,7 +40,44 @@ bool VarSuivi22 = HIGH ; bool EtatEntree23 = HIGH ; - bool VarSuivi23 = HIGH ; + bool VarSuivi23 = HIGH ; */ + + const byte Masque1 = B00000001 ; + const byte Masque2 = B00000010 ; + const byte Masque4 = B00000100 ; + const byte Masque8 = B00001000 ; + const byte Masque16 = B00010000 ; + const byte Masque32 = B00100000 ; + const byte Masque64 = B01000000 ; + const byte Masque128 = B10000000 ; + + +char PortA = 0 ; + + + +char EPA0 = 1 ; +char EPA1 = 2 ; +char EPA2 = 4 ; +char EPA3 = 8 ; +char EPA4 = 16 ; +char EPA5 = 32 ; +char EPA6 = 64 ; +char EPA7 = 128 ; + +char DePA0 = 1 ; +char DePA1 = 2 ; +char DePA2 = 4 ; +char DePA3 = 8 ; +char DePA4 = 16 ; +char DePA5 = 32 ; +char DePA6 = 64 ; +char DePA7 = 128 ; + + + + + void noteOn(int cmd, int pitch, int velocity) /* plays a MIDI note. Doesn't check to see that cmd is greater than 127, @@ -57,7 +94,8 @@ void noteOn(int cmd, int pitch, int velocity) /* plays a MIDI note. Doesn't chec void setup() { - + pinMode(22,INPUT); + pinMode(23,INPUT); pinMode(24,INPUT); pinMode(25,INPUT); pinMode(26,INPUT); @@ -66,6 +104,8 @@ void setup() pinMode(29,INPUT); pinMode(22,INPUT); pinMode(23,INPUT); + + @@ -88,9 +128,6 @@ void setup() noteOn(0x80, 0x30 , 0x00 ) ; -char PortA = 0 ; -char DernierEtatPortA = 0 ; -char ModifPortA = 0 ; } @@ -99,16 +136,65 @@ char ModifPortA = 0 ; void loop() { - PortA = PINA ; - ModifPortA = DernierEtatPortA ^ DernierEtatPortA + PortA = PINA ; /* lecture du port A */ + + EPA0 = PortA & Masque1 ; + EPA1 = PortA & Masque2 ; + EPA2 = PortA & Masque4 ; + EPA3 = PortA & Masque8 ; + EPA4 = PortA & Masque16 ; + EPA5 = PortA & Masque32 ; + EPA6 = PortA & Masque64 ; + EPA7 = PortA & Masque128 ; + + if ( ( EPA0 == 0 ) && ( DePA0 == 1 ) ) noteOn(0x90, 0x24 , 0x70 ) ; + if ( ( EPA0 == 1 ) && ( DePA0 == 0 ) ) noteOn(0x80, 0x24 , 00 ) ; + + if ( ( EPA1 == 0 ) && ( DePA1 == 1 ) ) noteOn(0x90, 0x26 , 0x70 ) ; + if ( ( EPA1 == 1 ) && ( DePA1 == 0 ) ) noteOn(0x80, 0x26 , 00 ) ; + + if ( ( EPA2 == 0 ) && ( DePA2 == 1 ) ) noteOn(0x90, 0x28 , 0x70 ) ; + if ( ( EPA2 == 1 ) && ( DePA2 == 0 ) ) noteOn(0x80, 0x28 , 00 ) ; + + if ( ( EPA3 == 0 ) && ( DePA3 == 1 ) ) noteOn(0x90, 0x29 , 0x70 ) ; + if ( ( EPA3 == 1 ) && ( DePA3 == 0 ) ) noteOn(0x80, 0x29 , 00 ) ; + + if ( ( EPA4 == 0 ) && ( DePA4 == 1 ) ) noteOn(0x90, 0x2B , 0x70 ) ; + if ( ( EPA4 == 1 ) && ( DePA4 == 0 ) ) noteOn(0x80, 0x2B , 00 ) ; + + if ( ( EPA5 == 0 ) && ( DePA5 == 1 ) ) noteOn(0x90, 0x2D , 0x70 ) ; + if ( ( EPA5 == 1 ) && ( DePA5 == 0 ) ) noteOn(0x80, 0x2D , 00 ) ; + + if ( ( EPA6 == 0 ) && ( DePA6 == 1 ) ) noteOn(0x90, 0x2F , 0x70 ) ; + if ( ( EPA6 == 1 ) && ( DePA6 == 0 ) ) noteOn(0x80, 0x2F , 00 ) ; + + if ( ( EPA7 == 0 ) && ( DePA7 == 1 ) ) noteOn(0x90, 0x30 , 0x70 ) ; + if ( ( EPA7 == 1 ) && ( DePA7 == 0 ) ) noteOn(0x80, 0x30 , 00 ) ; + + + + + DePA0 = EPA0 ; + DePA1 = EPA1 ; + DePA2 = EPA2 ; + DePA3 = EPA3 ; + DePA4 = EPA4 ; + DePA5 = EPA5 ; + DePA6 = EPA6 ; + DePA7 = EPA7 ; + + + + + + + - DernierEtatPortA = PortA ; - /* FIN */