NagaokaRoboticsClub_mbedTeam / Mbed 2 deprecated 2022_FEPTX-TokiPS4

Dependencies:   FEP_TX22 SerialArduino mbed

Committer:
watarushimoda
Date:
Sat Oct 08 04:08:26 2022 +0000
Revision:
2:81cf98f7f721
Parent:
0:df41f530dbd9
FEP TX program TokiPS4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
watarushimoda 2:81cf98f7f721 1 //PS4コントローラーにしわき拡張版
piroro4560 0:df41f530dbd9 2 #include "FEP_TX22.h"
piroro4560 0:df41f530dbd9 3 #include "SerialArduino.h"
piroro4560 0:df41f530dbd9 4 #include "pinconfig.h"
piroro4560 0:df41f530dbd9 5 #define SWNUM 8
watarushimoda 2:81cf98f7f721 6 #define DATANUM 128
piroro4560 0:df41f530dbd9 7
piroro4560 0:df41f530dbd9 8 SerialArduino mini(TXino, RXino, 115200);
piroro4560 0:df41f530dbd9 9
piroro4560 0:df41f530dbd9 10 //FEP,PCの宣言
watarushimoda 2:81cf98f7f721 11 FEP_TX22 FEP_TX22(fepTX, fepRX, fepad);
piroro4560 0:df41f530dbd9 12 Serial pc(USBTX, USBRX, 115200);
piroro4560 0:df41f530dbd9 13
watarushimoda 2:81cf98f7f721 14 //拡張部の宣言
watarushimoda 2:81cf98f7f721 15 AnalogIn volume1(vol1);
watarushimoda 2:81cf98f7f721 16 AnalogIn volume2(vol2);
watarushimoda 2:81cf98f7f721 17 AnalogIn volume3(vol3);
watarushimoda 2:81cf98f7f721 18 DigitalIn stop(em_stop);
watarushimoda 2:81cf98f7f721 19 DigitalIn toggle1(tgl1);
watarushimoda 2:81cf98f7f721 20 DigitalIn toggle2(tgl2);
watarushimoda 2:81cf98f7f721 21 DigitalIn toggle3(tgl3);
watarushimoda 2:81cf98f7f721 22
piroro4560 0:df41f530dbd9 23 int main()
piroro4560 0:df41f530dbd9 24 {
piroro4560 0:df41f530dbd9 25 uint8_t data[DATANUM];
piroro4560 0:df41f530dbd9 26 while(1)
piroro4560 0:df41f530dbd9 27 {
piroro4560 0:df41f530dbd9 28 mini.getState(data);
watarushimoda 2:81cf98f7f721 29 data[9] = (int)(volume1*255); //左
watarushimoda 2:81cf98f7f721 30 data[10] = (int)(volume2*255); //中
watarushimoda 2:81cf98f7f721 31 data[11] = (int)(volume3*255); //右
watarushimoda 2:81cf98f7f721 32 data[12] = stop; //上
watarushimoda 2:81cf98f7f721 33 data[13] = toggle1; //左
watarushimoda 2:81cf98f7f721 34 data[14] = toggle2; //中
watarushimoda 2:81cf98f7f721 35 data[15] = toggle3; //右
piroro4560 0:df41f530dbd9 36 //PC表示部分
watarushimoda 2:81cf98f7f721 37 pc.printf("%3d | sw:%3d %3d | stick:%3d %3d %3d %3d | trig:%3d %3d | vol:%3d %3d %3d | tgl:%3d %3d %3d | %3d\r\n"
watarushimoda 2:81cf98f7f721 38 , data[12], data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[9], data[10], data[11], data[13], data[14], data[15], data[8]);
piroro4560 0:df41f530dbd9 39
watarushimoda 2:81cf98f7f721 40 FEP_TX22.SendData(data, 16);
piroro4560 0:df41f530dbd9 41 }
piroro4560 0:df41f530dbd9 42 }