2025-11-21 11:59 AM
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();
}Solved! Go to Solution.
2025-11-21 12:48 PM
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
2025-11-21 12:48 PM
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
2025-11-21 6:45 PM
Thank you Peter, unchecking AutoSize does the trick, and of course the unsigned is a mistake.