4-Axisと同じラインセンサのライブラリ

Dependents:   00_yotsuba 10_motor-test 00_yotsuba 200_yotsuba_21

line.cpp

Committer:
piroro4560
Date:
2021-03-04
Revision:
1:2d25db124969
Parent:
0:058a2a20c0d1
Child:
2:fb0d0bb8fc5b

File content as of revision 1:2d25db124969:

#include "line.h"

Line::Line(PinName line_):linesensor(line_)
{
    lineborder = DEFAULT_LINESENSOR_JUDGVALUE;
    thread.start(callback(this, &Line::lineassemble));
}
Line::Line(PinName line_, float border_):linesensor(line_)
{
    thread.start(callback(this, &Line::lineassemble));
    lineborder = border_;
}

void Line::border(float border_)
{
    lineborder = border_;
}


void Line::lineassemble()
{
    while(true) {
        linevalue = 3300 * linesensor.read();
        if(linevalue > lineborder) judgvalue = true;
        else judgvalue = false;
        thread_sleep_for(1000);
    }
}

Line::operator bool(){
    return judgvalue;
    }

float Line::value()
{
    return linevalue;
}

bool Line::judg()
{
    return judgvalue;
}