This drive is working well with "LPD3806-600BM-G5-24G", and have Simple program, external pull-up resistance is required
注意:需要外置上拉电阻。
Rotary_Encoder.h
- Committer:
- Yifan_Du
- Date:
- 2019-02-08
- Revision:
- 2:7d34758c3cc4
- Parent:
- 0:b2ffb830539c
File content as of revision 2:7d34758c3cc4:
/* Copyright (c) 2019 Yifan DU Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1.0 2-Feb.-2019 - Initial release. ***************************************************************** Attention: This drive is working well with "LPD3806-600GM-G5-24G' ***************************************************************** @code #include "mbed.h" #include "Rotary_Encoder.h" Rotary_Encoder Encoder(PA_0, PA_1); int main(void) { while(1) { printf("Direction: %s\r\n", Encoder.Calculate_Direction()); printf("\r\n"); wait(0.2); } } @endcode ***************************************************************** */ #ifndef _ROTARY_ENCODER_H_ #define _ROTARY_ENCODER_H_ #include "mbed.h" class Rotary_Encoder { private: char Direction[5]; int Encoder_Counter; InterruptIn Green_Pin, White_Pin; public: Rotary_Encoder(PinName White, PinName Green); // @Param White The pin whitch is connected to the encoder white line. // @Param Green The pin whitch is connected to the encoder green line. void Green_Pin_Rise(void); // Change 'Encoder_Direction' when detecting voltage in 'Green Pin' from LOW to HIGH. void White_Pin_Rise(void); // Change 'Encoder_Direction' when detecting voltage in 'White Pin' from LOW to HIGH. char *Calculate_Direction(void); // Return Direciton. }; #endif