64,654
社区成员
发帖
与我相关
我的任务
分享
#define MAX_B_IDX stpBlock::maxBlockIdx
#define CUR_B_IDX stpBlock::curBlockIdx
#define CUR_BLOCK pBlocks[CUR_B_IDX]
#define CUR_B_LaIdx CUR_BLOCK.LaIdx
#define CUR_B_LaPhs CUR_BLOCK.LaCurPhase
class stpBlock
{
public:
static byte Prescaler; //定时器分频值
static byte maxBlockIdx; //最大block索引值,0开始
static byte curBlockIdx; //当前执行的block索引值
stpBlock() {} ; //有重载一定要定义一次
//axises=轴数量,1开始计数; LaPhases=阶段数,1开始计数
stpBlock(byte axises, byte LaPhases)
{
LaMaxPhaseIdx = LaPhases - 1;
pLaTickCs = new unsigned int[LaPhases];
pLaTickTG = new unsigned int[LaPhases];
pLaDeltaTick = new int[LaPhases];
pLaGroupCycle = new byte[LaPhases];
pLaPcd = new unsigned long[LaPhases];
pAllDir = new bool[axises];
pAllLev = new bool[axises];
pAllPcd = new unsigned long[axises];
counter = new unsigned long[axises];
}
byte status = 1; //0=已完成 ;1=已计算,未完成或未执行
unsigned long maxPf = 0; //最大步数
//byte maxAxisIdx = 0; //轴索引数,0开始 (轴数量) //考虑到此对象与电机数对应,所以不动作的电机都要存在,不动作的电机*pAllPcd=0
byte LaIdx = 0; //长轴索引号
byte LaMaxPhaseIdx = 0; //长轴phase数量,0开始 (阶段数量)
byte LaCurPhase = 0; //当前阶段标记
unsigned int* pLaTickCs = NULL; //长轴各阶段Tick的数组指针
unsigned int* pLaTickTG = NULL; //长轴各阶段Tick目标值的数组指针
int* pLaDeltaTick = NULL; //长轴各阶段DeltaTick的数组指针 加速,delta<0 匀速,delta=0 减速,delta>0
byte* pLaGroupCycle = NULL; //长轴各阶段GC的数组指针
byte GC_count = 1; //长轴当前阶段的GC count,1开始
unsigned long* pLaPcd = NULL; //长轴各阶段步数的数组指针,执行时count down
bool* pAllDir = NULL; //各轴方向电平,建立Block时赋值
bool* pAllLev = NULL; //各轴驱动电平标记
unsigned long* pAllPf = NULL; //所有轴每个的总部数,不倒数
unsigned long* pAllPcd = NULL; //各轴步数的数组指针,执行时count down
unsigned long* counter = NULL; //各轴插补counter
//完成后释放里面的指针
void clear();
~stpBlock()
{
status = 1;
delete pLaTickCs;
pLaTickCs = NULL;
delete pLaTickTG;
pLaTickTG = NULL;
delete pLaDeltaTick;
pLaDeltaTick = NULL;
delete pLaGroupCycle;
pLaGroupCycle = NULL;
delete pLaPcd;
pLaPcd = NULL;
delete pAllDir;
pAllDir = NULL;
delete pAllLev;
pAllLev = NULL;
delete pAllPcd;
pAllPcd = NULL;
delete counter;
counter = NULL;
}
}; //stpBlock类定义结束
//------------------------------------------------------------------------
stpBlock* pBlocks = NULL; //block数组指针全局变量
#include "bwStepBlock.h"
byte stpBlock::maxBlockIdx = 0;
byte stpBlock::curBlockIdx = 0;
byte stpBlock::Prescaler = 64;
void stpBlock::clear()
{
status = 1;
delete pLaTickCs;
pLaTickCs = NULL;
delete pLaTickTG;
pLaTickTG = NULL;
delete pLaDeltaTick;
pLaDeltaTick = NULL;
delete pLaGroupCycle;
pLaGroupCycle = NULL;
delete pLaPcd;
pLaPcd = NULL;
delete pAllDir;
pAllDir = NULL;
delete pAllLev;
pAllLev = NULL;
delete pAllPcd;
pAllPcd = NULL;
delete counter;
counter = NULL;
}
In file included from C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.cpp:1:0:
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:10:9: error: 'byte' does not name a type
static byte Prescaler; //瀹氭椂鍣ㄥ垎棰戝??
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:11:9: error: 'byte' does not name a type
static byte maxBlockIdx; //鏈?澶lock绱㈠紩鍊硷紝0寮?濮?
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:12:9: error: 'byte' does not name a type
static byte curBlockIdx; //褰撳墠鎵ц鐨刡lock绱㈠紩鍊?
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:16:16: error: expected ')' before 'axises'
stpBlock(byte axises, byte LaPhases)
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:31:2: error: 'byte' does not name a type
byte status = 1; //0=宸插畬鎴? 锛?1=宸茶绠楋紝鏈畬鎴愭垨鏈墽琛?
^
In file included from C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.cpp:1:0:
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:35:2: error: 'byte' does not name a type
byte LaIdx = 0; //闀胯酱绱㈠紩鍙?
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:36:2: error: 'byte' does not name a type
byte LaMaxPhaseIdx = 0; //闀胯酱phase鏁伴噺锛?0寮?濮? (闃舵鏁伴噺)
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:37:2: error: 'byte' does not name a type
byte LaCurPhase = 0; //褰撳墠闃舵鏍囪
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:41:2: error: 'byte' does not name a type
byte* pLaGroupCycle = NULL; //闀胯酱鍚勯樁娈礕C鐨勬暟缁勬寚閽?
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:42:2: error: 'byte' does not name a type
byte GC_count = 1; //闀胯酱褰撳墠闃舵鐨凣C count锛?1寮?濮?
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:38:28: error: 'NULL' was not declared in this scope
unsigned int* pLaTickCs = NULL; //闀胯酱鍚勯樁娈礣ick鐨勬暟缁勬寚閽?
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:39:28: error: 'NULL' was not declared in this scope
unsigned int* pLaTickTG = NULL; //闀胯酱鍚勯樁娈礣ick鐩爣鍊肩殑鏁扮粍鎸囬拡
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:40:26: error: 'NULL' was not declared in this scope
int* pLaDeltaTick = NULL; //闀胯酱鍚勯樁娈礑eltaTick鐨勬暟缁勬寚閽? 鍔犻?燂紝delta<0 鍖?閫燂紝delta=0 鍑忛?燂紝delta>0
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:43:26: error: 'NULL' was not declared in this scope
unsigned long* pLaPcd = NULL; //闀胯酱鍚勯樁娈垫鏁扮殑鏁扮粍鎸囬拡锛屾墽琛屾椂count down
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:45:21: error: 'NULL' was not declared in this scope
bool* pAllDir = NULL; //鍚勮酱鏂瑰悜鐢靛钩锛屽缓绔婤lock鏃惰祴鍊?
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:46:21: error: 'NULL' was not declared in this scope
bool* pAllLev = NULL; //鍚勮酱椹卞姩鐢靛钩鏍囪
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:47:26: error: 'NULL' was not declared in this scope
unsigned long* pAllPf = NULL; //鎵?鏈夎酱姣忎釜鐨勬?婚儴鏁帮紝涓嶅?掓暟
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:48:27: error: 'NULL' was not declared in this scope
unsigned long* pAllPcd = NULL; //鍚勮酱姝ユ暟鐨勬暟缁勬寚閽堬紝鎵ц鏃禼ount down
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:49:27: error: 'NULL' was not declared in this scope
unsigned long* counter = NULL; //鍚勮酱鎻掕ˉcounter
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h: In destructor 'stpBlock::~stpBlock()':
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:56:3: error: 'status' was not declared in this scope
status = 1;
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:58:15: error: 'NULL' was not declared in this scope
pLaTickCs = NULL;
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:63:10: error: 'pLaGroupCycle' was not declared in this scope
delete pLaGroupCycle;
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h: At global scope:
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.h:81:21: error: 'NULL' was not declared in this scope
stpBlock* pBlocks = NULL; //block鏁扮粍鎸囬拡鍏ㄥ眬鍙橀噺
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.cpp:3:1: error: 'byte' does not name a type
byte stpBlock::maxBlockIdx = 0;
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.cpp:4:1: error: 'byte' does not name a type
byte stpBlock::curBlockIdx = 0;
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.cpp:5:1: error: 'byte' does not name a type
byte stpBlock::Prescaler = 64;
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.cpp: In member function 'void stpBlock::clear()':
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.cpp:9:2: error: 'status' was not declared in this scope
status = 1;
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.cpp:11:14: error: 'NULL' was not declared in this scope
pLaTickCs = NULL;
^
C:\Program Files (x86)\Arduino\libraries\bwStepper\bwStepBlock.cpp:16:9: error: 'pLaGroupCycle' was not declared in this scope
delete pLaGroupCycle;
^
exit status 1
为开发板 Arduino Pro or Pro Mini 编译时出错。