2015-03-12 13:11:22 -04:00
|
|
|
/*
|
|
|
|
|
* Author: Zion Orent <zorent@ics.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-03-12 13:11:22 -04:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-03-12 13:11:22 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
2015-09-09 16:07:44 -06:00
|
|
|
#include <string>
|
|
|
|
|
#include <stdexcept>
|
2015-03-12 13:11:22 -04:00
|
|
|
|
2016-04-25 14:27:51 -07:00
|
|
|
#include "flex.hpp"
|
2015-03-12 13:11:22 -04:00
|
|
|
|
|
|
|
|
using namespace upm;
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
Flex::Flex(int pin)
|
|
|
|
|
{
|
|
|
|
|
if ( !(m_aio = mraa_aio_init(pin)) )
|
|
|
|
|
{
|
2015-09-09 16:07:44 -06:00
|
|
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
|
|
|
|
": mraa_aio_init() failed, invalid pin?");
|
2015-03-12 13:11:22 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Flex::~Flex()
|
|
|
|
|
{
|
|
|
|
|
mraa_aio_close(m_aio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Flex::value()
|
|
|
|
|
{
|
|
|
|
|
return mraa_aio_read(m_aio);
|
|
|
|
|
}
|