sidoh / epaper_templates

Template-oriented driver for e-paper displays
MIT License
256 stars 27 forks source link

Allow the change of bitmaps background color #23

Closed nullstalgia closed 4 years ago

nullstalgia commented 4 years ago

tenor

And you thought you were rid of me.

Hasn't even been 24 hours.


Four main things:

  1. The bitmap color changing does work! So you can have red-on-white/white-on-black bitmaps.

image

Vs

image

  1. I need help getting two things working

    1. Background color showing up properly in the template editor
    2. Rectangle color properly filling when filled in the template editor
  2. (Static?) Rectangles were not being rendered on boot without some change happening to them first. Adding region->render() to it being added to the region list solved that.

    • Should we instead of rendering text and bitmaps in their respective renderX functions, would it be better to create a temporary Region instance, run region->render(), and let the stack reclaim the memory? That way, we only have to change the render functions in one spot (and it looks nicer).
  3. everything needs a fscking background color. I considered adding it to the Region parent class, but didn't have any luck... Would it be better to instead add it to the json object when passing it to the renderX functions?

sidoh commented 4 years ago

Thanks for doing this! Looks good. I pushed fixes for the two things you mentioned in (2)

re: (3) -- all other types of regions render the appropriate shape without creating a Region instance. For example, with texts, it's just calling display->print directly:

    if (text.containsKey("value")) {
      text = text["value"];

      if (text["type"] == "static") {
        display->print(text["value"].as<const char*>());
      }
      // fall back on v1 format where "static" and "variable" are inline with
      // the definition
    } else {
      if (text.containsKey("static")) {
        display->print(text["static"].as<const char*>());
      }
    }

we could do the same with rectangle, but it's a slightly harder to detect whether the region is static or variable because both width and height can be variable.

calling region->render() in place is probably fine. the overhead is gonna be pretty minimal.

re: (4), probably best to just make sure regions that should support background colors have it. Would rather not add it to the base schema as it doesn't make sense for everything (mainly things that only have a stroke, like lines).

sidoh commented 4 years ago

@nullstalgia, I think this is ready to go if you're comfortable.

nullstalgia commented 4 years ago

I haven't tested it yet, sorry!

I've been out of state for a few days, should be back by the weekend.

sidoh commented 4 years ago

No rush at all. Safe travels.

nullstalgia commented 4 years ago

Seems good. Merge when ready, @sidoh


Question though, do you have a way to test webpage changes without uploading them to the ESP? If so, can you write out a guide and post it either here or in a .md for us contributors? :)

sidoh commented 4 years ago

Sweet. Thanks!

Yeah, you can run:

npm run start

from ./web. The dev server will proxy API requests to a host named epaper-display. You can edit the remote host by changing the constant API_SERVER_ADDRESS in .neutrinorc.js.

Happy to add this to a README, will do that sometime soon (thanks for the suggestion)