/*--------------------------------------------------------------------------
  Project:  Manual 2D Library - m2d
  File:     touchPanel.h

  Copyright (C)2007-2009 Nintendo  All Rights Reserved.

  These coded instructions, statements, and computer programs contain
  proprietary information of Nintendo of America Inc. and/or Nintendo
  Company Ltd., and are protected by Federal copyright law. They may
  not be disclosed to third parties or copied or duplicated in any form,
  in whole or in part, without the prior written consent of Nintendo.

  $Revision: 1758 $
 *-------------------------------------------------------------------------*/

#ifndef NTMV_M2D_TOUCHPANEL_H_
#define NTMV_M2D_TOUCHPANEL_H_

#if defined(__CWCC__)
#pragma once
#endif

namespace ntmv
{
namespace m2d
{

struct TouchPanelData;

/*
    Touch Panel class
*/
class TouchPanel
{
    //
    // Auto-sampling parameters
    //
    static const int    SAMPLING_START_VCOUNT   = 0;        // Base VCount value for auto-sampling.
    static const int    SAMPLING_FREQUENCE      = 4;        // Number of times to sample per frame. (maximum of 4)
    static const int    SAMPLING_BUFSIZE                    // Size of the auto-sampling buffer
                            = (SAMPLING_FREQUENCE * 2) + 1;

    // For determining whether (tapping on) the Touch Panel is ON/OFF
    // Value that determines the number of consecutive detections of tapping (or lack thereof) for ON/OFF to be determined
    // (measure to prevent chattering when tapping the Touch Panel)
    static const u8     SEQUENCE_COUNT = 3;

public:
                        TouchPanel();

    void                InitHardware();

    bool                GetData(TouchPanelData* pTPData);

private:
    TPData              mTpBuf[SAMPLING_BUFSIZE];
    u8                  mOnCnt;
    u8                  mOffCnt;
    bool                mbOn;
    u16                 mRawX;
    u16                 mRawY;
};

}   // namespace m2d
}   // namespace ntmv

/* NTMV_M2D_TOUCHPANEL_H_ */
#endif

