king2 Posted January 14, 2016 Report Share Posted January 14, 2016 I need to paint graphs in my application, three of them, like in oscilloscope. I cannot use second layer of LTDC because I'm using 800x600 screen and FMC SDRAM, and displaying second layer makes STM32 crazy (not enough bus bandwidth).Should I do this completely manually or uGFX can make my life easier?Can you provide me with some starting point, where to start at?May be some code examples or advices?Thank you in advance! Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted January 14, 2016 Report Share Posted January 14, 2016 uGFX comes with an existing graph widget: http://wiki.ugfx.org/index.php/GraphExamples:https://i.ytimg.com/vi/WcNgBEWWnrc/maxresdefault.jpghttp://wiki.ugfx.org/images/b/b4/Graph_demo_640x480.gifWhether you want to use the existing graph widget or not is up to you. The graph widget is one of the first widgets that we created. It isn't the most used thing in the uGFX library and therefore we didn't spend a lot of time extending and optimizing it. Don't get me wrong, the code that is there works very well and there are many people who use it. It's just not the holy grail for all your graph needs.Writing your own graph widget would be very easy as the graph itself is not a widget but a window (read the GWIN article in the wiki for more information). The basic difference is that a window doesn't take any user input while a widget does. Therefore, creating a custom graph window is just a matter of using the already available GDISP drawing functions to make it look and behave like you want.You can look at the existing graph implementation (/src/gwin/gwin_graph.c) to learn how to implement your own, it's really straight forward.Please do not hesitate to ask should you have any other questions regarding the existing graph widget or writing your own. We are happy to help wherever we can.If you decide to either write your own graph from scratch or extend the existing one, we would of course be very happy if we can add your contribution to the library so others will benefit too ~ Tectu Link to comment Share on other sites More sharing options...
king2 Posted January 14, 2016 Author Report Share Posted January 14, 2016 Thanks!But can I place three graphs on same window with another widgets or I can use it as one main window only? Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted January 14, 2016 Report Share Posted January 14, 2016 Displaying multiple graphs at the same time is not a problem at all. You can have as many windows and widgets on your display at the same time.Just think of the graph window as if it were a regular widget like a button or a slider: You can have as many of them as you want, working independently. That is also why I used the term "graph widget" instead of "graph window" in my first post - to avoid confusion.~ Tectu Link to comment Share on other sites More sharing options...
king2 Posted January 14, 2016 Author Report Share Posted January 14, 2016 Thank you!Sotty, I have overlooked 'Graph', it looked like some abstract module for me Link to comment Share on other sites More sharing options...
king2 Posted January 14, 2016 Author Report Share Posted January 14, 2016 I looked at graph widget. As I understand, it have no ability to add new point when shifting old points to desired direction, right?So, if I want to make something like slow oscilloscope, I should: - add points to widget, until x=max (this fills empty area with points, one point in a tick) - then for each new point in each new tick I should: - shift data array like Y(n-1) = Y(n) - Y(max) = new value - redraw entire widget with all points from data arrayIs it right? Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted January 15, 2016 Report Share Posted January 15, 2016 The built-in graph widget only provides very basic functionalities. It doesn't have an internal list of points. Each time the graph is redrawn you must redraw your points manually using gwinGraphDrawPoints(). This means that if you want to scroll your graph you'll have to shift your points manually using the process you described.If you have needs for a graph that can shift points I would strongly recommend implementing your own graph widget!~ Tectu Link to comment Share on other sites More sharing options...
inmarket Posted January 18, 2016 Report Share Posted January 18, 2016 If you are after oscilloscope type functionality have a look at the GADC demo and the gaudio record demo.They both have a custom oscilloscope type widget that you might be able to adapt to your needs. The demo's even support multiple forms of trigger level.These custom widgets are not a "standard" widget because the implementation is very specific to the demo applications (and slightly different between the two applications). To generalise the oscilloscope widget for general use was considered too hard at the time so they have remained as code hidden away in those demos rather than receiving the glory of being part of the main widget set. Link to comment Share on other sites More sharing options...
king2 Posted March 25, 2016 Author Report Share Posted March 25, 2016 Sorry to bring this thread up again, but I'm really started to write my own graph widget. As usual for me I want to use parts of existing graph widget, like its axis drawing routines, dotted lines and so on, but with my own modifications, mainly about taking data from app and autoscaling. I do not want to make widget from scratch, because Graph already have well-written optimized routines, that need not to be rewritten. I saw GADC example and its gwinosc widget, but it seems like it not uses Graph at all. Can I make widget that will use Graph as base class or something like this, but will use its own function for data preparing, will generate its own touch panel events and so on? How do to it if it is possible? Thanks! Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted March 26, 2016 Report Share Posted March 26, 2016 It's correct that the GADC oscilloscope demo doesn't use the graph widget. The oscilloscope is a custom widget. As C is not an object oriented programming language it's not possible to simply inherit from the existing graph widget and adding your own modifications. There are two possible ways: Create a new widget and copy-paste the corresponding code from the existing graph widget and then modify to your needs Create a new widget that uses the existing graph widget internally. This would mean that inside your own widget you'd have a GHandle and you call gwinGraphCreate() in your own widget init routine. Which of the two you take depends a lot on your needs.If you want to add things like touch events and so on then option 2 will be a lot simpler. Also autoscaling and other things are possible to implement this way because you simply manipulate the data in your own widget and then forward to the actual graph widget instance. Your widget would basically be a proxy widget. However, as soon as you have to modify anything in the existing graph widget that cannot be modified using the provided API then you have to choose option 1. I hope that helps. Please do not hesitate to ask if you have any other questions Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now