Automate écran capacitif
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI SeeedStudioTFTv2 TFT_fonts mbed
Fork of DISCO-F469NI_LCD_demo by
F469_GUI/SeekbarGroup.cpp@2:2182df2d7810, 2017-03-31 (annotated)
- Committer:
- SquirrelGod
- Date:
- Fri Mar 31 15:36:26 2017 +0000
- Revision:
- 2:2182df2d7810
Programme ?cran capacitif
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SquirrelGod | 2:2182df2d7810 | 1 | //----------------------------------------------------------- |
SquirrelGod | 2:2182df2d7810 | 2 | // SeekbarGroup class |
SquirrelGod | 2:2182df2d7810 | 3 | // |
SquirrelGod | 2:2182df2d7810 | 4 | // 2016/04/30, Copyright (c) 2016 MIKAMI, Naoki |
SquirrelGod | 2:2182df2d7810 | 5 | //----------------------------------------------------------- |
SquirrelGod | 2:2182df2d7810 | 6 | |
SquirrelGod | 2:2182df2d7810 | 7 | #include "SeekbarGroup.hpp" |
SquirrelGod | 2:2182df2d7810 | 8 | |
SquirrelGod | 2:2182df2d7810 | 9 | namespace Mikami |
SquirrelGod | 2:2182df2d7810 | 10 | { |
SquirrelGod | 2:2182df2d7810 | 11 | SeekbarGroup::SeekbarGroup( |
SquirrelGod | 2:2182df2d7810 | 12 | uint16_t x0, uint16_t y0, uint16_t length, |
SquirrelGod | 2:2182df2d7810 | 13 | uint16_t number, uint16_t space, |
SquirrelGod | 2:2182df2d7810 | 14 | float min, float max, float initialValue, |
SquirrelGod | 2:2182df2d7810 | 15 | SeekBar::Orientation hv, |
SquirrelGod | 2:2182df2d7810 | 16 | uint32_t thumbColor, |
SquirrelGod | 2:2182df2d7810 | 17 | uint16_t thumbSize, uint16_t width, |
SquirrelGod | 2:2182df2d7810 | 18 | uint32_t colorL, uint32_t colorH, |
SquirrelGod | 2:2182df2d7810 | 19 | uint32_t backColor) |
SquirrelGod | 2:2182df2d7810 | 20 | : GuiBase(x0, y0, Font12, GuiBase::ENUM_TEXT, backColor, thumbColor), |
SquirrelGod | 2:2182df2d7810 | 21 | numberOfSeekBar_(number) |
SquirrelGod | 2:2182df2d7810 | 22 | { |
SquirrelGod | 2:2182df2d7810 | 23 | seekBars_ = new SeekBar *[number]; |
SquirrelGod | 2:2182df2d7810 | 24 | for (int n=0; n<number; n++) |
SquirrelGod | 2:2182df2d7810 | 25 | { |
SquirrelGod | 2:2182df2d7810 | 26 | uint16_t x = x0; |
SquirrelGod | 2:2182df2d7810 | 27 | uint16_t y = y0; |
SquirrelGod | 2:2182df2d7810 | 28 | if (hv == SeekBar::Holizontal) y += space*n; |
SquirrelGod | 2:2182df2d7810 | 29 | else x += space*n; |
SquirrelGod | 2:2182df2d7810 | 30 | seekBars_[n] = |
SquirrelGod | 2:2182df2d7810 | 31 | new SeekBar(x, y, length, min, max, initialValue, hv, |
SquirrelGod | 2:2182df2d7810 | 32 | thumbColor, thumbSize, width, |
SquirrelGod | 2:2182df2d7810 | 33 | colorL, colorH, backColor); |
SquirrelGod | 2:2182df2d7810 | 34 | } |
SquirrelGod | 2:2182df2d7810 | 35 | } |
SquirrelGod | 2:2182df2d7810 | 36 | |
SquirrelGod | 2:2182df2d7810 | 37 | // Destructor |
SquirrelGod | 2:2182df2d7810 | 38 | SeekbarGroup::~SeekbarGroup() |
SquirrelGod | 2:2182df2d7810 | 39 | { |
SquirrelGod | 2:2182df2d7810 | 40 | for (int n=0; n<numberOfSeekBar_; n++) delete seekBars_[n]; |
SquirrelGod | 2:2182df2d7810 | 41 | delete[] seekBars_; |
SquirrelGod | 2:2182df2d7810 | 42 | } |
SquirrelGod | 2:2182df2d7810 | 43 | |
SquirrelGod | 2:2182df2d7810 | 44 | // Get slided number |
SquirrelGod | 2:2182df2d7810 | 45 | bool SeekbarGroup::GetSlidedNumber(int &num) |
SquirrelGod | 2:2182df2d7810 | 46 | { |
SquirrelGod | 2:2182df2d7810 | 47 | bool active = false; |
SquirrelGod | 2:2182df2d7810 | 48 | for (int n=0; n<numberOfSeekBar_; n++) |
SquirrelGod | 2:2182df2d7810 | 49 | if (seekBars_[n]->IsActive()) active = true; |
SquirrelGod | 2:2182df2d7810 | 50 | if (!active) return false; |
SquirrelGod | 2:2182df2d7810 | 51 | |
SquirrelGod | 2:2182df2d7810 | 52 | if (!PanelTouched()) |
SquirrelGod | 2:2182df2d7810 | 53 | { |
SquirrelGod | 2:2182df2d7810 | 54 | for (int n=0; n<numberOfSeekBar_; n++) |
SquirrelGod | 2:2182df2d7810 | 55 | { |
SquirrelGod | 2:2182df2d7810 | 56 | if (seekBars_[n]->GetSlided()) |
SquirrelGod | 2:2182df2d7810 | 57 | seekBars_[n]->Draw(seekBars_[n]->GetValue()); |
SquirrelGod | 2:2182df2d7810 | 58 | seekBars_[n]->SetSlided(false); |
SquirrelGod | 2:2182df2d7810 | 59 | } |
SquirrelGod | 2:2182df2d7810 | 60 | return false; |
SquirrelGod | 2:2182df2d7810 | 61 | } |
SquirrelGod | 2:2182df2d7810 | 62 | |
SquirrelGod | 2:2182df2d7810 | 63 | bool rtn = false; |
SquirrelGod | 2:2182df2d7810 | 64 | uint16_t x, y; |
SquirrelGod | 2:2182df2d7810 | 65 | for (int n=0; n<numberOfSeekBar_; n++) |
SquirrelGod | 2:2182df2d7810 | 66 | { |
SquirrelGod | 2:2182df2d7810 | 67 | if (seekBars_[n]->IsOnThumb(x, y)) |
SquirrelGod | 2:2182df2d7810 | 68 | { |
SquirrelGod | 2:2182df2d7810 | 69 | if ((num != n) && Range(num)) |
SquirrelGod | 2:2182df2d7810 | 70 | seekBars_[num]->Draw(seekBars_[num]->GetValue()); |
SquirrelGod | 2:2182df2d7810 | 71 | num = n; |
SquirrelGod | 2:2182df2d7810 | 72 | seekBars_[n]->SetValue(seekBars_[n]->ToValue(SeekBar::Point(x, y))); |
SquirrelGod | 2:2182df2d7810 | 73 | seekBars_[n]->Draw(seekBars_[n]->GetValue(), true); |
SquirrelGod | 2:2182df2d7810 | 74 | seekBars_[n]->SetSlided(true); |
SquirrelGod | 2:2182df2d7810 | 75 | rtn = true; |
SquirrelGod | 2:2182df2d7810 | 76 | } |
SquirrelGod | 2:2182df2d7810 | 77 | if (rtn) break; |
SquirrelGod | 2:2182df2d7810 | 78 | } |
SquirrelGod | 2:2182df2d7810 | 79 | return rtn; |
SquirrelGod | 2:2182df2d7810 | 80 | } |
SquirrelGod | 2:2182df2d7810 | 81 | } |