Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
Public Member Functions | List of all members
DiscretePot Class Reference

#include <DiscretePot.h>

Public Member Functions

 DiscretePot (const uint8_t pin)
 
void begin (int8_t min=0, int8_t max=11, bool reversed=false, uint8_t threshold=AbstractDebouncedButton::DefaultThreshold, uint8_t delay=AbstractDebouncedButton::DefaultButtonDelay)
 
void update ()
 
int8_t value ()
 

Detailed Description

Discrete values from a potential divider.

Monitors an analog input pin and converts the voltage on the input to a discrete value within a specified range (the default goes up to 11).

Definition at line 12 of file DiscretePot.h.

Constructor & Destructor Documentation

◆ DiscretePot()

DiscretePot::DiscretePot ( const uint8_t  pin)

Constructor.

Parameters
pinthe analog input pin to monitor (e.g. A0)

Definition at line 5 of file DiscretePot.cpp.

Member Function Documentation

◆ begin()

void DiscretePot::begin ( int8_t  min = 0,
int8_t  max = 11,
bool  reversed = false,
uint8_t  threshold = AbstractDebouncedButton::DefaultThreshold,
uint8_t  delay = AbstractDebouncedButton::DefaultButtonDelay 
)

Initializtion.

Parameters
minthe minimum value
maxthe maximum value
reversedset to true to reverse the scale (return max when analogRead is at 0)
thresholddebouncing threshold (see DebouncedButton for details)
delaydebouncing delay (see DebouncedButton for details)

Definition at line 10 of file DiscretePot.cpp.

◆ update()

void DiscretePot::update ( )

Allocate Timeslice.

This method must be called frequently - usually from loop()

Definition at line 20 of file DiscretePot.cpp.

◆ value()

int8_t DiscretePot::value ( )

Get value.

Returns
Current value for the pot.

Definition at line 35 of file DiscretePot.cpp.


The documentation for this class was generated from the following files: