mirror of
				https://github.com/eclipse/upm.git
				synced 2025-10-31 23:24:20 +03:00 
			
		
		
		
	Removed old interfaces and replaced them with the new ones.
Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
This commit is contained in:
		| @@ -4,9 +4,9 @@ file (GLOB example_src_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cxx") | ||||
| # - Handle special cases here -------------------------------------------------- | ||||
|  | ||||
| # Test temperature interface for 2 sensor libraries | ||||
| add_example(iTemperature_sample.cxx TARGETS new_interfaces lm35 abp) | ||||
| add_example(iTemperature_sample.cxx TARGETS interfaces lm35 abp) | ||||
| # Test light interface for 3 sensor libraries | ||||
| add_example(iLight_sample.cxx TARGETS new_interfaces apds9002 bh1750 max44009) | ||||
| add_example(iLight_sample.cxx TARGETS interfaces apds9002 bh1750 max44009) | ||||
|  | ||||
| # - Create an executable for all other src files in this directory ------------- | ||||
| foreach (_example_src ${example_src_list}) | ||||
|   | ||||
| @@ -27,7 +27,6 @@ | ||||
| #include <stddef.h> | ||||
|  | ||||
| #include "ads1015.hpp" | ||||
| #include "iADC.hpp" | ||||
| #include "mraa/gpio.hpp" | ||||
| #include "upm_utilities.h" | ||||
|  | ||||
| @@ -39,24 +38,21 @@ int | ||||
| main() | ||||
| { | ||||
|     /* Create an instance of the ADS1015 sensor */ | ||||
|     upm::ADS1015 sensor(EDISON_I2C_BUS); | ||||
|     upm::ADS1015 adc(EDISON_I2C_BUS); | ||||
|     mraa::Gpio gpio(EDISON_GPIO_SI7005_CS); | ||||
|     gpio.dir(mraa::DIR_OUT_HIGH); | ||||
|  | ||||
|     /* Show usage from the IADC interface */ | ||||
|     upm::IADC* adc = static_cast<upm::IADC*>(&sensor); | ||||
|  | ||||
|     if (adc == NULL) { | ||||
|         std::cout << "ADC not detected" << std::endl; | ||||
|         return 1; | ||||
|     } | ||||
|     std::cout << "ADC " << adc->getModuleName() << " detected. "; | ||||
|     std::cout << adc->getNumInputs() << " inputs available" << std::endl; | ||||
|     // if (adc == NULL) { | ||||
|     //     std::cout << "ADC not detected" << std::endl; | ||||
|     //     return 1; | ||||
|     // } | ||||
|     std::cout << "ADC " << adc.getModuleName() << " detected. "; | ||||
|     std::cout << adc.getNumInputs() << " inputs available" << std::endl; | ||||
|     while (true) { | ||||
|         for (unsigned int i = 0; i < adc->getNumInputs(); ++i) { | ||||
|         for (unsigned int i = 0; i < adc.getNumInputs(); ++i) { | ||||
|             std::cout << "Input " << i; | ||||
|             try { | ||||
|                 float voltage = adc->getVoltage(i); | ||||
|                 float voltage = adc.getVoltage(i); | ||||
|                 std::cout << ": Voltage = " << voltage << "V" << std::endl; | ||||
|             } catch (std::exception& e) { | ||||
|                 std::cerr << e.what() << std::endl; | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| #define DS1808_GPIO_PWR 15 // Edison GP165 | ||||
|  | ||||
| void | ||||
| printState(upm::ILightController& lightController) | ||||
| printState(upm::DS1808LC& lightController) | ||||
| { | ||||
|     if (lightController.isPowered()) { | ||||
|         std::cout << "Light is powered, brightness = " << lightController.getBrightness() | ||||
|   | ||||
| @@ -3,13 +3,12 @@ | ||||
| #include <string> | ||||
|  | ||||
| #include "hlg150h.hpp" | ||||
| #include "iLightController.hpp" | ||||
|  | ||||
| #define HLG150H_GPIO_RELAY 21 | ||||
| #define HLG150H_GPIO_PWM 22 | ||||
|  | ||||
| void | ||||
| printState(upm::ILightController& lightController) | ||||
| printState(upm::HLG150H& lightController) | ||||
| { | ||||
|     if (lightController.isPowered()) { | ||||
|         std::cout << "Light is powered, brightness = " << lightController.getBrightness() | ||||
|   | ||||
| @@ -2,14 +2,13 @@ | ||||
| #include <stdlib.h> | ||||
| #include <string> | ||||
|  | ||||
| #include "iLightController.hpp" | ||||
| #include "lp8860.hpp" | ||||
|  | ||||
| #define EDISON_I2C_BUS 1   // Edison I2C-1 | ||||
| #define LP8860_GPIO_PWR 45 // Edison GP45 | ||||
|  | ||||
| void | ||||
| printState(upm::ILightController& lightController) | ||||
| printState(upm::LP8860& lightController) | ||||
| { | ||||
|     if (lightController.isPowered()) { | ||||
|         std::cout << "Light is powered, brightness = " << lightController.getBrightness() | ||||
|   | ||||
| @@ -27,7 +27,6 @@ | ||||
| #include <stddef.h> | ||||
| #include <stdint.h> | ||||
|  | ||||
| #include "iCO2Sensor.hpp" | ||||
| #include "mraa/common.h" | ||||
| #include "t6713.hpp" | ||||
| #include "upm_utilities.h" | ||||
| @@ -40,19 +39,16 @@ int | ||||
| main() | ||||
| { | ||||
|     /* Create an instance of the T6713 sensor */ | ||||
|     upm::T6713 sensor(EDISON_I2C_BUS); | ||||
|     upm::T6713 cO2Sensor(EDISON_I2C_BUS); | ||||
|  | ||||
|     /* Show usage from the ICO2Sensor interface */ | ||||
|     upm::ICO2Sensor* cO2Sensor = static_cast<upm::ICO2Sensor*>(&sensor); | ||||
|  | ||||
|     if (cO2Sensor == NULL) { | ||||
|         std::cout << "CO2 sensor not detected" << std::endl; | ||||
|         return 1; | ||||
|     } | ||||
|     std::cout << "CO2 sensor " << cO2Sensor->getModuleName() << " detected" << std::endl; | ||||
|     // if (cO2Sensor == NULL) { | ||||
|     //     std::cout << "CO2 sensor not detected" << std::endl; | ||||
|     //     return 1; | ||||
|     // } | ||||
|     std::cout << "CO2 sensor " << cO2Sensor.getModuleName() << " detected" << std::endl; | ||||
|     while (true) { | ||||
|         try { | ||||
|             uint16_t value = cO2Sensor->getPpm(); | ||||
|             uint16_t value = cO2Sensor.getPpm(); | ||||
|             std::cout << "CO2 level = " << value << " ppm" << std::endl; | ||||
|         } catch (std::exception& e) { | ||||
|             std::cerr << e.what() << std::endl; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Serban Waltter
					Serban Waltter