BatteryPanel
Revision 0:fe4a274c3785, committed 2019-06-04
- Comitter:
- williequesada
- Date:
- Tue Jun 04 17:00:52 2019 +0000
- Commit message:
- pablo
Changed in this revision
BatteryPanel.cpp | Show annotated file Show diff for this revision Revisions of this file |
BatteryPanel.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r fe4a274c3785 BatteryPanel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BatteryPanel.cpp Tue Jun 04 17:00:52 2019 +0000 @@ -0,0 +1,57 @@ +#include "BatteryPanel.h" +#include "mbed.h" + +float ValorLectura; +float ValorCalculado; + +BATTERY_PANEL::BATTERY_PANEL(PinName AnalogBattery, PinName AnalogPanel, PinName Control) : _AnalogBattery(AnalogBattery), _AnalogPanel(AnalogPanel), _Control(Control) +{ + _Control = 0; +} + +float BATTERY_PANEL::BatteryRead() +{ + ValorLectura = _AnalogBattery.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) + ValorCalculado = ValorLectura*23; // Converts value in the 0V-3.3V range + return ValorCalculado; +} + +float BATTERY_PANEL::PanelRead() +{ + ValorLectura = _AnalogPanel.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) + ValorCalculado = ValorLectura*23; // Converts value in the 0V-3.3V range + return ValorCalculado; +} + +float BATTERY_PANEL::BatteryAnalog() +{ + ValorLectura = _AnalogBattery.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) + ValorCalculado = ValorLectura*3.3; // Converts value in the 0V-3.3V range + return ValorCalculado; +} + +float BATTERY_PANEL::PanelAnalog() +{ + ValorLectura = _AnalogPanel.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) + ValorCalculado = ValorLectura*3.3; // Converts value in the 0V-3.3V range + return ValorCalculado; +} + +int BATTERY_PANEL::Control() +{ + ValorLectura = _AnalogBattery.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) + ValorCalculado = ValorLectura*23; + + if(ValorCalculado>15){ + _Control=0; + return 2; + } else { + _Control=1; + } + if(ValorCalculado<12){ + return 0; + } + return 1; +}; + +
diff -r 000000000000 -r fe4a274c3785 BatteryPanel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BatteryPanel.h Tue Jun 04 17:00:52 2019 +0000 @@ -0,0 +1,25 @@ + +#ifndef MBED_BATTERYPANEL_H +#define MBED_BATTERYPANEL_H + +#include "mbed.h" + +class BATTERY_PANEL { +public: + BATTERY_PANEL(PinName AnalogBattery, PinName AnalogPanel, PinName Control); + + float PanelRead(); + float BatteryRead(); + float PanelAnalog(); + float BatteryAnalog(); + int Control(); + +private: + AnalogIn _AnalogBattery; + AnalogIn _AnalogPanel; + DigitalOut _Control; +}; + +#endif + + \ No newline at end of file