Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ExioBufferedRotaryEncoder.h
00001 /** 00002 * ============================================================================= 00003 * Rotary Encoder class (Version 0.0.1) 00004 * ============================================================================= 00005 * Copyright (c) 2010 Shinichiro Nakamura (CuBeatSystems) 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a copy 00008 * of this software and associated documentation files (the "Software"), to deal 00009 * in the Software without restriction, including without limitation the rights 00010 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00011 * copies of the Software, and to permit persons to whom the Software is 00012 * furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included in 00015 * all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00018 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00020 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00021 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00022 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00023 * THE SOFTWARE. 00024 * ============================================================================= 00025 */ 00026 00027 /* 00028 * 2016.11.5 Customized for MCP23S17 Buffered Input by ryood 00029 */ 00030 00031 #ifndef EXIOBUFFEREDROTARY_ENCODER_H 00032 #define EXIOBUFFEREDROTARY_ENCODER_H 00033 00034 #include "mbed.h" 00035 #include "ExioBufferedIn.h" 00036 00037 /** 00038 */ 00039 class ExioBufferedRotaryEncoder 00040 { 00041 public: 00042 /** 00043 * Create rotary encoder. 00044 * @param buffer 00045 * @param pin1 00046 * @param pin2 00047 * @param min Minimum value. 00048 * @param max Maximum value. 00049 * @param val Default value. 00050 */ 00051 //RotaryEncoder(PinName pin1_name, PinName pin2_name, int min = 0, int max = 100, int val = 50); 00052 ExioBufferedRotaryEncoder( 00053 ExioInBuffer* buffer, int pin1, int pin2, int min = 0, int max = 100, int val = 50 00054 ); 00055 00056 /** 00057 * Dispose. 00058 */ 00059 ~ExioBufferedRotaryEncoder(); 00060 00061 /** 00062 * Get the minimum value. 00063 * 00064 * @return The minimum value. 00065 */ 00066 int getMin() const { 00067 return min; 00068 } 00069 00070 /** 00071 * Get the maximum value. 00072 * 00073 * @return The maximum value. 00074 */ 00075 int getMax() const { 00076 return max; 00077 } 00078 00079 /** 00080 * Get the value. 00081 * 00082 * @return The value. 00083 */ 00084 int getVal() const { 00085 return val; 00086 } 00087 00088 /** 00089 * Set the value. 00090 * 00091 * @param The value. 00092 */ 00093 void setVal(int _val) { 00094 if (min <= _val && _val <= max) { 00095 val = _val; 00096 } 00097 } 00098 00099 /** 00100 * Set the ticker interval. 00101 * 00102 * @param The interval in microseconds. 00103 */ 00104 void setInterval(timestamp_t t) { 00105 ticker.attach_us(this, &ExioBufferedRotaryEncoder::func_ticker, t); 00106 } 00107 00108 private: 00109 ExioBufferedIn* in1; 00110 ExioBufferedIn* in2; 00111 const int min; 00112 const int max; 00113 int val; 00114 Ticker ticker; 00115 00116 uint8_t code; 00117 00118 /** 00119 * Internal tick function. 00120 */ 00121 void func_ticker(); 00122 }; 00123 00124 #endif
Generated on Sat Jul 16 2022 02:09:56 by
1.7.2