"'map' was not declared in this scope"

Hello. I have this problem with map() not really being recognised it seems. If it matters, I am using Arduino IDE 1.8.1, and a MEGA 2560 board.

Currently I am trying to make a class work,

DSDroneSignal.h

#include "Config.h"

class DSDroneSignal
{
 public:
  //DSDroneSignal();    // Constructor set default ppm-values
  void EditControl(char InputSegment[]);
  void ChangeVelocity(int Channel, int Value);
 private: 
  int PPM[CHANNEL_NUMBER];
};

and DSDroneSignal.cpp,

void DSDroneSignal::EditControl(char InputSegment[])
{
  if ( InputSegment[0] == ( ('t' || 'r' || 'a' || 'y') || ('T' || 'R' || 'A' || 'Y') ) )
  {
    // TODO: Make channel recogniser-function instead,
    int ChannelIndex = 1;
    int VelocityRate = atoi(&InputSegment[1]);
    int NewVelocity = map(VelocityRate, 0, 100, CHANNEL_MIN_VALUE, CHANNEL_MAX_VALUE);
    
    DSDroneSignal::ChangeVelocity(ChannelIndex, NewVelocity);
  }

};



void DSDroneSignal::ChangeVelocity(int Channel, int Value)
{
  DSDroneSignal::PPM[Channel] = Value;
};

And I get this error,

sketch/DroneSignal.cpp: In member function 'void DSDroneSignal::EditControl(char*)':
DroneSignal.cpp:11: error: 'map' was not declared in this scope
     int NewVelocity = map(VelocityRate, 0, 100, CHANNEL_MIN_VALUE, CHANNEL_MAX_VALUE);

Inside of the Config.h file are the capitalised constants given as well as the standard library included (<stdlib.h>).

I dont' really see anyone having this problem except for one guy in 2008, because map() was recently introduced back then, and he had not updated his software. Now, I am borrowing this Arduino from someone else, but I doubt it is that old.

You need to include Arduino.h. We're used to having access to all the Arduino core library functions in our sketches because the IDE automatically adds the line:

#include <Arduino.h>

to the sketch when you compile but it does not do so for other source files.

Ah, that makes sense, and it seems to work now. Thank you very much for the help!

if ( InputSegment[0] == ( ('t' || 'r' || 'a' || 'y') || ('T' || 'R' || 'A' || 'Y') ) )This is not how you compare a value with one or more other values. You need to do the comparisons individually or iterate through a string looking at each character in turn.

Following on Bob's comment, you might use:

   char testInput[] = "TRAY";

   // more code...

   for (i...
      for (j...
         if (toupper(InputSegment[i]) == testInput[j]) {

The toupper() macro makes it so you can abstract from upper and lower case letters.

Hello. Sorry, I thought I had replied. Thank you for the tips, both of you. It's been a while since I've done C++. With my school work, you pretty much only work with high level programming/scripting, so I don't really get to work with not-so-forgiving code too much anymore.