Giter Club home page Giter Club logo

Comments (15)

cattanimarco avatar cattanimarco commented on June 1, 2024

What type of plot are you trying to draw? Can I have a look at the code? It seems to me that you have have run out of memory (this happens, for example, on the arduino uno if you use the spline datasource)

from grafici-gfx.

makuser avatar makuser commented on June 1, 2024

Your basic example code, actually all three/four variations of it.
No memory problems, because it's running on an ESP32.

from grafici-gfx.

cattanimarco avatar cattanimarco commented on June 1, 2024

I updated the wiki with more info on how the coordinate system works (still a WIP). I hope it helps

from grafici-gfx.

makuser avatar makuser commented on June 1, 2024

No, just a white screen, no matter any parameter.

from grafici-gfx.

cattanimarco avatar cattanimarco commented on June 1, 2024

At creation Grafici will clear your display. This could be one of your problems. Could you try to comment the fill_rect line?

	Grafici(Adafruit_GFX &hal)
	    : _display_driver{ hal }
	{
		_display_driver.fill_rect({ 0, 0 }, { 1, 1 }, black);
	}

Still, I would expect a black background rather than a white one

from grafici-gfx.

cattanimarco avatar cattanimarco commented on June 1, 2024

Can you try this basic example?

void setup(void)
{
	gfx.begin();

	Grafici plot{ gfx };

	unsigned int raw_data[] = {1, 2, 4, 5, 2};
	DataArrayXY<unsigned int> data{ raw_data, 5};

	plot.set_color_map(black_and_white);
	plot.line(data.x(), data.y(), data.y(), full_screen);
}

void loop(void)
{
}

from grafici-gfx.

makuser avatar makuser commented on June 1, 2024

I added the part to initialize GxEPD2 instead of the regular Adafruit GFX, to make it compatible with my display, but I am still only getting a white or rather gray screen.

I also tried putting the actual drawing code info the required nextPage wrapper, which seems like it is required to be able to desigate when to render and actually send the data to the epaper.

from grafici-gfx.

makuser avatar makuser commented on June 1, 2024

At creation Grafici will clear your display. This could be one of your problems. Could you try to comment the fill_rect line?

	Grafici(Adafruit_GFX &hal)
	    : _display_driver{ hal }
	{
		_display_driver.fill_rect({ 0, 0 }, { 1, 1 }, black);
	}

Still, I would expect a black background rather than a white one

I already commented that out and before also changed black to white, because I thought it might help to at least display, the other stuff on the screen, but sadly no.

Well, it's a gray/white screen, which looks like an unititialized state, or an aborted reset operation or so. epaper displays special love to display items on the screen.

from grafici-gfx.

makuser avatar makuser commented on June 1, 2024

Example code:

#include <GxEPD2_BW.h>
#define ENABLE_GxEPD2_GFX 0 // also tried turning it on/1

#define DISPLAY_BUSY 4
#define DISPLAY_RST 0
#define DISPLAY_DC 2
#define DISPLAY_CS 15

/* setup display driver */
GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(DISPLAY_CS, DISPLAY_DC, DISPLAY_RST, DISPLAY_BUSY));
SPIClass hspi(HSPI);

#include "Grafici.h"
constexpr size_t ARRAY_SIZE = 25;
constexpr size_t MAX_VALUE = 255;

unsigned int raw_data[ARRAY_SIZE];
DataArrayXY<unsigned int> data{ raw_data, ARRAY_SIZE, { 0, MAX_VALUE } };

void setup(void)
{
  Serial.begin(115200);
  Serial.println("Hello!");
  /* init display driver and select landscape mode */
  display.init(115200, true, 2, false, hspi, SPISettings(4000000, MSBFIRST, SPI_MODE0));
  Serial.println("step1");

  display.firstPage();
  do {
    display.fillScreen(GxEPD_WHITE);
    display.println("Starting...");
    display.println(millis());
  } while (display.nextPage());

  Serial.println("step1b");

        // Init the plotting library with the display driver
        Grafici plot{ display };
  Serial.println("step2");

        // generate some random data and save it into `raw_data`
        randomSeed(66);
        for (size_t i = 0; i < ARRAY_SIZE; ++i)
        {
                raw_data[i] = random(MAX_VALUE + 1);
        }
  Serial.println("step3");

  auto graph_window = full_screen.sub_window({ 0, 1 }, { .2, .6 });
        // Set the color map
        plot.set_color_map(black_and_white);
  Serial.println("step4");

        // break plot lines in multiple segments to create a gradient of colors between two data points
        PlotLineOpts opts;
        opts.segments = 10;
  Serial.println("step5");

        // Plot data as a line. Color line using `data_y`
        plot.line(data.x(), data.y(), data.y(), graph_window, opts);
  Serial.println("step6");

}

void loop(void)
{
}

I also tried extending the do ... while nextPage loop that i mentioned above up to the plot.line part, no change unfortunately.

from grafici-gfx.

cattanimarco avatar cattanimarco commented on June 1, 2024

from the docs

drawing to full screen buffer is done using Adafruit_GFX methods without picture loop or drawCallback
and then calling method display()

try the following:

  display.init(115200, true, 2, false, hspi, SPISettings(4000000, MSBFIRST, SPI_MODE0));

  Grafici plot{ display };
  plot.set_color_map(black_and_white);
  plot.line(data.x(), data.y(), data.y(), full_screen);

  display.display(false);

Basically, use display() rather than firstPage() and nextPage()

from grafici-gfx.

cattanimarco avatar cattanimarco commented on June 1, 2024

I looked at this example
https://github.com/ZinggJM/GxEPD2/blob/master/examples/GxEPD2_NotPagedExample/GxEPD2_NotPagedExample.ino

from grafici-gfx.

makuser avatar makuser commented on June 1, 2024

from the docs

drawing to full screen buffer is done using Adafruit_GFX methods without picture loop or drawCallback
and then calling method display()

Basically, use display() rather than firstPage() and nextPage()

Thank you very much, using a non-paged approach for the views where your graph library is used, allowed me to display the graph on the e-Paper screen.

from grafici-gfx.

makuser avatar makuser commented on June 1, 2024
	Grafici(Adafruit_GFX &hal)
	    : _display_driver{ hal }
	{
		_display_driver.fill_rect({ 0, 0 }, { 1, 1 }, black);
	}

Being able to disable this, would be awesome btw ;)

from grafici-gfx.

cattanimarco avatar cattanimarco commented on June 1, 2024

done

from grafici-gfx.

makuser avatar makuser commented on June 1, 2024

done

Well done! 😄 Thank you again!

May this be released as 3.1.1 or 3.2.0?

from grafici-gfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.