[AccelStepper][PlatformIO][mbed] 请求''中的成员'',非class类型
[AccelStepper][PlatformIO][mbed] Request for member '' in '', which is of non-class type
所以我一直在尝试创建 3 个 'accelstepper' 对象。
This is a screenshot of my code in case the code section doesn't appear. Also, this is a screenshot of the file "stepper_directory.h"
#include <mbed.h>
#include "stepper_directory.h"
//Include accelstepper library
#include <AccelStepper.h>
//Create accelstepper object for the Z-Axis actuator
AccelStepper zaxis(uint8_t interface = AccelStepper::DRIVER, uint8_t zstep = ZSTEP, uint8_t zdir = ZDIR);
//Create accelstepper object for the theta axis actuator
AccelStepper taxis(uint8_t interface = AccelStepper::DRIVER, uint8_t tstep = TSTEP, uint8_t tdir = TDIR);
//Create accelstepper object for the magnet actuator
AccelStepper maxis(uint8_t interface = AccelStepper::DRIVER, uint8_t mstep = MSTEP, uint8_t mdir = MDIR);
这是我用过的头文件"stepper_directory.h"
#ifndef _STEPPER_DIRECTORY
#define _STEPPER_DIRECTORY
#include "PinNames.h"
//Pin Definitions
#define ZSTEP PA_7
#define ZDIR PA_0
#define TSTEP PA_8
#define TDIR PA_1
#define MSTEP PA_9
#define MDIR PA_2
我尝试在 main.cpp 的主代码中设置一个步进器,如下所示:
int main() {
// put your setup code here, to run once:
zaxis.setMaxSpeed(188000);
while(1) {
// put your main code here, to run repeatedly:
}
}
但是 platformIO 编译器抛出了这几行:
src\main.cpp: In function 'int main()':
src\main.cpp:17:7: error: request for member 'setMaxSpeed' in 'zaxis', which is of non-class type 'AccelStepper(uint8_t, uint8_t, uint8_t)
{aka AccelStepper(unsigned char, unsigned char, unsigned char)}'
zaxis.setMaxSpeed(188000);
^~~~~~~~~~~
*** [.pio\build\nucleo_f410rb\src\main.o] Error 1
我一直在尝试搜索我的对象实例化有什么问题,但无济于事。如果有人可以解释这有什么问题,我将不胜感激。 This is a screenshot of the error in question
问题就在这里。
//Create accelstepper object for the Z-Axis actuator
AccelStepper zaxis(uint8_t interface = AccelStepper::DRIVER, uint8_t zstep = ZSTEP, uint8_t zdir = ZDIR);
这是一个函数声明。它需要三个参数和 returns AccelStepper
。您不能用这行代码初始化 AccelStepper
的实例。
我假设 AccelStepper
的构造函数是这样的:
AccelStepper AccelStepper(uint8_t interface, uint8_t zstep, uint8_t zdir);
您可以这样初始化您的实例:
AccelStepper zaxis(AccelStepper::DRIVER, ZSTEP, ZDIR);
所以我一直在尝试创建 3 个 'accelstepper' 对象。 This is a screenshot of my code in case the code section doesn't appear. Also, this is a screenshot of the file "stepper_directory.h"
#include <mbed.h>
#include "stepper_directory.h"
//Include accelstepper library
#include <AccelStepper.h>
//Create accelstepper object for the Z-Axis actuator
AccelStepper zaxis(uint8_t interface = AccelStepper::DRIVER, uint8_t zstep = ZSTEP, uint8_t zdir = ZDIR);
//Create accelstepper object for the theta axis actuator
AccelStepper taxis(uint8_t interface = AccelStepper::DRIVER, uint8_t tstep = TSTEP, uint8_t tdir = TDIR);
//Create accelstepper object for the magnet actuator
AccelStepper maxis(uint8_t interface = AccelStepper::DRIVER, uint8_t mstep = MSTEP, uint8_t mdir = MDIR);
这是我用过的头文件"stepper_directory.h"
#ifndef _STEPPER_DIRECTORY
#define _STEPPER_DIRECTORY
#include "PinNames.h"
//Pin Definitions
#define ZSTEP PA_7
#define ZDIR PA_0
#define TSTEP PA_8
#define TDIR PA_1
#define MSTEP PA_9
#define MDIR PA_2
我尝试在 main.cpp 的主代码中设置一个步进器,如下所示:
int main() {
// put your setup code here, to run once:
zaxis.setMaxSpeed(188000);
while(1) {
// put your main code here, to run repeatedly:
}
}
但是 platformIO 编译器抛出了这几行:
src\main.cpp: In function 'int main()':
src\main.cpp:17:7: error: request for member 'setMaxSpeed' in 'zaxis', which is of non-class type 'AccelStepper(uint8_t, uint8_t, uint8_t)
{aka AccelStepper(unsigned char, unsigned char, unsigned char)}'
zaxis.setMaxSpeed(188000);
^~~~~~~~~~~
*** [.pio\build\nucleo_f410rb\src\main.o] Error 1
我一直在尝试搜索我的对象实例化有什么问题,但无济于事。如果有人可以解释这有什么问题,我将不胜感激。 This is a screenshot of the error in question
问题就在这里。
//Create accelstepper object for the Z-Axis actuator
AccelStepper zaxis(uint8_t interface = AccelStepper::DRIVER, uint8_t zstep = ZSTEP, uint8_t zdir = ZDIR);
这是一个函数声明。它需要三个参数和 returns AccelStepper
。您不能用这行代码初始化 AccelStepper
的实例。
我假设 AccelStepper
的构造函数是这样的:
AccelStepper AccelStepper(uint8_t interface, uint8_t zstep, uint8_t zdir);
您可以这样初始化您的实例:
AccelStepper zaxis(AccelStepper::DRIVER, ZSTEP, ZDIR);