Project

General

Profile

Revision 1543

Added by Brad Neuman over 14 years ago

Added a bunch of debug prints to the library

View differences:

bom.c
38 38
#include "serial.h"
39 39
#include "analog.h"
40 40

  
41
//#define DEBUG_BOM_VERBOSE
42

  
41 43
//On the original BOM1.0, the emmitter angular order does not match the analog mux order
42 44
//so you need to iterate through the mux index in the following order if you want to get
43 45
//the detector readings in order:
......
132 134
 **/
133 135
int bom_init(char type) {
134 136

  
135
    if(bom_initd)
136
      return ERROR_INIT_ALREADY_INITD;
137
  if(bom_initd) {
138
    DRAGONFLY_DEBUG_PRINT("ERROR: BOM already init'd\r\n");
139
    return ERROR_INIT_ALREADY_INITD;
140
  }
137 141

  
138 142

  
139 143
    bom_type = type;
......
159 163
    case RBOM:
160 164
        break;
161 165
    default:
166
      DRAGONFLY_DEBUG_PRINT("ERROR: unknown BOM type ");
167
      DRAGONFLY_DEBUG_PRINT_INT(bom_type);
168
      DRAGONFLY_DEBUG_PRINT_STR("\r\n");
162 169
      return -1;        
163 170
    //default:
164 171
    }
......
184 191
    int i;
185 192
    int loop_was_running = 0;
186 193

  
187
    if(!bom_initd)
194
    if(!bom_initd) {
195
      DRAGONFLY_DEBUG_PRINT("ERROR: BOM not init'd\r\n");
188 196
      return ERROR_LIBRARY_NOT_INITD;
197
    }
189 198

  
190 199
    
191 200
    //Check analog loop status
......
222 231
 * see bom_refresh
223 232
 **/
224 233
int bom_get(int which) {
225
    if(!bom_initd)
226
      return -1;
234
  if(!bom_initd) {
235
    DRAGONFLY_DEBUG_PRINT("ERROR: BOM not init'd\r\n");
236
    return -1;
237
  }
227 238

  
228 239
    return bom_val[which];
229 240
}
......
238 249
int bom_get_max(void) {
239 250
    int i, lowest_val, lowest_i;
240 251

  
241
    if(!bom_initd)
252
    if(!bom_initd) {
253
      DRAGONFLY_DEBUG_PRINT("ERROR: BOM not init'd\r\n");
242 254
      return -2;
255
    }
243 256

  
244 257
    lowest_i = -1;
245 258
    lowest_val = 255;
......
252 265
    
253 266
    if(lowest_val < BOM_VALUE_THRESHOLD)
254 267
        return lowest_i;
255
    else
268
    else {
269
#ifdef DEBUG_BOM_VERBOSE
270
      DRAGONFLY_DEBUG_PRINT("ERROR: no BOM values above threshold\r\n");
271
#endif
256 272
        return -1;
273
    }
257 274
}
258 275

  
259 276
/** 
......
268 285
    int i, max;
269 286
    long long mean = 0, sum = 0;
270 287

  
271
    if(!bom_initd)
288
    if(!bom_initd) {
289
      DRAGONFLY_DEBUG_PRINT("ERROR: BOM not init'd\r\n");
272 290
      return ERROR_LIBRARY_NOT_INITD;
291
    }
273 292

  
274 293

  
275 294
    max = bom_get_max();
......
279 298
        {
280 299
            *dist = -1;
281 300
        }
301
#ifdef DEBUG_BOM_VERBOSE
302
	DRAGONFLY_DEBUG_PRINT("ERROR: no BOM values above threshold\r\n");
303
#endif
282 304
        return -1;
283 305
    }
284 306
    /* Record values into an array */
......
314 336
    int i;
315 337
    unsigned int mask = 1<<(NUM_BOM_LEDS-1);
316 338

  
317
    if(!bom_initd)
339
    if(!bom_initd) {
340
      DRAGONFLY_DEBUG_PRINT("ERROR: BOM not init'd\r\n");
318 341
      return ERROR_LIBRARY_NOT_INITD;
342
    }
319 343

  
320 344
    switch(bom_type) {
321 345
    case BOM10:
......
371 395
 **/
372 396
int bom_on(void)
373 397
{
374
  if(!bom_initd)
398
  if(!bom_initd) {
399
    DRAGONFLY_DEBUG_PRINT("ERROR: BOM not init'd\r\n");
375 400
    return ERROR_LIBRARY_NOT_INITD;
401
  }
376 402

  
377 403
  switch(bom_type) {
378 404
  case BOM10:
......
384 410
  case RBOM:
385 411
	break;
386 412
  default:
413
    DRAGONFLY_DEBUG_PRINT("ERROR: no valid BOM type, cannot turn on\r\n");
387 414
    return -1;
388 415
  }
389 416

  
......
399 426
 **/
400 427
int bom_off(void)
401 428
{
402
  if(!bom_initd)
429
  if(!bom_initd) {
430
    DRAGONFLY_DEBUG_PRINT("ERROR: BOM not init'd\r\n");
403 431
    return ERROR_LIBRARY_NOT_INITD;
432
  }
404 433

  
405 434
  switch(bom_type) {
406 435
  case BOM10:

Also available in: Unified diff