util.h 3.8 KB

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