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
Diff: main.cpp
- Revision:
- 0:8e823c21ce5d
- Child:
- 1:44e048e53fcf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Oct 16 06:55:08 2021 +0000 @@ -0,0 +1,61 @@ +#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_); + } +} \ No newline at end of file