Commit 5e9ff3d3ab9949ab7262809209d3b201d33bfa13

Authored by rguillom
1 parent db0bdba2

supp comm inutiles

Showing 1 changed file with 7 additions and 19 deletions   Show diff stats
... ... @@ -64,14 +64,13 @@ if(value==0) PORTB &= 0xfe; else PORTB |= 0x01;
64 64 void input_init(void){
65 65 DDRD &= 0b10000011; // PIN 2-6 as input (Bouton Joystick + boutons)
66 66 PORTD |= 0x7C; // Pull up de 0 à 1
67   - //DDRC &= 0b11111100; // PIN 0-1 analogiques comme input (x et y joystick)
68 67 }
69 68  
70   -
  69 +/*
71 70 unsigned char input_get(void){
72 71 return ((PIND&0x04)!=0)?1:0;
73 72 }
74   -
  73 +*/
75 74  
76 75 /* Commande des LED */
77 76 void commande_leds(){
... ... @@ -99,7 +98,6 @@ void commande_leds(){
99 98  
100 99 /* Récupération de la valeur des boutons et mise en forme */
101 100 unsigned char get_buttons(void){
102   - //unsigned char boutons = (((PIND & 0x7C)>>2) &0x3f) | 0b00100000;
103 101 unsigned char boutons = PIND;
104 102 boutons = boutons >>2;
105 103 boutons = boutons & 0b00111111;
... ... @@ -110,8 +108,7 @@ unsigned char get_buttons(void){
110 108  
111 109 /* Met en forme l'octet de l'axe pos du joystick */
112 110 unsigned char shape_joy(unsigned char pos){
113   - //pos = ((pos >> 3) | &0b00111111) 0b00100000;
114   - pos = pos >>3;
  111 + pos = pos >>3; //On récupère les 5 bits de poids forts de l'ADCH (diminuer sensibilité)
115 112 pos = pos & 0b00111111;
116 113 pos = pos | 0b00100000;
117 114 return pos;
... ... @@ -153,32 +150,23 @@ int main(void){
153 150 joystick_x = get_joystick(0);
154 151 _delay_ms(tempo);
155 152 joystick_y = get_joystick(1);
156   -
157 153  
158 154 //Port série libre
159 155 if ((UCSR0A & (1<<RXC0)) == 0){
160   -
161   - //if (boutons_anc != boutons){
162   - //if (joystick_x_anc != joystick_x){
163   - //if (joystick_y_anc != joystick_y){
  156 + // Si une des grandeurs a changé
164 157 if ((boutons_anc != boutons) || (joystick_x_anc != joystick_x) || (joystick_y_anc != joystick_y)){
165   - send_serial(boutons);
166   - //if ((joystick_x > 126) || (joystick_x <33)) send_serial('e');
  158 + send_serial(boutons); //on envoie l'état global des grandeurs
167 159 send_serial(joystick_x);
168   - send_serial(joystick_y);
169   -
170   - //send_serial('r');
171   -
  160 + send_serial(joystick_y);
172 161 //retour chariot
173 162 send_serial(0x0a);
174 163 send_serial(0x0d);
175 164 }
176   -
177 165 }
178 166  
179 167 //Port série occupé
180 168 else{
181   - commande_leds();
  169 + commande_leds(); //On gère la commande des leds
182 170 }
183 171 }
184 172 return 0;
... ...