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 2021BconTX
main.cpp
- Committer:
- piroro4560
- Date:
- 2021-10-16
- Revision:
- 0:8e823c21ce5d
- Child:
- 1:44e048e53fcf
File content as of revision 0:8e823c21ce5d:
#include "mbed.h" #include "Bcon.h" #include "pinconfig.h" #define SWNUM 8 //バスインの宣言 BusIn Button(topB, leftB, btmB, rightB, triagl, square, cross, circle); //スティックのアナログイン宣言 AnalogIn stick[]={Lx, Ly, Rx, Ry}; //FEP,PCの宣言 BconFEP fep(fepTX, fepRX, fepad); Serial pc(USBTX, USBRX, 115200); int main() { double stick_val[4]; bool sw[SWNUM]={};// 各ボタン表示用 uint8_t data[256]={}, sum, temp, intensity;//data 送る, sum BusIn値 uint8_t data_[5]; Button.mode(PullDown); while(1) { //スティックの値を代入 for(int i=0; i<4; i++){ stick_val[i]=stick[i]; } //スイッチ各個表示 sum = Button & Button.mask(); for (int i=0; i<SWNUM; i++) { sw[i] = (sum>>i) & 1; } //スイッチ,スティック,トリガーを変数にいれる for (int i=0; i<2; i++) { data[i] = sum; } for (int i=0; i<4; i++) { data[2+i] = stick_val[i]*255; } for (int i=0; i<2; i++) { data[6+i] = 50*(i+1); } //PC表示部分 pc.printf("sw:%3d %3d | stick:%3d %3d %3d %3d | trig:%3d %3d\r\n" , data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); data_[0] = sum; for (int i=1; i<5; i++) { data_[i] = stick_val[i-1]*255; } fep.SendData(data_); } }