util.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef UTIL_H
  2. #define UTIL_H
  3. extern const char* FW_VERSION_STR_P();
  4. // Definition of a firmware flavor numerical values.
  5. enum FirmwareRevisionFlavorType
  6. {
  7. FIRMWARE_REVISION_DEV = 0,
  8. FIRMWARE_REVISION_ALPHA = 1,
  9. FIRMWARE_REVISION_BETA = 2,
  10. FIRMWARE_REVISION_RC,
  11. FIRMWARE_REVISION_RC2,
  12. FIRMWARE_REVISION_RC3,
  13. FIRMWARE_REVISION_RC4,
  14. FIRMWARE_REVISION_RC5,
  15. FIRMWARE_REVISION_RELEASED = 127
  16. };
  17. extern bool show_upgrade_dialog_if_version_newer(const char *version_string);
  18. extern bool force_selftest_if_fw_version();
  19. extern void update_current_firmware_version_to_eeprom();
  20. inline int8_t eeprom_read_int8(unsigned char* addr) {
  21. uint8_t v = eeprom_read_byte(addr);
  22. return *reinterpret_cast<int8_t*>(&v);
  23. }
  24. inline void eeprom_update_int8(unsigned char* addr, int8_t v) {
  25. eeprom_update_byte(addr, *reinterpret_cast<uint8_t*>(&v));
  26. }
  27. //-//
  28. #define EEPROM_NOZZLE_DIAMETER_uM_DEFAULT 400
  29. enum class ClPrintChecking:uint_least8_t
  30. {
  31. _Nozzle=1,
  32. _Model=2,
  33. _Smodel=3,
  34. _Version=4,
  35. _Gcode=5
  36. };
  37. enum class ClNozzleDiameter:uint_least8_t
  38. {
  39. _Diameter_250=25,
  40. _Diameter_400=40,
  41. _Diameter_600=60,
  42. _Diameter_Undef=EEPROM_EMPTY_VALUE
  43. };
  44. enum class ClCheckMode:uint_least8_t
  45. {
  46. _None,
  47. _Warn,
  48. _Strict,
  49. _Undef=EEPROM_EMPTY_VALUE
  50. };
  51. enum class ClCheckModel:uint_least8_t
  52. {
  53. _None,
  54. _Warn,
  55. _Strict,
  56. _Undef=EEPROM_EMPTY_VALUE
  57. };
  58. enum class ClCheckVersion:uint_least8_t
  59. {
  60. _None,
  61. _Warn,
  62. _Strict,
  63. _Undef=EEPROM_EMPTY_VALUE
  64. };
  65. enum class ClCheckGcode:uint_least8_t
  66. {
  67. _None,
  68. _Warn,
  69. _Strict,
  70. _Undef=EEPROM_EMPTY_VALUE
  71. };
  72. #define COMPARE_VALUE_EQUAL (((uint8_t)ClCompareValue::_Equal<<6)+((uint8_t)ClCompareValue::_Equal<<4)+((uint8_t)ClCompareValue::_Equal<<2)+((uint8_t)ClCompareValue::_Equal))
  73. enum class ClCompareValue:uint_least8_t
  74. {
  75. _Less=0,
  76. _Equal=1,
  77. _Greater=2
  78. };
  79. extern ClNozzleDiameter oNozzleDiameter;
  80. extern ClCheckMode oCheckMode;
  81. extern ClCheckModel oCheckModel;
  82. extern ClCheckVersion oCheckVersion;
  83. extern ClCheckGcode oCheckGcode;
  84. void fCheckModeInit();
  85. void nozzle_diameter_check(uint16_t nDiameter);
  86. void printer_model_check(uint16_t nPrinterModel);
  87. void printer_smodel_check(char* pStrPos);
  88. void fw_version_check(const char *pVersion);
  89. void gcode_level_check(uint16_t nGcodeLevel);
  90. void fSetMmuMode(bool bMMu);
  91. #endif /* UTIL_H */