Skip to content

Support specifying parameter in constructor of UI components #109

Open
@SmallpTsai

Description

@SmallpTsai

Sample code

class Label : public LRemoteLabel {
public:
  Label(const String &text, uint8_t x, uint8_t y, uint8_t w, uint8_t h, RCColorType color = RC_GREY) : LRemoteLabel() {
    setText(text);
    setPos(x, y);
    setSize(w, h);
    setColor(color);
  }
};

Usage example

Label label1("Select leg", L_X(0), L_Y(0), L_W, L_H);

Much cleaner code

static Label label1("Select leg", L_X(0), L_Y(0), L_W, L_H);
static Label text1("", T_X(0), T_Y(0), T_W, T_H, RC_PINK);
static Button button1l(10, "<", Bl_X(0), Bl_Y(0), B_W, B_H, RC_BLUE);
static Button button1r(11, ">", Br_X(0), Br_Y(0), B_W, B_H, RC_BLUE);
...

setup() {
  ...
  LRemote_addControls({
    &label1, &text1, &button1l, &button1r,  // row1
    ...
  });
  ...
}

reference: https://github.com/SmallpTsai/hexapod-v2-7697/blob/master/software/hexapod7697/src/setting_mode.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions