diff --git a/developpment/$ b/developpment/$ new file mode 100644 index 0000000..18046a5 --- /dev/null +++ b/developpment/$ @@ -0,0 +1,126 @@ +/* + * Authors : Kerem Yollu & Edwin Koch + * Date : 07.03.2021 + * + * Description : + * TODO : Write description or doxygene + * + */ + +#include +#include +#include +#include +#include "./management/errorHandling.h" +#include "./management/commandManager.h" +//#include "./drivers/bh1750/bh1750.h" +//#include "./drivers/pf8574/pf8574lcd.h" +#include "./algorithms/bitgestion.h" +//#include "./periferals/i2c/i2c.hpp" +#include "./pimpl/implementation.hpp" + + +ErrorHandler errorHandle; +CommandManager commander; + +Device pimplTest; + +//i2c_ch1_pImpL i2c(1, &errorHandle); + +/* +char char_array[TOTAL_CHAR_CAP]; +int freq = 0; + +int initPlatform() +{ + lcd_init(&i2c); + return 0; +} + + +void pca9685_test() +{ + Pca9685 pwmGenarator(&i2c, &errorHandle); + pwmGenarator.setOnDutyPercent(0,50); + for(int i = 3 ; i <= 255; i++) + { + pwmGenarator.setPwmRaw(i); + strcpy(char_array, "Pwm Freq: "); + lcd_display_string(1,0,char_array,0); + std::string Msg = std::to_string(pwmGenarator.getPwmFreq()); + strcpy(char_array, Msg.c_str()); + lcd_display_string(1,10, char_array, 7); + strcpy(char_array, "Hz"); + lcd_display_string(1,18, char_array, 7); + usleep(200000); + freq = getchar(); + } +} + +void bh1750_test() +{ + Bh1750 lightSens(&i2c); + while(1) + { +// std::cout << "value "<< lightSens.continious(BH1750_CONTINUOUS_HIGH_RES_MODE_1,1) << " Lux" < namespace serial { @@ -33,24 +34,24 @@ namespace serial class I2C { public: - I2C(const uint8_t& mode):pImpL(mode) + I2C(const uint8_t& mode) { } uint8_t readByte(const uint8_t& address, const uint8_t& reg) { - return pImpL -> readByte(address, reg); + return pImpL.readByte(address, reg); } uint16_t readWord(const uint8_t& address, const uint8_t& reg) { - return pImpL -> readWord(address,reg); + return pImpL.readWord(address,reg); } uint8_t writeByte(const uint8_t& address, const uint8_t& data) { - return pImpL -> writeByte(address, data); + return pImpL.writeByte(address, data); } uint8_t writeWord(const uint8_t& address, const uint8_t& reg, const uint16_t& data) { - return pImpL -> writeWord(address, reg, data); + return pImpL.writeWord(address, reg, data); } private: @@ -65,24 +66,24 @@ namespace serial class I2C { public: - I2C(const uint8_t& mode):pImpL(mode) + I2C(const uint8_t& mode) { } uint8_t readByte(const uint8_t& address, const uint8_t& reg) { - return pImpL -> readByte(address, reg); + return pImpL.readByte(address, reg); } uint16_t readWord(const uint8_t& address, const uint8_t& reg) { - return pImpL -> readWord(address,reg); + return pImpL.readWord(address,reg); } uint8_t writeByte(const uint8_t& address, const uint8_t& data) { - return pImpL -> writeByte(address, data); + return pImpL.writeByte(address, data); } uint8_t writeWord(const uint8_t& address, const uint8_t& reg, const uint16_t& data) { - return pImpL -> writeWord(address, reg, data); + return pImpL.writeWord(address, reg, data); } private: diff --git a/developpment/periferals/i2c/i2c_ch0_pImpL.cpp b/developpment/periferals/i2c/i2c_ch0_pImpL.cpp index 6201bc8..0e2aeab 100644 --- a/developpment/periferals/i2c/i2c_ch0_pImpL.cpp +++ b/developpment/periferals/i2c/i2c_ch0_pImpL.cpp @@ -1,18 +1,5 @@ -#include "i2c_ch0_pImpL.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define PORT_I2C "/dev/i2c-1" +#include "i2c_ch0_pImpL.hpp" // some curious things https://www.john.geek.nz/2012/12/update-reading-data-from-a-bosch-bmp085-with-a-raspberry-pi/ diff --git a/developpment/periferals/i2c/i2c_ch0_pImpL.h b/developpment/periferals/i2c/i2c_ch0_pImpL.hpp similarity index 77% rename from developpment/periferals/i2c/i2c_ch0_pImpL.h rename to developpment/periferals/i2c/i2c_ch0_pImpL.hpp index 51fa22a..a560b1d 100644 --- a/developpment/periferals/i2c/i2c_ch0_pImpL.h +++ b/developpment/periferals/i2c/i2c_ch0_pImpL.hpp @@ -2,10 +2,23 @@ #define _I2C_CH0_PIMPL_H_ #include +#include +#include +#include #include -#include -#include "../../management/errorHandling.h" + +#include +#include +#include +#include +#include + + +#define PORT_I2C "/dev/i2c-1" #include "../../systems/systemCall.h" +#include "../../management/errorHandling.h" + +#include "i2c.hpp" class i2c_ch0_pImpL { diff --git a/developpment/periferals/i2c/i2c_ch1_pImpL.cpp b/developpment/periferals/i2c/i2c_ch1_pImpL.cpp index 350f87f..897472d 100644 --- a/developpment/periferals/i2c/i2c_ch1_pImpL.cpp +++ b/developpment/periferals/i2c/i2c_ch1_pImpL.cpp @@ -1,18 +1,4 @@ #include "i2c_ch1_pImpL.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define PORT_I2C "/dev/i2c-1" - // some curious things https://www.john.geek.nz/2012/12/update-reading-data-from-a-bosch-bmp085-with-a-raspberry-pi/ diff --git a/developpment/periferals/i2c/i2c_ch1_pImpL.hpp b/developpment/periferals/i2c/i2c_ch1_pImpL.hpp index eabd91e..8ba2952 100644 --- a/developpment/periferals/i2c/i2c_ch1_pImpL.hpp +++ b/developpment/periferals/i2c/i2c_ch1_pImpL.hpp @@ -2,11 +2,24 @@ #define _I2C_CH1_PIMPL_H_ #include +#include +#include +#include #include -#include + +#include +#include +#include +#include +#include + + +#define PORT_I2C "/dev/i2c-1" #include "../../systems/systemCall.h" #include "../../management/errorHandling.h" +#include "i2c.hpp" + class i2c_ch1_pImpL { public: diff --git a/developpment/periferals/i2c/i2c_driver.o b/developpment/periferals/i2c/i2c_driver.o new file mode 100644 index 0000000..57c9c26 Binary files /dev/null and b/developpment/periferals/i2c/i2c_driver.o differ diff --git a/developpment/pimpl/implementations.hpp b/developpment/pimpl/implementations.hpp new file mode 100644 index 0000000..f47214d --- /dev/null +++ b/developpment/pimpl/implementations.hpp @@ -0,0 +1,20 @@ +#ifndef _IMPLEMENTATION_H_ +#define _IMPLEMENTATION_H_ + +#include "interface.hpp" +#include +#include + +struct Device::deviceImpl +{ + deviceImpl() + { + std::cout << "Device implementation Constarctor For Liunx "<< std::endl; + } + void printNumber(const uint8_t& no) + { + std::cout << "selected no: "<< unsigned(no*2) << std::endl; + } +}; + +#endif // _IMPLEMENTATION_H_ diff --git a/developpment/pimpl/implementations2.hpp b/developpment/pimpl/implementations2.hpp new file mode 100644 index 0000000..777d5af --- /dev/null +++ b/developpment/pimpl/implementations2.hpp @@ -0,0 +1,20 @@ +#ifndef _IMPLEMENTATION2_H_ +#define _IMPLEMENTATION2_H_ + +#include "interface.hpp" +#include +#include + +struct Device::deviceImpl +{ + deviceImpl() + { + std::cout << "Device implementation Constarctor For STM "<< std::endl; + } + void printNumber(const uint8_t& no) + { + std::cout << "selected no: "<< unsigned(no) << std::endl; + } +}; + +#endif // _IMPLEMENTATION2_H_ diff --git a/developpment/pimpl/interface.cpp b/developpment/pimpl/interface.cpp new file mode 100644 index 0000000..effcc05 --- /dev/null +++ b/developpment/pimpl/interface.cpp @@ -0,0 +1,24 @@ +#include "interface.hpp" + +#if PLATFORM == STM +#include "implementations2.hpp" +#endif + +#if PLATFORM == LINUX +#include "implementations.hpp" +#endif + +Device::Device() + :pImpl(new deviceImpl()) +{ +} + +void Device::printNumber(const uint8_t& no) +{ + pImpl->printNumber(no); +} + +Device::~Device() +{ + +} diff --git a/developpment/pimpl/interface.hpp b/developpment/pimpl/interface.hpp new file mode 100644 index 0000000..4dbc73b --- /dev/null +++ b/developpment/pimpl/interface.hpp @@ -0,0 +1,22 @@ +#ifndef _INTERFACE_H_ +#define _INTERFACE_H_ + +#include "../config.h" +#include +#include + +class Device +{ + public: + Device(); + ~Device(); + void printNumber(const uint8_t& no); + + private: + struct deviceImpl; + std::unique_ptr pImpl; +}; + + + +#endif // _INTERFACE_H_