Skip to content

File evaSlider.h

File List > src > evaSlider.h

Go to the documentation of this file

#pragma once

#include "evaStdReaders.h"
#include <Arduino.h>

namespace eva
{
  template <class TReader, unsigned short MIN_POS, unsigned short MAX_POS>
  class Slider : public TReader
  {
  public:
    signed short getValue()
    {
      return constrain(map(TReader::getValue(), MIN_POS, MAX_POS, 1000, 2000), 1000, 2000);
    }
  };
  template <unsigned short PIN, int PIN_MODE, unsigned short MIN_POS, unsigned short MAX_POS>
  using PinSlider = Slider<AnalogPinReader<PIN, PIN_MODE>, MIN_POS, MAX_POS>;
};