A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MAX44009Config.cpp Source File

MAX44009Config.cpp

00001 /*
00002  * MAX44009Config.cpp
00003  *
00004  *  Created on: 25.05.2016
00005  *      Author: Adrian
00006  */
00007 
00008 #include "MAX44009Config.h "
00009 
00010 MAX44009Config::MAX44009Config() {
00011     // TODO Auto-generated constructor stub
00012 
00013 }
00014 
00015 MAX44009Config::MAX44009Config(MAX44009_MODE desiredMode) {
00016     build(desiredMode);
00017 }
00018 
00019 MAX44009Config::~MAX44009Config() {
00020     // TODO Auto-generated destructor stub
00021 }
00022 
00023 void MAX44009Config::build(MAX44009_MODE desiredMode){
00024     switch(desiredMode){
00025         case MAX44009_MODE_0:
00026             setIntegrationTime(MAX_44009_INTEGRATION_TIME_800_MS);
00027             setContinousMode(MAX_44009_CONTINOUS_MODE_OFF);
00028             setManualConfig(MAX_44009_MANUAL_CONFIG_OFF);
00029         case MAX44009_MODE_1:
00030             setIntegrationTime(MAX_44009_INTEGRATION_TIME_400_MS);
00031             setContinousMode(MAX_44009_CONTINOUS_MODE_ON);
00032             setManualConfig(MAX_44009_MANUAL_CONFIG_OFF);
00033             break;
00034         case MAX44009_MODE_2:
00035             setIntegrationTime(MAX_44009_INTEGRATION_TIME_200_MS);
00036             setContinousMode(MAX_44009_CONTINOUS_MODE_ON);
00037             setManualConfig(MAX_44009_MANUAL_CONFIG_OFF);
00038             break;
00039         case MAX44009_MODE_3:
00040             setIntegrationTime(MAX_44009_INTEGRATION_TIME_100_MS);
00041             setContinousMode(MAX_44009_CONTINOUS_MODE_ON);
00042             setManualConfig(MAX_44009_MANUAL_CONFIG_OFF);
00043             break;
00044         case MAX44009_MODE_4:
00045             setIntegrationTime(MAX_44009_INTEGRATION_TIME_50_MS);
00046             setContinousMode(MAX_44009_CONTINOUS_MODE_ON);
00047             setManualConfig(MAX_44009_MANUAL_CONFIG_ON);
00048             setInterruptEnable(MAX_44009_IRQ_ENABLED);
00049             setInterruptUpperThreshold(MAX_44009_THRESHOLD_4096_LUX);
00050             setInterruptLowerThreshold(0);
00051             break;
00052         case MAX44009_MODE_5:
00053             setIntegrationTime(MAX_44009_INTEGRATION_TIME_25_MS);
00054             setContinousMode(MAX_44009_CONTINOUS_MODE_ON);
00055             setManualConfig(MAX_44009_MANUAL_CONFIG_ON);
00056             break;
00057         case MAX44009_MODE_6:
00058             setIntegrationTime(MAX_44009_INTEGRATION_TIME_12_5_MS);
00059             setContinousMode(MAX_44009_CONTINOUS_MODE_ON);
00060             setManualConfig(MAX_44009_MANUAL_CONFIG_ON);
00061             break;
00062         default:
00063             setIntegrationTime(MAX_44009_INTEGRATION_TIME_800_MS);
00064             setContinousMode(MAX_44009_CONTINOUS_MODE_ON);
00065         }
00066 }
00067 
00068 uint8_t MAX44009Config::getIntegrationTime(){
00069     return this->integrationTime;
00070 }
00071 
00072 uint8_t MAX44009Config::getContinousMode(){
00073     return this->continousMode;
00074 }
00075 
00076 uint8_t MAX44009Config::getManualConfig(){
00077     return this->manualConfig;
00078 }
00079 
00080 uint8_t MAX44009Config::getInterruptEnable(){
00081     return this->interruptEnable;
00082 }
00083 
00084 uint8_t MAX44009Config::getUpperThreshold(){
00085     return this->upperThreshold;
00086 }
00087 
00088 uint8_t MAX44009Config::getLowerThreshold(){
00089     return this->lowerThreshold;
00090 }
00091 
00092 void MAX44009Config::setIntegrationTime(uint8_t integrationTime){
00093     this->integrationTime = integrationTime;
00094 }
00095 
00096 void MAX44009Config::setContinousMode(uint8_t continousMode){
00097     this->continousMode = continousMode;
00098 }
00099 
00100 void MAX44009Config::setManualConfig(uint8_t manualConfig){
00101     this->manualConfig = manualConfig;
00102 }
00103 
00104 void MAX44009Config::setInterruptEnable(uint8_t interruptEnable){
00105     this->interruptEnable = interruptEnable;
00106 }
00107 
00108 void MAX44009Config::setInterruptUpperThreshold(uint8_t upperThreshold){
00109     this->upperThreshold = upperThreshold;
00110 }
00111 
00112 void MAX44009Config::setInterruptLowerThreshold(uint8_t lowerThreshold){
00113     this->lowerThreshold = lowerThreshold;
00114 }