My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rotary_encoder.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /*****************************************************************************
  24. * @file rotary_encoder.h
  25. * @author LEO / Creality3D
  26. * @date 2019/07/06
  27. * @version 2.0.1
  28. * @brief Rotary encoder functions
  29. ****************************************************************************/
  30. #include "../../../inc/MarlinConfig.h"
  31. #include "../../../MarlinCore.h"
  32. /*********************** Encoder Set ***********************/
  33. typedef struct {
  34. bool enabled = false;
  35. int encoderMoveValue = 0;
  36. millis_t lastEncoderTime = 0;
  37. } ENCODER_Rate;
  38. extern ENCODER_Rate EncoderRate;
  39. typedef enum {
  40. ENCODER_DIFF_NO = 0, // no state
  41. ENCODER_DIFF_CW = 1, // clockwise rotation
  42. ENCODER_DIFF_CCW = 2, // counterclockwise rotation
  43. ENCODER_DIFF_ENTER = 3 // click
  44. } ENCODER_DiffState;
  45. // Encoder initialization
  46. void Encoder_Configuration();
  47. // Analyze encoder value and return state
  48. ENCODER_DiffState Encoder_ReceiveAnalyze();
  49. /*********************** Encoder LED ***********************/
  50. #if PIN_EXISTS(LCD_LED)
  51. #define LED_NUM 4
  52. #define LED_DATA_HIGH WRITE(LCD_LED_PIN, 1)
  53. #define LED_DATA_LOW WRITE(LCD_LED_PIN, 0)
  54. #define RGB_SCALE_R10_G7_B5 1
  55. #define RGB_SCALE_R10_G7_B4 2
  56. #define RGB_SCALE_R10_G8_B7 3
  57. #define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5
  58. #define RGB_SCALE_WARM_WHITE RGB_SCALE_R10_G7_B4
  59. #define RGB_SCALE_COOL_WHITE RGB_SCALE_R10_G8_B7
  60. extern unsigned int LED_DataArray[LED_NUM];
  61. // LED light operation
  62. void LED_Action();
  63. // LED initialization
  64. void LED_Configuration();
  65. // LED write data
  66. void LED_WriteData();
  67. // LED control
  68. // RGB_Scale: RGB color ratio
  69. // luminance: brightness (0~0xFF)
  70. void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance);
  71. // LED gradient control
  72. // RGB_Scale: RGB color ratio
  73. // luminance: brightness (0~0xFF)
  74. // change_Time: gradient time (ms)
  75. void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval);
  76. #endif // LCD_LED