How to present this example concept in UML: Using 2 LCD displays in C/C++

33 views Asked by At

I make it a short as possile. I am an embedded software engineer. I know C and learn modern C++ for embedded, making my own examples. Also, I want to learn UML. ChatGPT can't help me out, since it doesn't understand visual language. Maybe ChatGPT 12 in 2049 can do that ;o My example: I have an NHD128x64 display, it comes with an ST7565p chip. My main goal here is TO LEARN UML. What I want to achieve:

  • Make a good architecture, here specifically, dependency inversion as part of uncle bob's "SOLID".
  • Make it possible to use 2 NHD128x64 displays on the same microcontroller
  • Re-Use my C-Code, but use C++ whereever the tradeoff "work vs. achievement of better architecture" makes sense.

So, here is the thing: There are basically 3 classes: the NHD driver class "Driver_nhd1k", the ST7565p driver class "St7565p", the "WhatPin"-class, which use dependency inversion to implement 2 child-classes to access the hardware for 2 displays, using different GPIO's and different SPI-interfaces. (I know I could just use chip select and then both LCD's can use the same pins, but I am doing this to learn soemthing about architecture).

Or, very simple: The hardware abstraction is done via inheritance of the "WhatPin" class, implementing "spi_send" and "gpio_set" stuff. The st7565p implements "setColumnAddr" and such things.

As a sidenote, the 1k display memory is used by my "Driver_nhd1k" as well as another, a GFX library, which uses "printf" on it and several "fonts" for this.

One last thing: I understand that "putting the runtime together" is kinda "factory" or "builder" pattern. In the diagram given below, this is not explicilty stated, since I don't knw yet how to make sense of UML.

It all works, in C, but as I said I want to make a software architecture in C++, using UML to describe it.

I made a diagram, which imho explains it pretty good ( or goof !? ).

enter image description here

In UML, I have various diagram types, for example, a class diagram. Or an object diagram. Or a sequence diagram. None of this give me, afaik, the ability to communicate the above concept usefully.

So, where is this going ? UML should HELP so simplify, and to visualize, but it seems things get overcomplicated with this. I mean, this amount of mess for one simple "dependency inversion"...

Any Idea, suggestion, further reading, whatever, that gives me a path to continue my learning, would be appreciated.

And sorry for the tldr and thank you very much for investing your time :)

0

There are 0 answers