Dcodes.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. #include "Dcodes.h"
  2. #include "Marlin.h"
  3. #ifdef DEBUG_DCODES
  4. #include "ConfigurationStore.h"
  5. #include "cmdqueue.h"
  6. #include "pat9125.h"
  7. #include "adc.h"
  8. #include "temperature.h"
  9. #include <avr/wdt.h>
  10. #define FLASHSIZE 0x40000
  11. #define RAMSIZE 0x2000
  12. #define boot_src_addr (*((uint32_t*)(RAMSIZE - 16)))
  13. #define boot_dst_addr (*((uint32_t*)(RAMSIZE - 12)))
  14. #define boot_copy_size (*((uint16_t*)(RAMSIZE - 8)))
  15. #define boot_reserved (*((uint8_t*)(RAMSIZE - 6)))
  16. #define boot_app_flags (*((uint8_t*)(RAMSIZE - 5)))
  17. #define boot_app_magic (*((uint32_t*)(RAMSIZE - 4)))
  18. #define BOOT_APP_FLG_ERASE 0x01
  19. #define BOOT_APP_FLG_COPY 0x02
  20. #define BOOT_APP_FLG_FLASH 0x04
  21. extern uint8_t fsensor_log;
  22. extern float current_temperature_pinda;
  23. extern float axis_steps_per_unit[NUM_AXIS];
  24. inline void print_hex_nibble(uint8_t val)
  25. {
  26. putchar((val > 9)?(val - 10 + 'a'):(val + '0'));
  27. }
  28. void print_hex_byte(uint8_t val)
  29. {
  30. print_hex_nibble(val >> 4);
  31. print_hex_nibble(val & 15);
  32. }
  33. void print_hex_word(uint16_t val)
  34. {
  35. print_hex_byte(val >> 8);
  36. print_hex_byte(val & 255);
  37. }
  38. void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperline = 16)
  39. {
  40. while (count)
  41. {
  42. if (type == 2)
  43. print_hex_nibble(address >> 16);
  44. print_hex_word(address);
  45. putchar(' ');
  46. uint8_t count_line = countperline;
  47. while (count && count_line)
  48. {
  49. uint8_t data = 0;
  50. switch (type)
  51. {
  52. case 0: data = *((uint8_t*)address++); break;
  53. case 1: data = eeprom_read_byte((uint8_t*)address++); break;
  54. case 2: data = pgm_read_byte_far((uint8_t*)address++); break;
  55. }
  56. putchar(' ');
  57. print_hex_byte(data);
  58. count_line--;
  59. count--;
  60. }
  61. putchar('\n');
  62. }
  63. }
  64. //#define LOG(args...) printf(args)
  65. #define LOG(args...)
  66. int parse_hex(char* hex, uint8_t* data, int count)
  67. {
  68. int parsed = 0;
  69. while (*hex)
  70. {
  71. if (count && (parsed >= count)) break;
  72. char c = *(hex++);
  73. if (c == ' ') continue;
  74. if (c == '\n') break;
  75. uint8_t val = 0x00;
  76. if ((c >= '0') && (c <= '9')) val |= ((c - '0') << 4);
  77. else if ((c >= 'a') && (c <= 'f')) val |= ((c - 'a' + 10) << 4);
  78. else return -parsed;
  79. c = *(hex++);
  80. if ((c >= '0') && (c <= '9')) val |= (c - '0');
  81. else if ((c >= 'a') && (c <= 'f')) val |= (c - 'a' + 10);
  82. else return -parsed;
  83. data[parsed] = val;
  84. parsed++;
  85. }
  86. return parsed;
  87. }
  88. void dcode__1()
  89. {
  90. printf("D-1 - Endless loop\n");
  91. cli();
  92. while (1);
  93. }
  94. void dcode_0()
  95. {
  96. if (*(strchr_pointer + 1) == 0) return;
  97. LOG("D0 - Reset\n");
  98. if (code_seen('B')) //bootloader
  99. {
  100. cli();
  101. wdt_enable(WDTO_15MS);
  102. while(1);
  103. }
  104. else //reset
  105. {
  106. #ifndef _NO_ASM
  107. asm volatile("jmp 0x00000");
  108. #endif //_NO_ASM
  109. }
  110. }
  111. void dcode_1()
  112. {
  113. LOG("D1 - Clear EEPROM and RESET\n");
  114. cli();
  115. for (int i = 0; i < 8192; i++)
  116. eeprom_write_byte((unsigned char*)i, (unsigned char)0xff);
  117. wdt_enable(WDTO_15MS);
  118. while(1);
  119. }
  120. void dcode_2()
  121. {
  122. LOG("D2 - Read/Write RAM\n");
  123. uint16_t address = 0x0000; //default 0x0000
  124. uint16_t count = 0x2000; //default 0x2000 (entire ram)
  125. if (code_seen('A')) // Address (0x0000-0x1fff)
  126. address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
  127. if (code_seen('C')) // Count (0x0001-0x2000)
  128. count = (int)code_value();
  129. address &= 0x1fff;
  130. if (count > 0x2000) count = 0x2000;
  131. if ((address + count) > 0x2000) count = 0x2000 - address;
  132. if (code_seen('X')) // Data
  133. {
  134. uint8_t data[16];
  135. count = parse_hex(strchr_pointer + 1, data, 16);
  136. if (count > 0)
  137. {
  138. for (int i = 0; i < count; i++)
  139. *((uint8_t*)(address + i)) = data[i];
  140. LOG("%d bytes written to RAM at address %04x", count, address);
  141. }
  142. else
  143. count = 0;
  144. }
  145. print_mem(address, count, 0);
  146. /* while (count)
  147. {
  148. print_hex_word(address);
  149. putchar(' ');
  150. uint8_t countperline = 16;
  151. while (count && countperline)
  152. {
  153. uint8_t data = *((uint8_t*)address++);
  154. putchar(' ');
  155. print_hex_byte(data);
  156. countperline--;
  157. count--;
  158. }
  159. putchar('\n');
  160. }*/
  161. }
  162. void dcode_3()
  163. {
  164. LOG("D3 - Read/Write EEPROM\n");
  165. uint16_t address = 0x0000; //default 0x0000
  166. uint16_t count = 0x2000; //default 0x2000 (entire eeprom)
  167. if (code_seen('A')) // Address (0x0000-0x1fff)
  168. address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
  169. if (code_seen('C')) // Count (0x0001-0x2000)
  170. count = (int)code_value();
  171. address &= 0x1fff;
  172. if (count > 0x2000) count = 0x2000;
  173. if ((address + count) > 0x2000) count = 0x2000 - address;
  174. if (code_seen('X')) // Data
  175. {
  176. uint8_t data[16];
  177. count = parse_hex(strchr_pointer + 1, data, 16);
  178. if (count > 0)
  179. {
  180. for (int i = 0; i < count; i++)
  181. eeprom_write_byte((uint8_t*)(address + i), data[i]);
  182. LOG(count, DEC);
  183. LOG(" bytes written to EEPROM at address ");
  184. print_hex_word(address);
  185. putchar('\n');
  186. }
  187. else
  188. count = 0;
  189. }
  190. print_mem(address, count, 1);
  191. /* while (count)
  192. {
  193. print_hex_word(address);
  194. putchar(' ');
  195. uint8_t countperline = 16;
  196. while (count && countperline)
  197. {
  198. uint8_t data = eeprom_read_byte((uint8_t*)address++);
  199. putchar(' ');
  200. print_hex_byte(data);
  201. countperline--;
  202. count--;
  203. }
  204. putchar('\n');
  205. }*/
  206. }
  207. void dcode_4()
  208. {
  209. LOG("D4 - Read/Write PIN\n");
  210. if (code_seen('P')) // Pin (0-255)
  211. {
  212. int pin = (int)code_value();
  213. if ((pin >= 0) && (pin <= 255))
  214. {
  215. if (code_seen('F')) // Function in/out (0/1)
  216. {
  217. int fnc = (int)code_value();
  218. if (fnc == 0) pinMode(pin, INPUT);
  219. else if (fnc == 1) pinMode(pin, OUTPUT);
  220. }
  221. if (code_seen('V')) // Value (0/1)
  222. {
  223. int val = (int)code_value();
  224. if (val == 0) digitalWrite(pin, LOW);
  225. else if (val == 1) digitalWrite(pin, HIGH);
  226. }
  227. else
  228. {
  229. int val = (digitalRead(pin) != LOW)?1:0;
  230. printf("PIN%d=%d", pin, val);
  231. }
  232. }
  233. }
  234. }
  235. /*
  236. void dcode_5()
  237. {
  238. LOG("D5 - Read/Write FLASH\n");
  239. uint32_t address = 0x0000; //default 0x0000
  240. uint16_t count = 0x0400; //default 0x0400 (1kb block)
  241. if (code_seen('A')) // Address (0x00000-0x3ffff)
  242. address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
  243. if (code_seen('C')) // Count (0x0001-0x2000)
  244. count = (int)code_value();
  245. address &= 0x3ffff;
  246. if (count > 0x2000) count = 0x2000;
  247. if ((address + count) > 0x40000) count = 0x40000 - address;
  248. bool bErase = false;
  249. bool bCopy = false;
  250. if (code_seen('E')) //Erase
  251. bErase = true;
  252. uint8_t data[16];
  253. if (code_seen('X')) // Data
  254. {
  255. count = parse_hex(strchr_pointer + 1, data, 16);
  256. if (count > 0) bCopy = true;
  257. }
  258. if (bErase || bCopy)
  259. {
  260. if (bErase)
  261. {
  262. LOG(count, DEC);
  263. LOG(" bytes of FLASH at address ");
  264. print_hex_word(address);
  265. putchar(" will be erased\n");
  266. }
  267. if (bCopy)
  268. {
  269. LOG(count, DEC);
  270. LOG(" bytes will be written to FLASH at address ");
  271. print_hex_word(address);
  272. putchar('\n');
  273. }
  274. cli();
  275. boot_app_magic = 0x55aa55aa;
  276. boot_app_flags = (bErase?(BOOT_APP_FLG_ERASE):0) | (bCopy?(BOOT_APP_FLG_COPY):0);
  277. boot_copy_size = (uint16_t)count;
  278. boot_dst_addr = (uint32_t)address;
  279. boot_src_addr = (uint32_t)(&data);
  280. wdt_enable(WDTO_15MS);
  281. while(1);
  282. }
  283. while (count)
  284. {
  285. print_hex_nibble(address >> 16);
  286. print_hex_word(address);
  287. putchar(' ');
  288. uint8_t countperline = 16;
  289. while (count && countperline)
  290. {
  291. uint8_t data = pgm_read_byte_far((uint8_t*)address++);
  292. putchar(' ');
  293. print_hex_byte(data);
  294. countperline--;
  295. count--;
  296. }
  297. putchar('\n');
  298. }
  299. }
  300. */
  301. void dcode_6()
  302. {
  303. LOG("D6 - Read/Write external FLASH\n");
  304. }
  305. void dcode_7()
  306. {
  307. LOG("D7 - Read/Write Bootloader\n");
  308. /*
  309. cli();
  310. boot_app_magic = 0x55aa55aa;
  311. boot_app_flags = BOOT_APP_FLG_ERASE | BOOT_APP_FLG_COPY | BOOT_APP_FLG_FLASH;
  312. boot_copy_size = (uint16_t)0xc00;
  313. boot_src_addr = (uint32_t)0x0003e400;
  314. boot_dst_addr = (uint32_t)0x0003f400;
  315. wdt_enable(WDTO_15MS);
  316. while(1);
  317. */
  318. }
  319. void dcode_8()
  320. {
  321. printf_P(PSTR("D8 - Read/Write PINDA\n"));
  322. uint8_t cal_status = calibration_status_pinda();
  323. float temp_pinda = current_temperature_pinda;
  324. float offset_z = temp_compensation_pinda_thermistor_offset(temp_pinda);
  325. if ((strchr_pointer[1+1] == '?') || (strchr_pointer[1+1] == 0))
  326. {
  327. printf_P(PSTR("cal_status=%d\n"), cal_status?1:0);
  328. for (uint8_t i = 0; i < 6; i++)
  329. {
  330. uint16_t offs = 0;
  331. if (i > 0) offs = eeprom_read_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + (i - 1));
  332. float foffs = ((float)offs) / axis_steps_per_unit[Z_AXIS];
  333. offs = 1000 * foffs;
  334. printf_P(PSTR("temp_pinda=%dC temp_shift=%dum\n"), 35 + i * 5, offs);
  335. }
  336. }
  337. else if (strchr_pointer[1+1] == '!')
  338. {
  339. cal_status = 1;
  340. eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, cal_status);
  341. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 8); //40C - 20um - 8usteps
  342. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 24); //45C - 60um - 24usteps
  343. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 48); //50C - 120um - 48usteps
  344. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 80); //55C - 200um - 80usteps
  345. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 120); //60C - 300um - 120usteps
  346. }
  347. else
  348. {
  349. if (code_seen('P')) // Pinda temperature [C]
  350. temp_pinda = code_value();
  351. offset_z = temp_compensation_pinda_thermistor_offset(temp_pinda);
  352. if (code_seen('Z')) // Z Offset [mm]
  353. {
  354. offset_z = code_value();
  355. }
  356. }
  357. printf_P(PSTR("temp_pinda=%d offset_z=%d.%03d\n"), (int)temp_pinda, (int)offset_z, ((int)(1000 * offset_z) % 1000));
  358. }
  359. const char* dcode_9_ADC_name(uint8_t i)
  360. {
  361. switch (i)
  362. {
  363. case 0: return PSTR("TEMP_HEATER0");
  364. case 1: return PSTR("TEMP_HEATER1");
  365. case 2: return PSTR("TEMP_BED");
  366. case 3: return PSTR("TEMP_PINDA");
  367. case 4: return PSTR("VOLT_PWR");
  368. case 5: return PSTR("TEMP_AMBIENT");
  369. case 6: return PSTR("VOLT_BED");
  370. }
  371. return 0;
  372. }
  373. extern int current_temperature_raw[EXTRUDERS];
  374. extern int current_temperature_bed_raw;
  375. extern int current_temperature_raw_pinda;
  376. #ifdef AMBIENT_THERMISTOR
  377. extern int current_temperature_raw_ambient;
  378. #endif //AMBIENT_THERMISTOR
  379. #ifdef VOLT_PWR_PIN
  380. extern int current_voltage_raw_pwr;
  381. #endif //VOLT_PWR_PIN
  382. #ifdef VOLT_BED_PIN
  383. extern int current_voltage_raw_bed;
  384. #endif //VOLT_BED_PIN
  385. uint16_t dcode_9_ADC_val(uint8_t i)
  386. {
  387. switch (i)
  388. {
  389. case 0: return current_temperature_raw[0];
  390. case 1: return 0;
  391. case 2: return current_temperature_bed_raw;
  392. case 3: return current_temperature_raw_pinda;
  393. #ifdef VOLT_PWR_PIN
  394. case 4: return current_voltage_raw_pwr;
  395. #endif //VOLT_PWR_PIN
  396. #ifdef AMBIENT_THERMISTOR
  397. case 5: return current_temperature_raw_ambient;
  398. #endif //AMBIENT_THERMISTOR
  399. #ifdef VOLT_BED_PIN
  400. case 6: return current_voltage_raw_bed;
  401. #endif //VOLT_BED_PIN
  402. }
  403. return 0;
  404. }
  405. void dcode_9()
  406. {
  407. printf_P(PSTR("D9 - Read/Write ADC\n"));
  408. if ((strchr_pointer[1+1] == '?') || (strchr_pointer[1+1] == 0))
  409. {
  410. for (uint8_t i = 0; i < ADC_CHAN_CNT; i++)
  411. printf_P(PSTR("\tADC%d=%4d\t(%S)\n"), i, dcode_9_ADC_val(i) >> 4, dcode_9_ADC_name(i));
  412. }
  413. else
  414. {
  415. uint8_t index = 0xff;
  416. if (code_seen('I')) // index (index of used channel, not avr channel index)
  417. index = code_value();
  418. if (index < ADC_CHAN_CNT)
  419. {
  420. if (code_seen('V')) // value to be written as simulated
  421. {
  422. adc_sim_mask |= (1 << index);
  423. adc_values[index] = (((int)code_value()) << 4);
  424. printf_P(PSTR("ADC%d=%4d\n"), index, adc_values[index] >> 4);
  425. }
  426. }
  427. }
  428. }
  429. void dcode_10()
  430. {//Tell the printer that XYZ calibration went OK
  431. LOG("D10 - XYZ calibration = OK\n");
  432. calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
  433. }
  434. void dcode_12()
  435. {//Time
  436. LOG("D12 - Time\n");
  437. }
  438. #ifdef TMC2130
  439. #include "planner.h"
  440. #include "tmc2130.h"
  441. extern void st_synchronize();
  442. /**
  443. * @brief D2130 Trinamic stepper controller
  444. * D2130<axis><command>[subcommand][value]
  445. * * Axis
  446. * * * 'X'
  447. * * * 'Y'
  448. * * * 'Z'
  449. * * * 'E'
  450. * * command
  451. * * * '0' current off
  452. * * * '1' current on
  453. * * * '+' single step
  454. * * * * value sereval steps
  455. * * * '-' dtto oposite direction
  456. * * * '?' read register
  457. * * * * "mres"
  458. * * * * "step"
  459. * * * * "mscnt"
  460. * * * * "mscuract"
  461. * * * * "wave"
  462. * * * '!' set register
  463. * * * * "mres"
  464. * * * * "step"
  465. * * * * "wave"
  466. * * * * *0, 180..250 meaning: off, 0.9..1.25, recommended value is 1.1
  467. * * * '@' home calibrate axis
  468. *
  469. * Example:
  470. * D2130E?wave //print extruder microstep linearity compensation curve
  471. * D2130E!wave0 //disable extruder linearity compensation curve, (sine curve is used)
  472. * D2130E!wave220 // (sin(x))^1.1 extruder microstep compensation curve used
  473. */
  474. void dcode_2130()
  475. {
  476. printf_P(PSTR("D2130 - TMC2130\n"));
  477. uint8_t axis = 0xff;
  478. switch (strchr_pointer[1+4])
  479. {
  480. case 'X': axis = X_AXIS; break;
  481. case 'Y': axis = Y_AXIS; break;
  482. case 'Z': axis = Z_AXIS; break;
  483. case 'E': axis = E_AXIS; break;
  484. }
  485. if (axis != 0xff)
  486. {
  487. char ch_axis = strchr_pointer[1+4];
  488. if (strchr_pointer[1+5] == '0') { tmc2130_set_pwr(axis, 0); }
  489. else if (strchr_pointer[1+5] == '1') { tmc2130_set_pwr(axis, 1); }
  490. else if (strchr_pointer[1+5] == '+')
  491. {
  492. if (strchr_pointer[1+6] == 0)
  493. {
  494. tmc2130_set_dir(axis, 0);
  495. tmc2130_do_step(axis);
  496. }
  497. else
  498. {
  499. uint8_t steps = atoi(strchr_pointer + 1 + 6);
  500. tmc2130_do_steps(axis, steps, 0, 1000);
  501. }
  502. }
  503. else if (strchr_pointer[1+5] == '-')
  504. {
  505. if (strchr_pointer[1+6] == 0)
  506. {
  507. tmc2130_set_dir(axis, 1);
  508. tmc2130_do_step(axis);
  509. }
  510. else
  511. {
  512. uint8_t steps = atoi(strchr_pointer + 1 + 6);
  513. tmc2130_do_steps(axis, steps, 1, 1000);
  514. }
  515. }
  516. else if (strchr_pointer[1+5] == '?')
  517. {
  518. if (strcmp(strchr_pointer + 7, "mres") == 0) printf_P(PSTR("%c mres=%d\n"), ch_axis, tmc2130_mres[axis]);
  519. else if (strcmp(strchr_pointer + 7, "step") == 0) printf_P(PSTR("%c step=%d\n"), ch_axis, tmc2130_rd_MSCNT(axis) >> tmc2130_mres[axis]);
  520. else if (strcmp(strchr_pointer + 7, "mscnt") == 0) printf_P(PSTR("%c MSCNT=%d\n"), ch_axis, tmc2130_rd_MSCNT(axis));
  521. else if (strcmp(strchr_pointer + 7, "mscuract") == 0)
  522. {
  523. uint32_t val = tmc2130_rd_MSCURACT(axis);
  524. int curA = (val & 0xff);
  525. int curB = ((val >> 16) & 0xff);
  526. if ((val << 7) & 0x8000) curA -= 256;
  527. if ((val >> 9) & 0x8000) curB -= 256;
  528. printf_P(PSTR("%c MSCURACT=0x%08lx A=%d B=%d\n"), ch_axis, val, curA, curB);
  529. }
  530. else if (strcmp(strchr_pointer + 7, "wave") == 0)
  531. {
  532. tmc2130_get_wave(axis, 0, stdout);
  533. }
  534. }
  535. else if (strchr_pointer[1+5] == '!')
  536. {
  537. if (strncmp(strchr_pointer + 7, "step", 4) == 0)
  538. {
  539. uint8_t step = atoi(strchr_pointer + 11);
  540. uint16_t res = tmc2130_get_res(axis);
  541. tmc2130_goto_step(axis, step & (4*res - 1), 2, 1000, res);
  542. }
  543. else if (strncmp(strchr_pointer + 7, "mres", 4) == 0)
  544. {
  545. uint8_t mres = strchr_pointer[11] - '0';
  546. if ((mres >= 0) && (mres <= 8))
  547. {
  548. st_synchronize();
  549. uint16_t res = tmc2130_get_res(axis);
  550. uint16_t res_new = tmc2130_mres2usteps(mres);
  551. tmc2130_set_res(axis, res_new);
  552. if (res_new > res)
  553. axis_steps_per_unit[axis] *= (res_new / res);
  554. else
  555. axis_steps_per_unit[axis] /= (res / res_new);
  556. }
  557. }
  558. else if (strncmp(strchr_pointer + 7, "wave", 4) == 0)
  559. {
  560. uint8_t fac1000 = atoi(strchr_pointer + 11) & 0xffff;
  561. if (fac1000 < TMC2130_WAVE_FAC1000_MIN) fac1000 = 0;
  562. if (fac1000 > TMC2130_WAVE_FAC1000_MAX) fac1000 = TMC2130_WAVE_FAC1000_MAX;
  563. tmc2130_set_wave(axis, 247, fac1000);
  564. tmc2130_wave_fac[axis] = fac1000;
  565. }
  566. }
  567. else if (strchr_pointer[1+5] == '@')
  568. {
  569. tmc2130_home_calibrate(axis);
  570. }
  571. }
  572. }
  573. #endif //TMC2130
  574. #ifdef PAT9125
  575. void dcode_9125()
  576. {
  577. LOG("D9125 - PAT9125\n");
  578. if ((strchr_pointer[1+4] == '?') || (strchr_pointer[1+4] == 0))
  579. {
  580. // printf("res_x=%d res_y=%d x=%d y=%d b=%d s=%d\n", pat9125_xres, pat9125_yres, pat9125_x, pat9125_y, pat9125_b, pat9125_s);
  581. printf("x=%d y=%d b=%d s=%d\n", pat9125_x, pat9125_y, pat9125_b, pat9125_s);
  582. return;
  583. }
  584. if (strchr_pointer[1+4] == '!')
  585. {
  586. pat9125_update();
  587. printf("x=%d y=%d b=%d s=%d\n", pat9125_x, pat9125_y, pat9125_b, pat9125_s);
  588. return;
  589. }
  590. /*
  591. if (code_seen('R'))
  592. {
  593. unsigned char res = (int)code_value();
  594. LOG("pat9125_init(xres=yres=%d)=%d\n", res, pat9125_init(res, res));
  595. }
  596. */
  597. if (code_seen('X'))
  598. {
  599. pat9125_x = (int)code_value();
  600. LOG("pat9125_x=%d\n", pat9125_x);
  601. }
  602. if (code_seen('Y'))
  603. {
  604. pat9125_y = (int)code_value();
  605. LOG("pat9125_y=%d\n", pat9125_y);
  606. }
  607. if (code_seen('L'))
  608. {
  609. fsensor_log = (int)code_value();
  610. LOG("fsensor_log=%d\n", fsensor_log);
  611. }
  612. }
  613. #endif //PAT9125
  614. #endif //DEBUG_DCODES