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.
Controller.h
00001 // DS4のみ通信が確認できているバージョンで,プロジェクトに公開しているクラス 00002 #ifndef CONTROLLER_H 00003 #define CONTROLLER_H 00004 00005 #include "mbed.h" 00006 #include "RawSerial.h" 00007 #include "define.h" 00008 /* 00009 struct ControllerData{ 00010 unsigned int ButtonState; 00011 uint8_t RJoyX, RJoyY, LJoyX, LJoyY; 00012 }; 00013 */ 00014 class Controller{ 00015 public: 00016 Controller(PinName tx, PinName rx, int baudrate); 00017 int count_ms, pre_count_ms; //受信時刻と前回の受信時刻 00018 00019 bool readButton_bin(unsigned int ButtonNum); //押していない時はfalse(0),押してるときはtrue(1)を返す. ButtonNumはデータの欲しいボタンの名前を 00020 int readButton(unsigned int ButtonNum); //上にプラスして 押した瞬間は2,放した瞬間は-1を返す. define.hを参考に数字を入力しても良い 00021 bool getComCheck(void); //値が更新されたときにtrueを返す. 00022 bool update(); //受信の処理+ボタンの情報の更新.受信割込みで処理 00023 00024 void init(int _time_out_ms, int _int_time_ms); //コントローラの通信速度と通信のタイムアウト時間を設定 00025 bool available(void); 00026 00027 unsigned int getButtonState(); //分解する前のButtonStateの情報をprint 0~255の値をとる 00028 void clearButtonState(); 00029 ControllerData getConData(); 00030 unsigned int getButtonFlagRise(); 00031 unsigned int getButtonFlagFall(); 00032 00033 // X 00034 double readJoyRX(); // ^ 00035 double readJoyRY(); // | 00036 double readJoyLX(); // Y<---+---- 00037 double readJoyLY(); // | 00038 // | 00039 // 1.0 ~ -1.0 00040 00041 // X 00042 uint8_t readJoyRXbyte(); // ^ 00043 uint8_t readJoyRYbyte(); // | 00044 uint8_t readJoyLXbyte(); // Y<---+---- 00045 uint8_t readJoyLYbyte(); // | 00046 // | 00047 // 255 ~ 0 00048 00049 private: 00050 00051 RawSerial serial; 00052 //Timer timer; 00053 00054 bool comCheck; 00055 ControllerData conData; 00056 ControllerData pre_conData; 00057 unsigned int lastButtonState; 00058 00059 int time_out_ms; 00060 double int_time_ms; 00061 bool conAvailable; 00062 00063 uint8_t serial_recieve(){ 00064 char temp; 00065 do{ 00066 temp = serial.getc(); 00067 } 00068 while(temp==-1); 00069 //CONTROL.write(temp); //受け取ったデータをTXピンからそのまま送っている.他のマイコンにも流したいとき用. 00070 return temp; 00071 } 00072 }; 00073 00074 #endif
Generated on Wed Jul 27 2022 04:51:22 by
1.7.2