GUI parts for DISCO-F746NG. GuiBase, Button, ButtonGroup, ResetButton, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup, NumericUpDown
Dependencies: Array_Matrix TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG
Diff: SeekBar.hpp
- Revision:
- 9:c379410bda15
- Parent:
- 6:b8f197b0012c
- Child:
- 10:5a2068884fd9
--- a/SeekBar.hpp Thu Apr 21 01:12:59 2016 +0000 +++ b/SeekBar.hpp Sun Apr 24 11:49:42 2016 +0000 @@ -1,7 +1,7 @@ //----------------------------------------------------------- // SeekBar class -- Header // -// 2016/04/12, Copyright (c) 2016 MIKAMI, Naoki +// 2016/04/24, Copyright (c) 2016 MIKAMI, Naoki //----------------------------------------------------------- #ifndef F746_SEEKBAR_HPP @@ -17,6 +17,12 @@ public: enum Orientation { Holizontal, Vertical }; + struct Point + { + uint16_t x, y; + Point(uint16_t x0 = 0, uint16_t y0 = 0) : x(x0), y(y0) {} + }; + // Constructor SeekBar(uint16_t x, uint16_t y, uint16_t length, float min, float max, float initialValue, @@ -47,16 +53,22 @@ bool Slide(); float GetValue() { return v_; } int GetIntValue() { return Round(v_); } + void Activate(); void Inactivate(); + bool IsActive() { return active_; } + + bool IsOnThumb(uint16_t &x, uint16_t &y); + void Draw(float value, bool fill = false); + float ToValue(Point pt); + + void SetValue(float v) { v_ = v; } + void SetSlided(bool tf) { slided_ = tf; } + bool GetSlided() { return slided_; } + + int Round(float x) { return x + 0.5f - (x < 0); } // Round up on 5 private: - struct Point - { - uint16_t x, y; - Point(uint16_t x0 = 0, uint16_t y0 = 0) : x(x0), y(y0) {} - }; - const uint16_t L_, W_; const uint16_t SIZE_; // Size of thumb const uint32_t COLOR_L_, COLOR_H_; @@ -68,11 +80,7 @@ bool slided_; bool active_; - void Draw(float value, bool fill = false); - bool IsOnThumb(uint16_t &x, uint16_t &y); Point ToPoint(float value); - float ToValue(Point pt); - int Round(float x) { return x + 0.5f - (x < 0); } // Round up on 5 float Saturate(float value); // disallow copy constructor and assignment operator