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.
touch.h
00001 /* 00002 Touchpad driver. 00003 00004 CPV, 3/9/2009 00005 */ 00006 00007 #ifndef __TOUCHPAD_H__ 00008 #define __TOUCHPAD_H__ 00009 00010 00011 #include "mbed.h" 00012 #include "filters.h" 00013 00014 00015 class TouchpadChannel 00016 { 00017 public: 00018 void initialise(int min, int quantise_step); 00019 void tick(int v) { m_filter.tick(v); } 00020 int quantise(void); 00021 int operator()(void) { return m_quantised; } 00022 int get_raw(void) { return m_filter(); } 00023 00024 protected: 00025 FilterBoxI m_filter; 00026 int m_min; 00027 int m_quantise_step; 00028 int m_quantised; 00029 }; 00030 00031 00032 class Touchpad 00033 { 00034 public: 00035 Touchpad(PinName x0, PinName x1, PinName y0, PinName y1); 00036 00037 void tick(void); 00038 00039 int get_raw_x(void) { return m_ch_x.get_raw(); } 00040 int get_raw_y(void) { return m_ch_y.get_raw(); } 00041 00042 int hotspot(void) { return (m_ch_x.quantise()>=0 && m_ch_y.quantise()>=0); } 00043 int get_hotspot_x(void) { return m_ch_x(); } 00044 int get_hotspot_y(void) { return m_ch_y(); } 00045 00046 protected: 00047 TouchpadChannel m_ch_x; 00048 TouchpadChannel m_ch_y; 00049 00050 PinName m_x0; 00051 PinName m_x1; 00052 PinName m_y0; 00053 PinName m_y1; 00054 00055 int read(PinName drive_hi, PinName drive_lo, PinName read_hi, PinName read_lo); 00056 int read_x(void) { return read(m_x1,m_x0,m_y1,m_y0); } 00057 int read_y(void) { return read(m_y1,m_y0,m_x1,m_x0); } 00058 }; 00059 00060 00061 #endif // __TOUCHPAD_H__
Generated on Wed Jul 13 2022 15:02:52 by
1.7.2