Commit 5e9ff3d3ab9949ab7262809209d3b201d33bfa13
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,14 +64,13 @@ if(value==0) PORTB &= 0xfe; else PORTB |= 0x01; | ||
64 | void input_init(void){ | 64 | void input_init(void){ |
65 | DDRD &= 0b10000011; // PIN 2-6 as input (Bouton Joystick + boutons) | 65 | DDRD &= 0b10000011; // PIN 2-6 as input (Bouton Joystick + boutons) |
66 | PORTD |= 0x7C; // Pull up de 0 à 1 | 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 | unsigned char input_get(void){ | 70 | unsigned char input_get(void){ |
72 | return ((PIND&0x04)!=0)?1:0; | 71 | return ((PIND&0x04)!=0)?1:0; |
73 | } | 72 | } |
74 | - | 73 | +*/ |
75 | 74 | ||
76 | /* Commande des LED */ | 75 | /* Commande des LED */ |
77 | void commande_leds(){ | 76 | void commande_leds(){ |
@@ -99,7 +98,6 @@ void commande_leds(){ | @@ -99,7 +98,6 @@ void commande_leds(){ | ||
99 | 98 | ||
100 | /* Récupération de la valeur des boutons et mise en forme */ | 99 | /* Récupération de la valeur des boutons et mise en forme */ |
101 | unsigned char get_buttons(void){ | 100 | unsigned char get_buttons(void){ |
102 | - //unsigned char boutons = (((PIND & 0x7C)>>2) &0x3f) | 0b00100000; | ||
103 | unsigned char boutons = PIND; | 101 | unsigned char boutons = PIND; |
104 | boutons = boutons >>2; | 102 | boutons = boutons >>2; |
105 | boutons = boutons & 0b00111111; | 103 | boutons = boutons & 0b00111111; |
@@ -110,8 +108,7 @@ unsigned char get_buttons(void){ | @@ -110,8 +108,7 @@ unsigned char get_buttons(void){ | ||
110 | 108 | ||
111 | /* Met en forme l'octet de l'axe pos du joystick */ | 109 | /* Met en forme l'octet de l'axe pos du joystick */ |
112 | unsigned char shape_joy(unsigned char pos){ | 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 | pos = pos & 0b00111111; | 112 | pos = pos & 0b00111111; |
116 | pos = pos | 0b00100000; | 113 | pos = pos | 0b00100000; |
117 | return pos; | 114 | return pos; |
@@ -153,32 +150,23 @@ int main(void){ | @@ -153,32 +150,23 @@ int main(void){ | ||
153 | joystick_x = get_joystick(0); | 150 | joystick_x = get_joystick(0); |
154 | _delay_ms(tempo); | 151 | _delay_ms(tempo); |
155 | joystick_y = get_joystick(1); | 152 | joystick_y = get_joystick(1); |
156 | - | ||
157 | 153 | ||
158 | //Port série libre | 154 | //Port série libre |
159 | if ((UCSR0A & (1<<RXC0)) == 0){ | 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 | if ((boutons_anc != boutons) || (joystick_x_anc != joystick_x) || (joystick_y_anc != joystick_y)){ | 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 | send_serial(joystick_x); | 159 | send_serial(joystick_x); |
168 | - send_serial(joystick_y); | ||
169 | - | ||
170 | - //send_serial('r'); | ||
171 | - | 160 | + send_serial(joystick_y); |
172 | //retour chariot | 161 | //retour chariot |
173 | send_serial(0x0a); | 162 | send_serial(0x0a); |
174 | send_serial(0x0d); | 163 | send_serial(0x0d); |
175 | } | 164 | } |
176 | - | ||
177 | } | 165 | } |
178 | 166 | ||
179 | //Port série occupé | 167 | //Port série occupé |
180 | else{ | 168 | else{ |
181 | - commande_leds(); | 169 | + commande_leds(); //On gère la commande des leds |
182 | } | 170 | } |
183 | } | 171 | } |
184 | return 0; | 172 | return 0; |