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: MMA8451Q TSI USBDevice mbed nRF24L01P
Fork of kl25Z_nRF_RX by
Revision 4:47d9d6c2d7e9, committed 2018-03-18
- Comitter:
- saitejarao
- Date:
- Sun Mar 18 16:05:36 2018 +0000
- Parent:
- 3:f3e27d1b37ad
- Commit message:
- WIRELESS MOUSE RX
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Sun Mar 18 16:05:36 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
--- a/Receiver.cpp Sat Jun 04 05:35:08 2016 +0000
+++ b/Receiver.cpp Sun Mar 18 16:05:36 2018 +0000
@@ -1,51 +1,57 @@
#include "mbed.h"
#include "nRF24L01P.h"
-
-Serial pc(USBTX, USBRX); // tx, rx
-
-nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4); // mosi, miso, sck, csn, ce, irq
-DigitalOut GreenLED(PTA12);
-
-
-int main() {
-
- char count[2];
- char RxDataCnt;
- char temp;
+#include "MMA8451Q.h"
+#include "TSISensor.h"
+#include "USBMouse.h"
+#define MMA8451_addr (0X1d<<1)
+USBMouse mouse;
+MMA8451Q acc(PTE25,PTE24,MMA8451_addr);
+TSISensor tsi;
+Serial pc(USBTX, USBRX);
+nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4);
+int main()
+{
+ char count[4];
+ char RxDataCnt;
+ float x,y;
+ char temp;
my_nrf24l01p.powerUp();
- my_nrf24l01p.setRfFrequency(2410);
-
- // Display the (default) setup of the nRF24L01+ chip
- pc.printf( "nRF24L01+ Frequency : %d MHz\r\n", my_nrf24l01p.getRfFrequency() );
- pc.printf( "nRF24L01+ Output power : %d dBm\r\n", my_nrf24l01p.getRfOutputPower() );
- pc.printf( "nRF24L01+ Data Rate : %d kbps\r\n", my_nrf24l01p.getAirDataRate() );
- pc.printf( "nRF24L01+ TX Address : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
- pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() );
-
- pc.printf( "Simple 2 Byte Receiver\r\n" );
+ my_nrf24l01p.setRfFrequency(2400);
- RxDataCnt = 2;
+ RxDataCnt = 4;
my_nrf24l01p.setTransferSize( RxDataCnt );
my_nrf24l01p.setReceiveMode();
my_nrf24l01p.enable();
- while (1) {
-
- // If we've received anything in the nRF24L01+...
- if ( my_nrf24l01p.readable() ) {
-
- // ...read the data into the receive buffer
- temp = my_nrf24l01p.read( NRF24L01P_PIPE_P0, count, RxDataCnt );
+ while (1)
+ {
-
- pc.printf( "Cnt %d = %d %d\r\n",temp,count[0],count[1]);
-
-
- // Toggle LED2 (to help debug nRF24L01+ -> Host communication)
- GreenLED = !GreenLED;
- wait_ms(10);
+ if ( my_nrf24l01p.readable() )
+ {
+ temp = my_nrf24l01p.read( NRF24L01P_PIPE_P0, count, RxDataCnt );
+ // pc.printf( "Cnt %d = %d %d %d %d\r\n",temp,count[0],count[1],count[2],count[3]);
+ y=count[0];
+ x=count[1];
+ y=(y/50.0f)-(float)2;
+ x=(x/50.0f)-(float)2;
+ mouse.move(-1.0f*y*20.0f,x*20.0f);
+ if(count[2]==1)
+ {
+ mouse.press(MOUSE_LEFT);
+ }
+ else if(count[3]==1)
+ {
+ mouse.press(MOUSE_RIGHT);
+ }
+ else
+ {
+ mouse.release(MOUSE_LEFT);
+ mouse.release(MOUSE_RIGHT);
+ }
+
+ wait_ms(50);
}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Sun Mar 18 16:05:36 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/emilmont/code/TSI/#507b1f67804b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Sun Mar 18 16:05:36 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/Kojto/code/USBDevice/#53949e6131f6
--- a/mbed.bld Sat Jun 04 05:35:08 2016 +0000 +++ b/mbed.bld Sun Mar 18 16:05:36 2018 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/cbbeb26dbd92 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/5571c4ff569f \ No newline at end of file
