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:
- 24:28c8b01b7d35
- Parent:
- 20:e068469ffb89
- Child:
- 25:02cdaf98e4ab
--- a/main.cpp Fri Apr 20 18:39:20 2018 +0000 +++ b/main.cpp Sat Apr 21 17:51:24 2018 +0000 @@ -23,9 +23,8 @@ 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 -InterruptIn Button(p20); //changed DitialIn to InterruptIn at 5:54 4/18/18 +InterruptIn Button(p18); //changed DitialIn to InterruptIn at 5:54 4/18/18 char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE]; //making these usable by other voids. int txDataCnt = 0;//and this. @@ -102,11 +101,17 @@ void receive() //most of this function added by david at 6:02pm 4/18/18 { - uint8_t spkrarray[29]; - while (Button == 0) { + uint8_t spkrarray[30]; + uint8_t spkrtemp; + while (Button.read() == 0) { if (my_nrf24l01p.readable(0)) { - rxbuff.push(spkrarray, 30); - spkr.write(spkrarray[1]); + pc.printf("receiving...."); + my_nrf24l01p.read(0, (char*)spkrarray, 30); + rxbuff.push(spkrarray, 30); + // rxbuff.push(spkrarray, 30); + rxbuff.pop(&spkrtemp, 1); + spkr.write(spkrtemp); + myled2 = !myled2; } } } @@ -118,28 +123,39 @@ // } // txData[txDataCnt++] = ; spkr.turnOff(); - while (Button == 1) { - my_nrf24l01p.write(0, (char *)micvalue, 30); + uint8_t txsendary[30]; + txbuff.pop(txsendary, 30); + while (Button.read()) { + // my_nrf24l01p.write(0, (char *)micvalue, 30); + pc.printf("transmitting...."); + my_nrf24l01p.write( NRF24L01P_PIPE_P0, (char*) txsendary, 30); + myled1 = !myled1; } } void pollmic() { - micvalue[micvalcount] = mymicrophone.getData(); - micvalcount = micvalcount + 1; - if (micvalcount > 30); - { - micvalcount = 0; - } + uint8_t txentry = mymicrophone.getData(); + txbuff.push(&txentry, 1); + pc.printf("polling...."); + // micvalcount = micvalcount + 1; + // if (micvalcount > 30); + // { + // micvalcount = 0; + // } } int main() { - Button.mode(PullUp);//added 6:23pm 4/18/18 - t.attach(&pollmic, 0.0001); - t.attach(&receive, 0.0001); + startup(); + pc.printf("starting up...."); + Button.mode(PullDown);//added 6:23pm 4/18/18 + Button.rise(&transmit); + Button.fall(&receive); + t.attach(&pollmic, 0.1); + // t.attach(&receive, 0.0001); while (1) { - + Thread::yield(); } } \ No newline at end of file