|
|
@ -7,14 +7,16 @@ |
|
|
|
using namespace iflytop; |
|
|
|
using namespace std; |
|
|
|
#define TAG "XYRobotCtrlModule"
|
|
|
|
void XYRobotCtrlModule::initialize(IStepperMotor* stepM1, //
|
|
|
|
IStepperMotor* stepM2, //
|
|
|
|
ZGPIO* Xgpio, //
|
|
|
|
ZGPIO* Ygpio, const char* flashmark) { |
|
|
|
m_stepM1 = stepM1; |
|
|
|
m_stepM2 = stepM2; |
|
|
|
m_Xgpio = Xgpio; |
|
|
|
m_Ygpio = Ygpio; |
|
|
|
void XYRobotCtrlModule::initialize(IStepperMotor* stepM1, //
|
|
|
|
IStepperMotor* stepM2, //
|
|
|
|
ZGPIO* gpiotable, //
|
|
|
|
int ngpio, const char* flashmark) { |
|
|
|
m_stepM1 = stepM1; |
|
|
|
m_stepM2 = stepM2; |
|
|
|
m_Xgpio = &gpiotable[0]; |
|
|
|
m_Ygpio = &gpiotable[1]; |
|
|
|
m_gpiotable = gpiotable; |
|
|
|
m_ngpio = ngpio; |
|
|
|
ZASSERT(m_stepM1); |
|
|
|
ZASSERT(m_stepM2); |
|
|
|
ZASSERT(m_Xgpio); |
|
|
@ -263,18 +265,26 @@ int32_t XYRobotCtrlModule::read_version(version_t& version) { |
|
|
|
} |
|
|
|
int32_t XYRobotCtrlModule::read_status(status_t& status) { |
|
|
|
zlock_guard lock(m_lock); |
|
|
|
status = {0}; |
|
|
|
status.status = m_thread.isworking() ? 0x01 : 0x00; |
|
|
|
if (m_Xgpio) status.iostate |= m_Xgpio->getState() ? 0x01 : 0x00; |
|
|
|
if (m_Ygpio) status.iostate |= m_Ygpio->getState() ? 0x02 : 0x00; |
|
|
|
status = {0}; |
|
|
|
status.status = m_thread.isworking() ? 0x01 : 0x00; |
|
|
|
status.iostate = 0xff; |
|
|
|
for (int i = 0; i < m_ngpio; i++) { |
|
|
|
if (i > 7) break; |
|
|
|
if (!m_gpiotable[i].getState()) status.iostate &= ~(1 << i); |
|
|
|
} |
|
|
|
|
|
|
|
getnowpos(status.x, status.y); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t XYRobotCtrlModule::read_detailed_status(detailed_status_t& debug_info) { |
|
|
|
zlock_guard lock(m_lock); |
|
|
|
debug_info = {0}; |
|
|
|
if (m_Xgpio) debug_info.iostate |= m_Xgpio->getState() ? 0x01 : 0x00; |
|
|
|
if (m_Ygpio) debug_info.iostate |= m_Ygpio->getState() ? 0x02 : 0x00; |
|
|
|
|
|
|
|
debug_info.iostate = 0xff; |
|
|
|
for (int i = 0; i < m_ngpio; i++) { |
|
|
|
if (i > 7) break; |
|
|
|
if (!m_gpiotable[i].getState()) debug_info.iostate &= ~(1 << i); |
|
|
|
} |
|
|
|
|
|
|
|
debug_info.status = m_thread.isworking() ? 0x01 : 0x00; |
|
|
|
getnowpos(debug_info.x, debug_info.y); |
|
|
|