2015-01-07 14:06:07 -08:00
|
|
|
/*
|
|
|
|
* Author: Sarah Knepper <sarah.knepper@intel.com>
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2015-01-07 14:06:07 -08:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-01-07 14:06:07 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2017-08-30 15:00:29 -07:00
|
|
|
|
2016-04-25 14:27:51 -07:00
|
|
|
#include "ttp223.hpp"
|
2017-08-30 15:00:29 -07:00
|
|
|
#include "upm_utilities.h"
|
2015-01-07 14:06:07 -08:00
|
|
|
|
|
|
|
int
|
2017-08-30 15:00:29 -07:00
|
|
|
main(int argc, char** argv)
|
2015-01-07 14:06:07 -08:00
|
|
|
{
|
|
|
|
// This example uses GPIO 0
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
2015-01-07 14:06:07 -08:00
|
|
|
|
|
|
|
// Create the TTP223 touch sensor object using GPIO pin 0
|
2017-08-30 15:00:29 -07:00
|
|
|
upm::TTP223 touch(0);
|
2015-01-07 14:06:07 -08:00
|
|
|
|
|
|
|
// Check whether or not a finger is near the touch sensor and
|
|
|
|
// print accordingly, waiting one second between readings
|
2017-08-30 15:00:29 -07:00
|
|
|
while (1) {
|
|
|
|
if (touch.isPressed()) {
|
|
|
|
std::cout << touch.name() << " is pressed" << std::endl;
|
2015-01-07 14:06:07 -08:00
|
|
|
} else {
|
2017-08-30 15:00:29 -07:00
|
|
|
std::cout << touch.name() << " is not pressed" << std::endl;
|
2015-01-07 14:06:07 -08:00
|
|
|
}
|
2017-08-30 15:00:29 -07:00
|
|
|
upm_delay(1);
|
2015-01-07 14:06:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the touch sensor object
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
2015-01-07 14:06:07 -08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|