Announcement

Collapse
No announcement yet.

Writing to String Object; Defined as Right Justified.

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

  • Writing to String Object; Defined as Right Justified.

    Click image for larger version

Name:	Screen 1.jpg
Views:	191
Size:	417.7 KB
ID:	47943 Click image for larger version

Name:	Screen 3.jpg
Views:	177
Size:	246.0 KB
ID:	47944 Writing to String Object; Defined as Right Justified, writing to the string object, it changes to left justified.
    Lee Snook

  • #2
    Here is the code;

    f_rx=f_rx-increment[inc_index]; //Else, freq_down_pin is Low, Decrease Frequency
    freq_low=(f_rx%10000);
    freq_high=(f_rx-freq_low)/10000;
    genie.WriteStr(0,freq_low, DEC);
    genie.WriteStr(1,freq_high, DEC);
    Lee Snook

    Comment


    • #3
      Dynamic strings are always 'left justified', as per the manual.

      To right justify them prepend the string with spaces (for a variable font use 2 spaces for each character that the text needs to be moved to the right)

      You could also do this using Genie Magic, by aligning the string in a magic object
      Mark

      Comment


      • #4
        Thanks,
        Can you identify the manual mentioned in your first sentence?
        Lee Snook

        Comment


        • #5
          Here is my uneducated attempt to Prepend the string with spaces;
          I downloaded the new library.

          #include <genieArduino.h>

          long A=43;
          String str_A=" ";
          String str_B=" ";

          Genie genie;

          void setup()
          {

          str_A=String(A); //cast variable A to a string
          str_B=String(" "+A); //Prepend " " to A

          genie.WriteStr(0, str_B);
          }

          Error;
          no matching function for call to 'Genie::WriteStr(int, String&)'
          Last edited by lsnook; 16 September 2015, 10:44 AM.
          Lee Snook

          Comment


          • #6
            It's in the ViSi Genie reference manual in the notes on strings in section 4.2.5.2

            There is a new version of the Genie Arduino library that should should be uploaded sometime today that will handle the above.
            Mark

            Comment


            • #7
              Thank you for the new library and your dedicated help putting up with my stupid questions, genie.WriteStr() works!!
              Lee Snook

              Comment


              • #8
                I am still having trouble with WriteStr.
                int HSDIV=11;
                String str_HSDIV='''';

                String Str_HSDIV=String(HSDIV);
                genie.WriteStr(11,Str_HSDIV, DEC);

                Error;
                Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"

                RX5_9-12-15.ino: In function 'void parse()':
                RX5_9-12-15:121: error: no matching function for call to 'Genie::WriteStr(int, String&, int)'
                RX5_9-12-15.ino:121:33: note: candidates are:
                In file included from RX5_9-12-15.ino:1:0:
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:179:17: note: uint16_t Genie::WriteStr(uint16_t, char*)
                uint16_t WriteStr (uint16_t index, char *string);
                ^
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:179:17: note: candidate expects 2 arguments, 3 provided
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:180:11: note: uint16_t Genie::WriteStr(uint16_t, long int)
                uint16_t WriteStr (uint16_t index, long n) ;
                ^
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:180:11: note: candidate expects 2 arguments, 3 provided
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:181:11: note: uint16_t Genie::WriteStr(uint16_t, long int, int)
                uint16_t WriteStr (uint16_t index, long n, int base) ;
                ^
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:181:11: note: no known conversion for argument 2 from 'String' to 'long int'
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:182:11: note: uint16_t Genie::WriteStr(uint16_t, int)
                uint16_t WriteStr (uint16_t index, int n) ;
                ^
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:182:11: note: candidate expects 2 arguments, 3 provided
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:183:11: note: uint16_t Genie::WriteStr(uint16_t, int, int)
                uint16_t WriteStr (uint16_t index, int n, int base) ;
                ^
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:183:11: note: no known conversion for argument 2 from 'String' to 'int'
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:184:11: note: uint16_t Genie::WriteStr(uint16_t, const String&)
                uint16_t WriteStr (uint16_t index, const String &s);
                ^
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:184:11: note: candidate expects 2 arguments, 3 provided
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:186:11: note: uint16_t Genie::WriteStr(uint16_t, const __FlashStringHelper*)
                uint16_t WriteStr (uint16_t index, const __FlashStringHelper *ifsh);
                ^
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:186:11: note: candidate expects 2 arguments, 3 provided
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:188:11: note: uint16_t Genie::WriteStr(uint16_t, double, int)
                uint16_t WriteStr (uint16_t index, double n, int digits);
                ^
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:188:11: note: no known conversion for argument 2 from 'String' to 'double'
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:189:11: note: uint16_t Genie::WriteStr(uint16_t, double)
                uint16_t WriteStr (uint16_t index, double n);
                ^
                C:\Users\Lee\Documents\Arduino\libraries\genieArduino/genieArduino.h:189:11: note: candidate expects 2 arguments, 3 provided
                no matching function for call to 'Genie::WriteStr(int, String&, int)'

                This report would have more information with
                "Show verbose output during compilation"
                enabled in File > Preferences.
                Last edited by lsnook; 18 September 2015, 09:07 AM.
                Lee Snook

                Comment


                • #9
                  Um, isn't that particular 'format' meant to receive an integer for the second parameter?

                  Like it is documented here https://www.arduino.cc/en/Serial/Print
                  Mark

                  Comment


                  • #10
                    Lee this seems to compile file

                    Code:
                    int HSDIV = 11;
                    String Str_HSDIV = String(HSDIV);
                    genie.WriteStr(11, Str_HSDIV);
                    Is that what your trying to achieve?
                    James

                    Comment


                    • #11
                      Thanks, that was it!!
                      So, when sending a string in the argument of genie.WriteStr, only two arguments are needed, obect index and string.
                      When sending an interger, three arguments can be given, object index,string, format(like DEC, INT, BIN....etc).
                      Should be, as you stated, genie.WriteStr(11, Str_HSDIV); Not, genie.WriteStr(11, Str_HSDIV, DEC);
                      Lee Snook

                      Comment


                      • #12
                        Yep, because trying to cast a String to be DEC doesnt make much sense does it...
                        you can only do that to numbers
                        James

                        Comment

                        Working...
                        X