My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

rotary_encoder.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. ******************************************************************************
  25. * @file rotary_encoder.h
  26. * @author LEO / Creality3D
  27. * @date 2019/07/06
  28. * @version 2.0.1
  29. * @brief 旋转编码器操作函数
  30. ******************************************************************************
  31. **/
  32. #include "../../inc/MarlinConfig.h"
  33. #include "../../MarlinCore.h"
  34. /*********************** Encoder Set ***********************/
  35. #define ENCODER_PHASE_0 0
  36. #define ENCODER_PHASE_1 2
  37. #define ENCODER_PHASE_2 3
  38. #define ENCODER_PHASE_3 1
  39. #define ENCODER_PULSES_PER_STEP 4
  40. #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
  41. typedef struct {
  42. bool encoderRateEnabled = 0;
  43. int encoderMoveValue = 0;
  44. millis_t lastEncoderTime = 0;
  45. } ENCODER_Rate;
  46. extern ENCODER_Rate EncoderRate;
  47. typedef enum {
  48. ENCODER_DIFF_NO = 0,
  49. ENCODER_DIFF_CW = 1,
  50. ENCODER_DIFF_CCW = 2,
  51. ENCODER_DIFF_ENTER = 3
  52. } ENCODER_DiffState;
  53. /*编码器初始化 PB12:Encoder_A PB13:Encoder_B PB14:Encoder_C*/
  54. void Encoder_Configuration(void);
  55. /*接收数据解析 返回值:ENCODER_DIFF_NO,无状态; ENCODER_DIFF_CW,顺时针旋转; ENCODER_DIFF_CCW,逆时针旋转; ENCODER_DIFF_ENTER,按下*/
  56. ENCODER_DiffState Encoder_ReceiveAnalyze(void);
  57. /*********************** Encoder LED ***********************/
  58. #if PIN_EXISTS(LCD_LED)
  59. #define LED_NUM 4
  60. #define LED_DATA_HIGH WRITE(LCD_LED_PIN, 1)
  61. #define LED_DATA_LOW WRITE(LCD_LED_PIN, 0)
  62. #define RGB_SCALE_R10_G7_B5 1
  63. #define RGB_SCALE_R10_G7_B4 2
  64. #define RGB_SCALE_R10_G8_B7 3
  65. #define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5 //正白
  66. #define RGB_SCALE_WARM_WHITE RGB_SCALE_R10_G7_B4 //暖白
  67. #define RGB_SCALE_COOL_WHITE RGB_SCALE_R10_G8_B7 //冷白
  68. extern unsigned int LED_DataArray[LED_NUM];
  69. /*状态LED初始化*/
  70. void STATE_LED_Configuration(void);
  71. /*LED灯操作*/
  72. void LED_Action(void);
  73. /*LED初始化*/
  74. void LED_Configuration(void);
  75. /*LED写数据*/
  76. void LED_WriteData(void);
  77. /*LED控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF)*/
  78. void LED_Control(unsigned char RGB_Scale, unsigned char luminance);
  79. /*LED渐变控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF) change_Time:渐变时间(ms)*/
  80. void LED_GraduallyControl(unsigned char RGB_Scale, unsigned char luminance, unsigned int change_Interval);
  81. #endif