Changes between Version 2 and Version 3 of SujetTP8-2016
- Timestamp:
- Apr 1, 2016, 11:48:30 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
SujetTP8-2016
v2 v3 10 10 L'API de commande du module NRF est la même sur Arduino et sur RaspberryPI et c'est grâce à ça qu'il est possible d'envisager de commencer par 100% Arduino avant de faire intervenir le RaspberryPI. 11 11 12 **Capteur** 12 13 {{{#!c 13 14 #include <SPI.h> … … 41 42 Adafruit_SSD1306 display(OLED_RESET); 42 43 RF24 radio(9,10); // radio(CE,CS) 43 byte addresses_tx[][6] = {"1 sens","2Sens"};44 byte addresses_rx[][6] = {"1 base","2base"};44 byte addresses_tx[][6] = {"1fwFW","2fwFW"}; 45 byte addresses_rx[][6] = {"1fwFW","2fwFW"}; 45 46 46 47 // Variables globales pour la communication inter-taches … … 69 70 if (!radio.available()) return; 70 71 radio.read( tsc, sizeof(unsigned long) ); 71 *tscFull = 1; 72 *tscFull = 1; 72 73 } 73 74 … … 90 91 printf_begin(); 91 92 radio.begin(); 92 radio.setPALevel(RF24_PA_LOW); 93 radio.openWritingPipe(addresses_tx[0]); 94 radio.openReadingPipe(1,addresses_rx[0]); 93 radio.openWritingPipe(addresses_tx[1]); 94 radio.openReadingPipe(1,addresses_rx[1]); 95 95 radio.printDetails(); 96 96 } 97 97 98 98 void loop() { 99 Lumi (0,100000 0, PIN_LUMI, &lumi, &lumiFull);99 Lumi (0,100000, PIN_LUMI, &lumi, &lumiFull); 100 100 SensRF (&lumi, &lumiFull); 101 101 RcvTSC (&tsc, &tscFull); … … 104 104 }}} 105 105 106 **Base** 106 107 {{{#!c 107 108 #include <SPI.h> … … 135 136 Adafruit_SSD1306 display(OLED_RESET); 136 137 RF24 radio(9,10); 137 byte addresses_tx[][6] = {"1 base","2base"};138 byte addresses_rx[][6] = {"1 Sens","2Sens"};138 byte addresses_tx[][6] = {"1fwFW","2fwFW"}; 139 byte addresses_rx[][6] = {"1fwFW","2fwFW"}; 139 140 140 141 // Variables globales pour la communication inter-taches 141 byte lumi, lumiFull ;142 143 void BaseRF (byte *lumi, byte *lumiFull )142 byte lumi, lumiFull, pipe; 143 144 void BaseRF (byte *lumi, byte *lumiFull, byte *pipe) 144 145 { 145 if (!radio.available( )) return;146 if (!radio.available(pipe)) return; 146 147 radio.read( lumi, sizeof(byte) ); 148 Serial.println(*pipe); 147 149 *lumiFull = 1; 148 150 } … … 158 160 } 159 161 160 void Oled1 (byte *mess, byte *full) { 162 void Oled1 (byte *mess, byte *full, byte *pipe) { 163 static byte value[2]; 161 164 if (! (*full) ) return; 162 165 *full = 0; 166 value[(*pipe) % 2] = *mess; 163 167 display.clearDisplay(); 164 168 display.setCursor(0,0); 165 display.print("Lumiere : "); 166 display.println(*mess); 169 display.print("Lumiere 1 : "); 170 display.println(value[0]); 171 display.print("Lumiere 2 : "); 172 display.println(value[1]); 167 173 display.display(); 168 174 } … … 175 181 display.setTextSize(1); 176 182 display.setTextColor(WHITE); 183 display.display(); 177 184 178 185 printf_begin(); 179 186 radio.begin(); 180 radio.setPALevel(RF24_PA_LOW);181 187 radio.openReadingPipe(1,addresses_rx[0]); 182 188 radio.openReadingPipe(2,addresses_rx[1]); … … 188 194 byte timer=0; 189 195 byte instSendTSC=0; 190 BaseRF(&lumi, &lumiFull );191 Oled1 (&lumi, &lumiFull );196 BaseRF(&lumi, &lumiFull, &pipe); 197 Oled1 (&lumi, &lumiFull, &pipe); 192 198 SendTSC (instSendTSC++, timer++, 1000000, addresses_tx[0]); 193 199 SendTSC (instSendTSC++, timer++, 500000, addresses_tx[1]);