util.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_800=80,
  43. _Diameter_Undef=EEPROM_EMPTY_VALUE
  44. };
  45. enum class ClCheckMode:uint_least8_t
  46. {
  47. _None,
  48. _Warn,
  49. _Strict,
  50. _Undef=EEPROM_EMPTY_VALUE
  51. };
  52. enum class ClCheckModel:uint_least8_t
  53. {
  54. _None,
  55. _Warn,
  56. _Strict,
  57. _Undef=EEPROM_EMPTY_VALUE
  58. };
  59. enum class ClCheckVersion:uint_least8_t
  60. {
  61. _None,
  62. _Warn,
  63. _Strict,
  64. _Undef=EEPROM_EMPTY_VALUE
  65. };
  66. enum class ClCheckGcode:uint_least8_t
  67. {
  68. _None,
  69. _Warn,
  70. _Strict,
  71. _Undef=EEPROM_EMPTY_VALUE
  72. };
  73. #define COMPARE_VALUE_EQUAL (((uint8_t)ClCompareValue::_Equal<<6)+((uint8_t)ClCompareValue::_Equal<<4)+((uint8_t)ClCompareValue::_Equal<<2)+((uint8_t)ClCompareValue::_Equal))
  74. enum class ClCompareValue:uint_least8_t
  75. {
  76. _Less=0,
  77. _Equal=1,
  78. _Greater=2
  79. };
  80. extern ClNozzleDiameter oNozzleDiameter;
  81. extern ClCheckMode oCheckMode;
  82. extern ClCheckModel oCheckModel;
  83. extern ClCheckVersion oCheckVersion;
  84. extern ClCheckGcode oCheckGcode;
  85. void fCheckModeInit();
  86. void nozzle_diameter_check(uint16_t nDiameter);
  87. void printer_model_check(uint16_t nPrinterModel);
  88. void printer_smodel_check(const char* pStrPos);
  89. void fw_version_check(const char *pVersion);
  90. void gcode_level_check(uint16_t nGcodeLevel);
  91. void fSetMmuMode(bool bMMu);
  92. #define IP4_STR_SIZE 16
  93. extern void ip4_to_str(char* dest, uint8_t* IP);
  94. #endif /* UTIL_H */