Files
upm/src/flex/flex.cxx
2020-03-05 15:13:36 -08:00

40 lines
746 B
C++

/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*
* SPDX-License-Identifier: MIT
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "flex.hpp"
using namespace upm;
using namespace std;
Flex::Flex(int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
}
Flex::~Flex()
{
mraa_aio_close(m_aio);
}
int Flex::value()
{
return mraa_aio_read(m_aio);
}