parent
f28dc3e09c
commit
066aac8f6d
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Authors : Kerem Yollu & Edwin Koch
|
||||
* Date : 07.03.2021
|
||||
*
|
||||
* Description :
|
||||
* TODO : Write description or doxygene
|
||||
*
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <bitset>
|
||||
#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" <<std::endl;
|
||||
std::string Msg = std::to_string(lightSens.continious(BH1750_CONTINUOUS_HIGH_RES_MODE_1,1));
|
||||
char char_array[TOTAL_CHAR_CAP];
|
||||
strcpy(char_array, Msg.c_str());
|
||||
lcd_display_string(2,0, char_array,5);
|
||||
usleep(150*1000);
|
||||
}
|
||||
}
|
||||
|
||||
void dummy()
|
||||
{
|
||||
uint16_t conf = 0;
|
||||
float conv = 0;
|
||||
Ads1015 adc(&i2c,&errorHandle);
|
||||
conf = adc.getConfig();
|
||||
adc.setOperationMode(ADS1015_MODE_SINGLE);
|
||||
adc.setMultiplexer(ADS1015_MUX_AIN0_GND);
|
||||
adc.setGain(ADS1015_GAIN_6144);
|
||||
adc.writeConfig();
|
||||
adc.pointToConvReg();
|
||||
conv = adc.getConversion();
|
||||
conv = (5.0 * conv)/2047.0;
|
||||
std::cout << "Convertion " << conv << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Init
|
||||
initPlatform();
|
||||
std::cout << "Main Begin" << std::endl;
|
||||
commander.addNewCommand("bh1750", "The test command for testing the bh1750", bh1750_test);
|
||||
commander.addNewCommand("pca9685", "The test command for testing the pca8695", pca9685_test);
|
||||
commander.addNewCommand("dummy", "The test command for testing the test", dummy);
|
||||
commander(argv[1]);
|
||||
std::cout << "Main End" << std::endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
int initPlatform()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dummy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Init
|
||||
initPlatform();
|
||||
std::cout << "Main Begin" << std::endl;
|
||||
commander.addNewCommand("dummy", "The test command for testing the test", dummy);
|
||||
commander(argv[1]);
|
||||
std::cout << "Main End" << std::endl;
|
||||
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#define STM 0
|
||||
#define LINUX 1
|
||||
|
||||
|
||||
#define PLATFORM STM
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -0,0 +1,20 @@
|
||||
#ifndef _IMPLEMENTATION_H_
|
||||
#define _IMPLEMENTATION_H_
|
||||
|
||||
#include "interface.hpp"
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
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_
|
@ -0,0 +1,20 @@
|
||||
#ifndef _IMPLEMENTATION2_H_
|
||||
#define _IMPLEMENTATION2_H_
|
||||
|
||||
#include "interface.hpp"
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
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_
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#ifndef _INTERFACE_H_
|
||||
#define _INTERFACE_H_
|
||||
|
||||
#include "../config.h"
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
|
||||
class Device
|
||||
{
|
||||
public:
|
||||
Device();
|
||||
~Device();
|
||||
void printNumber(const uint8_t& no);
|
||||
|
||||
private:
|
||||
struct deviceImpl;
|
||||
std::unique_ptr<deviceImpl> pImpl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // _INTERFACE_H_
|
Loading…
Reference in new issue