Automate écran capacitif
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI SeeedStudioTFTv2 TFT_fonts mbed
Fork of DISCO-F469NI_LCD_demo by
Revision 2:2182df2d7810, committed 2017-03-31
- Comitter:
- SquirrelGod
- Date:
- Fri Mar 31 15:36:26 2017 +0000
- Parent:
- 1:63e8edd5d29a
- Commit message:
- Programme ?cran capacitif
Changed in this revision
diff -r 63e8edd5d29a -r 2182df2d7810 BSP_DISCO_F469NI.lib --- a/BSP_DISCO_F469NI.lib Fri Dec 18 07:34:21 2015 +0000 +++ b/BSP_DISCO_F469NI.lib Fri Mar 31 15:36:26 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/ST/code/BSP_DISCO_F469NI/#0002c86c2220 +https://developer.mbed.org/teams/CRAC-Team/code/BSP_DISCO_F469NI/#c508cb96fa5a
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/BlinkLabel.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/BlinkLabel.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,45 @@ +//----------------------------------------------------------- +// BlinkLabel class -- derived class of Label class +// For displaying error message +// +// 2016/08/16, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#ifndef F746_BLINK_LABEL_HPP +#define F746_BLINK_LABEL_HPP + +#include "Label.hpp" +#include "ResetButton.hpp" + +namespace Mikami +{ + class BlinkLabel : public Label + { + 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 *reset = new ResetButton(); + while (true) // Blinking here + { + wait_ms(on); + Draw(backColor); + wait_ms(off); + Draw(textColor); + reset->Do(); + } + } + + private: + // disallow copy constructor and assignment operator + BlinkLabel(const BlinkLabel&); + BlinkLabel& operator=(const BlinkLabel&); + }; +} +#endif // F746_BLINK_LABEL_HPP
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/Button.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/Button.cpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,67 @@ +//----------------------------------------------------------- +// Button class handling multi-touch +// Multi-touch: Enabled (default) +// +// 2016/04/08, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#include "Button.hpp" + +namespace Mikami +{ + // Draw button + void Button::Draw(uint32_t color, uint32_t textColor) + { + if (color == BACK_COLOR_) active_ = true; + if (!active_) return; + lcd_.SetTextColor(color); + lcd_.FillRect(X_, Y_, W_, H_); + + if (STR_.length() != 0) + { + lcd_.SetFont(FONTS_); + lcd_.SetBackColor(color); + lcd_.SetTextColor(textColor); + uint16_t x0 = X_ + (W_ - FONTS_->Width*(STR_.length()))/2; + uint16_t y0 = Y_ + (H_ - FONTS_->Height)/2 + 1; + DrawString(x0, y0, STR_); + lcd_.SetBackColor(BACK_COLOR_); // recover back color + } + } + + // Check touch detected + bool Button::Touched() + { + if (!active_) return false; + if (!PanelTouched()) return false; + if (!IsOnButton()) return false; + Draw(TOUCHED_COLOR_, TEXT_COLOR_); + return true; + } + + // If touched position is on the button, return true + bool Button::IsOnButton() + { + int nTouch = multiTouch_ ? state_.touchDetected : 1; + for (int n=0; n<nTouch; n++) + { + uint16_t x = state_.touchX[n]; + uint16_t y = state_.touchY[n]; + if ( (X_ <= x) && (x <= X_+W_) && + (Y_ <= y) && (y <= Y_+H_) ) return true; + } + return false; + } + + void Button::Activate() + { + active_ = true; + Draw(); + } + + void Button::Inactivate() + { + Draw(INACTIVE_COLOR_, INACTIVE_TEXT_COLOR_); + active_ = false; + } +}
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/Button.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/Button.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,65 @@ +//----------------------------------------------------------- +// Button class handling multi-touch -- Header +// Multi-touch: Enabled (default) +// +// 2016/03/29, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#ifndef F746_BUTTON_HPP +#define F746_BUTTON_HPP + +#include "GuiBase.hpp" + +namespace Mikami +{ + class Button : public GuiBase + { + public: + // Constructor + Button(uint16_t x, uint16_t y, + uint16_t width, uint16_t height, + const string str = "", sFONT &fonts = Font12, + uint32_t textColor = GuiBase::ENUM_TEXT, + uint32_t backColor = GuiBase::ENUM_BACK, + uint32_t createdColor = GuiBase::ENUM_CREATED, + uint32_t touchedColor = GuiBase::ENUM_TOUCHED, + uint32_t inactiveColor = GuiBase::ENUM_INACTIVE, + uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT) + : GuiBase(x, y, fonts, + textColor, backColor, createdColor, + touchedColor, inactiveColor, + inactiveTextColor), + W_(width), H_(height), STR_(str), active_(true) + { Draw(); } + + // Draw button + void Draw(uint32_t color, uint32_t textColor); + void Draw(uint32_t color) { Draw(color, TEXT_COLOR_); } + void Draw() { Draw(CREATED_COLOR_, TEXT_COLOR_); } + + // Erase button + void Erase() { Draw(BACK_COLOR_, BACK_COLOR_); } + + // Check touch detected and redraw button + bool Touched(); + + bool IsOnButton(); + + void Activate(); + void Inactivate(); + bool IsActive() { return active_; } + + // Set or reset multi-touch + static void SetMultiTouch(bool tf) { multiTouch_ = tf; } + + private: + const uint16_t W_, H_; + const string STR_; + bool active_; + + // disallow copy constructor and assignment operator + Button(const Button&); + Button& operator=(const Button&); + }; +} +#endif // F746_BUTTON_HPP
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/ButtonGroup.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/ButtonGroup.cpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,123 @@ +//----------------------------------------------------------- +// ButtonGroup class +// +// 2016/07/03, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#include "ButtonGroup.hpp" + +namespace Mikami +{ + // Constructor + ButtonGroup::ButtonGroup( + uint16_t x0, uint16_t y0, + uint16_t width, uint16_t height, + uint16_t number, const string str[], + uint16_t spaceX, uint16_t spaceY, + uint16_t column, int touched, + sFONT &fonts, + uint32_t textColor, uint32_t backColor, + uint32_t createdColor, uint32_t touchedColor, + uint32_t inactiveColor, uint32_t inactiveTextColor) + : GuiBase(x0, y0, fonts, textColor, backColor, + createdColor, touchedColor, + inactiveColor, inactiveTextColor), + number_(number), prevNum_(touched) + { + buttons_ = new Button *[number]; + for (int n=0; n<number; n++) + { + div_t u1 = div(n, column); + uint16_t x = x0 + u1.rem*(width + spaceX); + uint16_t y = y0 + u1.quot*(height + spaceY); + buttons_[n] = + new Button(x, y, width, height, str[n], fonts, + TEXT_COLOR_, BACK_COLOR_, + CREATED_COLOR_, TOUCHED_COLOR_, + INACTIVE_COLOR_, INACTIVE_TEXT_COLOR_); + } + // On created, set touched color as needed + if (touched >= 0) TouchedColor(touched); + } + + // Destructor + ButtonGroup::~ButtonGroup() + { + for (int n=0; n<number_; n++) delete buttons_[n]; + delete[] buttons_; + } + + // Draw button + bool ButtonGroup::Draw(int num, uint32_t color, uint32_t textColor) + { + if (!Range(num)) return false; + buttons_[num]->Draw(color, textColor); + return true; + } + + // Change to touched color + bool ButtonGroup::TouchedColor(int num) + { + if (prevNum_ != num) prevNum_ = num; + return Draw(num, TOUCHED_COLOR_, TEXT_COLOR_); + } + + // Erase button + bool ButtonGroup::Erase(int num) + { + if (!Range(num)) return false; + buttons_[num]->Erase(); + return true; + } + + // Check touch detected for specified button + bool ButtonGroup::Touched(int num) + { + if (!Range(num)) return false; + if (!buttons_[num]->IsActive()) return false; + int touched; + if (!GetTouchedNumber(touched)) return false; + bool rtn = (touched == num) ? true : false; + return rtn; + } + + // Get touched number + bool ButtonGroup::GetTouchedNumber(int &num) + { + bool rtn = false; + if (PanelTouched()) + { + for (int n=0; n<number_; n++) + if (buttons_[n]->IsOnButton() && + buttons_[n]->IsActive()) + { + num = n; + rtn = true; + } + + if (!rtn) return false; + } + else + return false; + + buttons_[num]->Draw(TOUCHED_COLOR_); + if ((prevNum_ >= 0) && (prevNum_ != num)) + buttons_[prevNum_]->Draw(); + if (prevNum_ != num) prevNum_ = num; + return true; + } + + // Activate and inactivate button(s) + bool ButtonGroup::Activate(int num) + { + if (!Range(num)) return false; + buttons_[num]->Activate(); + return true; + } + bool ButtonGroup::Inactivate(int num) + { + if (!Range(num)) return false; + buttons_[num]->Inactivate(); + return true; + } +}
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/ButtonGroup.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/ButtonGroup.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,80 @@ +//----------------------------------------------------------- +// ButtonGroup class -- Header +// +// 2016/07/12, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#ifndef F746_BUTTON_GROUP_HPP +#define F746_BUTTON_GROUP_HPP + +#include "Button.hpp" + +namespace Mikami +{ + class ButtonGroup : public GuiBase + { + public: + // Constructor + ButtonGroup(uint16_t x0, uint16_t y0, + uint16_t width, uint16_t height, + uint16_t number, const string str[], + uint16_t spaceX = 0, uint16_t spaceY = 0, + uint16_t column = 1, + int touched = -1, // number for button initially touched-color + sFONT &fonts = Font12, + uint32_t textColor = GuiBase::ENUM_TEXT, + uint32_t backColor = GuiBase::ENUM_BACK, + uint32_t createdColor = GuiBase::ENUM_CREATED, + uint32_t touchedColor = GuiBase::ENUM_TOUCHED, + uint32_t inactiveColor = GuiBase::ENUM_INACTIVE, + uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT); + + // Destructor + virtual ~ButtonGroup(); + + // Draw button + bool Draw(int num, uint32_t color, uint32_t textColor); + bool Draw(int num) { return Draw(num, CREATED_COLOR_, TEXT_COLOR_); } + + // Change to touched color + bool TouchedColor(int num); + + // Draw all buttons + void DrawAll(uint32_t color, uint32_t textColor) + { for (int n=0; n<number_; n++) Draw(n, color, textColor); } + void DrawAll() { DrawAll(CREATED_COLOR_, TEXT_COLOR_); } + + // Erase button + bool Erase(int num); + void EraseAll() + { for (int n=0; n<number_; n++) Erase(n); } + + // Check touch detected for specified button + bool Touched(int num); + + // Get touched number + bool GetTouchedNumber(int &num); + + // Activate and inactivate button(s) + bool Activate(int num); + void ActivateAll() + { for (int n=0; n<number_; n++) Activate(n); } + bool Inactivate(int num); + void InactivateAll() + { for (int n=0; n<number_; n++) Inactivate(n); } + + private: + Button **buttons_; + int number_; + __IO int prevNum_; + + // Check range of argument + bool Range(int n) + { return ((n >= 0) && (n < number_)); } + + // disallow copy constructor and assignment operator + ButtonGroup(const ButtonGroup&); + ButtonGroup& operator=(const ButtonGroup&); + }; +} +#endif // F746_BUTTON_GROUP_HPP
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/F469_GUI.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/F469_GUI.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,22 @@ +//-------------------------------------------------------------- +// F746-DISCO の GUI 用のインクルード文とそれらを使うための +// using 宣言をまとめたもの +// Include statements for F746-DISCO GUI and using directive +// +// 2016/08/15, Copyright (c) 2016 MIKAMI, Naoki +// 2016/09/21, modifyed for use whith F469I-DISCO Axel Karch +// +//-------------------------------------------------------------- + +#include "mbed.h" +#ifndef __STM32F469xx_H +#error Platform is not F469I-DISCOVERY +#endif + +#include "BlinkLabel.hpp" +#include "ButtonGroup.hpp" +#include "NumericLabel.hpp" +#include "ResetButton.hpp" +#include "SeekbarGroup.hpp" + +using namespace Mikami;
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/GuiBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/GuiBase.cpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,44 @@ +//----------------------------------------------------------- +// GuiBase class (abstract base class) +// +// 2016/03/29, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#include "GuiBase.hpp" + +namespace Mikami +{ + GuiBase::GuiBase( + uint16_t x, uint16_t y, sFONT &fonts, + uint32_t textColor, uint32_t backColor, + uint32_t createdColor, uint32_t touchedColor, + uint32_t inactiveColor, uint32_t inactiveTextColor) + : X_(x), Y_(y), FONTS_(&fonts), + TEXT_COLOR_(textColor), BACK_COLOR_(backColor), + CREATED_COLOR_(createdColor), + TOUCHED_COLOR_(touchedColor), + INACTIVE_COLOR_(inactiveColor), + INACTIVE_TEXT_COLOR_(inactiveTextColor) + { + if (first_) + { + lcd_.Clear(backColor); + first_ = false; + } + } + + // If panel touched, return true + bool GuiBase::PanelTouched() + { + ts_.GetState(&state_); + return (bool)(state_.touchDetected); + } + + LCD_DISCO_F469NI GuiBase::lcd_; + TS_DISCO_F469NI GuiBase::ts_; + + TS_StateTypeDef GuiBase::state_; + + bool GuiBase::multiTouch_ = false; + bool GuiBase::first_ = true; +}
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/GuiBase.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/GuiBase.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,70 @@ +//----------------------------------------------------------- +// GuiBase class (abstract base class) ---- Header +// +// 2016/04/10, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#ifndef F746_GUI_BASE_HPP +#define F746_GUI_BASE_HPP + +#include "mbed.h" +#include <string> +#include "TS_DISCO_F469NI.h" +#include "LCD_DISCO_F469NI.h" + +namespace Mikami +{ + class GuiBase + { + public: + static LCD_DISCO_F469NI* GetLcdPtr() { return &lcd_; } + static TS_DISCO_F469NI* GetTsPtr() { return &ts_; } + + // If panel touched, return true + static bool PanelTouched(); + // Get touch panel state + static TS_StateTypeDef GetTsState() { return state_; } + + enum { ENUM_TEXT = 0xFFFFFFFF, ENUM_BACK = 0xFF003538, + ENUM_CREATED = 0xFF0068B7, ENUM_TOUCHED = 0xFF7F7FFF, + ENUM_INACTIVE = 0xD0003538, ENUM_INACTIVE_TEXT = 0xFF808080}; + + protected: + static LCD_DISCO_F469NI lcd_; // for LCD display + static TS_DISCO_F469NI ts_; // for touch pannel + + static TS_StateTypeDef state_; + static bool multiTouch_; + + const uint16_t X_, Y_; + sFONT *const FONTS_; + + const uint32_t TEXT_COLOR_; + const uint32_t BACK_COLOR_; + const uint32_t CREATED_COLOR_; + const uint32_t TOUCHED_COLOR_; + const uint32_t INACTIVE_COLOR_; + const uint32_t INACTIVE_TEXT_COLOR_; + + // Constructor + GuiBase(uint16_t x =0, uint16_t y =0, + sFONT &fonts = Font12, + uint32_t textColor = GuiBase::ENUM_TEXT, + uint32_t backColor = GuiBase::ENUM_BACK, + uint32_t createdColor = GuiBase::ENUM_CREATED, + uint32_t touchedColor = GuiBase::ENUM_TOUCHED, + uint32_t inactiveColor = GuiBase::ENUM_INACTIVE, + uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT); + + void DrawString(uint16_t x, uint16_t y, const string str) + { lcd_.DisplayStringAt(x, y, (uint8_t *)str.c_str(), LEFT_MODE); } + + private: + static bool first_; + + // disallow copy constructor and assignment operator + GuiBase(const GuiBase&); + GuiBase& operator=(const GuiBase&); + }; +} +#endif // F746_GUI_BASE_HPP
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/Label.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/Label.cpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,50 @@ +//----------------------------------------------------------- +// Label class +// +// 2016/04/24, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#include "Label.hpp" + +namespace Mikami +{ + // Constructor + Label::Label(uint16_t x, uint16_t y, + const string str, TextAlignMode mode, sFONT &fonts, + uint32_t textColor, uint32_t backColor) + : GuiBase(x, y, fonts, textColor, backColor), + MODE_(mode), STR_(str) + { + length_ = str.length(); + lcd_.SetBackColor(backColor); + lcd_.SetTextColor(textColor); + lcd_.SetFont(&fonts); + DrawString(PosX(x), y, str); + } + + void Label::Draw(const string str, uint32_t textColor) + { + // Erase previously-drawn string + lcd_.SetTextColor(BACK_COLOR_); + length_ = (length_ > str.length()) ? length_ : str.length(); + lcd_.FillRect(PosX(X_), Y_, FONTS_->Width*length_+1, FONTS_->Height); + + // Draw new string + length_ = str.length(); + lcd_.SetFont(FONTS_); + lcd_.SetTextColor(textColor); + DrawString(PosX(X_), Y_, str); + } + + uint16_t Label::PosX(uint16_t x) + { + if (MODE_ == LEFT) return x; + else + { + if (MODE_ == CENTER) + return x - length_*FONTS_->Width/2; + else + return x - length_*FONTS_->Width; + } + } +}
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/Label.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/Label.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,58 @@ +//----------------------------------------------------------- +// Label class -- Header +// +// 2016/04/24, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#ifndef F746_LABEL_HPP +#define F746_LABEL_HPP + +#include "GuiBase.hpp" + +namespace Mikami +{ + class Label : public GuiBase + { + public: + enum TextAlignMode { LEFT, CENTER, RIGHT }; + // Constructor + Label(uint16_t x, uint16_t y, const string str, + TextAlignMode mode = LEFT, + sFONT &fonts = Font12, + uint32_t textColor = GuiBase::ENUM_TEXT, + uint32_t backColor = GuiBase::ENUM_BACK); + + // Constructor without string + Label(uint16_t x, uint16_t y, + TextAlignMode mode = LEFT, + sFONT &fonts = Font12, + uint32_t textColor = GuiBase::ENUM_TEXT, + uint32_t backColor = GuiBase::ENUM_BACK) + : GuiBase(x, y, fonts, textColor, backColor), + MODE_(mode), STR_("") {} + + void Draw() + { Draw(STR_, TEXT_COLOR_); } + + void Draw(const string str) + { Draw(str, TEXT_COLOR_); } + + void Draw(uint32_t textColor) + { Draw(STR_, textColor); } + + void Draw(const string str, + uint32_t textColor); + + private: + const TextAlignMode MODE_; + const string STR_; + + uint8_t length_; + uint16_t PosX(uint16_t x); + + // disallow copy constructor and assignment operator + Label(const Label&); + Label& operator=(const Label&); + }; +} +#endif // F746_LABEL_HPP
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/NumericLabel.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/NumericLabel.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,54 @@ +//----------------------------------------------------------- +// NumericLabel class -- derived class of Label class +// +// 2016/04/12, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#ifndef F746_NUMERIC_LABEL_HPP +#define F746_NUMERIC_LABEL_HPP + +#include "Label.hpp" + +namespace Mikami +{ + template <typename T> class NumericLabel : public Label + { + public: + // Constructor without drawing value + NumericLabel(uint16_t x, uint16_t y, + TextAlignMode mode = LEFT, + sFONT &fonts = Font12, + uint32_t textColor = GuiBase::ENUM_TEXT, + uint32_t backColor = GuiBase::ENUM_BACK) + : Label(x, y, "", mode, fonts, textColor, backColor) {} + + // Constructor with drawing value + NumericLabel(uint16_t x, uint16_t y, + const char fmt[], T val, + TextAlignMode mode = LEFT, + sFONT &fonts = Font12, + uint32_t textColor = GuiBase::ENUM_TEXT, + uint32_t backColor = GuiBase::ENUM_BACK) + : Label(x, y, "", mode, fonts, textColor, backColor) + { Draw(fmt, val); } + + // Draw value + void Draw(const char fmt[], T val) + { + sprintf(str_, fmt, val); + Label::Draw(str_); + } + + // Draw previous value with specified color + void Draw(uint32_t color) + { Label::Draw(str_, color); } + + private: + char str_[81]; + + // disallow copy constructor and assignment operator + NumericLabel(const NumericLabel&); + NumericLabel& operator=(const NumericLabel&); + }; +} +#endif // F746_NUMERIC_LABEL_HPP
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/ResetButton.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/ResetButton.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,46 @@ +//----------------------------------------------------------- +// ResetButton class -- derived class of Button class +// +// 2016/08/15, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#ifndef F746_RESET_BUTTON_HPP +#define F746_RESET_BUTTON_HPP + +#include "Button.hpp" + +namespace Mikami +{ + class ResetButton : public Button + { + public: + 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() + { + if (!Touched()) return; + + wait(0.2f); + NVIC_SystemReset(); + } + + void Draw() + { + Activate(); + lcd_.SetTextColor(LCD_COLOR_WHITE); + lcd_.FillPolygon(pt_, 3); + } + + private: + Point pt_[3]; + }; +} +#endif // F746_RESET_BUTTON_HPP
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/SeekBar.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/SeekBar.cpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,187 @@ +//----------------------------------------------------------- +// SeekBar class +// +// 2016/07/12, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#include "SeekBar.hpp" + +namespace Mikami +{ + // Constructor with scale value (only horizontal) + SeekBar::SeekBar(uint16_t x, uint16_t y, uint16_t length, + float min, float max, float initialValue, + string left, string center, string right, + uint32_t thumbColor, + uint16_t thumbSize, uint16_t width, + uint32_t colorL, uint32_t colorH, + uint32_t backColor) + : GuiBase(x, y, Font12, GuiBase::ENUM_TEXT, backColor, thumbColor), + L_(length), W_(width), + SIZE_(thumbSize), COLOR_L_(colorL), COLOR_H_(colorH), + MIN_(min), MAX_(max), ORIENT_(Holizontal), v_(initialValue), + labelOn_(true), slided_(false), active_(true) + { + Draw(initialValue); + uint16_t y0 = y - thumbSize/2 - 13; + labelLCR_[0] = new Label(x, y0, left, Label::CENTER); + labelLCR_[1] = new Label(x+length/2, y0, center, Label::CENTER); + labelLCR_[2] = new Label(x+length, y0, right, Label::CENTER); + } + + SeekBar::~SeekBar() + { + if (labelOn_) + for (int n=0; n<3; n++) delete labelLCR_[n]; + } + + // Slide thumb + // If the thumb is not touched, return false + bool SeekBar::Slide() + { + if (!active_) return false; + + if (!PanelTouched()) + { + if (slided_) Draw(v_); + slided_ = false; + return false; + } + + uint16_t x, y; + bool rtn = IsOnThumb(x, y); + if (rtn || slided_) + { + if (rtn) v_ = ToValue(Point(x, y)); + Draw(v_, rtn); + slided_ = rtn; + } + return rtn; + } + + void SeekBar::Activate() + { + active_ = true; + Draw(v_); + if (labelOn_) + for (int n=0; n<3; n++) labelLCR_[n]->Draw(TEXT_COLOR_); + } + + void SeekBar::Inactivate() + { + active_ = false; + Draw(v_); + if (labelOn_) + for (int n=0; n<3; n++) labelLCR_[n]->Draw(INACTIVE_TEXT_COLOR_); + } + + // If touched position is on the thumb, return true + bool SeekBar::IsOnThumb(uint16_t &x, uint16_t &y) + { + x = state_.touchX[0]; + y = state_.touchY[0]; + + uint16_t th = SIZE_/2; + Point pt = ToPoint(v_); + if (ORIENT_ == Holizontal) + { + if ( (pt.x-th <= x) && (x <= pt.x+th) && + (pt.y-th <= y) && (y <= pt.y+th) ) return true; + } + else + { + if ( (pt.x-th <= x) && (x <= pt.x+th) && + (pt.y-th <= y) && (y <= pt.y+th) ) return true; + } + + return false; + } + + // 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_-sizeS/2, Y_-SIZE_/2, L_+sizeS+1, SIZE_+1); + else + 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 + + // Draw upper line + if (active_) lcd_.SetTextColor(COLOR_H_); + else lcd_.SetTextColor(INACTIVE_TEXT_COLOR_-0x404040); + if ((ORIENT_ == Holizontal) && ((X_+L_-pt.x) > 0)) + lcd_.FillRect(pt.x, Y_-W_/4, X_+L_-pt.x, W_/2); + if ((ORIENT_ == Vertical) && ((pt.y-Y_) > 0)) + lcd_.FillRect(X_-W_/4, Y_, W_/2, pt.y-Y_); + + // Draw lower line + if (active_) lcd_.SetTextColor(COLOR_L_); + else lcd_.SetTextColor(INACTIVE_TEXT_COLOR_-0x202020); + if ((ORIENT_ == Holizontal) && ((pt.x-X_) > 0)) + lcd_.FillRect(X_, Y_-W_/2, pt.x-X_, W_); + if ((ORIENT_ == Vertical) && ((Y_+L_-pt.y) > 0)) + lcd_.FillRect(X_-W_/2, pt.y, W_, Y_+L_-pt.y); + + // 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_.FillRect(xPos, yPos, width+1, height+1); + else + { + lcd_.DrawRect(xPos, yPos, width, height); + lcd_.DrawHLine(pt.x+width/2, pt.y+height/2, 1); + lcd_.DrawRect(xPos+1, yPos+1, width-2, height-2); + lcd_.DrawHLine(pt.x+width/2-1, pt.y+height/2-1, 1); + if (ORIENT_ == Holizontal) + lcd_.DrawVLine(pt.x, yPos+4, SIZE_-7); + else + lcd_.DrawHLine(xPos+4, pt.y, SIZE_-7); + } + } + + void SeekBar::Redraw(bool fill) + { + Draw(GetValue(), fill); + if (labelOn_) + for (int n=0; n<3; n++) labelLCR_[n]->Draw(TEXT_COLOR_); + } + + SeekBar::Point SeekBar::ToPoint(float value) + { + if (ORIENT_ == Holizontal) + return Point(X_ + Round(L_*(value - MIN_)/(MAX_ - MIN_)), Y_); + else + return Point(X_, Y_ + L_ - Round(L_*(value - MIN_)/(MAX_ - MIN_))); + } + + float SeekBar::ToValue(Point pt) + { + float value; + if (ORIENT_ == Holizontal) + value = (pt.x - X_)*(MAX_ - MIN_)/(float)L_ + MIN_; + else + value = -(pt.y - Y_ - L_)*(MAX_ - MIN_)/(float)L_ + MIN_; + return Saturate(value); + } + + float SeekBar::Saturate(float value) + { + if (value < MIN_) value = MIN_; + if (value > MAX_) value = MAX_; + return value; + } +} +
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/SeekBar.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/SeekBar.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,93 @@ +//----------------------------------------------------------- +// SeekBar class -- Header +// +// 2016/07/12, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#ifndef F746_SEEKBAR_HPP +#define F746_SEEKBAR_HPP + +#include "GuiBase.hpp" +#include "Label.hpp" + +namespace Mikami +{ + class SeekBar : public GuiBase + { + 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, + Orientation hv = Holizontal, + uint32_t thumbColor = 0xFFB0B0FF, + uint16_t thumbSize = 30, uint16_t width = 4, + uint32_t colorL = LCD_COLOR_LIGHTGRAY, + uint32_t colorH = 0xFFB0B0B0, + uint32_t backColor = GuiBase::ENUM_BACK) + : GuiBase(x, y, Font12, 0, backColor, thumbColor), + L_(length), W_(width), + SIZE_(thumbSize), COLOR_L_(colorL), COLOR_H_(colorH), + MIN_(min), MAX_(max), ORIENT_(hv), v_(initialValue), + labelOn_(false), slided_(false), active_(true) + { Draw(initialValue); } + + // Constructor with scale value (only horizontal) + SeekBar(uint16_t x, uint16_t y, uint16_t length, + float min, float max, float initialValue, + string left, string center, string right, + uint32_t thumbColor = 0xFFB0B0FF, + uint16_t thumbSize = 30, uint16_t width = 4, + uint32_t colorL = LCD_COLOR_LIGHTGRAY, + uint32_t colorH = 0xFFB0B0B0, + uint32_t backColor = GuiBase::ENUM_BACK); + + virtual ~SeekBar(); + + 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); + void Redraw(bool fill = false); + float ToValue(Point pt); + + void SetValue(float v) { v_ = v; } + void SetSlided(bool tf) { slided_ = tf; } + bool GetSlided() { return slided_; } + + private: + const uint16_t L_, W_; + const uint16_t SIZE_; // Size of thumb + const uint32_t COLOR_L_, COLOR_H_; + const float MIN_, MAX_; + const Orientation ORIENT_; + + Label *labelLCR_[3]; + float v_; // value of seekbar + bool labelOn_; + bool slided_; + bool active_; + + int Round(float x) { return x + 0.5f - (x < 0); } + Point ToPoint(float value); + float Saturate(float value); + + // disallow copy constructor and assignment operator + SeekBar(const SeekBar&); + SeekBar& operator=(const SeekBar&); + }; +} +#endif // F746_SEEKBAR_HPP
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/SeekbarGroup.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/SeekbarGroup.cpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,81 @@ +//----------------------------------------------------------- +// SeekbarGroup class +// +// 2016/04/30, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#include "SeekbarGroup.hpp" + +namespace Mikami +{ + SeekbarGroup::SeekbarGroup( + uint16_t x0, uint16_t y0, uint16_t length, + uint16_t number, uint16_t space, + float min, float max, float initialValue, + SeekBar::Orientation hv, + uint32_t thumbColor, + uint16_t thumbSize, uint16_t width, + uint32_t colorL, uint32_t colorH, + uint32_t backColor) + : GuiBase(x0, y0, Font12, GuiBase::ENUM_TEXT, backColor, thumbColor), + numberOfSeekBar_(number) + { + seekBars_ = new SeekBar *[number]; + for (int n=0; n<number; n++) + { + uint16_t x = x0; + uint16_t y = y0; + if (hv == SeekBar::Holizontal) y += space*n; + else x += space*n; + seekBars_[n] = + new SeekBar(x, y, length, min, max, initialValue, hv, + thumbColor, thumbSize, width, + colorL, colorH, backColor); + } + } + + // Destructor + SeekbarGroup::~SeekbarGroup() + { + for (int n=0; n<numberOfSeekBar_; n++) delete seekBars_[n]; + delete[] seekBars_; + } + + // Get slided number + bool SeekbarGroup::GetSlidedNumber(int &num) + { + bool active = false; + for (int n=0; n<numberOfSeekBar_; n++) + if (seekBars_[n]->IsActive()) active = true; + if (!active) return false; + + if (!PanelTouched()) + { + for (int n=0; n<numberOfSeekBar_; n++) + { + if (seekBars_[n]->GetSlided()) + seekBars_[n]->Draw(seekBars_[n]->GetValue()); + seekBars_[n]->SetSlided(false); + } + return false; + } + + bool rtn = false; + uint16_t x, y; + for (int n=0; n<numberOfSeekBar_; n++) + { + 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); + seekBars_[n]->SetSlided(true); + rtn = true; + } + if (rtn) break; + } + return rtn; + } +}
diff -r 63e8edd5d29a -r 2182df2d7810 F469_GUI/SeekbarGroup.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/F469_GUI/SeekbarGroup.hpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,76 @@ +//----------------------------------------------------------- +// SeekbarGroup class -- Header +// +// 2016/07/12, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#ifndef F746_SEEKBAR_GROUP_HPP +#define F746_SEEKBAR_GROUP_HPP + +#include "SeekBar.hpp" + +namespace Mikami +{ + class SeekbarGroup : public GuiBase + { + public: + SeekbarGroup(uint16_t x0, uint16_t y0, uint16_t length, + uint16_t number, uint16_t space, + float min, float max, float initialValue, + SeekBar::Orientation hv = SeekBar::Holizontal, + uint32_t thumbColor = 0xFFB0B0FF, + uint16_t thumbSize = 30, uint16_t width = 4, + uint32_t colorL = LCD_COLOR_LIGHTGRAY, + uint32_t colorH = 0xFFB0B0B0, + uint32_t backColor = GuiBase::ENUM_BACK); + + virtual ~SeekbarGroup(); + + bool Slide(int num) { return seekBars_[num]->Slide(); } + float GetValue(int num) { return seekBars_[num]->GetValue(); } + int GetIntValue(int num) { return seekBars_[num]->GetIntValue(); } + + // Get slided number + bool GetSlidedNumber(int &num); + + void Draw(int num, float value, bool fill = false) + { seekBars_[num]->Draw(value, fill); } + + // Draw all thumbs with same value + void DrawAll(float value, bool fill = false) + { for (int n=0; n<numberOfSeekBar_; n++) Draw(n, 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(); } + void Inactivate(int num) { seekBars_[num]->Inactivate(); } + void ActivateAll() + { + for (int n=0; n<numberOfSeekBar_; n++) + seekBars_[n]->Activate(); + } + void InactivateAll() + { + for (int n=0; n<numberOfSeekBar_; n++) + seekBars_[n]->Inactivate(); + } + + private: + SeekBar **seekBars_; + int numberOfSeekBar_; + + // Check range of argument + bool Range(int n) + { return ((n >= 0) && (n < numberOfSeekBar_)); } + + // disallow copy constructor and assignment operator + SeekbarGroup(const SeekbarGroup&); + SeekbarGroup& operator=(const SeekbarGroup&); + }; +} +#endif // F746_SEEKBAR_GROUP_HPP
diff -r 63e8edd5d29a -r 2182df2d7810 SeeedStudioTFTv2.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SeeedStudioTFTv2.lib Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/Ganstrich/code/SeeedStudioTFTv2/#23288c15e11d
diff -r 63e8edd5d29a -r 2182df2d7810 TFT_fonts.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT_fonts.lib Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/CRAC-Team/code/TFT_fonts/#b028fb6059d9
diff -r 63e8edd5d29a -r 2182df2d7810 TS_DISCO_F469NI/TS_DISCO_F469NI.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F469NI/TS_DISCO_F469NI.cpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,68 @@ +/* Copyright (c) 2010-2011 mbed.org, MIT License +* +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software +* and associated documentation files (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or +* substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "TS_DISCO_F469NI.h" + +// Constructor +TS_DISCO_F469NI::TS_DISCO_F469NI() +{ + BSP_TS_Init(100, 100); +} + +// Destructor +TS_DISCO_F469NI::~TS_DISCO_F469NI() +{ + +} + +//================================================================================================================= +// Public methods +//================================================================================================================= + +uint8_t TS_DISCO_F469NI::Init(uint16_t ts_SizeX, uint16_t ts_SizeY) +{ + return BSP_TS_Init(ts_SizeX, ts_SizeY); +} + +uint8_t TS_DISCO_F469NI::ITConfig(void) +{ + return BSP_TS_ITConfig(); +} + +uint8_t TS_DISCO_F469NI::GetState(TS_StateTypeDef *TS_State) +{ + return BSP_TS_GetState(TS_State); +} + +#if (TS_MULTI_TOUCH_SUPPORTED == 1) + +uint8_t TS_DISCO_F469NI::Get_GestureId(TS_StateTypeDef *TS_State) +{ + return BSP_TS_Get_GestureId(TS_State); +} + +uint8_t TS_DISCO_F469NI::ResetTouchData(TS_StateTypeDef *TS_State) +{ + return BSP_TS_ResetTouchData(TS_State); +} + +#endif // (TS_MULTI_TOUCH_SUPPORTED == 1) + +//================================================================================================================= +// Private methods +//=================================================================================================================
diff -r 63e8edd5d29a -r 2182df2d7810 TS_DISCO_F469NI/TS_DISCO_F469NI.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F469NI/TS_DISCO_F469NI.h Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,120 @@ +/* Copyright (c) 2010-2011 mbed.org, MIT License +* +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software +* and associated documentation files (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or +* substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __TS_DISCO_F469NI_H +#define __TS_DISCO_F469NI_H + +#ifdef TARGET_DISCO_F469NI + +#include "mbed.h" +#include "stm32469i_discovery_ts.h" + +/* + This class drives the touch screen module ( device) of the LCD display + present on DISCO_F469NI board. + + Usage: + + #include "mbed.h" + #include "TS_DISCO_F469NI.h" + + TS_DISCO_F469NI ts; + + DigitalOut led1(LED1); + + int main() + { + TS_StateTypeDef TS_State; + + ts.Init(420, 272); + + while(1) + { + ts.GetState(&TS_State); + if ((TS_State.touchDetected) && (TS_State.touchX[0] > 240)) + { + led1 = 1; + } + else + { + led1 = 0; + } + } + } +*/ +class TS_DISCO_F469NI +{ + +public: + //! Constructor + TS_DISCO_F469NI(); + + //! Destructor + ~TS_DISCO_F469NI(); + + /** + * @brief Initializes and configures the touch screen functionalities and + * configures all necessary hardware resources (GPIOs, I2C, clocks..);. + * @param ts_SizeX : Maximum X size of the TS area on LCD + * @param ts_SizeY : Maximum Y size of the TS area on LCD + * @retval TS_OK if all initializations are OK. Other value if error. + */ + uint8_t Init(uint16_t ts_SizeX, uint16_t ts_SizeY); + + /** + * @brief Configures and enables the touch screen interrupts both at GPIO level and + * in TouchScreen IC driver configuration. + * @retval TS_OK if all initializations are OK. + */ + uint8_t ITConfig(void); + + /** + * @brief Returns status and positions of the touch screen. + * @param TS_State: Pointer to touch screen current state structure + * @retval TS_OK if all initializations are OK. Other value if error. + */ + uint8_t GetState(TS_StateTypeDef *TS_State); + +#if (TS_MULTI_TOUCH_SUPPORTED == 1) + + /** + * @brief Update gesture Id following a touch detected. + * @param TS_State: Pointer to touch screen current state structure + * @retval TS_OK if all initializations are OK. Other value if error. + */ + uint8_t Get_GestureId(TS_StateTypeDef *TS_State); + + /** + * @brief Function used to reset all touch data before a new acquisition + * of touch information. + * @param TS_State: Pointer to touch screen current state structure + * @retval TS_OK if OK, TE_ERROR if problem found. + */ + uint8_t ResetTouchData(TS_StateTypeDef *TS_State); + +#endif // (TS_MULTI_TOUCH_SUPPORTED == 1) + +private: + +}; + +#else +#error "This class must be used with DISCO_F469NI board only." +#endif // TARGET_DISCO_F469NI + +#endif
diff -r 63e8edd5d29a -r 2182df2d7810 demo_1.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo_1.cpp Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,701 @@ +#include "mbed.h" +#include "TS_DISCO_F469NI.h" +#include "LCD_DISCO_F469NI.h" +#include "F469_GUI.hpp" +#include "ident_crac.h" +#include <CAN.h> +#include "fonts.h" + +#define BLEU 0xFF0000FF +#define ROUGE 0xFFFF0000 +#define VERT 0xFF7FFF00 +#define JAUNE 0xFF8F8F25 +#define BLANC 0xFF000000 +#define SIZE_FIFO 16 + +CAN can1(PB_8, PB_9); //laisser le 1er CAN car probleme sinon +CAN can2(PB_5, PB_13); + +CANMessage msgRxBuffer[SIZE_FIFO]; + +Ticker ticker; +TS_DISCO_F469NI ts; +LCD_DISCO_F469NI lcd; +DigitalOut led1(LED1); +DigitalOut led2(LED2); +Timeout timeout; +Timeout AffTime; +Timer timerAck; +Timer timer; + +unsigned char test[32] = {32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32}; + +char counter = 0; +char check; +char Jack = 1; +int check_cartes = 0, demo_fin = 0; +char Ack_strat = 0; +signed char Strat = 0; + +void SendRawId (unsigned short id); +void SelectionStrat (unsigned char numeroStrat); +void Setflag(void); +void canProcessRx(void); +void canRx_ISR(void); +signed char Bouton_Strat (void); +void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement); + +typedef enum {ATT, CHOIX, DEMO, DEMO_EN_COURS, SELECT_SIDE, TACTIQUE, DETAILS, LAUNCH, WAIT_JACK, FIN} T_etat; +T_etat etat = ATT; +unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN +signed char FIFO_lecture=0;//Position du fifo de lecture des messages CAN +int flagSendCan=1; +unsigned char Cote = 0; //0 -> bleu | 1 -> jaune + +int main() +{ + ts.Init(lcd.GetXSize(), lcd.GetYSize()); + TS_StateTypeDef TS_State; + CANMessage trame_Tx = CANMessage(); + can2.frequency(1000000); // fréquence de travail 1Mbit/s + can2.attach(&canRx_ISR); //interrutpion can en reception + int cpt_dizaine,cpt_unite; + + //Initialisation CAN + trame_Tx.len = 1; + trame_Tx.format = CANStandard; + trame_Tx.type = CANData; + + /////////////////DEFINITION DES BOUTONS//////////////////// + Button COTE_BLEU(20, 25, 755, 200, "Bleu"); + Button COTE_JAUNE(20, 255, 500, 200, "Jaune"); + Button RETOUR (530, 255, 245, 200, "--Precedent--"); + Button LANCER (20, 255, 230, 200, "--LANCER--"); + Button CHECK (275, 255, 230, 200, "Valider"); + Button MATCH (10, 25, 780, 200, "Match"); + Button DEMONSTRATION (10, 255, 780, 200, "Demo"); + Button TEST_MOTEUR(20, 25, 200, 200, "Moteur"); + Button TEST_BRAS(240, 25, 200, 200, "Bras"); + Button FORCE_LAUNCH(530, 255, 245, 200, "Force Launch"); + //////////////////////////////////////////////////////////// + + signed char Strategie = 0; //N° de la strategie (1-10) + + lcd.SetBackColor(LCD_COLOR_WHITE); + lcd.SetTextColor(LCD_COLOR_BLACK); + lcd.Clear (LCD_COLOR_WHITE); + lcd.SetFont(&Font24); + lcd.DisplayStringAt(0, 200, (uint8_t *)"Verification des cartes ...", CENTER_MODE); + FORCE_LAUNCH.Draw(0xFFFF0000, 0); + + while(1) + { + canProcessRx(); + ts.GetState(&TS_State); + wait(0.1); + switch (etat) + { + case ATT : + if(check_cartes == 1) + { + etat = CHOIX; + check_cartes = 0; + + lcd.Clear (LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", CENTER_MODE); + DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0); + MATCH.Draw(0xFFF01010, 0); + //canProcessRx(); + } + if (FORCE_LAUNCH.Touched()) + { + //etat = CHOIX; + SendRawId(ECRAN_ALL_CHECK); + etat = CHOIX; + while(FORCE_LAUNCH.Touched()) + canProcessRx(); + + lcd.Clear (LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", CENTER_MODE); + DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0); + MATCH.Draw(0xFFF01010, 0); + } + break; + + case CHOIX : + //canProcessRx(); + if(DEMONSTRATION.Touched()) + { + etat = DEMO; + while(DEMONSTRATION.Touched()) + canProcessRx(); + + lcd.Clear(LCD_COLOR_WHITE); + TEST_MOTEUR.Draw(0xFFF0F0F0, 0); + TEST_BRAS.Draw(0xFFF0F0F0, 0); + RETOUR.Draw(0xFFFF0000, 0); + trame_Tx.id = 0x602; + trame_Tx.data[0] = 0; + can2.write(trame_Tx); + } + + if(MATCH.Touched()) + { + etat = SELECT_SIDE; + while(MATCH.Touched()) + canProcessRx(); + + lcd.Clear(LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Choisis un cote gros", CENTER_MODE); + COTE_BLEU.Draw(0xFF0070FF, 0); + COTE_JAUNE.Draw(0xFFFFF000, 0); + RETOUR.Draw(0xFFFF0000, 0); + trame_Tx.id = 0x602; + } + break; + + case DEMO : + + trame_Tx.id=0x601; + //canProcessRx(); + if(TEST_MOTEUR.Touched()) + { + Strat = 0x10; + trame_Tx.data[0] = Strat; + while(TEST_MOTEUR.Touched()) + canProcessRx(); + can2.write(trame_Tx); + TEST_MOTEUR.Draw(0xFFF0F0F0, 0); + //etat = DEMO_EN_COURS; + } + + if(TEST_BRAS.Touched()) + { + Strat = 0x11; + trame_Tx.data[0] = Strat; + while(TEST_BRAS.Touched()) + canProcessRx(); + can2.write(trame_Tx); + TEST_MOTEUR.Draw(0xFFF0F0F0, 0); + //etat = DEMO_EN_COURS; + } + + if(RETOUR.Touched()) + { + etat = CHOIX; + while(RETOUR.Touched()) + canProcessRx(); + + lcd.Clear (LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", CENTER_MODE); + DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0); + MATCH.Draw(0xFFF01010, 0); + } + //SelectionStrat(trame_Tx.data[0]); + if (Ack_strat == 1) + { + etat = DEMO_EN_COURS; + lcd.Clear(LCD_COLOR_WHITE); + lcd.SetFont(&Font24); + lcd.DisplayStringAt(0, 190, (uint8_t *)"DEMONSTRATION EN COURS", CENTER_MODE); + Ack_strat = 0; + } + + break; + + case DEMO_EN_COURS: + + if (demo_fin == 1) + { + etat = DEMO; + lcd.Clear(LCD_COLOR_WHITE); + TEST_MOTEUR.Draw(0xFFF0F0F0, 0); + TEST_BRAS.Draw(0xFFF0F0F0, 0); + RETOUR.Draw(0xFFFF0000, 0); + trame_Tx.id = 0x602; + trame_Tx.data[0] = 0; + can2.write(trame_Tx); + } + Ack_strat = 0; + + case SELECT_SIDE : + + //canProcessRx(); + if(COTE_BLEU.Touched()) + { + Cote = 0x0; + trame_Tx.data[0] = Cote; + can2.write(trame_Tx); + while(COTE_BLEU.Touched()) + canProcessRx(); + } + + if(COTE_JAUNE.Touched()) + { + Cote = 0x1; + trame_Tx.data[0] = Cote; + can2.write(trame_Tx); + while(COTE_JAUNE.Touched()) + canProcessRx(); + } + + if(RETOUR.Touched()) + { + etat = CHOIX; + while(RETOUR.Touched()) + canProcessRx(); + + lcd.Clear (LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", CENTER_MODE); + DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0); + MATCH.Draw(0xFFF01010, 0); + } + break; + + case TACTIQUE : + if (Cote == 0){ + lcd.Clear(0xFF0070FF); + lcd.SetBackColor(0xFF0070FF); + } + else if (Cote == 1){ + lcd.Clear(0xFFFFF000); + lcd.SetBackColor(0xFFFFF000); + } + else { + lcd.Clear(0xFF0070FF); + lcd.SetBackColor(0xFF0070FF); + } + + lcd.SetTextColor(LCD_COLOR_BLACK); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Choisis une strat gros", CENTER_MODE); + + Strategie = Bouton_Strat(); // retourne valeur de Strategie si bouton strat renvoi -1 on reviens en arriere + if (Strategie == -1) + { + etat = SELECT_SIDE; + lcd.Clear(LCD_COLOR_WHITE); + lcd.SetBackColor(LCD_COLOR_WHITE); + lcd.SetTextColor(LCD_COLOR_BLACK); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Choisis un cote gros", CENTER_MODE); + COTE_BLEU.Draw(0xFF0070FF, 0); + COTE_JAUNE.Draw(0xFFFFF000, 0); + RETOUR.Draw(0xFFFF0000, 0); + trame_Tx.id = 0x602; + } + else + { + etat = DETAILS; + lcd.Clear(LCD_COLOR_WHITE); + CHECK.Draw(0xFF00FF00); + RETOUR.Draw(0xFFFF0000); + SelectionStrat(Strategie); + } + + break; + + case DETAILS : + //canProcessRx(); + if (CHECK.Touched()) + { + SendRawId(ECRAN_START_MATCH); + //etat = WAIT_JACK; + while(CHECK.Touched()) + canProcessRx(); + } + + if(RETOUR.Touched()) + { + etat = TACTIQUE; + while(RETOUR.Touched()); + } + break; + + + case WAIT_JACK : + lcd.SetBackColor(LCD_COLOR_WHITE); + lcd.SetTextColor(LCD_COLOR_BLACK); + lcd.Clear(LCD_COLOR_WHITE); + lcd.SetFont(&Font24); + if (Cote == 0){ + lcd.Clear(0xFF0070FF); + lcd.SetBackColor(0xFF0070FF); + } + else if (Cote == 1){ + lcd.Clear(0xFFFFF000); + lcd.SetBackColor(0xFFFFF000); + } + else { + lcd.Clear(0xFF0070FF); + lcd.SetBackColor(0xFF0070FF); + } + SendRawId(DEBUG_FAKE_JAKE); // PERMET DE SIMULER LE RETRAIT DU JACK POUR QUE LE ROBOT DEMARRE APRES LA VALIDATION DE LA STRAT + /* while (Jack == 1){ + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"En attente du Jack", CENTER_MODE); + }*/ + cpt_dizaine = 57, cpt_unite = 48; + while (cpt_dizaine !=47){ + lcd.DisplayChar(390,190,cpt_dizaine); + while (cpt_unite != 47) + { + lcd.DisplayChar(410,190,cpt_unite);//la fonction affiche un caractere en ASCII d'ou la valeur de cpt + cpt_unite--; + wait(1); + } + cpt_dizaine--; + cpt_unite = 57; + } + lcd.DisplayStringAt(0, 190, (uint8_t *)"FIN DU MATCH", CENTER_MODE); + wait(5); + etat = FIN; + break; + + case FIN : + lcd.Clear (LCD_COLOR_WHITE); + lcd.SetBackColor(LCD_COLOR_WHITE); + lcd.SetFont(&Font24); + lcd.DisplayStringAt(0, 170, (uint8_t *)"REDEMARAGE", CENTER_MODE); + lcd.DisplayStringAt(0, 190, (uint8_t *)"NECESSAIRE", CENTER_MODE); + while(1); // force le redemarage du robot + break; + + } + + } +} + + +void SendRawId (unsigned short id) +{ + CANMessage msgTx=CANMessage(); + msgTx.id=id; + msgTx.len=0; + can2.write(msgTx); +} + +void SelectionStrat (unsigned char numeroStrat) +{ + lcd.SetBackColor(LCD_COLOR_WHITE); + lcd.SetTextColor(LCD_COLOR_BLACK); + lcd.SetFont(&Font24); + switch (numeroStrat) + { + case 0x1 : + //description de Strategie n°1 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 1 :", LEFT_MODE); + break; + + case 0x2 : + //description de Strategie n°2 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 2 :", LEFT_MODE); + break; + + case 0x3 : + //description de Strategie n°3 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 3 :", LEFT_MODE); + break; + + case 0x4 : + //description de Strategie n°4 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 4 :", LEFT_MODE); + break; + + case 0x5 : + //description de Strategie n°5 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 5 :", LEFT_MODE); + break; + + case 0x6 : + //description de Strategie n°5 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 6 :", LEFT_MODE); + break; + + case 0x7 : + //description de Strategie n°5 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 7 :", LEFT_MODE); + break; + + case 0x8 : + //description de Strategie n°5 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 8 :", LEFT_MODE); + break; + + case 0x9 : + //description de Strategie n°5 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 9 :", LEFT_MODE); + break; + + case 0xA : + //description de Strategie n°5 + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 10 :", LEFT_MODE); + break; + + case 0x10 : + lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 10 :", LEFT_MODE); + break; + } +} + +void Setflag(void) +{ + flagSendCan = 1; +} + +void canProcessRx(void) +{ + static signed char FIFO_occupation=0,FIFO_max_occupation=0; + char useless1 = 0; + + FIFO_occupation=FIFO_ecriture-FIFO_lecture; + if(FIFO_occupation<0) + FIFO_occupation=FIFO_occupation+SIZE_FIFO; + if(FIFO_max_occupation<FIFO_occupation) + FIFO_max_occupation=FIFO_occupation; + if(FIFO_occupation!=0) { + + switch(msgRxBuffer[FIFO_lecture].id) { + case ECRAN_PRINTF_1: + for(useless1 = 0; useless1 <8; useless1++) { + test[useless1] = msgRxBuffer[FIFO_lecture].data[useless1]; + } + //updateDisplay(); + break; + case ECRAN_PRINTF_2: + for(useless1 = 0; useless1 <8; useless1++) { + test[useless1+8] = msgRxBuffer[FIFO_lecture].data[useless1]; + } + //updateDisplay(); + //Ecrire_CANtxt(test); + break; + case ECRAN_PRINTF_3: + for(useless1 = 0; useless1 <8; useless1++) { + test[useless1+2*8] = msgRxBuffer[FIFO_lecture].data[useless1]; + } + //updateDisplay(); + //Ecrire_CANtxt(test); + break; + case ECRAN_PRINTF_4: + for(useless1 = 0; useless1 <8; useless1++) { + test[useless1+3*8] = msgRxBuffer[FIFO_lecture].data[useless1]; + } + //updateDisplay(); + //Ecrire_CANtxt(test); + break; + case ECRAN_PRINTF_CLEAR: + etat = CHOIX; + break; + case CHECK_IHM: + SendRawId(ALIVE_IHM); + break; + case RESET_IHM: + etat = CHOIX; + break; + case CHECK_BALISE: + //Check[1].color = Orange; + //DrawChecks(); + break; + case ALIVE_BALISE: + //Check[1].color = Green; + //DrawChecks(); + break; + case CHECK_MOTEUR: + //Check[2].color = Orange; + //DrawChecks(); + break; + case ALIVE_MOTEUR: + //Check[2].color = Green; + //DrawChecks(); + break; + case CHECK_ACTIONNEURS: + //Check[3].color = Orange; + //DrawChecks(); + break; + case ALIVE_ACTIONNEURS: + //Check[3].color = Green; + //DrawChecks(); + break; + case ECRAN_ALL_CHECK: + check_cartes=1; + //DrawEcran(1); + //EcranActuel = 1; + //menusOnEcranActuel = Liste_ecrans[EcranActuel-1].menus; + break; + case ECRAN_ACK_STRAT: + if (msgRxBuffer[FIFO_lecture].data[0] == Strat) + Ack_strat = 1; + break; + case ECRAN_ACK_COLOR: + if (etat != DEMO) + etat = TACTIQUE; + break; + case ECRAN_ACK_START_MATCH: + if (etat == DEMO_EN_COURS) + { + SendRawId(DEBUG_FAKE_JAKE); + } + else + { + etat = WAIT_JACK; + } + break; + case GLOBAL_START: + Jack=0; + break; + + case DEBUG_STRATEGIE_AUTOMATE : + if (msgRxBuffer[FIFO_lecture].data[0] == 19) { + demo_fin = 1; + } + break; + + default: + break; + } + FIFO_lecture=(FIFO_lecture+1)%SIZE_FIFO; + } +} + +void canRx_ISR (void) +{ + if (can2.read(msgRxBuffer[FIFO_ecriture])) { + led2 = !led2; + if(msgRxBuffer[FIFO_ecriture].id==RESET_IHM) + lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"Erreur", CENTER_MODE);//mbed_reset(); + else FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO; + } +} + +signed char Bouton_Strat (void) +{ + CANMessage msgTx=CANMessage(); + msgTx.id=0x601; + msgTx.len=1; + + Button STRAT_1 (20, 10, 150, 150, "Strategie 1"); + Button STRAT_2 (180, 10, 150, 150, "Strategie 2"); + Button STRAT_3 (340, 10, 150, 150, "Strategie 3"); + Button STRAT_4 (20, 165, 150, 150, "Strategie 4"); + Button STRAT_5 (180, 165, 150, 150, "Strategie 5"); + Button STRAT_6 (340, 165, 150, 150, "Strategie 6"); + Button STRAT_7 (20, 320, 150, 150, "Strategie 7"); + Button STRAT_8 (180, 320, 150, 150, "Strategie 8"); + Button STRAT_9 (340, 320, 150, 150, "Strategie 9"); + Button STRAT_10 (530, 25, 245, 200, "Strategie 10"); + Button RETOUR (530, 255, 245, 200, "--Precedent--"); + //Definition des boutons + + Ack_strat = 0; + Strat = 0; + STRAT_1.Draw(0xFFF0F0F0, 0); + STRAT_2.Draw(0xFFF0F0F0, 0); + STRAT_3.Draw(0xFFF0F0F0, 0); + STRAT_4.Draw(0xFFF0F0F0, 0); + STRAT_5.Draw(0xFFF0F0F0, 0); + STRAT_6.Draw(0xFFF0F0F0, 0); + STRAT_7.Draw(0xFFF0F0F0, 0); + STRAT_8.Draw(0xFFF0F0F0, 0); + STRAT_9.Draw(0xFFF0F0F0, 0); + STRAT_10.Draw(0xFFF0F0F0, 0); + RETOUR.Draw(0xFFFF0000, 0); + + while(Ack_strat == 0) + { + canProcessRx(); + if (RETOUR.Touched()) + return -1; + while(RETOUR.Touched()); + //////////////////////////////STRATEGIE N°1 + if (STRAT_1.Touched()){ + Strat = 1; + msgTx.data[0] = 0x1; + can2.write(msgTx); + while(STRAT_1.Touched()); + } + /////////////////////////////STRATEGIE N°2 + if (STRAT_2.Touched()){ + Strat = 2; + msgTx.data[0] = 0x2; + can2.write(msgTx); + while(STRAT_2.Touched()); + } + //////////////////////////////STRATEGIE N°3 + if (STRAT_3.Touched()){ + Strat = 3; + msgTx.data[0] = 0x3; + can2.write(msgTx); + while(STRAT_3.Touched()); + } + /////////////////////////////STRATEGIE N°4 + if (STRAT_4.Touched()){ + Strat = 4; + msgTx.data[0] = 0x4; + can2.write(msgTx); + while(STRAT_4.Touched()); + } + ///////////////////////////////STRATEGIE N°5 + if (STRAT_5.Touched()){ + Strat = 5; + msgTx.data[0] = 0x5; + can2.write(msgTx); + while(STRAT_5.Touched()); + } + ////////////////////////////////STRATEGIE N°6 + if (STRAT_6.Touched()){ + Strat = 6; + msgTx.data[0] = 0x6; + can2.write(msgTx); + while(STRAT_6.Touched()); + } + /////////////////////////////////STRATEGIE N°7 + if (STRAT_7.Touched()){ + Strat = 7; + msgTx.data[0] = 0x7; + can2.write(msgTx); + while(STRAT_7.Touched()); + } + /////////////////////////////////STRATEGIE N°8 + if (STRAT_8.Touched()){ + Strat = 8; + msgTx.data[0] = 0x8; + can2.write(msgTx); + while(STRAT_8.Touched()); + } + /////////////////////////////////STRATEGIE N°9 + if (STRAT_9.Touched()){ + Strat = 9; + msgTx.data[0] = 0x9; + can2.write(msgTx); + while(STRAT_9.Touched()); + } + ///////////////////////////////////STRATEGIE N°10 + if (STRAT_10.Touched()){ + Strat = 10; + msgTx.data[0] = 0xA; + can2.write(msgTx); + while(STRAT_10.Touched()); + } + } + return Strat; +} + +//FONCTION DE L'ASSERVISSEMENT POUR LA DEMONSTRATION +void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement) +{ + CANMessage msgTx=CANMessage(); + msgTx.id=ASSERVISSEMENT_RECALAGE; + msgTx.len=6; + msgTx.format=CANStandard; + msgTx.type=CANData; + // x sur 2 octets + msgTx.data[0]=(unsigned char)distance; + msgTx.data[1]=(unsigned char)(distance>>8); + //Recalage sur 1 octet + msgTx.data[2]=recalage; + //Valeur du recalage sur 2 octets + msgTx.data[3]=(unsigned char)newValue; + msgTx.data[4]=(unsigned char)(newValue>>8); + //Enchainement sur 1 octet + msgTx.data[5]=isEnchainement; + + can1.write(msgTx); + //wait_ms(500); +} \ No newline at end of file
diff -r 63e8edd5d29a -r 2182df2d7810 ident_crac/ident_crac.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ident_crac/ident_crac.h Fri Mar 31 15:36:26 2017 +0000 @@ -0,0 +1,95 @@ +#define GLOBAL_GAME_END 0x004 // Stop fin du match +#define GLOBAL_START 0x002 // Start +#define GLOBAL_END_INIT_POSITION 0x005 // Fin positionnement robot avant depart +#define GLOBAL_FUNNY_ACTION 0x007 // Funny action start (0: start, 1: stop) + +#define BALISE_STOP 0x003 // Trame stop (angle en °, Type du robot : 1=>gros robot, 2=> petit) +#define BALISE_DANGER 0xA // Trame danger (angle en °, Type du robot : 1=>gros robot, 2=> petit) +#define BALISE_END_DANGER 0xB // Trame fin de danger + +#define ASSERVISSEMENT_STOP 0x001 // Stop moteur +#define ASSERVISSEMENT_SPEED_DANGER 0x006 // Vitesse de danger +#define ASSERVISSEMENT_XYT 0x020 // Asservissement (x,y,theta) (0 : au choix 1 : avant -1 : arrière) +#define ASSERVISSEMENT_COURBURE 0x021 // Asservissement rayon de courbure (+ gauche, - droite , sens : 1avt , -1arr; enchainement => 1 oui, 0 => non, 2=>derniére instruction de l'enchainement) +#define ASSERVISSEMENT_CONFIG 0x022 // Asservissement paramètre (définir les valeurs de vitesse max et d'eccélération max) +#define ASSERVISSEMENT_ROTATION 0x023 // Asservissement rotation +#define ASSERVISSEMENT_RECALAGE 0x024 // Moteur tout droit (recalage : 0 mouvement seul, 1 x, 2y valeur : coordonnée à laquelle est recalé x/y; enchainement => 1 oui, 0 => non) + +#define ODOMETRIE_BIG_POSITION 0x026 // Odométrie position robot (Position actuel du robot) +#define ODOMETRIE_BIG_VITESSE 0x027 // Odométrie vitesse (Indication sur l'état actuel) +#define ODOMETRIE_SMALL_POSITION 0x028 // Odométrie position robot (Position actuel du robot) +#define ODOMETRIE_SMALL_VITESSE 0x029 // Odométrie vitesse (Indication sur l'état actuel) + +#define ASSERVISSEMENT_INFO_CONSIGNE 0x1F0 // Info Consigne et Commande moteur +#define ASSERVISSEMENT_CONFIG_KPP_DROITE 0x1F1 // Config coef KPP_Droit +#define ASSERVISSEMENT_CONFIG_KPI_DROITE 0x1F2 // Config coef KPI_Droit +#define ASSERVISSEMENT_CONFIG_KPD_DROITE 0x1F3 // Config coef KPD_Droit +#define ASSERVISSEMENT_CONFIG_KPP_GAUCHE 0x1F4 // Config coef KPP_Gauche +#define ASSERVISSEMENT_CONFIG_KPI_GAUCHE 0x1F5 // Config coef KPI_Gauche +#define ASSERVISSEMENT_CONFIG_KPD_GAUCHE 0x1F6 // Config coef KPD_Gauche +#define ASSERVISSEMENT_ENABLE 0x1F7 // Activation asservissement (0 : désactivation, 1 : activation) + +#define RESET_BALISE 0x030 // Reset balise +#define RESET_MOTEUR 0x031 // Reset moteur +#define RESET_IHM 0x032 // Reset écran tactile +#define RESET_ACTIONNEURS 0x033 // Reset actionneurs +#define RESET_STRAT 0x3A // Reset stratégie + +#define CHECK_BALISE 0x060 // Check balise +#define CHECK_MOTEUR 0x061 // Check moteur +#define CHECK_IHM 0x062 // Check écran tactile +#define CHECK_ACTIONNEURS 0x063 // Check actionneurs + +#define ALIVE_BALISE 0x070 // Alive balise +#define ALIVE_MOTEUR 0x071 // Alive moteur +#define ALIVE_IHM 0x072 // Alive écran tactile +#define ALIVE_ACTIONNEURS 0x073 // Alive actionneurs + +#define DEMO_MOTEUR 0x075 // Demonstration des moteurs + +#define ACKNOWLEDGE_BALISE 0x100 // Acknowledge balise +#define ACKNOWLEDGE_MOTEUR 0x101 // Acknowledge moteur +#define ACKNOWLEDGE_IHM 0x102 // Acknowledge ecran tactile +#define ACKNOWLEDGE_ACTIONNEURS 0x103 // Acknowledge actionneurs + +#define INSTRUCTION_END_BALISE 0x110 // Fin instruction balise (Indique que l'instruction est terminée) +#define INSTRUCTION_END_MOTEUR 0x111 // Fin instruction moteur (Indique que l'instruction est terminée) +#define INSTRUCTION_END_IHM 0x112 // Fin instruction ecran tactile (Indique que l'instruction est terminée) +#define INSTRUCTION_END_ACTIONNEURS 0x113 // Fin instruction actionneurs (Indique que l'instruction est terminée) + +#define ECRAN_CHOICE_STRAT 0x601 // Choix d'une stratégie (n° strat (1-4)) +#define ECRAN_CHOICE_COLOR 0x602 // Couleur (0->Purple;1->green) +#define ECRAN_START_MATCH 0x603 // Match (Indique que l'on souhaite commencer le match) +#define ECRAN_DEMO_BEGIN 0x604 // Debut du mode Demonstration +#define ECRAN_ACK_STRAT 0x611 // Acknowledge stratégie (si 0 erreur, sinon n°strat) +#define ECRAN_ACK_COLOR 0x612 // Acknowledge couleur (0->Purple;1->green) +#define ECRAN_ACK_START_MATCH 0x613 // Acknowledge Match (Indique que l'on a bien reçu le debut du match) +#define ECRAN_ACK_DEMO 0x614 // Acknowledge Demonstration +#define ECRAN_ALL_CHECK 0x620 // Carte all check (Si provient de carte strat => toutes les cartes sont en ligne, Si provient IHM => forcer le lancement) +#define ECRAN_TIME 0x621 // Time match (Indication de moment cle du temps (10,30,60,70,80,85,90)) +#define ECRAN_PRINTF_1 0x6C0 // Tactile printf (Afficher les 8 permier caractères) +#define ECRAN_PRINTF_2 0x6C1 // Tactile printf (Afficher les 8 second caractères) +#define ECRAN_PRINTF_3 0x6C2 // Tactile printf (Afficher les 8 troisième caractères) +#define ECRAN_PRINTF_4 0x6C3 // Tactile printf (Afficher les 8 quatrième caractères) +#define ECRAN_PRINTF_CLEAR 0x6CF // Tactile printf clear (Permet d'effacer l'ecran) + +#define ERROR_OVERFLOW_BALISE 0x040 // Overflow odométrie +#define ERROR_OVERFLOW_MOTEUR 0x041 // Overflow asservissement +#define ERROR_OVERFLOW_IHM 0x042 // Overflow balise +#define ERROR_OVERFLOW_STRAT 0x043 // Overflow stratégie +#define ERROR_BALISE 0x785 // Bug balise +#define ERROR_RTC 0x786 // Bug RTC +#define ERROR_MOTEUR 0x787 // Bug moteur +#define ERROR_TELEMETRIE 0x788 // Bug télémètre +#define ERROR_STRATEGIE 0x789 // Bug stratégie + +#define DEBUG_STRATEGIE_AUTOMATE 0x760 // Etat automate stratégie (Permet de savoir l'etat de l'automate) +#define DEBUG_FAKE_JAKE 0x761 // Fake jack (Permet d'outre passerr le JACk du robot) +#define DEBUG_ASSERV 0x762 // Info debug carte moteur + +#define SERVO_AX12_SETGOAL 0x090 // AX12 setGoal (Indiquer la nouvelle position de l'AX12 !! Ne bouge pas) +#define SERVO_AX12_PROCESS 0x091 // AX12 processChange (Lancer le déplacement des AX12) +#define SERVO_AX12_DONE 0x092 // AX12 done (Indique q'un AX12 a terminé son déplacement) +#define SERVO_XL320 0x093 // XL320 +#define POMPE_PWM 0x9A // pwm des pompes +
diff -r 63e8edd5d29a -r 2182df2d7810 main.cpp --- a/main.cpp Fri Dec 18 07:34:21 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -#include "mbed.h" -#include "LCD_DISCO_F469NI.h" - -LCD_DISCO_F469NI lcd; - -DigitalOut led1(LED1); - -int main() -{ - led1 = 1; - - lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"MBED EXAMPLE", CENTER_MODE); - wait(1); - - while(1) - { - lcd.Clear(LCD_COLOR_BLUE); - lcd.SetBackColor(LCD_COLOR_BLUE); - lcd.SetTextColor(LCD_COLOR_WHITE); - wait(0.3); - lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"DISCOVERY", CENTER_MODE); - lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"STM32F469NI", CENTER_MODE); - wait(1); - - lcd.Clear(LCD_COLOR_GREEN); - - lcd.SetTextColor(LCD_COLOR_BLUE); - lcd.FillRect(10, 20, 50, 50); - wait(0.1); - lcd.SetTextColor(LCD_COLOR_BROWN); - lcd.FillCircle(80, 80, 50); - wait(0.1); - lcd.SetTextColor(LCD_COLOR_YELLOW); - lcd.FillEllipse(150, 150, 50, 100); - wait(0.1); - lcd.SetTextColor(LCD_COLOR_RED); - lcd.FillCircle(200, 200, 40); - wait(1); - - lcd.SetBackColor(LCD_COLOR_ORANGE); - lcd.SetTextColor(LCD_COLOR_CYAN); - BSP_LCD_SetFont(&Font20); - lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"HAVE FUN !!!", CENTER_MODE); - wait(1); - - led1 = !led1; - wait(0.5); - } -} -
diff -r 63e8edd5d29a -r 2182df2d7810 mbed.bld --- a/mbed.bld Fri Dec 18 07:34:21 2015 +0000 +++ b/mbed.bld Fri Mar 31 15:36:26 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5 \ No newline at end of file