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.
counter.h
00001 #ifndef counter_H 00002 #define counter_H 00003 00004 /** 00005 * Includes 00006 */ 00007 #include "mbed.h" 00008 00009 /** 00010 * Simple counter 00011 */ 00012 class counter { 00013 00014 public: 00015 00016 00017 /** 00018 * Constructor. 00019 * 00020 * Attaches the encode function to the rise edge of 00021 * channel A. 00022 * 00023 * @param channelA mbed pin for counter input. 00024 */ 00025 counter(PinName channelA); 00026 00027 /** 00028 * Reset the encoder. 00029 * 00030 * Sets the pulses to zero. 00031 */ 00032 void reset(void); 00033 00034 /** 00035 * Read the number of pulses recorded by the encoder. 00036 * 00037 * @return Number of pulses which have occured. 00038 */ 00039 int getPulses(void); 00040 00041 private: 00042 00043 /** 00044 * Update the pulse count. 00045 * 00046 * Called on every rising edge of channels A. 00047 * 00048 */ 00049 void encode(void); 00050 00051 InterruptIn channelA_; 00052 00053 volatile int pulses_; 00054 00055 }; 00056 00057 #endif /* counter_H */
Generated on Mon Jul 18 2022 02:03:22 by
1.7.2