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: ResetButton.hpp
- Revision:
- 22:fa0181712d9c
- Parent:
- 21:5abb486c68e0
- Child:
- 27:115219bcd9f5
diff -r 5abb486c68e0 -r fa0181712d9c ResetButton.hpp --- a/ResetButton.hpp Wed Aug 17 06:12:49 2016 +0000 +++ b/ResetButton.hpp Wed Aug 17 06:17:30 2016 +0000 @@ -1,45 +1,46 @@ //----------------------------------------------------------- -// BlinkLabel class -- derived class of Label class -// For displaying error message +// ResetButton class -- derived class of Button class // -// 2016/08/16, Copyright (c) 2016 MIKAMI, Naoki +// 2016/08/15, Copyright (c) 2016 MIKAMI, Naoki //----------------------------------------------------------- -#ifndef F746_BLINK_LABEL_HPP -#define F746_BLINK_LABEL_HPP +#ifndef F746_RESET_BUTTON_HPP +#define F746_RESET_BUTTON_HPP -#include "Label.hpp" -#include "ResetButton.hpp" +#include "Button.hpp" namespace Mikami { - class BlinkLabel : public Label + class ResetButton : public Button { public: - // Constructor - BlinkLabel(uint16_t x, uint16_t y, const string str, - TextAlignMode mode = LEFT, - sFONT &fonts = Font20, - uint32_t textColor = LCD_COLOR_RED, - uint32_t backColor = GuiBase::ENUM_BACK, - uint32_t on = 500, uint32_t off = 200) - : Label(x, y, str, mode, fonts, textColor, backColor) + ResetButton(uint16_t x = 0, uint16_t y = 240, + uint16_t w = 32, uint16_t h = 32) + : Button(x, y, w, h) + { + pt_[0] = (Point){x+0.2f*w, y+h/2}; + pt_[1] = (Point){x+0.75f*w, y+0.175f*h}; + pt_[2] = (Point){x+0.75f*w, y+0.825f*h}; + Draw(); + } + + void Do() { - ResetButton *reset = new ResetButton(); - while (true) // Blinking here - { - wait_ms(on); - Draw(backColor); - wait_ms(off); - Draw(textColor); - reset->Do(); - } + if (!Touched()) return; + + wait(0.2f); + NVIC_SystemReset(); + } + + void Draw() + { + Activate(); + lcd_.SetTextColor(LCD_COLOR_WHITE); + lcd_.FillPolygon(pt_, 3); } private: - // disallow copy constructor and assignment operator - BlinkLabel(const BlinkLabel&); - BlinkLabel& operator=(const BlinkLabel&); + Point pt_[3]; }; } -#endif // F746_BLINK_LABEL_HPP +#endif // F746_RESET_BUTTON_HPP