conflict between the inputs

ayman.dab
Posts: 8
Joined: Mon Aug 29, 2022 12:10 pm

conflict between the inputs

Postby ayman.dab » Thu Sep 15, 2022 5:06 am

Hello, I have my own system and when I need to change one input the other one change but the desired doesn't, any advice ?
When I change the Current level from application, Full level changes and the current remains the same and vice versa

write call back function code:

Code: Select all

void write_callback(Device *device, Param *param, const param_val_t vall, void *priv_data, write_ctx_t *ctx)
{
  const char *device_name = device->getDeviceName();
  const char *param_name = param->getParamName();


  if (strcmp(param_name,"Current level (cm)") == 0) {
    Serial.printf("Received value = %2.2f for %s - %s\n", vall.val.f, device_name, param_name);
    curlevel = vall.val.f;
    val =curlevel ;
    param->updateAndReport(vall);
    set_value();
  }


  else if (strcmp(param_name, "Full volume(L)") == 0) {
    Serial.printf("Received value = %2.2f for %s - %s\n", vall.val.f, device_name, param_name);
    full_volume = vall.val.f;
    preferences.putInt("full_volume",full_volume);
    param->updateAndReport(vall);
  }

  
   else if (strcmp(param_name, "Full level(cm)") == 0) {
    Serial.printf("Received value = %2.2f for %s - %s\n", vall.val.f, device_name, param_name);
    fullevel = vall.val.f;
    val = fullevel ;
    full_value();
    param->updateAndReport(vall);
  }
  }

create the parameters for device code:

Code: Select all

  Param currentlevel("Current level (cm)", "custom.param.clevel", value((float)DEFAULT_current_level), PROP_FLAG_WRITE );
  calibration.addParam(currentlevel);

  Param fulllevel("Full level(cm)", "custom.param.flevel", value((float)DEFAULT_full_level), PROP_FLAG_WRITE );
  calibration.addParam(fulllevel);

  Param fullvolume("Full volume(L)", "custom.param.fvolume", value((float)DEFAULT_full_volume), PROP_FLAG_WRITE );
  calibration.addParam(fullvolume);

Who is online

Users browsing this forum: No registered users and 7 guests