Menu

Max7219_LEDMatrix_GLCDPrint does'nt work

G. C.
2023-10-23
2023-10-24
  • G. C.

    G. C. - 2023-10-23

    Hi there,
    I am trying to emulate a watch on 4 8x8 LEd matrix modules.. But I am not able to print a single string in a "permanent" way (better: to be changed only once per minute) on the display..

    Searching into the library I saw this command: Max7219_LEDMatrix_GLCDPrint , but when I try to use it in this simple way: Max7219_LEDMatrix_GLCDPrint(0, 0, "12:54"), I do not get anything on the matrixes.

    Please note that if I send a scrolling message with Max7219_LEDMatrix_ScrollMessage ( "my msg",1) everything works fine and I get the text scrolled onto the display..

    What am I doing wrong with the Max7219_LEDMatrix_GLCDPrint command? Perhaps is a problem of coordinates? Where is the 0,0 point on a group of 4 8x8 matrixes?

    Also, I am using a photoresistor to read the ambient light and adapt the led brightness.. Reading the ADC sections I found some instructions to optimize code for the analog channels that need to change an header file to disable all other channels.. Is it really mandatory to do that or can I simply use one channel with the ReadAD10 (input, true) and just forget the rest of analog inputs?

    Sorry if I make simpple questions like these, but it's difficult to debug a board without a step by step debugger/watches etc), at least for me.. Even to check if the ADC conversions result is correct is not a simple task, as I see the brightness of the display behaving quite differently from expected and having only to make continuos trials and errors.

    Regards,
    GC

     
    • Anobium

      Anobium - 2023-10-23

      I always recommend using Serial Terminal debugging. Then you can dump lots of values.


      Post you program. It is easy that way to load your program to understand what is happening with Max7219_LEDMatrix_GLCDPrint.

       
      • G. C.

        G. C. - 2023-10-23

        Here it is, attached here...

        comments etc are in italian, but I guess the few instructions used at present are so simple to understand..

        Abut using the terminal to debug, honestly I do not know how to do it, as for my boards developments in the past I always used Mplab with XC8 and the ICD3, placing breakpoints here and there to look at the watch window the variables contents.

        If you have some stuff to read about how to use the terminal, I'llbe more than happy to learn it out. I am much more familiar with Basic (I think I still have some MS version on 3.5" disks somewhere) than C, and discovering GCB let me write code at a much faster speed..

        Thx,
        GC

         
  • Anobium

    Anobium - 2023-10-23

    I do not have the LEDs here but try this.

    Background.

    The different LEDs have different geometry - different pinouts. So, the GLCDPRINT takes the string, char by char and it calls PSET ( pixel set) to set the pixel ON or OFF for each column of the char.

    PSET is a logical call to update the same buffer that Scroll uses.

    Try this

       GLCDPrint (1, 0, "Wait...")
      Max7219_LEDMatrix_Update
    

    Note this.... Max7219_LEDMatrix_Update. You need to push the buffer to the LEDs.


    Note: There are four PSETs for the four geometries.

      'Default is _0, can be _90, _180 or _270
      #define Pset max7219_LEDMatrix_PSet_0
      '#define Pset max7219_LEDMatrix_PSet_90
      '#define Pset max7219_LEDMatrix_PSet_180
      '#define Pset max7219_LEDMatrix_PSet_270
    
     
    • G. C.

      G. C. - 2023-10-23

      Yes, it works... It shows only the first 5 characters, but that's the limitation of the 32x8 display, of course.

      So after any write to the display it's necessary a "refresh" for the display, that is made by the Max7219_LEDMatrix_Update sub that resends the display buffer, I guess..
      The "scroll" sub probably calls directly the update, as it does not need the explicit call.

      Thanks.
      GC

       
      • Anobium

        Anobium - 2023-10-23

        Try increasing the string size, test by defining a string variable and pass that variable rather then the constant "12:54".

        Dim myString * 5

        The method in the .H library is Max7219_LEDMatrix_GLCDPrint() this seems to be handling the string on line 488. So, if the handling of the main program call is not passing the correct length then I would need to look properly. Some debug on this would confirm the string legnth is correct. If that is correct then the Max7219_LEDMatrix_Update method would be next place to look for the root cause.

         
  • G. C.

    G. C. - 2023-10-23

    Ok, I made a few tests and can confirm that the key is to refresh the buffer..

    The print works with both commands (GLCD or MAX_GLCDPRint), and it's not a problem to pass a costant string or a variable with the text to show.
    ex1:
    Max7219_LEDMatrix_GLCDPrint(0, 0, "12:54")
    Max7219_LEDMatrix_Update

    ex2:
    dim testo as String
    testo = "pippo"

    Max7219_LEDMatrix_GLCDPrint(0, 0, testo)
    Max7219_LEDMatrix_Update
    

    Both these work.. But the Max7219_LEDMatrix_Update is mandatory, or the display wil stay blank.

    Rgds,
    GC

     
  • Anobium

    Anobium - 2023-10-23

    Great insights.

     
  • Anobium

    Anobium - 2023-10-24

    @GC

    Can you share if there was any documentation for the library ? Where the demos any use? What improvements should be made to ease use of the library?


    Did you sort serial debug? It is very simple. If needed i can do a YouTube on 'how to'.

     
    • G. C.

      G. C. - 2023-10-24

      Hi Anobium,
      I did not say that there was'nt any doc on the MAX72library, either on the Help of the IDE nor I was able to find online a "guide" on how to use the commands...
      That is because I don't pretend to get everything well documented and precisely explained as for a commercial product. I am grateful of the availability of GCB even if it's not "state of the art" yet. And I did not want to press out or demotivate the Developer's team with such claims.. But if you "like" to have some feedback on my experience as long as I make some use of GCB, I'll be more than happy to send it to you.

      On Max7219 lib, for example, there was not autocompletion in VS of the commands and I had to download the .h file and try to understand in it how to write a correct syntax. As I said, in the help there is no mention of MAX7219 commands, and also there is some ambiguity that many GLCD commands will work also with MAX7219as, the header files make some connections between the two libs.. Also a little more explaination on parameters would be great, i.e. for the MAX7219 scrolling command it's mentioned a parameter that is a delay.. It works even put at 0..for me it's someting strange, but the point is there is no indication of the range that you can give to it and what exactly means: it's the delay between characters, between columns shift or what?

      The demos are good, indeed I took some text directly from there during my tests, instead of writng them myself and avoding typing errors. Invaluable help for the novice. Sometime it's a bit confusing the repositories in wich one can reach them, but it's not a big issue. Some search in this forum helps.

      About the serial debug - as I said I am not familiar with such tecnique as I never had to use it. I always used an HW debugger and got the old friend Oscilloscope available...
      Perhaps because I am more of an Analog guy than a digital one. But I'll find out how to use the serial port redirected to terminal , sooner or later. If you have time and willingness to do it, of course I will watch any video you'll prepare..

      Overall, I am just playing with GCB for only two weeks, and find it a great tool that simplifies firmware reading for small uCs, missing for the time being just the old school line by line debugging I was used to, and some more clear description of the commands available..

      But le me be clear again: I think you make a great job in sharing your knowledge and giving good tools at no cost for designers, hobbysts and anyone else. Thanks!

      Now I'll go on with testing some of the math functions: in my clock there is also an NTC that measures the ambient temperature, and I'll need LOGs to read it.. Will see how it goes, eventually i'll ask for help.

      Bye,
      GC

       
  • Anobium

    Anobium - 2023-10-24

    Thank you!

    You feedback is really good. Lots of good ideas for me and for others.

    And, the goal is to provide tools for designers, hobbysts and anyone for free. But, providing the tool chain is no longer at no cost.... November/December is time to provide donations for the coming year ( costs of hosting, software dev tools licenses, certs etc etc ). :-)


    VS Autocompletion. We should look at autocompletion for library when they are loaded. So, if you have an #include then only show the valid additional autocomplete. We have missed adding these commands in - a great insight by you.

    The parameters should be documented in the Help. I guess there was no Help when this library was written. I cannot remember. I will add to the backlog.

    Debugging. I have a video on debuggging on YouTube. It shows many different method including walking the code line by line. But, if the Help was there and the library was documented then walking the code should not be required.

     
    • G. C.

      G. C. - 2023-10-24

      I understand the need for support of the project, and I will not wait for christmas time... :)

      About one way to contribute, that is in purchasing a PICKIT2, I will write you a separate email at yr website, as I do not think for commercial stuff this is the correct platform to use, right?

      I will watch your youtube channel, surely will find some good advice. About going line by line for debugging what I really meant is that if I could stop the program running on a real board, with interrupt coming in while state machines are switching here and there the code, and looking after the variables etc at specific times, I can precisely understand what's wrong with my code (and not the potentially wrong behaviour of a GCB command, wich i give is correct for granted). I am not sure that a simulator can work in all cases, nor I am too willing to pass trough the learning curve that those programs require..

      Take for example my little test program I wrote and posted up here: the sampling routine of the ambient light is not giving me the expected result. I have an input that goes from almost zero (no light) to 4.5 Volts. Read it 5 times and take the average, then divide it in 16 intervals that MAX7219 uses to control the LED brightness. Simple stuff.. But it doe'snt work. If I had the HW debugger in, I could stop and read in the watch window the ADC conversion value, the result of the average calculation etc..

      At present, I can't do it and am waiting to learn how to send the ADC result to the Terminal etc. etc.. I have no urgency, it's only an hobbyst project, and will take my time as GCB and it's libraries look like a promising tool to reduce the time for writing the code, and I am willing to spend some time to better use it... But the debug phase at present (in respect to my previous experience) is slowed down, as I am not familiar yet with all the ways to make the most of it..

      Thanks a lot,
      GC

       
  • Anobium

    Anobium - 2023-10-24

    :=)

    PICKitPlus does not fund GCBASIC. Different project. PICKitPlus is still recovering the investment I made to develop all the different versions. Any purchases help PICKitPlus survive as a project.

    If you really want to stop the microcontroller then the best option is using GCBASIC to generate your code, then use MPLAB-X debugger and a PICKit4/5. Some chips will support a PICKit3 in the debugger. But, you need to installed MPLAB-X.

    I very very rarely debug in MPLAB-X, and, I am developing the low level compiler and library and MLAB-X slows me down. Serial is excellent. Chris Roper has a great idea for a serial debugger. And, if I had enough time I would write a debugger for a PICKit2 or PICKit3.

    Good dicussion, have fun!

     

    Last edit: Anobium 2023-10-24

Log in to post a comment.