Skip to content

Output widgits as functions rather than embedded in mainDraw() #7

@iaincoulter

Description

@iaincoulter

Currently experimenting with this and creating my own widgets but also noticed if for example I add multiple of the same widget in the mainDraw() function will end up with multiple copies of the exact same code.

Hence if instead widgets were output as functions with parameters

for example

void digitalclock(int h, int m, int center_x, int center_y, in size)
{
for (int i = 0; i < 60; ++i) {
       if (i % 5 == 0)
           display.drawThickLine(widget0_center_x + widget0_r1 * cos((double)i / 60.0 * 2.0 * 3.14159265),
               widget0_center_y + widget0_r1 * sin((double)i / 60.0 * 2.0 * 3.14159265),
               widget0_center_x + widget0_r3 * cos((double)i / 60.0 * 2.0 * 3.14159265),
               widget0_center_y + widget0_r3 * sin((double)i / 60.0 * 2.0 * 3.14159265), 0, 3);
       else if (widget0_size > 150)
       
      .... <cut rest of digitalclock implementation>
 }

In mainDraw() could then add


digitalclock(10,20,82,544,64);
digitalclock(11,20,28,154,64);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions