Project

General

Profile

Revision 1985

Fixed barcodes first read problem.

Barcodes used to always read gray for the first bit, but this problem is now fixed by better initializiation in lineFollow init.

View differences:

trunk/code/projects/linefollowing/lineFollow.h
54 54
int mergeLeft(void);
55 55
int mergeRight(void);
56 56

  
57
void addToBuckets(int curColor, int i);
58
void printBuckets();
59

  
57 60
/**
58 61
 * @brief Updates the values stored in the array to white or black based on
59 62
 * current sensor readings.
trunk/code/projects/linefollowing/lineFollow.c
35 35

  
36 36
int duration[2] = {0};
37 37
int lastColor[2] = {0};
38
char isReset[2] = {0};
38
char isReset[2] = {1};
39 39
int lastReadings[2][ NUM_READINGS ] = {{0}};
40 40
int lastReadingsPtr[2] = {0};
41 41
int numLast[2][4] = { {0, 0, 0, NUM_READINGS}, {0, 0, 0, NUM_READINGS} };
......
67 67
        {
68 68
            lastReadings[i][j] = BAD_READING;
69 69
        }
70
        isReset[i] = 1;
70 71
    }
71 72

  
72 73
    //numLast = { {0, 0, 0, NUM_READINGS}, {0, 0, 0, NUM_READINGS} };
......
308 309
	return (wsum/count)-4; // Subtract 4 to center the index around the center.
309 310
}
310 311

  
312
void printBuckets(int i)
313
{
314
    int j;
315

  
316
    usb_puts("LP[");
317
    usb_puti(i);
318
    usb_puts("]: ");
319
    usb_puti(lastReadingsPtr[i]);
320
    usb_puts(", Totals: ");
321

  
322
    for(int j=0; j<=3; j++)
323
    {
324
        usb_puts("[");
325
        usb_puti(j);
326
        usb_puts("]: ");
327
        usb_puti(numLast[i][j]);
328
        usb_puts(" ");
329
    }
330
    usb_puts("\t ");
331
    usb_puts("\n");
332
}
333

  
311 334
void addToBuckets(int curColor, int i)
312 335
{
313 336
    int oldest = lastReadings[i][lastReadingsPtr[i]];
......
318 341

  
319 342
    if(DBG_LINEFOLLOW == 1)
320 343
    {
321
        usb_puts("LP[");
322
        usb_puti(i);
323
        usb_puts("]: ");
324
        usb_puti(lastReadingsPtr[i]);
325
        usb_puts(", oldest: ");
326
        usb_puti(oldest);
327
        usb_puts(", Totals: ");
328

  
329
        for(int j=0; j<=3; j++)
330
        {
331
            usb_puts("[");
332
            usb_puti(j);
333
            usb_puts("]: ");
334
            usb_puti(numLast[i][j]);
335
            usb_puts(" ");
336
        }
337
        usb_puts("\t ");
338
        usb_puts("\n");
344
        printBuckets(i);
339 345
    }
340 346
}
341 347

  
......
429 435
                        (bitColor[i] == LBLACK) ? 1 : 0;
430 436
                    usb_puts("Reset. Read bit: ");
431 437
                    usb_puts(((bitColor[i] == LBLACK) ? "BLACK" : "GREY"));
438
                    usb_puts("\t");
439
                    usb_puts(((curColor==LWHITE) ? "LWHITE" : "NOTWHITE"));
432 440
                    usb_puts("\n");
433 441

  
434 442
                    bitColor[i] = LWHITE;

Also available in: Unified diff