Advertisement
Guest User

events.h

a guest
Oct 15th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. #ifndef EVENTS_H_INCLUDED
  2. #define EVENTS_H_INCLUDED
  3.  
  4. /*
  5. Event system in a nutshell:
  6.  
  7. All printers are different and my need additions in th eone or other place.
  8. It is not very convenient to add these code parts across the firmware. For this
  9. reason repetier-firmware uses a simple event system that comes at no cost if
  10. a event is not used.
  11.  
  12. - simple: Only one subscriber is possible
  13. - cost effective: Macros work as event caller. By default all macros are empty
  14.  
  15. How to use the system:
  16.  
  17. 1. In Configuration.h add
  18. #define CUSTOM_EVENTS
  19. 2. Add a file "CustomEvents.h" which overrides all event macros you need.
  20. It shoudl also include the function declarations used.
  21. 3. Add a file "CustomEventsImpl.h" which includes all function definitions.
  22. Also it is named .h it will be included inside a cpp file only once.
  23. This is to compile only when selected and still keep ArduinoIDE happy.
  24.  
  25. Each of the following events describe the parameter and when it is called.
  26. */
  27.  
  28. // Catch heating events. id is extruder id or -1 for heated bed.
  29. #define EVENT_WAITING_HEATER(id) {}
  30. #define EVENT_HEATING_FINISHED(id) {}
  31.  
  32. // This gets called every 0.1 second
  33. #define EVENT_TIMER_100MS {}
  34. // This gets called every 0.5 second
  35. #define EVENT_TIMER_500MS {}
  36. // Gets called on a regular basis as time allows
  37. #define EVENT_PERIODICAL {}
  38. // Gets called when kill gets called. only_steppes = true -> we only want to disable steppers, not everything.
  39. #define EVENT_KILL(only_steppers) {}
  40. // Gets called when a jam was detected.
  41. #define EVENT_JAM_DETECTED {}
  42. // Gets called every time the jam detection signal switches. Steps are the extruder steps since last change.
  43. #define EVENT_JAM_SIGNAL_CHANGED(extruderId,steps) {}
  44. // Gets called if a heater decoupling is detected.
  45. #define EVENT_HEATER_DECOUPLED(id) {}
  46. // Gets called if a missing/shorted thermistor is detected.
  47. #define EVENT_HEATER_DEFECT(id) {}
  48. // Gets called if a action in ui.cpp okAction gets executed.
  49. #define EVENT_START_UI_ACTION(shortAction) {}
  50. // Gets called if a nextPrevius actions gets executed.
  51. #define EVENT_START_NEXTPREVIOUS(action,increment) {}
  52. // Gets called before a move is queued. Gives the ability to limit moves.
  53. #define EVENT_CONTRAIN_DESTINATION_COORDINATES
  54. // Gets called when a fatal error occurs and all actions should be stopped
  55. #define EVENT_FATAL_ERROR_OCCURED
  56. // Gets called after a M999 to continue from fatal errors
  57. #define EVENT_CONTINUE_FROM_FATAL_ERROR
  58.  
  59. // Called to initialize laser pins. Return false to prevent default initialization.
  60. #define EVENT_INITALIZE_LASER true
  61. // Set laser to intensity level 0 = off, 255 = full. Return false if you have overridden the setting routine.
  62. // with true the default solution will set it as digital value.
  63. #define EVENT_SET_LASER(intensity) true
  64.  
  65. // Called to initialize CNC pins. Return false to prevent default initialization.
  66. #define EVENT_INITALIZE_CNC true
  67. // Turn off spindle
  68. #define EVENT_SPINDLE_OFF true
  69. // Turn spindle clockwise
  70. #define EVENT_SPINDLE_CW(rpm) true
  71. // Turn spindle counter clockwise
  72. #define EVENT_SPINDLE_CCW(rpm) true
  73.  
  74. // Allow adding new G and M codes. To implement it create a function
  75. // bool eventUnhandledGCode(GCode *com)
  76. // that returns true if it handled the code, otherwise false.
  77. // Event define would then be
  78. // #define EVENT_UNHANDLED_G_CODE(c) eventUnhandledGCode(c)
  79. #define EVENT_UNHANDLED_G_CODE(c) false
  80. #define EVENT_UNHANDLED_M_CODE(c) false
  81.  
  82. // This gets called every time the user has saved a value to eeprom
  83. // or any other reason why dependent values may need recomputation.
  84. #define EVENT_UPDATE_DERIVED {}
  85.  
  86. // This gets called after the basic firmware functions have initialized.
  87. // Use this to initalize your hardware etc.
  88. #define EVENT_INITIALIZE {}
  89.  
  90. #endif // EVENTS_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement