Phoenard
PHNBarGraph.h
Go to the documentation of this file.
1 /*
2 The MIT License (MIT)
3 
4 This file is part of the Phoenard Arduino library
5 Copyright (c) 2014 Phoenard
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 THE SOFTWARE.
24 */
25 
31 #include "PHNWidget.h"
32 
33 #ifndef _PHN_BARGRAPH_H_
34 #define _PHN_BARGRAPH_H_
35 
37 class PHN_BarGraph : public PHN_Widget {
38  public:
40  void setRange(float minimum, float maximum);
42  void setBaseValue(float baseValue);
44  void setValue(float value);
46  float value() const { return _valueReq; }
47 
48  virtual void update(void);
49  virtual void draw(void);
50  private:
51  void drawBar(float val_a, float val_b, color_t color);
52  float _minimum, _maximum, _value, _valueReq, _baseVal;
53 };
54 
55 #endif
float value() const
Gets the value displayed by the gauge.
Definition: PHNBarGraph.h:46
void setValue(float value)
Sets the value displayed by the gauge.
Definition: PHNBarGraph.cpp:34
virtual void draw(void)
Draw function routine, where widgets must perform drawing.
Definition: PHNBarGraph.cpp:72
Shows a value on a variable sized colored bar, the range and value changeable.
Definition: PHNBarGraph.h:37
const color_t color(int colorId)
Gets a style color set for this widget.
Definition: PHNWidget.h:178
void setBaseValue(float baseValue)
Sets the base value of the bar graph from which the bar is drawn.
Definition: PHNBarGraph.cpp:44
uint16_t color_t
Definition of the 16-bit 565 color type.
Definition: PHNDisplayHardware.h:97
A single widget which covers a rectangular area of the screen.
Definition: PHNWidget.h:145
void setRange(float minimum, float maximum)
Sets the minimum and maximum value of the gauge.
Definition: PHNBarGraph.cpp:26
virtual void update(void)
Update function routine, where widget logic must be performed.
Definition: PHNBarGraph.cpp:49
Holds the PHN_Widget and PHN_WidgetContainer classes used for managing widgets.