2023-09-13 12:29 AM
Hello
I'm still very new to Touch GFX
Still finding my way with programming in C++ as I'm more C based,
The biggest drawback I’m finding is the TouchGFX design environment when laying out screens does not allow you to add objects (Widgets) as arrays (multiples of the same).
Why on earth would this not have been implemented ??
This approach allows for much more efficient and logical coding for controlling each widget in for loops etc.
Is there any plan in the future to add this much needed option in the ToughGFX designer when laying out more complex screens of multiple objects / widgets
Thank in advance for any info
Solved! Go to Solution.
2023-09-13 02:51 AM
Thank you very much for your reply and code, very much appreciated
could you please explain what this does ? is it using images created from the youch design i.e. gradient led images as Im looking for nice gradient LED images on my screen,
or is the code using flat colours, I don't fully understand what is going on with this code ???
is the
&led1, &led2, &led3, &led4, &led5, &led6, &led7,
refering to images created in the touch gfx designer ?
thak you for any advice
2023-09-13 01:17 AM - edited 2023-09-13 01:21 AM
Have you thought about how much memory this will take?
You can create an array of widgets, but I strongly advise against it.
2023-09-13 01:46 AM
thanks for your reply
but not the reply I was expecting!
so your saying touch gfx and the high end displays a flawed for more complex designs ?
if you want say 30 red on leds images and 30 red off leds images on a screen, you then place the 30 red led off images on top of the 30 red on leds images
you then have to initialise each led image separately ??? and control 60 separate widgets ??? just to turn on and off some led images,
this should all be done in for loops as arrays, but if the hardware screens, arm processors and touch gfx is not up for this type of efficient code practice, it just shows how flawed it all is going down this design route
2023-09-13 02:01 AM
This is from me
/// \brief LedsRow
/// \file LedsRow.hpp
/// \version 1 \date 05.11.2022
#pragma once
#include <array>
#include <gui_generated/containers/LedsRowBase.hpp>
class LedsRow : public LedsRowBase
{
public:
using SColors = Led::SColors;
/// \brief Leds Row Constructor
LedsRow ();
/// \brief Leds Row class destructor
~LedsRow () = default;
/// \brief Initialize Container
void initialize () override;
/// \brief Set the Value
/// \param value
void setValue (uint16_t value);
void setParameters (uint8_t start_index, const SColors & colors_on, const SColors & colors_off);
// auto at (uint32_t index, Led ** led_ptr) -> void;
private:
SColors _Colors [2];
std::array<Led *, 12> _Array; ///< Array with pointers
uint16_t _Value;
};
#include <gui/containers/LedsRow.hpp>
LedsRow::LedsRow ()
{
_Array = {
&led1,
&led2,
&led3,
&led4,
&led5,
&led6,
&led7,
&led8,
&led9,
&led10,
&led11,
&led12,
};
}
void LedsRow::initialize ()
{
LedsRowBase::initialize ();
}
void LedsRow::setParameters (uint8_t start_index, const SColors & colors_on, const SColors & colors_off)
{
_Colors [0] = colors_off;
_Colors [1] = colors_on;
for (auto & iter : _Array)
{
iter->setNumber (start_index++);
iter->setColors (colors_off);
}
}
void LedsRow::setValue (uint16_t value)
{
if (_Value == value) return;
for (auto i = 0; i < _Array.size (); i++)
{
auto mask = (1 << i);
_Array [i]->setColors (_Colors [(value & mask) != 0]);
if (value ^ _Value) _Array [i]->invalidate ();
}
_Value = value;
}
Greetings
2023-09-13 02:51 AM
Thank you very much for your reply and code, very much appreciated
could you please explain what this does ? is it using images created from the youch design i.e. gradient led images as Im looking for nice gradient LED images on my screen,
or is the code using flat colours, I don't fully understand what is going on with this code ???
is the
&led1, &led2, &led3, &led4, &led5, &led6, &led7,
refering to images created in the touch gfx designer ?
thak you for any advice
2023-09-13 02:54 AM
these are the type of led images I would like to make in to arrays, that are placed in Touch GFX as arrays
2023-09-13 03:48 AM - edited 2023-09-13 03:54 AM
2023-09-13 06:34 AM
thank you, will try to work through code
Regards
2023-09-13 06:59 AM
Hello
I have tried going through the various files and code ??? To be honest none of this make a great deal of sense ??
This is so so so different to the C embedded nucleo boards that I program and use the various CAN / peripherals
I'm beginning to feel at a total loss with the touch gfx coding, could do with some real basic tutorial explaining this whole system,
I understand the model is the main central location to store all variables,
I understand the presenter always talks to the model and vice versa
but the other code and header files, god only knows whats going on ??
Appreciate your help even if I have no idea
Regards
2023-09-13 07:03 AM
Is this all so alien to me because it uses RTOS, I have never really studied RTOS,
this maybe what the issue is for me and why nothing looks like standard C code and why its all so hard to understand and use touchgfx