diff --git a/software/app/ads101x.h b/software/app/ads101x.h deleted file mode 100644 index 96b2504..0000000 --- a/software/app/ads101x.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ADS101x.h - * - * Created on: Jul 20, 2017 - * Author: Elmar - */ - -#ifndef APP_ADS101X_H_ -#define APP_ADS101X_H_ - -#include -#include "hardware.h" -#include "adc.h" - -namespace rijnfel { - -namespace ads { - -//Voltage in uV -typedef int32_t ads_voltage_t; - -enum eInputMux { - AIN_0_1, AIN_0_3, AIN_1_3, AIN_2_3, AIN_0, AIN_1, AIN_2, AIN_3 -}; -enum eGainAmplifier { - FSR_6_144, FSR_4_096, FSR_2_048, FSR_1_024, FSR_0_512, FSR_0_256 -}; -enum eSampleSpeed { - SPS_128, SPS_250, SPS_490, SPS_920, SPS_1600, SPS_2400, SPS_3300 -}; - -struct ads_sample_t { - uint16_t rawSample; - enum eInputMux mux; - enum eGainAmplifier gain; -}; - -class cADS101x: public cADC { -public: - - cADS101x(uint8_t i_address = 0x48); - cADS101x(uint8_t i_readyPin, uint8_t i_address = 0x48); - - void SetOneShot(bool i_oneShot = true); - void SetGain(enum eGainAmplifier i_gain); - void SetMux(enum eInputMux i_mux); - void SetSampleSpeed(enum eSampleSpeed i_speed); - virtual void WaitSample(void); - virtual bool IsReady(void); - uint16_t GetSettings(void); - - virtual ads_sample_t RawSample(void); - virtual ads_voltage_t ConvertSample(ads_sample_t & sample); - virtual ~cADS101x() { - - } -private: - uint16_t CreateSettings(uint8_t i_startSample); - uint16_t ReadRegister(uint8_t i_register); - void WriteSettings(uint16_t i_settings); - void SetDefaults(void); - void OneShot(void); -private: - uint8_t m_address, m_readyPin; - bool m_oneShot; - enum eInputMux m_mux; - enum eGainAmplifier m_gain; - enum eSampleSpeed m_sampleSpeed; -private: -#ifdef DUMMY_ADC - uint16_t m_counter; -#endif -}; -} -} -#endif /* APP_ADS101X_H_ */ diff --git a/software/app/ads_converter.cpp b/software/app/ads_converter.cpp index b518cf0..e047c02 100644 --- a/software/app/ads_converter.cpp +++ b/software/app/ads_converter.cpp @@ -6,8 +6,7 @@ */ #include "ads_converter.h" -#include "double_buffer.h" -#include "helper_structs.h" + namespace rijnfel { cAdsConverter::cAdsConverter(cADC & i_adc) : diff --git a/software/app/ads_converter.h b/software/app/ads_converter.h deleted file mode 100644 index f8e795a..0000000 --- a/software/app/ads_converter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ads_converter.h - * - * Created on: Aug 22, 2017 - * Author: Elmar - */ - -#ifndef APP_ADS_CONVERTER_H_ -#define APP_ADS_CONVERTER_H_ - -#include "data_receiver.h" -#include "data_provider.h" -#include "ads101x.h" - -namespace rijnfel { - -class cAdsConverter: public cDataSink { -public: - cAdsConverter(cADC & i_adc); - virtual void ReceiveCallback(void * i_data, cDataReceiver * i_provider); - // Every channel has its own provider, after this we can not distinguish anymore - cDataProvider m_convertedSamples[4]; - cDataReceiver m_rawSamples; - virtual ~cAdsConverter(); -private: - cADC & m_adc; -}; - -} /* namespace rijnfel */ - -#endif /* APP_ADS_CONVERTER_H_ */ diff --git a/software/app/application.cpp b/software/app/application.cpp index 64da8d3..3e77d6d 100644 --- a/software/app/application.cpp +++ b/software/app/application.cpp @@ -1,17 +1,17 @@ #include +#include #include #include -#include "excitation_light.h" -#include "sensor_settings.h" -#include "double_buffer.h" -#include "web_interface.h" +#include #include + +#include +#include "excitation_light.h" +#include "ads101x.h" #include "ads_converter.h" +#include "web_interface.h" #include "signal_process.h" -#include -#include #include "sensor_hub.h" -#include "ads101x.h" using namespace rijnfel; diff --git a/software/app/dac101c085.h b/software/app/dac101c085.h deleted file mode 100644 index d0e6ac2..0000000 --- a/software/app/dac101c085.h +++ /dev/null @@ -1,72 +0,0 @@ -//---------------------------------------------------------------------------------------------------------------------------- -// Project: Uppsense -// Name: dac101c085.h -// Author: Maximilian Stiefel -// Date: 08.08.2017 -// -// Description: Small simple driver for the TI DAC101C085. -// -//---------------------------------------------------------------------------------------------------------------------------- - -#ifndef APP_DAC101C085_H_ -#define APP_DAC101C085_H_ - -//-------------------------------------Libraries------------------------------------------------------------------------------ -#include -#include "defines.h" - -//-------------------------------------Defines-------------------------------------------------------------------------------- -#define PD_BITS_POS 13 // Position of power down bits -#define D_BITS_POS 2 // Position of data bits - -//-------------------------------------Namespaces----------------------------------------------------------------------------- -namespace rijnfel { -namespace dac { - -//-------------------------------------Enums---------------------------------------------------------------------------------- -/** Represents the operational mode of the DAC. - */ -enum eOpMode {NORMAL, PULL_DOWN_2K5, PULL_DOWN_100K, HIGH_IMPEDANCE}; - -//-------------------------------------cDAC101085----------------------------------------------------------------------------- -/** Small simple driver for the TI DAC101C085. - */ -class cDAC101C085 -{ -public: - /** @brief Instantiate DAC, assign a number and an address. - * @param i_dac_number Number of the DAC. - * @param i_address I2C address of this DAC. - */ - cDAC101C085(uint8_t i_dac_number, uint8_t i_address); // Constructor - - /** @brief Free DAC, is currently doing nothing. - */ - ~cDAC101C085(); // Destructor - - /** @brief Check if the device is answering on the bus. - * @retval uint8_t Returns 1 on success, 0 when failing. - */ - uint8_t CheckDev(); // Check if device is available and alive - - /** @brief Read out 16 bit register of the DAC. - * @retval uint16_t 16 bit read from the DAC. - */ - uint16_t ReadSettings(void); - - /** @brief Write new setting to DAC register. - * @retval uint8_t Returns 1 on success, 0 when failing. - */ - uint8_t ChangeSettings(enum eOpMode mode, uint16_t val); - -private: - uint8_t m_dac_number; // Which of the dacs is it? - uint8_t m_address; - uint8_t WriteSettings(uint16_t settings); - uint8_t I2CError(uint8_t error); -}; - -} -} - -#endif /* APP_DAC101C085_H_ */ diff --git a/software/app/dummy_adc.cpp b/software/app/dummy_adc.cpp deleted file mode 100644 index 9474bb2..0000000 --- a/software/app/dummy_adc.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * dummy_adc.cpp - * - * Created on: Aug 15, 2017 - * Author: Elmar - */ - -#include "dummy_adc.h" - -namespace rijnfel { - -cDymmyAdc::cDymmyAdc() { - m_sampleCounter = 0; -} - -void cDymmyAdc::WaitSample(void) { -} - -bool cDymmyAdc::IsReady(void) { - return true; -} - -uint32_t cDymmyAdc::RawSample(void) { - m_sampleCounter++; - return m_sampleCounter; -} - -uint32_t cDymmyAdc::ConvertSample(uint32_t& sample) { - return sample - 1; -} - -cDymmyAdc::~cDymmyAdc() { - // TODO Auto-generated destructor stub -} - -} /* namespace rijnfel */ diff --git a/software/app/dummy_adc.h b/software/app/dummy_adc.h deleted file mode 100644 index 2f9c557..0000000 --- a/software/app/dummy_adc.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * dummy_adc.h - * - * Created on: Aug 15, 2017 - * Author: Elmar - */ - -#ifndef APP_DUMMY_ADC_H_ -#define APP_DUMMY_ADC_H_ - -#include "adc.h" -#include - -namespace rijnfel { - -class cDymmyAdc: public cADC { -public: - cDymmyAdc(); - virtual void WaitSample(void); - virtual bool IsReady(void); - virtual uint32_t RawSample(void); - virtual uint32_t ConvertSample(uint32_t & sample); - virtual ~cDymmyAdc(); -private: - uint32_t m_sampleCounter; -}; - -} /* namespace rijnfel */ - -#endif /* APP_DUMMY_ADC_H_ */ diff --git a/software/app/excitation_light.cpp b/software/app/excitation_light.cpp index dc38160..2c87935 100644 --- a/software/app/excitation_light.cpp +++ b/software/app/excitation_light.cpp @@ -10,7 +10,7 @@ //-------------------------------------Libraries------------------------------------------------------------------------------ #include "excitation_light.h" -#include "defines.h" +#include #include //-------------------------------------Namespaces----------------------------------------------------------------------------- diff --git a/software/app/excitation_light.h b/software/app/excitation_light.h deleted file mode 100644 index 2df0514..0000000 --- a/software/app/excitation_light.h +++ /dev/null @@ -1,64 +0,0 @@ -//---------------------------------------------------------------------------------------------------------------------------- -// Project: Uppsense -// Name: excitation_light.h -// Author: Maximilian Stiefel -// Date: 09.08.2017 -// -// Description: Class to use the excitation light in an advanced way with the help of a DAC. -// -//---------------------------------------------------------------------------------------------------------------------------- - -#ifndef APP_EXCITATION_LIGHT_H_ -#define APP_EXCITATION_LIGHT_H_ - -//-------------------------------------Libraries------------------------------------------------------------------------------ -#include -#include "dac101c085.h" -#include "hardware.h" - -//-------------------------------------Defines-------------------------------------------------------------------------------- - -//-------------------------------------Namespaces----------------------------------------------------------------------------- -namespace rijnfel { -namespace light { - -//-------------------------------------Enums---------------------------------------------------------------------------------- - -//-------------------------------------cExcitationLight----------------------------------------------------------------------- -/** Class to use the excitation light in an advanced way with the help of a DAC. - */ -class cExcitationLight -{ -public: - /** Construct object, allocate space for DAC. - */ - cExcitationLight(); // Constructor - - /** Destruct object, free space for DAC. - */ - ~cExcitationLight(); // Destructor - - /** Set the desired current through excitation light. - * @param microamp Current in uA. - * @retval uint8_t Returns 1 on success, 0 when failing. - */ - uint8_t SetCurrent(uint16_t microamp); - - /** Function to be hooked up to a timer to generate rectangular signal. - * @retval uint8_t Returns 1 on success, 0 when failing. - */ - uint8_t RectangleUpdate(); - - /** Use 2K5 pull-down resistor to turn LED completely off. - * @retval uint8_t Returns 1 on success, 0 when failing. - */ - uint8_t DeactivateLED(); -private: - dac::cDAC101C085 *m_DAC; - uint8_t m_rectangleStatus; - uint16_t m_DACRectHigh; -}; - -} -} -#endif /* APP_EXCITATION_LIGHT_H_ */ diff --git a/software/app/sensor_hub.h b/software/app/sensor_hub.h index 80fe455..1fbf925 100644 --- a/software/app/sensor_hub.h +++ b/software/app/sensor_hub.h @@ -8,8 +8,8 @@ #ifndef APP_SENSOR_HUB_H_ #define APP_SENSOR_HUB_H_ +#include #include "ads101x.h" -#include "sensor_settings.h" namespace rijnfel { diff --git a/software/app/signal_process.cpp b/software/app/signal_process.cpp index 5749e5f..42f1eb2 100644 --- a/software/app/signal_process.cpp +++ b/software/app/signal_process.cpp @@ -6,8 +6,9 @@ */ #include "signal_process.h" -#include "helper_structs.h" #include + +#include "../include/rijnfel_core/helper_structs.h" //TODO remove this namespace rijnfel { diff --git a/software/app/signal_process.h b/software/app/signal_process.h index cacb261..f90fc31 100644 --- a/software/app/signal_process.h +++ b/software/app/signal_process.h @@ -7,8 +7,8 @@ #ifndef APP_SIGNAL_PROCESS_H_ #define APP_SIGNAL_PROCESS_H_ -#include "data_receiver.h" -#include "data_provider.h" +#include "../include/rijnfel_core/data_provider.h" +#include "../include/rijnfel_core/data_receiver.h" namespace rijnfel { diff --git a/software/app/temperature.h b/software/app/temperature.h deleted file mode 100644 index 1d354e9..0000000 --- a/software/app/temperature.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * temperature.h - * - * Created on: Aug 1, 2017 - * Author: Elmar - */ - -#ifndef APP_TEMPERATURE_H_ -#define APP_TEMPERATURE_H_ - -#include "sensor.h" - -namespace rijnfel { -template -class cTemperatureSensor: cSensor { -public: - cTemperatureSensor() { - - } - virtual Temperature ConvertSample(Sample sample) = 0; - virtual ~cTemperatureSensor() { - - } -}; - -} - -#endif /* APP_TEMPERATURE_H_ */ diff --git a/software/app/web_interface.cpp b/software/app/web_interface.cpp index 0a1c36a..2685736 100644 --- a/software/app/web_interface.cpp +++ b/software/app/web_interface.cpp @@ -6,7 +6,6 @@ */ #include "web_interface.h" -#include "helper_structs.h" #include #include #include diff --git a/software/app/web_interface.h b/software/app/web_interface.h deleted file mode 100644 index 7ef76c6..0000000 --- a/software/app/web_interface.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * web_interface.h - * - * Created on: Aug 6, 2017 - * Author: Elmar - */ - -#ifndef APP_WEB_INTERFACE_H_ -#define APP_WEB_INTERFACE_H_ - -#include "adc.h" -//TODO remove this -#include "ads101x.h" -#include "dummy_adc.h" - -#include "double_buffer.h" -#include -#include "data_receiver.h" - -namespace rijnfel { -#define RAW_CHANNEL 1 -#define RAW_SAMPLES 1000 -class cWebInterface: public cDataSink { -public: - /** - * Returns the global cWebInterface instance. - * Only one webserver should ever be running - * @return global cWebInterface instance - */ - static cWebInterface *GetInstance() { - if (cWebInterface::s_instance == NULL) - cWebInterface::s_instance = new cWebInterface(); - return cWebInterface::s_instance; - } - - /// Singleton instance - static cWebInterface *s_instance; - -public: - /** - * Should not be used because it's a singleton - * @param delete - */ - cWebInterface(cWebInterface const&) = delete; - - /** - * Should not be used because it's a singleton - * @param delete - * @return delete - */ - cWebInterface& operator=(cWebInterface const&) = delete; - - /** - * Registers the paths and starts the server - */ - void StartServer(); - - /** - * Stops the server - */ - void StopServer(); - - /** - * This is a debug function that prints out the average values - * @todo remove this - */ - void PrintValues(); - - /** - * Destructor - */ - virtual ~cWebInterface(); - - // This is what the future will look like - // cDataReceiver m_sensorVal[2]; - // cDataReceiver m_battery; - // cDataReceiver m_ledLife; - // cDataReceiver m_temp; - // But for now... - cDataReceiver m_adc_0; - cDataReceiver m_adc_1; - cDataReceiver m_adc_2; - cDataReceiver m_adc_3; - - virtual void ReceiveCallback(void * i_data, cDataReceiver * i_receiver); -public: - /** - * - * @param i_request - * @param i_response Response to the client, index.html - */ - void OnIndex(HttpRequest & i_request, HttpResponse & i_response); - - /** - * Function gets called from the mobile to refresh the average values - * @param i_request Request from the client - * @param i_response Response to the client, contains JSON with averages - */ - void OnRefresh(HttpRequest & i_request, HttpResponse & i_response); - - /** - * - * @param i_request - * @param i_response - */ - void OnRawUpdate(HttpRequest& i_request, HttpResponse& i_response); - void OnConfiguration_json(HttpRequest &request, HttpResponse &response); - void OnConfiguration(HttpRequest &request, HttpResponse &response); - - //TODO migrate this - WebSocketConnection * m_connectedUser; - bool m_sendWebsocket; -protected: - /** - * Initializes the variables - */ - cWebInterface(); -private: - void ResetRawValues(); - /// Whether the server has started or not - bool m_serverStarted; - /// Holds the average for all the channels - int32_t m_adc_value_average[4]; - /// Server instance - HttpServer m_server; -}; - -} /* namespace rijnfel */ - -#endif /* APP_WEB_INTERFACE_H_ */ diff --git a/software/app/defines.h b/software/include/defines.h similarity index 100% rename from software/app/defines.h rename to software/include/defines.h diff --git a/software/app/adc.h b/software/include/rijnfel_core/adc.h similarity index 95% rename from software/app/adc.h rename to software/include/rijnfel_core/adc.h index 6290397..3843d26 100644 --- a/software/app/adc.h +++ b/software/include/rijnfel_core/adc.h @@ -8,7 +8,7 @@ #ifndef APP_ADC_H_ #define APP_ADC_H_ -#include "sensor.h" +#include "../rijnfel_core/sensor.h" namespace rijnfel { diff --git a/software/app/data_provider.h b/software/include/rijnfel_core/data_provider.h similarity index 100% rename from software/app/data_provider.h rename to software/include/rijnfel_core/data_provider.h diff --git a/software/app/data_receiver.h b/software/include/rijnfel_core/data_receiver.h similarity index 100% rename from software/app/data_receiver.h rename to software/include/rijnfel_core/data_receiver.h diff --git a/software/app/data_sink.h b/software/include/rijnfel_core/data_sink.h similarity index 100% rename from software/app/data_sink.h rename to software/include/rijnfel_core/data_sink.h diff --git a/software/app/double_buffer.h b/software/include/rijnfel_core/double_buffer.h similarity index 97% rename from software/app/double_buffer.h rename to software/include/rijnfel_core/double_buffer.h index ee09dcf..8b68c3f 100644 --- a/software/app/double_buffer.h +++ b/software/include/rijnfel_core/double_buffer.h @@ -9,7 +9,6 @@ #define APP_DOUBLE_BUFFER_H_ #include -#include namespace rijnfel { diff --git a/software/app/helper_structs.h b/software/include/rijnfel_core/helper_structs.h similarity index 100% rename from software/app/helper_structs.h rename to software/include/rijnfel_core/helper_structs.h diff --git a/software/include/rijnfel_core/rijnfel_core.h b/software/include/rijnfel_core/rijnfel_core.h new file mode 100644 index 0000000..407f7b8 --- /dev/null +++ b/software/include/rijnfel_core/rijnfel_core.h @@ -0,0 +1,21 @@ +/* + * core.h + * + * Created on: Aug 23, 2017 + * Author: Elmar + */ + +#ifndef APP_CORE_CORE_H_ +#define APP_CORE_CORE_H_ + +#include "adc.h" +#include "data_provider.h" +#include "data_receiver.h" +#include "data_sink.h" +#include "double_buffer.h" +#include "helper_structs.h" +#include "sensor_settings.h" + + + +#endif /* APP_CORE_CORE_H_ */ diff --git a/software/app/sensor.h b/software/include/rijnfel_core/sensor.h similarity index 100% rename from software/app/sensor.h rename to software/include/rijnfel_core/sensor.h diff --git a/software/app/sensor_settings.h b/software/include/rijnfel_core/sensor_settings.h similarity index 100% rename from software/app/sensor_settings.h rename to software/include/rijnfel_core/sensor_settings.h index d11423e..efd216a 100644 --- a/software/app/sensor_settings.h +++ b/software/include/rijnfel_core/sensor_settings.h @@ -8,8 +8,8 @@ #ifndef APP_SENSOR_SETTINGS_H_ #define APP_SENSOR_SETTINGS_H_ -#include "double_buffer.h" #include "data_provider.h" +#include "double_buffer.h" namespace rijnfel { //timebase, in miliseconds.