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.
PS3_Controller.cpp
- Committer:
- kitta5687
- Date:
- 2019-03-01
- Revision:
- 0:03f05f023ff4
- Child:
- 3:378f57911f5d
File content as of revision 0:03f05f023ff4:
#include "PS3_Controller.h"
PS3_controller::PS3_controller(PinName TX, PinName RX) : _uno(TX,RX)
{
_uno.baud(57600);
}
PS3_controller::PS3_controller(Serial &uno):_uno(uno)
{
_uno.baud(57600);
}
void PS3_controller::read_PAD()
{
_uno.putc(send_data);
while(!_uno.readable()) {}
for(int i=0; i<9; i++) str[i]=_uno.getc();
all_button_on_off = (str[1] << 8);
all_button_on_off = (all_button_on_off & 0xff00);
all_button_on_off = (all_button_on_off | str[0]);
for(int i=0; i<6; i++) sthick_value[i] = str[i+2];
controller_check = str[8];
}
void PS3_controller::send_UNO(int send_pattern)
{
send_data = send_pattern;
}
int PS3_controller::button(int button_pattern)
{
return bitRead(all_button_on_off,button_pattern);
}
int PS3_controller::analog(int sthick_pattern)
{
return sthick_value[sthick_pattern];
}
bool PS3_controller::conect(void)
{
return controller_check;
}