×¢²á µÇ¼
µç×Ó¹¤³ÌÊÀ½ç-ÂÛ̳ ·µ»ØÊ×Ò³ EEWORLDÊ×Ò³ ƵµÀ EE´óѧÌà ÏÂÔØÖÐÐÄ Datasheet רÌâ
damiaaµÄ¸öÈË¿Õ¼ä https://home.eeworld.com.cn/space-uid-59433.html [ÊÕ²Ø] [¸´ÖÆ] [·ÖÏí] [RSS]
ÈÕÖ¾

¡¾STM32H7S78-DK¡¿ ËÄ ÏÂÔØʧ°ÜÎÊÌâ¼°½â¾ö¡¢¼ÆÊýÆ÷ʵÏÖ¼°·ÖÎö

ÒÑÓÐ 200 ´ÎÔĶÁ2024-11-3 11:23 |¸öÈË·ÖÀà:STM32

                ¡¾STM32H7S78-DK¡¿ ËÄ ÏÂÔØʧ°ÜÎÊÌâ¼°½â¾ö¡¢¼ÆÊýÆ÷ʵÏÖ¼°·ÖÎö
 
 
 
Ò»¡¢ ÔÚ²âÊԺ͵÷ÊÔÒ»¸ö¼ÆÊýÆ÷µÄ³ÌÐòµÄʱºò·¢ÏÖÏÂÔز»ÐУ¬²é¿´ÊÇÁ¬½Ó²»ÉÏST-link V3ÁË ÈçÏ£º
µ«ÉÏ´ÎϵĻ¹ÊÇÔÚÏÔʾÆÁÉÏÏÔʾ¡£
 Ê¹ÓÃSTM32CubeProgrammerÁ¬½ÓÒ²ÊÇÁ¬½Ó²»ÉÏ£º
 
·¢ÏÖÕâЩÎÊÌâºóÏëÏëÖ±½ÓÔÚ¸´Î»Ê±Á¬½Óstlink½Ó¿ÚIO£¬¿´Ðв»ÐУ¬ÈçÊÇ»¹ÊÇÓÃSTM32CubeProgrammerÁ¬½Ó ͬʱ°´°å×Ó¸´Î»¼ü¡£Á¬ÉÏ ÁË»¹ÄܶÁºÍ²Á³ý¡£
 
ÓÃͬÑùµÄ·½·¨(ÔÚtouchgfxÏÂÔسÌÐòʱ°´¸´Î»)£¬touchgfx designer ÏÂÔØÒ³¿ÉÒÔÁË£¬
 
¶þ¡¢ÏÂÃæ¿´¿´Õâ¸ö¼ÆÊýÆ÷µÄÀý×Ó
 
´Ó¼ýÍ·ÄÄÀïÁ½¸öµã µÄµØ·½½øÈ¥¿ÉÒԱ༭Դ´úÂë
ÎÒÃÇÒ»°ã¹Ø×¢ÏÂÃ漸¸öÎļþ
MainViewBase.hppºÍMainViewBase.cppÊÇtouchgfx designer²úÉúµÄÎļþ£¬ÀïÃæ°üº¬ÁË»ù±¾µÄÀàºÍʵÏÖ¡£
MainViewBase.hpp£º
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#ifndef MAINVIEWBASE_HPP
#define MAINVIEWBASE_HPP

#include <gui/common/FrontendApplication.hpp>
#include <mvp/View.hpp>
#include <gui/main_screen/MainPresenter.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/Image.hpp>
#include <touchgfx/widgets/TextAreaWithWildcard.hpp>
#include <touchgfx/widgets/Button.hpp>

class MainViewBase : public touchgfx::View<MainPresenter>
{
public:
    MainViewBase();
    virtual ~MainViewBase();
    virtual void setupScreen();

    /*
     * Virtual Action Handlers
     */
    virtual void increaseValue()
    {
        // Override and implement this function in Main
    }
    virtual void decreaseValue()
    {
        // Override and implement this function in Main
    }

protected:
    FrontendApplication& application() {
        return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
    }

    /*
     * Member Declarations
     */
    touchgfx::Box __background;
    touchgfx::Image backgroundImage;
    touchgfx::Image counterBackgroundImage;
    touchgfx::TextAreaWithOneWildcard countTxt;
    touchgfx::Button buttonUp;
    touchgfx::Button buttonDown;

    /*
     * Wildcard Buffers
     */
    static const uint16_t COUNTTXT_SIZE = 5;
    touchgfx::Unicode::UnicodeChar countTxtBuffer[COUNTTXT_SIZE];

private:

    /*
     * Callback Declarations
     */
    touchgfx::Callback<MainViewBase, const touchgfx::AbstractButton&> buttonCallback;

    /*
     * Callback Handler Declarations
     */
    void buttonCallbackHandler(const touchgfx::AbstractButton& src);

};

#endif // MAINVIEWBASE_HPP

 

MainViewBase.cpp

/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/main_screen/MainViewBase.hpp>
#include <touchgfx/Color.hpp>
#include <images/BitmapDatabase.hpp>
#include <texts/TextKeysAndLanguages.hpp>

MainViewBase::MainViewBase() :
    buttonCallback(this, &MainViewBase::buttonCallbackHandler)
{
    __background.setPosition(0, 0, 800, 480);
    __background.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
    add(__background);

    backgroundImage.setXY(150, 120);
    backgroundImage.setBitmap(touchgfx::Bitmap(BITMAP_BG_ID));
    add(backgroundImage);

    counterBackgroundImage.setXY(400, 152);
    counterBackgroundImage.setBitmap(touchgfx::Bitmap(BITMAP_COUNTER_BOX_ID));
    add(counterBackgroundImage);

    countTxt.setPosition(316, 189, 302, 104);
    countTxt.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
    countTxt.setLinespacing(4);
    Unicode::snprintf(countTxtBuffer, COUNTTXT_SIZE, "%s", touchgfx::TypedText(T___SINGLEUSE_XERM).getText());
    countTxt.setWildcard(countTxtBuffer);
    countTxt.setTypedText(touchgfx::TypedText(T_TEXTID1));
    add(countTxt);

    buttonUp.setXY(169, 173);
    buttonUp.setBitmaps(touchgfx::Bitmap(BITMAP_UP_BTN_ID), touchgfx::Bitmap(BITMAP_UP_BTN_PRESSED_ID));
    buttonUp.setAction(buttonCallback);
    add(buttonUp);

    buttonDown.setXY(169, 265);
    buttonDown.setBitmaps(touchgfx::Bitmap(BITMAP_DOWN_BTN_ID), touchgfx::Bitmap(BITMAP_DOWN_BTN_PRESSED_ID));
    buttonDown.setAction(buttonCallback);
    add(buttonDown);
}

MainViewBase::~MainViewBase()
{

}

void MainViewBase::setupScreen()
{

}

void MainViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
    if (&src == &buttonUp)
    {
        //IncreaseValue
        //When buttonUp clicked call virtual function
        //Call increaseValue
        increaseValue();
    }
    if (&src == &buttonDown)
    {
        //DecreaseValue
        //When buttonDown clicked call virtual function
        //Call decreaseValue
        decreaseValue();
    }
}

 

MainView.hppºÍMainView.cppÊÇtouchgfx designer²úÉúµÄÎļþ£¬ÀïÃæ°üº¬ÁËÓû§¿ÉÒÔÐ޸ĵÄÀàºÍʵÏÖ£¬ÊǼ̳ÐÁËÉÏÃæÁ½¸öÎļþÀïÃæʵÏֵĻùÀà¡£
MainView.hpp:
#ifndef MAIN_VIEW_HPP
#define MAIN_VIEW_HPP

#include <gui_generated/main_screen/MainViewBase.hpp>
#include <gui/main_screen/MainPresenter.hpp>

class MainView : public MainViewBase
{
public:
    MainView();
    ~MainView() {};
    virtual void setupScreen();
    virtual void increaseValue();
    virtual void decreaseValue();

    void updateGFXElements();
protected:

private:
    uint32_t count;
};

#endif // MAIN_VIEW_HPP

MainView.cpp:

#include <gui/main_screen/MainView.hpp>
#include "BitmapDatabase.hpp"

const uint32_t UPPER_LIMIT = 9999;
const uint32_t LOWER_LIMIT = 0;


MainView::MainView() : count(0) {}

void MainView::setupScreen()
{
    updateGFXElements();
}

void MainView::increaseValue()
{
    count = (count++ > UPPER_LIMIT) ? UPPER_LIMIT : count;
    updateGFXElements();
}

void MainView::decreaseValue()
{
    count = (count-- <= LOWER_LIMIT) ? LOWER_LIMIT : count;
    updateGFXElements();
}

void MainView::updateGFXElements()
{
    //Counter text area GFX uptade.
    Unicode::snprintf(countTxtBuffer, 5, "%d", count);
    //Button GFX update and touchable.
    if (count < UPPER_LIMIT)
    {
        buttonUp.setBitmaps(Bitmap(BITMAP_UP_BTN_ID), Bitmap(BITMAP_UP_BTN_PRESSED_ID));
        buttonUp.setTouchable(true);
    }
    else
    {
        buttonUp.setBitmaps(Bitmap(BITMAP_UP_BTN_DISABLED_ID), Bitmap(BITMAP_UP_BTN_DISABLED_ID));
        buttonUp.setTouchable(false);
    }
    if (count > LOWER_LIMIT)
    {
        buttonDown.setBitmaps(Bitmap(BITMAP_DOWN_BTN_ID), Bitmap(BITMAP_DOWN_BTN_PRESSED_ID));
        buttonDown.setTouchable(true);
    }
    else
    {
        buttonDown.setBitmaps(Bitmap(BITMAP_DOWN_BTN_DISABLED_ID), Bitmap(BITMAP_DOWN_BTN_DISABLED_ID));
        buttonDown.setTouchable(false);
    }
    // Invalidate all GFX area, which will result in it being redrawn in next tick.
    countTxt.invalidate();
    buttonUp.invalidate();
    buttonDown.invalidate();
}

 

 
ΪÁË°ÑÏÔʾ·ÅµÄλÖ÷ŵ½ÖÐ¼ä ²¢ÇÒÏÔʾÊý×Ö¿ÉÒÔ9999ÒÔÏ£¬ÐÞ¸ÄÁ˼¸¸öµØ·½
1,MainviewBase.hppµÄ»ùÀàÖÐÐÞ¸ÄÁËÕâÀĿµÄÊÇ°Ñ»º³åÇø±ä´ó£¬ÄÜ´æ5¸ö×Ö½Ú £º£¨Õâ¸öÎļþÒ»°ãÓû§´úÂë²»ÔõôÐÞ¸ÄÒ»°ãÓÉtouchgfx designerÐ޸ģ¬µ«ÎÒÕâÀïÊǽèÓõÄÀý×Ó£¬¾ÍÖ±½ÓÐÞ¸ÄÁË£©
2£¬ÐÞ¸ÄÏÂÃæMainviewBase.cpp
3£¬ÐÞ¸ÄMainview.hppµÄuint8_t count uint32_t count
4,ÐÞ¸ÄMainview.cppµÄUPPER_LIMITΪ9999
 
5£¬´úÂëdzÊÍ£º
Mainview.hppÖж¨ÒåÁ˼̳ÐÓÚMainViewBase µÄMainView Àà
Ö÷Òª¶¨ÒåÁËÐ麯Êý ÉèÖÃÆÁÄ»¡¢Öµ¼Ó¼õ¡¢ºÍͼƬ¸üк¯ÊýºÍ±äÁ¿count
class MainView : public MainViewBase
{
public:
    MainView();
    ~MainView() {};
    virtual void setupScreen();
    virtual void increaseValue();
    virtual void decreaseValue();
    void updateGFXElements();
protected:
private:
    uint32_t count;
};
 
Mainview.cppÖж¨ÒåÁËÕâЩº¯ÊýµÄʵÏÖ
increaseValue()ºÍdecreaseValue()·Ö±ðʵÏÖ¼ÓÊýºÍ¼õÊý£¬²¢ÇÒµ÷ÓÃupdateGFXElements();½øÐнçÃæÊý¾ÝºÍ°´¼ü±³¾°¸üС£
 
½çÃæÉèÖÃÖжÔÏÔʾcountTxtµÄÒ³Ãæ½øÐÐÁËÏÂÃæµÄÉèÖÃ
ËùÒÔÔÚupdateGFXElements()º¯ÊýÖÐʹÓÃ
Unicode::snprintf(countTxtBuffer, 5, "%d", count);
ÄܶÔcountTxtµÄÄÚÈݽøÐиüÐÂ
updateGFXElements()º¯ÊýÒ³¶ÔÊýÖµµÄ´óС½øÐÐÁËÏÞÖÆ£¬¶øÇÒÖØÐÂÉèÖÃÁË°´¼üµÄ±³¾°Í¼Æ¬¡£
×îºóÈÃcountTxtºÍbuttonUpºÍbuttonDownʧЧ£¬ÕâÑù¾ÍÄÜʵÏÖÖØ»­¶ø¸üнçÃæ¡£
 
ºÃ£¬ÏÈ·ÖÎöµ½ÕâÀï¡£
лл

±¾ÎÄÀ´×ÔÂÛ̳£¬µã»÷²é¿´ÍêÕûÌû×ÓÄÚÈÝ¡£

ÆÀÂÛ (0 ¸öÆÀÂÛ)

facelist doodle Í¿Ñ»°å

ÄúÐèÒªµÇ¼ºó²Å¿ÉÒÔÆÀÂÛ µÇ¼ | ×¢²á

ÈÈÃÅÎÄÕÂ