Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P
Diff: main.cpp
- Revision:
- 20:e068469ffb89
- Parent:
- 18:e2a8ea6f55d3
- Child:
- 21:95009b231c1f
- Child:
- 24:28c8b01b7d35
diff -r 6b4f3b12a527 -r e068469ffb89 main.cpp --- a/main.cpp Fri Apr 20 16:12:01 2018 +0000 +++ b/main.cpp Fri Apr 20 18:39:20 2018 +0000 @@ -1,37 +1,44 @@ #include "mbed.h" #include "rtos.h" + #include "Microphone.h" -#include "nRF24L01P.h" -#define TRANSFER_SIZE 4 //added 5:54pm 4/18/18 -#include "CircularBuf.h" +#include "Speaker.h" #include "HUD.h" -#include "Speaker.h" +#include "nRF24L01P.h" + +#include "CircularBuf.h" +#include "CircularBuf.cpp" // Hack to get templates to work + +#define TRANSFER_SIZE 4 //added 5:54pm 4/18/18 + + Serial pc(USBTX, USBRX); // tx, rx - -nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10); // mosi, miso, sck, csn, ce, irq DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); + +Speaker spkr(p18); +Microphone mymicrophone(p16); + +nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10); // mosi, miso, sck, csn, ce, irq +CircularBuf<uint8_t> txbuff(30); +CircularBuf<uint8_t> rxbuff(30); + Ticker t; //10:41 am 4/20 -CircularBuf<uint_8> txbuf(30); -CircularBuf<uint_8> rxbuf(30); -Speakr spkr(p18); -Microphone mymicrophone(p16); InterruptIn Button(p20); //changed DitialIn to InterruptIn at 5:54 4/18/18 -AnalogOut speaker(p18); //added 6:34 pm at 4/18/18 char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE]; //making these usable by other voids. int txDataCnt = 0;//and this. int rxDataCnt = 0;//and this. //David Rechtmann 6.24 pm 4/18/18 -int micvalue[30]; - int micvalcount = 0; +uint8_t micvalue[30]; +int micvalcount = 0; + void startup() { // The nRF24L01+ supports transfers from 1 to 32 bytes, but Sparkfun's // "Nordic Serial Interface Board" (http://www.sparkfun.com/products/9019) // only handles 4 byte transfers in the ATMega code. -//define TRANSFER_SIZE 4 // char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE]; //making these usable by other voids. // int txDataCnt = 0;//and this. @@ -95,20 +102,14 @@ void receive() //most of this function added by david at 6:02pm 4/18/18 { - // float sample; - // float average = 0.67/3.3;//initial DC bias level - uint8_t spkrarray[29]; + uint8_t spkrarray[29]; while (Button == 0) { if (my_nrf24l01p.readable(0)) { - rxBuf.push(spkrarray, 30); + rxbuff.push(spkrarray, 30); spkr.write(spkrarray[1]); - // sample = uint8_t (rxData); - // average = 0.9999*average + 0.0001*sample; //This is in the mPA demo but I'm not sure how it works -david - // speaker = 0.5 +((sample - average)*33.0); } - } -}` +} void transmit() { @@ -116,9 +117,9 @@ // txData[txDataCnt++] = mymicrophone.getData(); // } // txData[txDataCnt++] = ; - speaker = 0; + spkr.turnOff(); while (Button == 1) { - my_nrf24l01P.write(0, micvalue, 30); + my_nrf24l01p.write(0, (char *)micvalue, 30); } } @@ -126,11 +127,12 @@ { micvalue[micvalcount] = mymicrophone.getData(); micvalcount = micvalcount + 1; - if (micvalcount > 30); { - micvalcount = 0; + if (micvalcount > 30); + { + micvalcount = 0; } - - } + +} int main() {