Announcement

Collapse
No announcement yet.

Converting from SGC to GFX

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

  • #31


    ok, so to modify your program, I'm using Serial1 on the uVGA, at 9600 baud (seems fast enough for
    Steve Spence KK4HFJ
    http://arduinotronics.blogspot.com

    Comment


    • #32


      repeatcomvar := serin();if(comvar == '$') result :=0;if(isdigit(comvar)) result:=(result*10)+(comvar-'0');endifif(comvar ==13) txt_MoveCursor(2,2); print(result," ");endifforever
      _______________
      Best Regards,
      Howard

      Comment


      • #33


        Sorry, posted "simple" version while you posted the next question.
        Change your format the send the $ first, then send a message ID (any value if code from post 21, or 'A', 'B', or 'c' for post 23, then the ascii, then a CR (value of 13).
        The ascii can be variable length, don't need to pad it out.....
        _______________
        Best Regards,
        Howard

        Comment


        • #34


          dang, bell rang. be back in 13.5 hours. Thanks for your help!
          Steve Spence KK4HFJ
          http://arduinotronics.blogspot.com

          Comment


          • #35
            Here is the really simple version. Note that I would NEVER use this in a real product, but I guess it would be fine for "Quick and Dirty". In this case the command structure is $12345<cr>
            #platform "uVGA-II_GFX2"
            func main() var comvar; var result; print("Com test"); com_SetBaud(COM0,960); to(COM0); print("serial input test:\n"); repeat comvar := serin(); if(comvar == '$') gfx_Cls(); print("$"); result :=0; endif if(lookup8(comvar,"0123456789")) result:=(result*10)+(comvar-'0'); print("\n Char:",comvar); endif if(comvar ==13) txt_MoveCursor(10,1); print(result," "); endif foreverendfunc
            _______________
            Best Regards,
            Howard

            Comment


            • #36
              ok, this is starting to look good. I now have a variable that contains my integer (result), and I can print it to the screen, or do other calculations on it. What is the syntax for initializing a variable as a float, and for typecasting an int to a float?

              Code:
               #platform "uVGA-II_GFX2"// Micrometer GFX#inherit "4DGL_16bitColours.fnc"func main()var comvar;var result;gfx_Cls();txt_Set(FONT_SIZE, FONT2);gfx_Rectangle(75,75,150,120,WHITE);//print("Com test");//com_SetBaud(COM0,960);//to(COM0); print("serial input test:\n");repeatcomvar := serin1();if(comvar == '$')//gfx_Cls();//print("$");result :=0;endifif(lookup8(comvar,"0123456789"))result:=(result*10)+(comvar-'0');//print("\n Char:",comvar);endifif(comvar ==13)txt_MoveCursor(12,10);print(result,"  ");endifforeverendfunc
              On the Arduino side I had to change Serial3.print(num, dec); to Serial3.println(num, DEC); to put the CR back in.
              Steve Spence KK4HFJ
              http://arduinotronics.blogspot.com

              Comment


              • #37


                What forum would be best for discussing 4DGL programming issues, like formulas, type conversion, etc., that really aren't platform dependent?
                Steve Spence KK4HFJ
                http://arduinotronics.blogspot.com

                Comment


                • #38


                  Why does

                  print(((1000*(23300 -(30/2) - (2300 * 10))) / 40)," ");

                  give me 571 instead of 7125?
                  Steve Spence KK4HFJ
                  http://arduinotronics.blogspot.com

                  Comment


                  • #39


                    ok, so there is only 16bit INT to work with, and I'm overflowing the 32,767 limit.

                    Now we are back to doing all the math on the arduino, and pushing the actual display values to the uVGA-II for generation. Now we have about 12 or so variables to send over, so 4DSysFan's Maserati with variable ID comes into play.
                    Steve Spence KK4HFJ
                    http://arduinotronics.blogspot.com

                    Comment


                    • #40


                      Once you get your head around 16 bit numbers and ways of manipluating them without needing floats you tend to wonder why you ever needed floats. Well most of the time.



                      When you said you needed to transfer 5 digits I assumed it was in the 'final' format, and at most, needed a decimal added somewhere (which you can do quite easily by using mod and div).



                      If you have huge equations it often helps to siplify them first, then you can often reorder them to keep them withing 16 bit integers.



                      Of course if you are calculating the speed of light, or somesuch it wont work.
                      Mark

                      Comment


                      • #41


                        print(((1000*(23300 -(30/2) - (2300 * 10))) / 40)," ");

                        is hardly the speed of light. Most microcontrollers can handle it. a long int would do the job. Floats are a very real part of the real world. The real world often has a decimal point. Maybe you'd like to pay $1 for a piece of gum? :-)

                        It looks like all my math will have to go back to the arduino. the uVGA-II is very good at graphics, so I'll let it concentrate on that. At least until you add a few more data types.
                        Steve Spence KK4HFJ
                        http://arduinotronics.blogspot.com

                        Comment


                        • #42


                          There are some Int32 operations, look in the release notes for R28 http://www.4dsystems.com.au/downloads/Semiconductors/PICASO-GFX2/PmmC/PICASO-GFX2-ReleaseNotes-R28.txt



                          The Picaso Chip is a small Powerful graphics chip, we can't add pure int32 or float to it, it is a small, economical, dedicated processor.



                          You need to think outside the box, or more correctly you just need to think about what you are really trying to achieve. You get too used to just using floats and int32s because you have huge processor speed with huge memory.



                          There are various int32 and float routines that you can find in these forums, just not sure that you really need them.



                          Maybe you'd like to pay $1 for a piece of gum? :-)
                          Sorry, you may have to spell that out to those of us who don't use gum and hence have no concept of the meaning of the expression
                          Mark

                          Comment


                          • #43


                            A piece of chewing gum is about $0.25 in the USA. That's a float, not an int. If all you have is Ints, then everything is $1, $2, $3 etc, and no change. It seems the way to go is to just move the math back to my Arduino with its "huge processor speed with huge memory", and just send the finished variables over to the uVGA.
                            Steve Spence KK4HFJ
                            http://arduinotronics.blogspot.com

                            Comment


                            • #44


                              Howard, attached is a photo of my existing display, using the uVGA-II (SGC). At the top of the screen, I display type of gear set I'm working with (J/H) and the Function (Sort). There are three types of gears Mini, Webster and J/H, and two functions (Sort or Match).



                              The next line tells me if the micrometer is displaying data in a particular family (JH280, JH335 or between those two sets (invalid) based on size.

                              The next line shows streaming values from the micrometer converted into bin numbers, for both the static and movable parts of the gear.

                              The next line shows S1, then S2, then S3, as the sample button is pushed, saving the raw mic readings for each, then averaging them and generating a new set of bin numbers for the next line.

                              if the three samples are too far apart (compared to a "wave" variable, usually .003 mm) then reject bins are generated.

                              All this to say, those numbers generated on the screen need to be passed to the uVGA-II, for generation and display. each would have to have its own ID number. I'm attaching my original SGC version code as a txt file for reference, and a higher res version of the photo.


                              Attached files micrometer.txt (32.3 KB)
                              Steve Spence KK4HFJ
                              http://arduinotronics.blogspot.com

                              Comment


                              • #45


                                Howard, I have the ComStateMachine.4dg from

                                http://4d.websitetoolbox.com/post/show_single_post?pid=1273346339&postcount=23

                                loaded. I changed serin to serin1, and com0 to com1. I assume I need to change my arduino sketch from:

                                Serial3.print("$");
                                Serial3.println(num, DEC);

                                to:

                                Serial3.print("$");
                                Serial3.print(id, DEC);
                                Serial3.println(num, DEC);

                                Where ID signifies the name of the variable on the uVGA-II side?
                                Steve Spence KK4HFJ
                                http://arduinotronics.blogspot.com

                                Comment

                                Working...
                                X