teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

HbMotor.cpp

Committer:
MasashiNomura
Date:
2018-12-12
Revision:
25:f3a6e7eec9c3
Parent:
24:c5945aaae777
Child:
27:ff63c23bc689

File content as of revision 25:f3a6e7eec9c3:

#include "HbMotor.h"
#include "fpga.h"

//=========================================
//コンストラクタ
//=========================================
HbMotor::HbMotor(UCHAR iID ){
    id      =iID;
    ofs     =0;//
    limitH  =2000;
    limitL  =-2000;
    curVal = 0;
}

//-----------------------------------------
//モーター設定
//-----------------------------------------
void HbMotor::setValue(INT16 iVal){
    UINT16  val;
    
    //入力リミット
    if( iVal > limitH ){
        val = limitH;
    }else if( iVal < limitL ){
        val = limitL;
    }else{
        val = iVal;
    }
    
    //オフセット重畳
    curVal = val = val + ofs;
    //sp.printf("MOT [%d]",curVal);//Test Code
    //PWM幅設定
    fpgaSubProp(id,val);
}

void HbMotor::setOfs(INT16 iVal){
    ofs = iVal;
}

INT16 HbMotor::getOfs(){
    return ofs;
}

void HbMotor::setLimit(INT16 low, INT16 hi){
    limitL = low;
    limitH = hi;
}

INT16 HbMotor::getCurrentValue(){
    return curVal;
}

void HbMotor::setValueDirect(INT16 iVal){
    //PWM幅設定
    //sp.printf("MOT [%d]",iVal);//Test Code
    fpgaSubProp(id,iVal);
}