Marlin_Firmware/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h

95 lines
2.8 KiB
C
Raw Normal View History

2020-06-16 01:45:27 -05:00
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2020-07-22 22:20:14 -05:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2020-06-16 01:45:27 -05:00
*
*/
#pragma once
2020-09-10 18:06:29 -05:00
/*****************************************************************************
2020-06-16 01:45:27 -05:00
* @file rotary_encoder.h
* @author LEO / Creality3D
* @date 2019/07/06
* @version 2.0.1
2020-09-10 18:06:29 -05:00
* @brief Rotary encoder functions
****************************************************************************/
2020-06-16 01:45:27 -05:00
2020-09-06 21:40:58 -05:00
#include "../../../inc/MarlinConfig.h"
2020-06-16 01:45:27 -05:00
/*********************** Encoder Set ***********************/
typedef struct {
bool enabled = false;
2020-06-16 01:45:27 -05:00
int encoderMoveValue = 0;
millis_t lastEncoderTime = 0;
} ENCODER_Rate;
extern ENCODER_Rate EncoderRate;
typedef enum {
2020-09-10 18:06:29 -05:00
ENCODER_DIFF_NO = 0, // no state
ENCODER_DIFF_CW = 1, // clockwise rotation
ENCODER_DIFF_CCW = 2, // counterclockwise rotation
ENCODER_DIFF_ENTER = 3 // click
2020-06-16 01:45:27 -05:00
} ENCODER_DiffState;
2020-09-10 18:06:29 -05:00
// Encoder initialization
2021-01-12 20:43:52 -06:00
void Encoder_Configuration();
2020-06-16 01:45:27 -05:00
2020-09-10 18:06:29 -05:00
// Analyze encoder value and return state
2021-01-12 20:43:52 -06:00
ENCODER_DiffState Encoder_ReceiveAnalyze();
2020-06-16 01:45:27 -05:00
/*********************** Encoder LED ***********************/
#if PIN_EXISTS(LCD_LED)
#define LED_NUM 4
#define LED_DATA_HIGH WRITE(LCD_LED_PIN, 1)
#define LED_DATA_LOW WRITE(LCD_LED_PIN, 0)
#define RGB_SCALE_R10_G7_B5 1
#define RGB_SCALE_R10_G7_B4 2
#define RGB_SCALE_R10_G8_B7 3
2020-09-10 18:06:29 -05:00
#define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5
#define RGB_SCALE_WARM_WHITE RGB_SCALE_R10_G7_B4
#define RGB_SCALE_COOL_WHITE RGB_SCALE_R10_G8_B7
2020-06-16 01:45:27 -05:00
extern unsigned int LED_DataArray[LED_NUM];
2020-09-10 18:06:29 -05:00
// LED light operation
2021-01-12 20:43:52 -06:00
void LED_Action();
2020-06-16 01:45:27 -05:00
2020-09-10 18:06:29 -05:00
// LED initialization
2021-01-12 20:43:52 -06:00
void LED_Configuration();
2020-06-16 01:45:27 -05:00
2020-09-10 18:06:29 -05:00
// LED write data
2021-01-12 20:43:52 -06:00
void LED_WriteData();
2020-06-16 01:45:27 -05:00
2020-09-10 18:06:29 -05:00
// LED control
// RGB_Scale: RGB color ratio
// luminance: brightness (0~0xFF)
2021-01-12 20:43:52 -06:00
void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance);
2020-06-16 01:45:27 -05:00
2020-09-10 18:06:29 -05:00
// LED gradient control
// RGB_Scale: RGB color ratio
// luminance: brightness (0~0xFF)
// change_Time: gradient time (ms)
2021-01-12 20:43:52 -06:00
void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval);
2020-06-16 01:45:27 -05:00
2020-09-10 18:06:29 -05:00
#endif // LCD_LED