C++ Gurus

Jason Wright jason at thought.net
Fri Feb 22 16:37:27 CST 2013


On Fri, Feb 22, 2013 at 3:29 PM, Karl W4KRL <W4KRL at arrl.net> wrote:

> I am creating a Button class to use with a touchscreen display. The
> touchscreen is actually a separate device glued to the front of the LCD
> display. The class must translate the touchscreen coordinates to the LCD
> coordinates to test if the user is touching the screen at the button
> position.****
>
> ** **
>
> Each button has several unique visible properties like position, size and
> color. The parameters needed to translate the touchscreen to LCD are the
> same for each button. However, they are unknown with precision until the
> screen is calibrated. I do have some generic parameters that are close
> enough without calibration.****
>
> ** **
>
> How do I get the touchscreen parameters into the class so that all objects
> will be able to do the translation? At the moment the generic parameters
> are hard coded into the class constructor. Is there a clever way to get the
> parameters into the class?****
>
> **
>
I think what you're looking for are static class variables [1].

If you declare them as:
  private: static int _tXmin, _tXmax, _tYmin, _tYmax, _tZmin, _tZmax;  //
touch plate ADC readings


****
Then that should be visible in all instances of the class.  Marking them
protected or public has the usual effects on child classes.  A change in
the variable in one instances affects them all (they are class variables
now).  Is this what you're looking for, or did I misunderstand?

[1] http://www.learncpp.com/cpp-tutorial/811-static-member-variables/

>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://amrad.org/pipermail/tacos/attachments/20130222/357f9674/attachment-0001.html>


More information about the Tacos mailing list