source: trunk/Arduino/libraries/Adafruit_Circuit_Playground/examples/mega_demo/Demo.h

Last change on this file was 3, checked in by markus, 7 years ago

Setup project structure

File size: 674 bytes
Line 
1#ifndef DEMO_H
2#define DEMO_H
3
4// Define each mode with the following interface for a loop and modePress
5// function that will be called during the main loop and if the mode button
6// was pressed respectively.  It's up to each mode implementation to fill
7// these in and add their logic.
8class Demo {
9public:
10  virtual ~Demo() {}
11
12  virtual void loop() = 0;
13  virtual void modePress() = 0;
14};
15
16// Linear interpolation function is handy for all the modes to use.
17float lerp(float x, float xmin, float xmax, float ymin, float ymax) {
18  if (x >= xmax) {
19    return ymax;
20  }
21  if (x <= xmin) {
22    return ymin;
23  }
24  return ymin + (ymax-ymin)*((x-xmin)/(xmax-xmin));
25}
26
27#endif
Note: See TracBrowser for help on using the repository browser.