colordetector.c

来自「为参加日本的ET机器人比赛写的LEGO机器人控制程序」· C语言 代码 · 共 100 行

C
100
字号
/******************************************************************************\
*
* File:          ColorDetector.C
* Creation date: June 23, 2008 10:30
* Latest update: July 09, 2008 16:39
* Author:        ClassBuilder
*                XXXX
* Purpose:       Method implementations of class 'ColorDetector'
* CB version:    ClassBuilder Version 2.9 (PR523)
*
* Modifications: @INSERT_MODIFICATIONS(* )
* July 05, 2008 20:47 Chijinliang
*     Updated code of method 'Detect'
* July 05, 2008 20:28 Chijinliang
*     Updated code of method 'Detect'
* July 05, 2008 14:29 Chijinliang
*     Updated code of method 'Detect'
* June 24, 2008 19:44 Chijinliang
*     Updated code of method 'Detect'
* June 23, 2008 14:03 Chijinliang
*     Updated code of method 'Detect'
* June 23, 2008 13:42 Chijinliang
*     Updated code of method 'Detect'
* June 23, 2008 10:30 Chijinliang
*     Added method 'DestructorInclude'
*     Added method 'ConstructorInclude'
*     Added method 'Detect'
*     Added method '~ColorDetector'
*
* Copyright 2008, XXXXX
* All rights are reserved. Reproduction in whole or part is prohibited
* without the written consent of the copyright owner.
*
\******************************************************************************/
// Master include file
#include "JASTInTime.h"


using namespace JASTInTime;




/*
Destructor method.
*/
ColorDetector::~ColorDetector()
{
    // Put in your own code

    DestructorInclude();
}


Color ColorDetector::Detect(unsigned int sensorValue,
                            const Calibration& calibration)
{
    if (sensorValue >= calibration.GetWhite() - 2)
    {
        return White;
    }
    else if (sensorValue <= calibration.GetBlack() + 2)
    {
        return Black;
    }
    else if (sensorValue <= (calibration.GetGray() - 1))
    {
        return BlackGray;
    }
    else if (sensorValue <= (calibration.GetGray() + 1))
    {
        return Gray;
    }
    else
    {
        return WhiteGray;
    }
}


/*
Method which must be called first in a constructor.
*/
void ColorDetector::ConstructorInclude()
{
}


/*
Method which must be called first in a destructor.
*/
void ColorDetector::DestructorInclude()
{
}


// Methods for the relation(s) of the class


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?