teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

HbMotor.cpp

Committer:
MasashiNomura
Date:
2018-12-10
Revision:
24:c5945aaae777
Parent:
19:4b0fe9a5ec38
Child:
25:f3a6e7eec9c3

File content as of revision 24:c5945aaae777:

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

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

//-----------------------------------------
//モーター設定
//-----------------------------------------
void HbMotor::setValue(INT16 iVal){
    UINT16  val;
    
    //入力リミット
    if( iVal > limitH ){
        val = limitH;
    }else if( iVal < limitL ){
        val = limitL;
    }else{
        val = iVal;
    }
    
    //オフセット重畳
    val = val + ofs;
    
    //PWM幅設定
    fpgaSubProp(id,val);
}
void HbMotor::setOffset(INT16 iVal){
    ofs = iVal;
}

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