cancel
Showing results for 
Search instead for 
Did you mean: 

counter will not increment beyond 9 and does not show negative numbers. Designer 4.26.0

ksale.1
Senior

I was following the tutorial in the link:  

https://www.youtube.com/watch?v=vy1c1LbypuM&list=PLfIJKC1ud8giOsk-C4BCOwSHtbXqTNb1W&index=3 

I couldn't gett the upclick to count greater than 9 and below 0. the screenView.hpp and cpp as follows:                       

hpp:

#ifndef SCREEN1VIEW_HPP
#define SCREEN1VIEW_HPP

#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include <gui/screen1_screen/Screen1Presenter.hpp>

class Screen1View : public Screen1ViewBase
{
public:
    Screen1View();
    virtual ~Screen1View() {}
    virtual void setupScreen();
    virtual void tearDownScreen();

    virtual void downclicked();
    virtual void upclicked();

    

protected:

    uint16_t counter = 0;
};

#endif // SCREEN1VIEW_HPP


cpp:


#include <gui/screen1_screen/Screen1View.hpp>

Screen1View::Screen1View()
{

}

void Screen1View::setupScreen()
{
    Screen1ViewBase::setupScreen();
}

void Screen1View::tearDownScreen()
{
    Screen1ViewBase::tearDownScreen();
}

void downclicked(){
	counter--;
	Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%u", counter);
	textArea1.invalidate();
}

void upclicked(){
	counter++;
	Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%u", counter);
	textArea1.invalidate();
}
Thank you in advance for your help
1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

Well, what is the value of TEXTAREA1_SIZE?
Because if it only covers one digit, you will inevitably only see the ones digit.

And how do you intend to obtain negative numbers if you define the counter as uint16_t?

Regards
/Peter

 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
Peter BENSCH
ST Employee

Well, what is the value of TEXTAREA1_SIZE?
Because if it only covers one digit, you will inevitably only see the ones digit.

And how do you intend to obtain negative numbers if you define the counter as uint16_t?

Regards
/Peter

 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ksale.1
Senior

Thank you Peter, unchecking AutoSize does the trick, and of course the unsigned is a mistake.