This commit is contained in:
2025-02-24 22:23:52 +03:00
parent 5e3cc5b31a
commit f83f95c9cc
12 changed files with 186 additions and 61 deletions

View File

@@ -129,29 +129,25 @@ int SSgetint(const char *cmd, int64_t *ans){
return TRUE;
}
// commands to move X and Y to given motor position in radians; @return FALSE if failed
// BE CAREFUL: after each poweron X and Y are 0
// BE CAREFUL: angle isn't checking here
int SSXmoveto(double pos){
char buf[64];
int64_t target = X_RAD2MOT(pos);
DBG("move to angle %grad = %ld", pos, target);
snprintf(buf, 63, "%s%" PRIi64, CMD_MOTX, target);
return SStextcmd(buf, NULL);
}
int SSYmoveto(double pos){
char buf[64];
int64_t target = Y_RAD2MOT(pos);
DBG("move to angle %grad = %ld", pos, target);
snprintf(buf, 63, "%s%" PRIi64, CMD_MOTY, target);
/**
* @brief SSsetterI - integer setter
* @param cmd - command to send
* @param ival - value
* @return false if failed
*/
int SSsetterI(const char *cmd, int32_t ival){
char buf[128];
snprintf(buf, 127, "%s%" PRIi64, cmd, ival);
return SStextcmd(buf, NULL);
}
int SSemergStop(){
int SSstop(int emerg){
int i = 0;
const char *cmdx = (emerg) ? CMD_EMSTOPX : CMD_STOPX;
const char *cmdy = (emerg) ? CMD_EMSTOPY : CMD_STOPY;
for(; i < 10; ++i){
if(!SStextcmd(CMD_EMSTOPX, NULL)) continue;
if(SStextcmd(CMD_EMSTOPY, NULL)) break;
if(!SStextcmd(cmdx, NULL)) continue;
if(SStextcmd(cmdy, NULL)) break;
}
if(i == 10) return FALSE;
return TRUE;