From 70c40cb92de407a9fb12776b765a4a12b9b3f099 Mon Sep 17 00:00:00 2001 From: gperson Date: Wed, 2 Dec 2020 21:55:03 +0100 Subject: [PATCH] changement des fonctions manette.c et joystick .h dans polytech lille et dans les drivers afin de faire fonctionner le potentiometre de la manette sur 8 bits pour gerer les deux axes, le programme compile, jattends demain pour tester --- src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h | 45 +++++++++++++++++++++++++++++++++++++++------ src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c | 22 +++++++++++----------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h b/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h index b75c90e..d91ef2a 100644 --- a/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h +++ b/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h @@ -51,9 +51,11 @@ * * @{ */ +#include +#include +#ifndef __JOYSTICK_PINGUI_H__ +#define __JOYSTICK_PINGUI_H__ -#ifndef __JOYSTICK_BUMBLEB_H__ -#define __JOYSTICK_BUMBLEB_H__ /* Includes: */ #include "../../../../Common/Common.h" @@ -77,12 +79,13 @@ /* Public Interface - May be used in end-application: */ /* Macros: */ /** Mask for the joystick being pushed in the left direction. */ - #define JOY_V (1 << 2) + //#define JOY_V (1 << 2) /** Mask for the joystick being pushed in the upward direction. */ - #define JOY_H (1 << 3) + //#define JOY_H (1 << 3) - + #define joy_X_ADC 6 //pour utilisrr l'adc par rapport aux 2 axes + #define joy_Y_ADC 7 // ** Mask for the joystick being pushed in the right direction. // #define JOY_RIGHT (1 << 0) // @@ -93,6 +96,29 @@ // #define JOY_PRESS (1 << 4) /* Inline Functions: */ +//these are the functions coming from the examples we got on Mr REDON website + + + void adc_init(unsigned char mux) + { + ADCSRA = (1<>4 //pour les quatres bits de poids faible pour axe Y, on place en fort et on decale de 4 bits into le poids faible + return (uint8_t)(Xquatrebits+Yquatrebits); } #endif diff --git a/src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c b/src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c index def135a..e9085e3 100644 --- a/src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c +++ b/src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c @@ -166,23 +166,23 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData; uint8_t JoyStatus_LCL = Joystick_GetStatus(); - uint8_t ButtonStatus_LCL = Buttons_GetStatus_HAUT(); + //uint8_t ButtonStatus_LCL = Buttons_GetStatus_HAUT(); // poir les boutons - if (JoyStatus_LCL & JOY_UP) - JoystickReport->Y = -100; - else if (JoyStatus_LCL & JOY_DOWN) - JoystickReport->Y = 100; - if (JoyStatus_LCL & JOY_LEFT) - JoystickReport->X = -100; - else if (JoyStatus_LCL & JOY_RIGHT) - JoystickReport->X = 100; + JoystickReport->X = JoyStatus_LCL & 0xF0; + JoystickReport->Y = JoyStatus_LCL & 0x0F; + + +// if (JoyStatus_LCL & JOY_LEFT) +// JoystickReport->X = -100; +// else if (JoyStatus_LCL & JOY_RIGHT) +// JoystickReport->X = 100; /* if (JoyStatus_LCL & JOY_PRESS) JoystickReport->Button |= (1 << 1); */ - if (ButtonStatus_LCL & BUTTONS_HAUT) - JoystickReport->Button |= (1 << 0); +// if (ButtonStatus_LCL & BUTTONS_HAUT) +// JoystickReport->Button |= (1 << 0); *ReportSize = sizeof(USB_JoystickReport_Data_t); return false; -- libgit2 0.21.2