Project

General

Profile

Revision 277

more cleanup

View differences:

dio.c
163 163
  int pins = portpin & 0x07;
164 164

  
165 165
  /* if you want to set to 0... */
166
  if(val == 0) {
166
  if (val == 0) {
167 167
    switch(portpin >> 3) {
168 168
    case _PORT_A:
169 169
      DDRA |= _BV(pins);
......
194 194
      PORTG &= (0XFF - _BV(pins));
195 195
      break;
196 196
    }
197
  }else { /* ( val == 1) */
197
  } else { /* ( val == 1) */
198 198
    switch(portpin >> 3) {
199 199
    case _PORT_A:
200 200
      DDRA |= _BV(pins);
......
237 237
 **/
238 238
int button1_read( void )
239 239
{
240
	int pin_val;
241
	DDRG &= ~_BV(PING0);
242
	PORTG|= _BV(PING0);
243
    pin_val = PING;
244
	return !((pin_val & _BV(PING0)));
245

  
240
  int pin_val;
241
  DDRG &= ~_BV(PING0);
242
  PORTG|= _BV(PING0);
243
  pin_val = PING;
244
  return !((pin_val & _BV(PING0)));
246 245
}
247 246

  
248 247
/**
......
252 251
 **/
253 252
void button1_wait( void )
254 253
{
255
  while(!button1_read() ) {
254
  while (!button1_read()) {
256 255
    delay_ms(15);
257 256
  }
258 257
}
......
267 266
 **/
268 267
int button1_click()
269 268
{
270
  if(button1_read()){
271
    while(button1_read());
269
  if (button1_read()) {
270
    while (button1_read());
272 271
    return 1;
273
  }else{
272
  } else {
274 273
    return 0;
275 274
  }
276 275
}
......
284 283
 **/
285 284
int button2_read( void )
286 285
{
287
	int pin_val;
288
	DDRG &= ~_BV(PING1);
289
	PORTG|= _BV(PING1);
290
    pin_val = PING;
291
	return !((pin_val & _BV(PING1)));
286
  int pin_val;
287
  DDRG &= ~_BV(PING1);
288
  PORTG|= _BV(PING1);
289
  pin_val = PING;
290
  return !((pin_val & _BV(PING1)));
292 291
}
293 292

  
294 293
/**
......
296 295
 *
297 296
 * @see button2_read, button2_click
298 297
 **/
299
void button2_wait( void )
298
void button2_wait(void)
300 299
{
301
  while(!button2_read()){
300
  while (!button2_read()) {
302 301
    delay_ms(15);
303 302
  }
304 303
}
......
313 312
 **/
314 313
int button2_click()
315 314
{
316
	if(button2_read()){
317
    while(button2_read());
315
  if (button2_read()) {
316
    while (button2_read());
318 317
    return 1;
319
  }else{
320
		return 0;
318
  } else {
319
    return 0;
321 320
  }
322 321
}
323 322

  
324 323
/** @} **/ //end defgroup
325

  

Also available in: Unified diff