la10compat.cpp 834 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "la10compat.h"
  2. #include "Marlin.h"
  3. static LA10C_MODE la10c_mode = LA10C_UNKNOWN;
  4. void la10c_mode_change(LA10C_MODE mode)
  5. {
  6. if(mode == la10c_mode) return;
  7. SERIAL_ECHOPGM("LA10C: Linear Advance mode: ");
  8. switch(mode)
  9. {
  10. case LA10C_UNKNOWN: SERIAL_ECHOLNPGM("UNKNOWN"); break;
  11. case LA10C_LA15: SERIAL_ECHOLNPGM("1.5"); break;
  12. case LA10C_LA10: SERIAL_ECHOLNPGM("1.0"); break;
  13. }
  14. la10c_mode = mode;
  15. }
  16. // Approximate a LA10 value to a LA15 equivalent.
  17. static float la10c_convert(float k)
  18. {
  19. float new_K = k * 0.004 - 0.06;
  20. return (new_K < 0? 0: new_K);
  21. }
  22. float la10c_value(float k)
  23. {
  24. if(la10c_mode == LA10C_UNKNOWN)
  25. la10c_mode_change(k < 10? LA10C_LA15: LA10C_LA10);
  26. if(la10c_mode == LA10C_LA15)
  27. return k;
  28. else
  29. return la10c_convert(k);
  30. }