CubeCell - map function error

Hi all. I am waiting for my cubecells arrived here in Brazil. I am converting my software to cubecell.
But, unfortunatelly, the map function is not working. I am receiving the error below
ht:191:65: error: ‘map’ was not declared in this scope

soil_hum_int = map(adc_mv_soil_moisture, minADC, maxADC, 0, 100);

Could someone help me on this subject ? I tried a lot of things, but not sussesfull.

Thank you
Sprenger

I have not yet tried the map function in CubeCell however you could try bypassing the inbult function with your own version. Something like.

I have not tested it

long mymap(long x, long in_min, long in_max, long out_min, long out_max)
{
  if ((in_max - in_min) > (out_max - out_min)) {
    return (x - in_min) * (out_max - out_min+1) / (in_max - in_min+1) + out_min;
  }
  else
  {
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
  }
}

Or one I use regularly to map floats.

float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
1 Like

Please can you put an example with data