2021-04-07 10:20 AM
I have noticed what might be a bug in the updateItemCallbackHandler() in my screen's ViewBase file where the itemIndex consistently moves ahead 1 index when I swipe up.
/* Scroll Wheel Item Update response to swiping is generated by TouchGFX */
void ModeScreenViewBase::updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex)
{
if (items == &scrollWheelModeListItems)
{
touchgfx::Drawable* d = items->getDrawable(containerIndex);
ValuesMenu* cc = (ValuesMenu*)d;
scrollWheelModeUpdateItem(*cc, itemIndex);
}
else if (items == &scrollWheelModeSelectedListItems)
{
touchgfx::Drawable* d = items->getDrawable(containerIndex);
ValuesMenu* cc = (ValuesMenu*)d;
scrollWheelModeUpdateCenterItem(*cc, itemIndex);
}
}
During debugging, I noticed my value for swiping down to decrement by 1 but swiping up increments by 1 twice initially. The function scrollWheelModeUpdateCenterItem(), which references itemIndex, is called twice when swiping up for after entering the screen or after swiping down.
Note: values in the scroll wheel are wildcard placeholders. The expected behavior is the string highlighted is supposed to match the center item in the scroll wheel. The text of the center item and my string match when swiping down. However, the string using the ViewBase index will be the next item in the scroll wheel.
/* Prints highlighted string */
Unicode::strncpy(textAreaSelectedModeBuffer, modeScreenList[itemIndex], TEXTAREASELECTEDMODE_SIZE-1);
ModeScreenViewBase::textAreaSelectedMode.setWildcard(textAreaSelectedModeBuffer);
ModeScreenViewBase::textAreaSelectedMode.invalidate();
Additional Notes:
My Scroll Wheel animation and list appearance
The project is programmed onto a STM32429I-EVAL
Solved! Go to Solution.
2021-04-11 12:38 AM
Sorry, I realized that my first advice is relevant only for Non-Circular Wheel.
But, I've tried another approach. I was wrong in the answer, actually there is scrollWheelAnimationEndCallback for handling animation end event.
class Wheel: public WheelBase
{
public:
Wheel();
virtual ~Wheel() {}
virtual void initialize();
protected:
Callback<Wheel> scrollWheelAnimationEndCallback;
void scrollWheelAnimationEndHandler(void);
};
Wheel::Wheel() :
scrollWheelAnimationEndCallback(this, &Wheel::scrollWheelAnimationEndHandler)
{
wheel.setAnimationEndedCallback(scrollWheelAnimationEndCallback);
}
void Wheel::scrollWheelAnimationEndHandler(void)
{
int correct_index = wheel.getSelectedItem();
}
If you call .getSelectedItem() at this point, selected item index will be correct.
2021-04-08 01:56 AM
I also encountered this problem. In one of the examples from TouchGFX Designer (Scroll Wheel and List Example, file Screen1View.cpp) I noticed that the item index is obtained in the function which is called at the end of the wheel movement animation (in the above example it is "scrollWheelAnimateToHandler" from Screen1View.cpp).
// The callback updates the selectedVal on the itemSelected parameter
void Screen1View::scrollWheelAnimateToHandler(int16_t itemSelected)
{
selectedVal.invalidate();
Unicode::snprintf(selectedValBuffer, SELECTEDVAL_SIZE, "%d", itemSelected);
}
In this file there is an example of how to use the callback to register this function.
This way I was able to get the correct index for further processing. :)
2021-04-09 10:22 AM
Thanks for the response, I gave the handler callback from the example a try. The index of the center item was printed. My list has 8 items. When I scroll up, I get:
A 0
B 1
C 2
D 3
E 4
F 5
G 6
H 7
A 8
B 1
C 2
D 3
E 4
F 5
G 6
H 7
A 8
.....
The only time that A was 0 was when I scrolled down and then scrolled back to A. But when I keep scrolling the index ranges from 1-8. Now when I scroll down:
.....
G 6
H -1
A 0
B 1
C 2
D 3
E 4
F 5
G 6
H -1
A 0
.....
Printing out the index does illustrate scroll up gives me index 1-8 and scroll down gives me 0-6 with the last item being -1. Nothing out of the ordinary was present in the widget configuration. Were there similar results for your situation?
2021-04-09 10:23 AM
Thanks for the response, I gave the handler callback from the example a try. The index of the center item was printed. My list has 8 items. When I scroll up, I get:
A 0
B 1
C 2
D 3
E 4
F 5
G 6
H 7
A 8
B 1
C 2
D 3
E 4
F 5
G 6
H 7
A 8
.....
The only time that A was 0 was when I scrolled down and then scrolled back to A. But when I keep scrolling the index ranges from 1-8. Now when I scroll down:
.....
G 6
H -1
A 0
B 1
C 2
D 3
E 4
F 5
G 6
H -1
A 0
.....
Printing out the index does illustrate scroll up gives me index 1-8 and scroll down gives me 0-6 with the last item being -1. Nothing out of the ordinary was present in the widget configuration. Were there similar results for your situation?
2021-04-09 05:54 PM
I want to contribute more details after some testing. The values I listed above were from dragging the scroll wheel, which I believe is supposed to move the center item by 1 in the list as opposed to swiping which is >1. Whenever I perform a hard swipe on the wheel, the index values I print are inconsistent and there is no pattern. Sometimes I will get the correct index for the item and other times I will get an out of bounds index.
Swiping down gets me negative itemSelected and swiping up gets me a positive itemSelected e.g. 10 when my list size is 8. This is with using scrollWheelAnimateToHandler with callback as opposed to printing the list item in scrollWheelModeUpdateCenterItem() before.
2021-04-11 12:38 AM
Sorry, I realized that my first advice is relevant only for Non-Circular Wheel.
But, I've tried another approach. I was wrong in the answer, actually there is scrollWheelAnimationEndCallback for handling animation end event.
class Wheel: public WheelBase
{
public:
Wheel();
virtual ~Wheel() {}
virtual void initialize();
protected:
Callback<Wheel> scrollWheelAnimationEndCallback;
void scrollWheelAnimationEndHandler(void);
};
Wheel::Wheel() :
scrollWheelAnimationEndCallback(this, &Wheel::scrollWheelAnimationEndHandler)
{
wheel.setAnimationEndedCallback(scrollWheelAnimationEndCallback);
}
void Wheel::scrollWheelAnimationEndHandler(void)
{
int correct_index = wheel.getSelectedItem();
}
If you call .getSelectedItem() at this point, selected item index will be correct.
2021-04-12 06:01 PM
Want to say getSelectedItem() was what I was looking for! The scroll items and index match now.