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.cpp
00001 /* 00002 Touchpad driver. 00003 00004 CPV, 3/9/2009 00005 */ 00006 00007 #include "touch.h" 00008 00009 00010 void TouchpadChannel::initialise(int min, int quantise_step) 00011 { 00012 m_min = min; 00013 m_quantise_step = quantise_step; 00014 m_filter.initialise(8); 00015 m_quantised = -1; 00016 } 00017 00018 00019 int TouchpadChannel::quantise(void) 00020 { 00021 m_quantised = -1; 00022 int raw = m_filter(); 00023 00024 if (raw>m_min) 00025 { 00026 m_quantised = 0; 00027 00028 while(raw>m_quantise_step) 00029 { 00030 raw -= m_quantise_step; 00031 m_quantised += 1; 00032 } 00033 } 00034 return m_quantised; 00035 } 00036 00037 00038 //=============================================== 00039 00040 00041 Touchpad::Touchpad(PinName x0, PinName x1, PinName y0, PinName y1) 00042 { 00043 m_x0 = x0; 00044 m_x1 = x1; 00045 m_y0 = y0; 00046 m_y1 = y1; 00047 m_ch_x.initialise(0.1*0xffff,0.16*0xffff); 00048 m_ch_y.initialise(0.1*0xffff,0.22*0xffff); 00049 } 00050 00051 00052 int Touchpad::read(PinName drive_hi, PinName drive_lo, PinName read_hi, PinName read_lo) 00053 { 00054 DigitalOut out1(drive_hi); 00055 DigitalOut out0(drive_lo); 00056 AnalogIn in1(read_hi); 00057 AnalogIn in0(read_lo); 00058 out0 = 0; 00059 out1 = 1; 00060 00061 return in1.read_u16(); 00062 } 00063 00064 00065 void Touchpad::tick(void) 00066 { 00067 m_ch_x.tick(read_x()); 00068 m_ch_y.tick(read_y()); 00069 }
Generated on Wed Jul 13 2022 15:02:52 by
1.7.2