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@0:8e823c21ce5d, 2021-10-16 (annotated)
- Committer:
- piroro4560
- Date:
- Sat Oct 16 06:55:08 2021 +0000
- Revision:
- 0:8e823c21ce5d
- Child:
- 1:44e048e53fcf
make
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
piroro4560 | 0:8e823c21ce5d | 1 | #include "mbed.h" |
piroro4560 | 0:8e823c21ce5d | 2 | #include "Bcon.h" |
piroro4560 | 0:8e823c21ce5d | 3 | #include "pinconfig.h" |
piroro4560 | 0:8e823c21ce5d | 4 | #define SWNUM 8 |
piroro4560 | 0:8e823c21ce5d | 5 | |
piroro4560 | 0:8e823c21ce5d | 6 | |
piroro4560 | 0:8e823c21ce5d | 7 | //バスインの宣言 |
piroro4560 | 0:8e823c21ce5d | 8 | BusIn Button(topB, leftB, btmB, rightB, triagl, square, cross, circle); |
piroro4560 | 0:8e823c21ce5d | 9 | //スティックのアナログイン宣言 |
piroro4560 | 0:8e823c21ce5d | 10 | AnalogIn stick[]={Lx, Ly, Rx, Ry}; |
piroro4560 | 0:8e823c21ce5d | 11 | |
piroro4560 | 0:8e823c21ce5d | 12 | //FEP,PCの宣言 |
piroro4560 | 0:8e823c21ce5d | 13 | BconFEP fep(fepTX, fepRX, fepad); |
piroro4560 | 0:8e823c21ce5d | 14 | Serial pc(USBTX, USBRX, 115200); |
piroro4560 | 0:8e823c21ce5d | 15 | |
piroro4560 | 0:8e823c21ce5d | 16 | |
piroro4560 | 0:8e823c21ce5d | 17 | int main() |
piroro4560 | 0:8e823c21ce5d | 18 | { |
piroro4560 | 0:8e823c21ce5d | 19 | double stick_val[4]; |
piroro4560 | 0:8e823c21ce5d | 20 | bool sw[SWNUM]={};// 各ボタン表示用 |
piroro4560 | 0:8e823c21ce5d | 21 | uint8_t data[256]={}, sum, temp, intensity;//data 送る, sum BusIn値 |
piroro4560 | 0:8e823c21ce5d | 22 | uint8_t data_[5]; |
piroro4560 | 0:8e823c21ce5d | 23 | Button.mode(PullDown); |
piroro4560 | 0:8e823c21ce5d | 24 | while(1) |
piroro4560 | 0:8e823c21ce5d | 25 | { |
piroro4560 | 0:8e823c21ce5d | 26 | //スティックの値を代入 |
piroro4560 | 0:8e823c21ce5d | 27 | for(int i=0; i<4; i++){ |
piroro4560 | 0:8e823c21ce5d | 28 | stick_val[i]=stick[i]; |
piroro4560 | 0:8e823c21ce5d | 29 | } |
piroro4560 | 0:8e823c21ce5d | 30 | |
piroro4560 | 0:8e823c21ce5d | 31 | //スイッチ各個表示 |
piroro4560 | 0:8e823c21ce5d | 32 | sum = Button & Button.mask(); |
piroro4560 | 0:8e823c21ce5d | 33 | for (int i=0; i<SWNUM; i++) { |
piroro4560 | 0:8e823c21ce5d | 34 | sw[i] = (sum>>i) & 1; |
piroro4560 | 0:8e823c21ce5d | 35 | } |
piroro4560 | 0:8e823c21ce5d | 36 | |
piroro4560 | 0:8e823c21ce5d | 37 | //スイッチ,スティック,トリガーを変数にいれる |
piroro4560 | 0:8e823c21ce5d | 38 | for (int i=0; i<2; i++) { |
piroro4560 | 0:8e823c21ce5d | 39 | data[i] = sum; |
piroro4560 | 0:8e823c21ce5d | 40 | } |
piroro4560 | 0:8e823c21ce5d | 41 | |
piroro4560 | 0:8e823c21ce5d | 42 | for (int i=0; i<4; i++) { |
piroro4560 | 0:8e823c21ce5d | 43 | data[2+i] = stick_val[i]*255; |
piroro4560 | 0:8e823c21ce5d | 44 | } |
piroro4560 | 0:8e823c21ce5d | 45 | |
piroro4560 | 0:8e823c21ce5d | 46 | for (int i=0; i<2; i++) { |
piroro4560 | 0:8e823c21ce5d | 47 | data[6+i] = 50*(i+1); |
piroro4560 | 0:8e823c21ce5d | 48 | } |
piroro4560 | 0:8e823c21ce5d | 49 | |
piroro4560 | 0:8e823c21ce5d | 50 | //PC表示部分 |
piroro4560 | 0:8e823c21ce5d | 51 | pc.printf("sw:%3d %3d | stick:%3d %3d %3d %3d | trig:%3d %3d\r\n" |
piroro4560 | 0:8e823c21ce5d | 52 | , data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); |
piroro4560 | 0:8e823c21ce5d | 53 | |
piroro4560 | 0:8e823c21ce5d | 54 | data_[0] = sum; |
piroro4560 | 0:8e823c21ce5d | 55 | for (int i=1; i<5; i++) { |
piroro4560 | 0:8e823c21ce5d | 56 | data_[i] = stick_val[i-1]*255; |
piroro4560 | 0:8e823c21ce5d | 57 | } |
piroro4560 | 0:8e823c21ce5d | 58 | |
piroro4560 | 0:8e823c21ce5d | 59 | fep.SendData(data_); |
piroro4560 | 0:8e823c21ce5d | 60 | } |
piroro4560 | 0:8e823c21ce5d | 61 | } |