Library for ELEC2645 Gamepad PCB. University of Leeds
Dependents: Project_MaZe1_copy Labirint Game_Controller_Project 200943373MAZE ... more
Diff: Gamepad.cpp
- Revision:
- 10:a13d2f9d8a14
- Parent:
- 9:893189072e89
- Child:
- 11:ff86b2ffce01
--- a/Gamepad.cpp Tue Feb 07 11:50:26 2017 +0000 +++ b/Gamepad.cpp Tue Feb 07 11:53:37 2017 +0000 @@ -3,12 +3,12 @@ //////////// constructor/destructor //////////// Gamepad::Gamepad() { - led1 = new PwmOut(PTA1); - led2 = new PwmOut(PTA2); - led3 = new PwmOut(PTC2); - led4 = new PwmOut(PTC3); - led5 = new PwmOut(PTC4); - led6 = new PwmOut(PTD3); + _led1 = new PwmOut(PTA1); + _led2 = new PwmOut(PTA2); + _led3 = new PwmOut(PTC2); + _led4 = new PwmOut(PTC3); + _led5 = new PwmOut(PTC4); + _led6 = new PwmOut(PTD3); button_A = new InterruptIn(PTB9); button_B = new InterruptIn(PTD0); @@ -32,7 +32,7 @@ Gamepad::~Gamepad() { - delete led1,led2,led3,led4,led5,led6; + delete _led1,_led2,_led3,_led4,_led5,_led6; delete button_A,button_B,button_joystick,vert,horiz; delete button_X, button_Y, button_back, button_start; delete button_L, button_R, buzzer, pot, timeout; @@ -57,15 +57,15 @@ void Gamepad::leds_off() { - set_leds(0.0); + leds(0.0); } void Gamepad::leds_on() { - set_leds(1.0); + leds(1.0); } -void Gamepad::set_leds(float val) +void Gamepad::leds(float val) { if (val < 0.0f) { val = 0.0f; @@ -78,31 +78,31 @@ // 0.0 corresponds to fully-off, 1.0 to fully-on val = 1.0f - val; - led1->write(val); - led2->write(val); - led3->write(val); - led4->write(val); - led5->write(val); - led6->write(val); + _led1->write(val); + _led2->write(val); + _led3->write(val); + _led4->write(val); + _led5->write(val); + _led6->write(val); } -void Gamepad::set_led1(float val) { - led1->write(1.0f-val); // active-low so subtract from 1 +void Gamepad::led1(float val) { + _led1->write(1.0f-val); // active-low so subtract from 1 } -void Gamepad::set_led2(float val) { - led2->write(1.0f-val); // active-low so subtract from 1 +void Gamepad::led2(float val) { + _led2->write(1.0f-val); // active-low so subtract from 1 } -void Gamepad::set_led3(float val) { - led3->write(1.0f-val); // active-low so subtract from 1 +void Gamepad::led3(float val) { + _led3->write(1.0f-val); // active-low so subtract from 1 } -void Gamepad::set_led4(float val) { - led4->write(1.0f-val); // active-low so subtract from 1 +void Gamepad::led4(float val) { + _led4->write(1.0f-val); // active-low so subtract from 1 } -void Gamepad::set_led5(float val) { - led5->write(1.0f-val); // active-low so subtract from 1 +void Gamepad::led5(float val) { + _led5->write(1.0f-val); // active-low so subtract from 1 } -void Gamepad::set_led6(float val) { - led6->write(1.0f-val); // active-low so subtract from 1 +void Gamepad::led6(float val) { + _led6->write(1.0f-val); // active-low so subtract from 1 } float Gamepad::read_pot()