mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-30 09:39:49 +02:00
clang format
This commit is contained in:
@@ -39,8 +39,6 @@ namespace Spindles {
|
||||
// Note: The direction command is always called on M3,M4, and M5
|
||||
// This is where the spindle start/stop should be sent
|
||||
|
||||
|
||||
|
||||
// NOTE: data length is excluding the CRC16 checksum.
|
||||
data.tx_length = 6;
|
||||
data.rx_length = 6;
|
||||
@@ -49,7 +47,7 @@ namespace Spindles {
|
||||
data.msg[2] = 0x25; // Command ID 0x2501
|
||||
data.msg[3] = 0x01;
|
||||
data.msg[4] = 0x00;
|
||||
switch(mode){
|
||||
switch (mode) {
|
||||
case SpindleState::Disable:
|
||||
//data.msg[4] = 0x00;
|
||||
data.msg[5] = 0x00;
|
||||
@@ -64,7 +62,6 @@ namespace Spindles {
|
||||
}
|
||||
|
||||
void L510::set_speed_command(uint32_t rpm, ModbusCommand& data) {
|
||||
|
||||
// NOTE: data length is excluding the CRC16 checksum.
|
||||
data.tx_length = 6;
|
||||
data.rx_length = 6;
|
||||
@@ -78,10 +75,10 @@ namespace Spindles {
|
||||
data.msg[5] = uint8_t(freq & 0xFF);
|
||||
|
||||
#ifdef VFD_DEBUG_MODE2
|
||||
grbl_msg_sendf(CLIENT_SERIAL,MsgLevel::Info,"setting speed to: %d",speed);
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "setting speed to: %d", speed);
|
||||
#endif
|
||||
}
|
||||
uint16_t L510::rpm_to_frequency(uint32_t rpm){
|
||||
uint16_t L510::rpm_to_frequency(uint32_t rpm) {
|
||||
auto max_rpm = this->_max_rpm;
|
||||
auto max_freq = this->_max_freq;
|
||||
uint16_t freq = (uint32_t(rpm) * max_freq) / uint32_t(max_rpm);
|
||||
@@ -94,11 +91,11 @@ namespace Spindles {
|
||||
return freq;
|
||||
}
|
||||
|
||||
uint32_t L510::freq_to_rpm(uint16_t freq){
|
||||
uint32_t L510::freq_to_rpm(uint16_t freq) {
|
||||
auto max_rpm = this->_max_rpm;
|
||||
auto max_freq = this->_max_freq;
|
||||
uint32_t rpm = (freq*max_rpm)/max_freq;
|
||||
if(rpm < 0){
|
||||
uint32_t rpm = (freq * max_rpm) / max_freq;
|
||||
if (rpm < 0) {
|
||||
// sometimes it returns -1 which causes an alarm
|
||||
rpm = 0;
|
||||
}
|
||||
@@ -111,7 +108,6 @@ namespace Spindles {
|
||||
data.tx_length = 6;
|
||||
data.rx_length = 11;
|
||||
|
||||
|
||||
// read parameters 02-03..02-06
|
||||
|
||||
// Send:
|
||||
@@ -121,8 +117,6 @@ namespace Spindles {
|
||||
data.msg[4] = 0x00; // Read 4 values
|
||||
data.msg[5] = 0x04;
|
||||
|
||||
|
||||
|
||||
// Recv: ??
|
||||
|
||||
return [](const uint8_t* response, Spindles::VFD* vfd) -> bool {
|
||||
@@ -136,7 +130,8 @@ namespace Spindles {
|
||||
l510->_max_rpm = rpm;
|
||||
l510->_max_freq = freq;
|
||||
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "L510 initialized: spindle max_rpm %d max_freq %d", vfd->_max_rpm,l510->_max_freq);
|
||||
grbl_msg_sendf(
|
||||
CLIENT_SERIAL, MsgLevel::Info, "L510 initialized: spindle max_rpm %d max_freq %d", vfd->_max_rpm, l510->_max_freq);
|
||||
|
||||
return true;
|
||||
};
|
||||
@@ -144,12 +139,11 @@ namespace Spindles {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
VFD::response_parser L510::get_status_ok(ModbusCommand& data){
|
||||
VFD::response_parser L510::get_status_ok(ModbusCommand& data) {
|
||||
// NOTE: data length is excluding the CRC16 checksum.
|
||||
data.tx_length = 6;
|
||||
data.rx_length = 5;
|
||||
|
||||
|
||||
// Send:
|
||||
data.msg[1] = 0x03; // READ
|
||||
data.msg[2] = 0x25; // 0x2520 = Get state
|
||||
@@ -160,8 +154,8 @@ namespace Spindles {
|
||||
return [](const uint8_t* response, Spindles::VFD* vfd) -> bool {
|
||||
uint32_t vfd_state = (response[3] << 8) | response[4];
|
||||
|
||||
if(bitRead(vfd_state,3)){
|
||||
grbl_msg_sendf(CLIENT_SERIAL,MsgLevel::Info,"L510 Fault detected");
|
||||
if (bitRead(vfd_state, 3)) {
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "L510 Fault detected");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -208,7 +202,7 @@ namespace Spindles {
|
||||
|
||||
return [](const uint8_t* response, Spindles::VFD* vfd) -> bool {
|
||||
uint16_t got = (uint16_t(response[3]) << 8) | uint16_t(response[4]);
|
||||
bool dir = bitRead(got,1);
|
||||
bool dir = bitRead(got, 1);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user