Announcement

Collapse
No announcement yet.

Serial programming from Arduino using a Library

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Serial programming from Arduino using a Library

    Hi all

    I freely admit I am stupid, but I hope someone has enough patience to point me in the right direction.

    A couple of years ago I developed a sensor analysis device using an Arduino ATMega 328 and a uOLED 128 G1 display. Everything worked as I wanted until the mylar connector from the Goldelox processor to the display became faulty.

    I have since purchased four new displays for my prototypes which are the 128 G2. I would really prefer to use my Arduino program and just change the relevant commands for the new serial graphics language supported on the G2 but I seem to be going around in circles. I have tried replacing the old "newsoftwareserial" library with the new 4D systems library but I can't find what the correct syntax is for the library command set. The manual (Goldelox serial command manual) just lists the Library function at the bottom of each serial command description with no explanation of the function syntax.

    Am I missing something (apart from brains)? I have searched everywhere for a serial command reference manual for the library functions but it doesn't exist. How can I use the 4D Systems library without knowing how to call the required functions?

    I guess I could rewrite the program using the low level byte commands but would much prefer to use the high level functions in the Library.

    Any Enlightenment with kind words or a baseball hat appreciated.

  • #2
    Um, are you looking for something more complicated than it is?

    Perhaps have a look at the demo program in C:\Users\Public\Documents\4D Labs\Goldelox Serial\Arduino\Goldelox_Serial_4DLib\Examples\GoldeloxBigDemo.ino
    Mark

    Comment


    • #3
      Um no, I am looking for something simpler than what is provided as the serial command manual.

      As an example, the library command to write a single character to the display is shown in the above document as "putCH". However there is no reference to the variables required with the library function or the syntax required.

      By trolling through the "BigDemo" I find that the correct syntax is: Display.putCH('x')

      I am assuming any variance to that exact syntax will produce an error.

      If my assumption is correct then why can't I find a complete listing of all valid library functions with their corresponding syntax?

      While the low level serial commands are well documented the equivalent library functions do not seem to have the same level of support.

      Am I still missing the point?

      Comment


      • #4
        I really think you are looking for something more complicated than it is.

        eg, the sample you have given uses 'x' which just says to the compiler that the value is 0x78, or decimal 120, so

        Display.putCH('x')
        Display.putCH(0x78)
        Display.putCH(120)

        would all produce the same thing. Actually, I think even
        Display.putCH(0xff78)
        would produce the same thing.
        Mark

        Comment


        • #5
          Hi again ESPsupport

          The example I gave using the value 'x' is just an arbitrary value.

          The issue I have is where in the documentation does it explain that functions sent from the Arduino to the display require the "Display." prefix, the function command, followed by open bracket single quote value/,values single quote close bracket?

          In other words my question is - where do 4D systems document their library functions syntax?

          And now, if the library functions (commands) allow ASCII, hexadecimal or decimal variables, where is that information documented?

          Comment


          • #6
            Hi MartyBoy,

            I may not be able to answer your question directly but I will try to give you some directions.

            You can actually use the Goldelox Serial Command Set Reference Manual

            http://www.4dsystems.com.au/product/..._IDE/downloads

            in conjunction with the Goldelox Serial Arduino library files as a learning guide. The library files that we are interested in are

            Goldelox_Serial_4DLib.h

            and

            Goldelox_Serial_4DLib.cpp

            You can find these files in the folder where you install your Arduino libraries. In my PC the files are here:

            C:\Users\4d-doff\Documents\Arduino\libraries\Goldelox_Serial_4DLib

            Let us try to analyze the library function Put Character or putCH. On page 13 of the SPE manual, it says that the stream of bytes sent to the display for the putCH function is composed of four bytes:

            cmd(MSB), cmd(LSB), character(MSB), character(LSB)

            The first two bytes are the command bytes, which are 0xFF (most significant byte) and 0xFE (least significant byte). There are two more bytes. In the given example these are 0x00 (MSB) and 0x39 (LSB). It further says,

            This will send the character ‘9’ (0x00, 0x39) to the display.
            We know that the ASCII hex code for the character '9' is 0x39. Hence, the MSB is just a "dummy" byte, since the display will only actually interpret the LSB.

            No if you open the file Goldelox_Serial_4DLib.h and search for the library function "putCH", you will see the function prototype:

            void putCH(word wordChar) ;

            This function returns nothing and expects a word as an argument. If you look further for the definition of putCH() in Goldelox_Serial_4DLib.cpp, you will see the following:

            void Goldelox_Serial_4DLib : : putCH(word WordChar)
            {
            _virtualPort->print((char)(F_putCH >> 8)) ;
            _virtualPort->print((char)(F_putCH)) ;
            _virtualPort->print((char)(WordChar >> 8)) ;
            _virtualPort->print((char)(WordChar)) ;
            GetAck() ;
            }

            This routine essentially sends to the display four bytes, the sequence of which is described earlier in the manual. As you may have guessed, F_putCH is a constant with the value "0xFFFE".

            So to make the display show the character '9', we write,

            Display.putCH('9');

            or any of the following:

            Display.putCH(0x39);
            Display.putCH(0x0039);
            Display.putCH(0xFF39); // MSB is irrelevant
            Display.putCH(57);



            We can now see the logic in Mark's post:
            Display.putCH('x');
            Display.putCH(0x78);
            Display.putCH(120);
            Display.putCH(0xff78);


            And now, if the library functions (commands) allow ASCII, hexadecimal or decimal variables, where is that information documented?
            The best solution for this is for you to convert your values to a string first then use the Put String or putStr library function. I trust that by following the procedure above, you can see how the putStr library is used. If you want actual examples of how the functions are used, you can consult the BigDemo sketch.

            Now there is an app note that explains the basics of interfacing a Goldelox display module (SPE mode) to an Arduino host:

            http://www.4dsystems.com.au/appnote/4D-AN-00092/

            Pages 8 and 9 can perhaps answer your question ..."sent from the Arduino to the display require the "Display." prefix....".

            Hopefully this helps and regards.
            Doff

            Comment

            Working...
            X