Commit c5c7ca70 authored by Sebastián Fernández's avatar Sebastián Fernández

paso a flotante valores a guardar en la memoria

parent cef42a45
......@@ -65,7 +65,7 @@ int front_position = LOW; // HIGH when present
// EEPROM
// define the number of byte needed
#define ADD_POWER_RAW 0 // address 0 and 1 store radiation power (4 bytes)
#define ADD_ON_TIME 4 // address 1 and 2 store TIME on decens of minutes (4 bytes)
#define ADD_ON_TIME 4 // address 1 and 2 store TIME on minutes (4 bytes)
#define ADD_CAL_G 8 // address 3 and 4 store Calibration parameter 1 (4 bytes)
#define ADD_CAL_O 12 // address 5 and 6 store Calibration parameter 1 (4 bytes)
#define EEPROM_SIZE 20 //
......@@ -76,8 +76,8 @@ float radiation_power = 1.0;
float calibration_gain = 1.0;
float calibration_offset = 1.0;
float fdec_minutes_on = 0;
int idec_minutes_on = 0;
float fminutes_on = 0;
int iminutes_on = 0;
float scaleRadiationPower(float radiation_raw)
{
......@@ -122,27 +122,27 @@ if (Serial.available() > 0)
inData[indexData] = incomingByte;
indexData++;
}
Serial.print("index data máximo: ");
Serial.println(indexData);
//Serial.print("index data máximo: ");
//Serial.println(indexData);
if (inData[0] == 'r') //r
{
Serial.println("===== comando recibido: leer eeprom ===== ");
// formato mensaje: r
Serial.print("Potencia guardada: ");
Serial.print("Potencia RAW guardada : ");
EEPROM.get(ADD_POWER_RAW, radiation_power_raw);
radiation_power = scaleRadiationPower(radiation_power_raw);
Serial.println(radiation_power);
Serial.print("Horas encendido: ");
EEPROM.get(ADD_ON_TIME, fdec_minutes_on);
Serial.println(fdec_minutes_on/6);
Serial.print("Horas encendido : ");
EEPROM.get(ADD_ON_TIME, fminutes_on);
Serial.println(fminutes_on/60);
Serial.print("Coeficiente ganancia: ");
Serial.print("Coeficiente ganancia : ");
EEPROM.get(ADD_CAL_G, calibration_gain);
Serial.println(calibration_gain);
Serial.print("Coeficiente offset: ");
Serial.print("Coeficiente offset : ");
EEPROM.get(ADD_CAL_O, calibration_offset);
Serial.println(calibration_offset);
}
......@@ -150,18 +150,18 @@ if (Serial.available() > 0)
if (inData[0] == 'h') //h
{
Serial.println("===== comando recibido: setear horas encendido ===== ");
// formato mensaje: h,decenas_minutos
int decenas_minutos_on = 1;
// formato mensaje: h,minutos
int minutos_on = 1;
bool recepcion_ok = false;
for (int j = 2; j < indexData; j = j + 1) {
readString += inData[j];
}
if (readString) {
decenas_minutos_on = round(readString.toInt());
Serial.print("Decenas de minutos a grabar en EEPROM: ");
Serial.println(decenas_minutos_on);
fdec_minutes_on= (float)decenas_minutos_on;
EEPROM.put(ADD_ON_TIME, fdec_minutes_on);
minutos_on = round(readString.toInt());
Serial.print("Minutos a grabar en EEPROM: ");
Serial.println(minutos_on);
fminutes_on= (float)minutos_on;
EEPROM.put(ADD_ON_TIME, fminutes_on);
EEPROM.commit();
recepcion_ok = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment