NagaokaRoboticsClub_mbedTeam
/
2022A_FEPRX_TokiPS4
FEP RX program TokiPS4
Revision 0:c2cc8f4e2ba0, committed 2022-10-08
- Comitter:
- watarushimoda
- Date:
- Sat Oct 08 10:20:18 2022 +0000
- Commit message:
- FEP RX program TokiPS4
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FEP_RX22.lib Sat Oct 08 10:20:18 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/FEP_RX22/#39eb865e21e1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Oct 08 10:20:18 2022 +0000 @@ -0,0 +1,82 @@ +//PS4コントローラーにしわき拡張版 +#include "FEP_RX22.h" +#include "pinconfig.h" +#include <cmath> + +FEP_RX22 mycon(fepTX, fepRX, fepad); +Serial pc(pcTX, pcRX, 115200); + +int main() +{ + mycon.StartReceive(); + uint8_t b[16]; + int16_t stick[4]; + int16_t trigger[4]; + int16_t volume[3]; + uint8_t toggle[4]; + uint8_t timeout; + uint8_t data[128]; + int pw; + while(1) { + +#if ControllerMode + for (int i=0; i<16; i++) b[i] = mycon.getButton(i); + for (int i=0; i<4; i++) stick[i] = mycon.getStick(i); + for (int i=0; i<2; i++) trigger[i] = mycon.getTrigger(i); + + for (int i=0; i<16; i++) pc.printf("%d ", b[i]); + pc.printf(" | "); + for (int i=0; i<4; i++) pc.printf("%3d ", stick[i]); + pc.printf(" | "); + for (int i=0; i<2; i++) pc.printf("%3d ", trigger[i]); + pc.printf(" | "); +#else + mycon.getData(data); + for (int i=0, tmp=1; i<8; i++) { + pw = pow((float)2,i); + b[i] = (int)((data[0] & tmp)/pw); + pc.printf("%d ", b[i]); + tmp *= 2; + } + for (int i=8, tmp=1, j=0; i<16; i++, j++) { + pw = pow((float)2,j); + b[i] = (int)((data[1] & tmp)/pw); + pc.printf("%d ", b[i]); + tmp *= 2; + } + pc.printf(" | "); + + for (int i=0; i<4; i++) { + stick[i] = data[i+2]; + pc.printf("%3d ", stick[i]); + } + pc.printf(" | "); + + for (int i=0; i<2; i++) { + trigger[i] = data[i+6]; + pc.printf("%3d ", trigger[i]); + } + pc.printf(" | "); + + for (int i=0; i<3; i++) { + volume[i] = data[i+9]; + pc.printf("%3d ", volume[i]); + } + pc.printf(" | "); + + for (int i=0; i<4; i++) { + toggle[i] = data[i+12]; + pc.printf("%3d ", toggle[i]); + } + pc.printf(" | "); + + timeout = data[8]; + pc.printf("%3d ", timeout); + pc.printf(" | "); + +#endif + if (mycon.getStatus()) pc.printf("received\r\n"); + else pc.printf("anything error...\r\n"); + + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Oct 08 10:20:18 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pinconfig.h Sat Oct 08 10:20:18 2022 +0000 @@ -0,0 +1,15 @@ +#ifndef PIN_CONFIG_H +#define PIN_CONFIG_H + +#include "mbed.h" + +/*FEP*/ +static PinName const fepTX = PC_12; +static PinName const fepRX = PD_2; +static uint8_t const fepad = 004; // 通信相手のアドレス + +/*PC*/ +static PinName const pcTX = USBTX; +static PinName const pcRX = USBRX; + +#endif \ No newline at end of file