util.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #pragma once
  2. #include <stdint.h>
  3. extern const char* FW_VERSION_STR_P();
  4. // Definition of a firmware flavor numerical values.
  5. // To keep it short as possible
  6. // DEVs/ALPHAs/BETAs limited to max 8 flavor versions
  7. // RCs limited to 32 flavor versions
  8. // Final Release always 64 as highest
  9. enum FirmwareRevisionFlavorType : uint16_t {
  10. FIRMWARE_REVISION_RELEASED = 0x0040,
  11. FIRMWARE_REVISION_DEV = 0x0000,
  12. FIRMWARE_REVISION_ALPHA = 0x008,
  13. FIRMWARE_REVISION_BETA = 0x0010,
  14. FIRMWARE_REVISION_RC = 0x0020
  15. };
  16. bool show_upgrade_dialog_if_version_newer(const char *version_string);
  17. bool eeprom_fw_version_older_than(const uint16_t (&req_ver)[4]);
  18. void update_current_firmware_version_to_eeprom();
  19. //-//
  20. #define EEPROM_NOZZLE_DIAMETER_uM_DEFAULT 400
  21. enum class ClPrintChecking:uint_least8_t
  22. {
  23. _Nozzle=1,
  24. _Model=2,
  25. _Smodel=3,
  26. _Version=4,
  27. _Gcode=5
  28. };
  29. enum class ClNozzleDiameter:uint_least8_t
  30. {
  31. _Diameter_250=25,
  32. _Diameter_400=40,
  33. _Diameter_600=60,
  34. _Diameter_800=80,
  35. _Diameter_Undef=EEPROM_EMPTY_VALUE
  36. };
  37. enum class ClCheckMode:uint_least8_t
  38. {
  39. _None,
  40. _Warn,
  41. _Strict,
  42. _Undef=EEPROM_EMPTY_VALUE
  43. };
  44. enum class ClCheckModel:uint_least8_t
  45. {
  46. _None,
  47. _Warn,
  48. _Strict,
  49. _Undef=EEPROM_EMPTY_VALUE
  50. };
  51. enum class ClCheckVersion:uint_least8_t
  52. {
  53. _None,
  54. _Warn,
  55. _Strict,
  56. _Undef=EEPROM_EMPTY_VALUE
  57. };
  58. enum class ClCheckGcode:uint_least8_t
  59. {
  60. _None,
  61. _Warn,
  62. _Strict,
  63. _Undef=EEPROM_EMPTY_VALUE
  64. };
  65. #define COMPARE_VALUE_EQUAL (((uint8_t)ClCompareValue::_Equal<<6)+((uint8_t)ClCompareValue::_Equal<<4)+((uint8_t)ClCompareValue::_Equal<<2)+((uint8_t)ClCompareValue::_Equal))
  66. enum class ClCompareValue:uint_least8_t
  67. {
  68. _Less=0,
  69. _Equal=1,
  70. _Greater=2
  71. };
  72. extern ClNozzleDiameter oNozzleDiameter;
  73. extern ClCheckMode oCheckMode;
  74. extern ClCheckModel oCheckModel;
  75. extern ClCheckVersion oCheckVersion;
  76. extern ClCheckGcode oCheckGcode;
  77. void fCheckModeInit();
  78. void nozzle_diameter_check(uint16_t nDiameter);
  79. void printer_model_check(uint16_t nPrinterModel, uint16_t actualPrinterModel);
  80. void printer_smodel_check(const char *pStrPos, const char *actualPrinterSModel);
  81. void fw_version_check(const char *pVersion);
  82. void gcode_level_check(uint16_t nGcodeLevel);
  83. uint16_t nPrinterType(bool bMMu);
  84. const char *sPrinterType(bool bMMu);
  85. #define IP4_STR_SIZE 16
  86. extern void ip4_to_str(char* dest, uint8_t* IP);
  87. // Calibration status of the machine
  88. // (unsigned char*)EEPROM_CALIBRATION_STATUS_V2
  89. typedef uint8_t CalibrationStatus;
  90. const CalibrationStatus CALIBRATION_STATUS_SELFTEST = 0b00000001; // Selftest
  91. const CalibrationStatus CALIBRATION_STATUS_XYZ = 0b00000010; // XYZ calibration
  92. const CalibrationStatus CALIBRATION_STATUS_Z = 0b00000100; // Z calibration
  93. #ifdef TEMP_MODEL
  94. const CalibrationStatus CALIBRATION_STATUS_TEMP_MODEL = 0b00001000; // Temperature model calibration
  95. #endif
  96. const CalibrationStatus CALIBRATION_STATUS_LIVE_ADJUST = 0b00010000; // 1st layer calibration
  97. const CalibrationStatus CALIBRATION_STATUS_UNKNOWN = 0b10000000; // Freshly assembled or unknown status
  98. // Calibration steps performed by the wizard
  99. const CalibrationStatus CALIBRATION_WIZARD_STEPS =
  100. CALIBRATION_STATUS_SELFTEST |
  101. CALIBRATION_STATUS_XYZ |
  102. CALIBRATION_STATUS_Z |
  103. #ifdef TEMP_MODEL
  104. CALIBRATION_STATUS_TEMP_MODEL |
  105. #endif
  106. CALIBRATION_STATUS_LIVE_ADJUST;
  107. // Calibration steps enforced after service prep
  108. const CalibrationStatus CALIBRATION_FORCE_PREP = CALIBRATION_STATUS_Z;
  109. bool calibration_status_get(CalibrationStatus components);
  110. void calibration_status_set(CalibrationStatus components);
  111. void calibration_status_clear(CalibrationStatus components);
  112. // PINDA has an independent calibration flag
  113. inline bool calibration_status_pinda() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA); }