mirror of
https://github.com/eclipse/upm.git
synced 2025-07-26 13:41:16 +03:00
C++ Core: Add base class per sensor/actuator type
Adding base classes for UPM sensors and actuators. Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
@ -2,4 +2,4 @@ set (libname "hlg150h")
|
||||
set (libdescription "150W Constant Voltage/current LED Driver")
|
||||
set (module_src ${libname}.cxx mraa-utils.cxx)
|
||||
set (module_hpp ${libname}.hpp)
|
||||
upm_module_init(mraa interfaces)
|
||||
upm_module_init(mraa core)
|
||||
|
@ -18,7 +18,7 @@ HLG150H::HLG150H(int pinRelay, int pinPWM)
|
||||
status = pwmBrightness->enable(true);
|
||||
status = pwmBrightness->period_us(PWM_PERIOD);
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("pwm config failed.");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + " : pwm config failed.");
|
||||
dutyPercent = getBrightness();
|
||||
isPoweredShadow = dutyPercent > 10;
|
||||
}
|
||||
@ -65,7 +65,7 @@ void HLG150H::setBrightness(int dutyPercent)
|
||||
status = pwmBrightness->pulsewidth_us(dutyUs);
|
||||
// std::cout << "Brightness = " << dutyPercent << "%, duty = " << dutyUs << "us" << std::endl;
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("setBrightness failed");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + " : setBrightness failed");
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "interfaces/iLightController.hpp"
|
||||
#include "iLightController.hpp"
|
||||
// #include "mraa/gpio.hpp"
|
||||
#include "mraa/pwm.hpp"
|
||||
|
||||
@ -60,7 +60,6 @@ public:
|
||||
~HLG150H();
|
||||
|
||||
virtual int getBrightness();
|
||||
const char* getModuleName() { return "hlg150h"; }
|
||||
void setPowerOn();
|
||||
void setPowerOff();
|
||||
bool isPowered();
|
||||
|
@ -1,11 +1,10 @@
|
||||
%include "../common_top.i"
|
||||
%include "iLightController.i"
|
||||
|
||||
/* BEGIN Java syntax ------------------------------------------------------- */
|
||||
#ifdef SWIGJAVA
|
||||
%include "arrays_java.i";
|
||||
%include "../java_buffer.i"
|
||||
%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%}
|
||||
%import "../interfaces/javaupm_iLightController.i"
|
||||
|
||||
JAVA_JNI_LOADLIBRARY(javaupm_hlg150h)
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@ void MraaUtils::setGpio(int pin, int level)
|
||||
mraa::Gpio gpio(pin);
|
||||
gpio.dir(mraa::DIR_OUT);
|
||||
if (gpio.write(level) != mraa::SUCCESS)
|
||||
UPM_THROW("gpio write failed");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + " : gpio write failed");
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user