TapeSensors.c

char Tape_isBlack(TAPE_Sensor_t tapeNum)

            Set rawValue equal to analog input value from sensor corresponding to tapeNum

            If lastReads[tapeNum] is WHITE

                        If rawValue > thresBlack

                                    lastReads[tapeNum] = BLACK

            Else

                        if rawValue < thresWhite

                                    lastReads[tapeNum] = WHITE   

            return  lastReads[tapeNum] == BLACK

 

char Tape_isParallel(void)

            Return True if front, center, and rear tape sensors all read BLACK

 

char Tape_isPerp(void)

            Return True if center, center_left, and center_right tape sensors all read BLACK

 

TAPE_TrackStatus_t Tape_getTrackStatus(void)

            Set combo = 4*Tape_isBlack(FRONT_LEFT) + 2*Tape_isBlack(FRONT) + Tape_isBlack(FRONT_RIGHT)

            switch(combo)

                        case 0: return LOST

                        case 1: return WAY_LEFT

                        case 2: return ALIGNED

                        case 3: return LIL_LEFT

                        case 4: return WAY_RIGHT

                        case 5: return ERROR

                        case 6: return LIL_RIGHT

                        case 7: return INTERSECTION