Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Array_Matrix BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
Fork of F746_GUI by
Revision 10:5a2068884fd9, committed 2016-04-27
- Comitter:
- MikamiUitOpen
- Date:
- Wed Apr 27 00:24:18 2016 +0000
- Parent:
- 9:c379410bda15
- Child:
- 11:7debdaa7b503
- Commit message:
- 11
Changed in this revision
--- a/SeekBar.cpp Sun Apr 24 11:49:42 2016 +0000
+++ b/SeekBar.cpp Wed Apr 27 00:24:18 2016 +0000
@@ -1,7 +1,7 @@
//-----------------------------------------------------------
// SeekBar class
//
-// 2016/04/24, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/04/27, Copyright (c) 2016 MIKAMI, Naoki
//-----------------------------------------------------------
#include "SeekBar.hpp"
@@ -101,12 +101,13 @@
// Draw seekbar
void SeekBar::Draw(float value, bool fill)
{
+ uint16_t sizeS = (uint16_t)(SIZE_*0.6f);
// Erase previous seekbar
lcd_.SetTextColor(BACK_COLOR_);
if (ORIENT_ == Holizontal)
- lcd_.FillRect(X_-SIZE_/2, Y_-SIZE_/2, L_+SIZE_+1, SIZE_+1);
+ lcd_.FillRect(X_-sizeS/2, Y_-SIZE_/2, L_+sizeS+1, SIZE_+1);
else
- lcd_.FillRect(X_-SIZE_/2, Y_-SIZE_/2, SIZE_+1, L_+SIZE_+1);
+ lcd_.FillRect(X_-SIZE_/2, Y_-sizeS/2, SIZE_+1, L_+sizeS+1);
v_ = Saturate(value); // current value
Point pt = ToPoint(v_); // Position of thumb
@@ -130,18 +131,33 @@
// Draw thumb
if (active_) lcd_.SetTextColor(CREATED_COLOR_);
else lcd_.SetTextColor(INACTIVE_TEXT_COLOR_);
+ uint16_t width = SIZE_;
+ uint16_t height = SIZE_;
+ if (ORIENT_ == Holizontal) width = sizeS;
+ else height = sizeS;
+ uint16_t xPos = pt.x - width/2;
+ uint16_t yPos = pt.y - height/2;
+
if (fill)
- lcd_.FillCircle(pt.x, pt.y, SIZE_/2);
+ lcd_.FillRect(xPos, yPos, width+1, height+1);
else
- lcd_.DrawCircle(pt.x, pt.y, SIZE_/2);
+ {
+ lcd_.DrawRect(xPos, yPos, width, height);
+ lcd_.DrawHLine(pt.x+width/2, pt.y+height/2, 1);
+ if (v_ == MAX_) lcd_.DrawHLine(xPos, yPos, width); // should not be necessary
+ if (ORIENT_ == Holizontal)
+ lcd_.DrawVLine(pt.x, yPos+3, SIZE_-5);
+ else
+ lcd_.DrawHLine(xPos+3, pt.y, SIZE_-5);
+ }
}
SeekBar::Point SeekBar::ToPoint(float value)
{
if (ORIENT_ == Holizontal)
- return Point(X_ + L_*(value - MIN_)/(MAX_ - MIN_), Y_);
+ return Point(X_ + Round(L_*(value - MIN_)/(MAX_ - MIN_)), Y_);
else
- return Point(X_, Y_ + L_ - L_*(value - MIN_)/(MAX_ - MIN_));
+ return Point(X_, Y_ + L_ - Round(L_*(value - MIN_)/(MAX_ - MIN_)));
}
float SeekBar::ToValue(Point pt)
--- a/SeekBar.hpp Sun Apr 24 11:49:42 2016 +0000 +++ b/SeekBar.hpp Wed Apr 27 00:24:18 2016 +0000 @@ -1,7 +1,7 @@ //----------------------------------------------------------- // SeekBar class -- Header // -// 2016/04/24, Copyright (c) 2016 MIKAMI, Naoki +// 2016/04/26, Copyright (c) 2016 MIKAMI, Naoki //----------------------------------------------------------- #ifndef F746_SEEKBAR_HPP
--- a/SeekBarGroup.cpp Sun Apr 24 11:49:42 2016 +0000
+++ b/SeekBarGroup.cpp Wed Apr 27 00:24:18 2016 +0000
@@ -1,7 +1,7 @@
//-----------------------------------------------------------
// SeekBarGroup class
//
-// 2016/04/24, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/04/26, Copyright (c) 2016 MIKAMI, Naoki
//-----------------------------------------------------------
#include "SeekBarGroup.hpp"
@@ -66,6 +66,8 @@
{
if (seekBars_[n]->IsOnThumb(x, y))
{
+ if ((num != n) && Range(num))
+ seekBars_[num]->Draw(seekBars_[num]->GetValue());
num = n;
seekBars_[n]->SetValue(seekBars_[n]->ToValue(SeekBar::Point(x, y)));
seekBars_[n]->Draw(seekBars_[n]->GetValue(), true);
--- a/SeekBarGroup.hpp Sun Apr 24 11:49:42 2016 +0000
+++ b/SeekBarGroup.hpp Wed Apr 27 00:24:18 2016 +0000
@@ -1,7 +1,7 @@
//-----------------------------------------------------------
// SeekBarGroup class -- Header
//
-// 2016/04/24, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/04/26, Copyright (c) 2016 MIKAMI, Naoki
//-----------------------------------------------------------
#ifndef F746_SEEKBAR_GROUP_HPP
@@ -36,6 +36,11 @@
void Draw(int num, float value, bool fill = false)
{ seekBars_[num]->Draw(value, fill); }
+ void Redraw(int num, bool fill = false)
+ { seekBars_[num]->Draw(seekBars_[num]->GetValue(), fill); }
+
+ void RedrawAll(bool fill = false)
+ { for (int n=0; n<numberOfSeekBar_; n++) Redraw(n, fill); }
// Activate and inactivate
void Activate(int num) { seekBars_[num]->Activate(); }
