Announcement

Collapse
No announcement yet.

String lf, n, and cr syntax?

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

  • String lf, n, and cr syntax?

    Brain not working today...late night last night...

    What is the correct syntax for writing to a string with lf, cr, and n from MPIDE/Arduino?

    example:

    char* letter[2] = {"A", "B"};

    genieWriteStr(0, letter[1]);
    genieWriteStr(0, letter[2]);


    in the string box I get "A", then just "B", not "AB".

  • #2
    Hi Martin

    You could do something like

    char thinggy[] = {'A', '\n', 'B', '\0'};genieWriteStr(0, thinggy);

    This will print:
    A
    B

    Each genieWriteStr you send to a single object on the screen, will overwrite what was previously written there, which is why when you do what you had above, an A then a B rather than a AB.

    Let me know if this is what you mean. If not, please state exactly what you are trying to achieve.

    \r = Carriage Return
    \n = Newline
    \0 = 0x00 or Null

    Regards
    James

    Comment


    • #3


      #include
      #include

      /////*****Keypad*****/////
      const byte ROWS = 3; //defines number of rows on keypad
      const byte COLS = 3; //defines number of columns on keypad
      char keys[ROWS][COLS] = { // defines names of keys at specific row/column alignments
      {'1','2','3'},
      {'4','5','6'},
      {'7','8','9'},
      };

      byte rowPins[ROWS] = {34,35,36}; //pins rows from keypad are connected to
      byte colPins[COLS] = {37,38,41}; // pins columns from keypad are connected to

      Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); //command to create the keypad from the above setup directions
      char key;
      /////*****Keypad****/////

      //display keyboard
      int keyBoardrow[44] = {0x37, 0x48, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x8d, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xa2, 0xad, 0xae, 0xaf}; //hex index number of GENIE_OBJ_USERIMAGES
      int keyBoardcharrow[44] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x20, 0x31, 0x32, 0x33, 0x48, 0x49, 0x4A, 0x4b, 0x4c, 0x4d, 0x4e, 0x20, 0x34, 0x35, 0x36, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x08, 0x37, 0x38, 0x39, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x2d, 0x2f, 0x08, 0x06, 0x30, 0x18}; //hex number of ASCII characters USERIMAGES represent

      int keyBoardkey = 0; //used to track current visual image on display keyboard
      int keyBoardchar = 0; //used to track current character of keyboard
      char currentKey = keyBoardcharrow[keyBoardchar];
      char userString[]= {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //buffer for user keyboard input
      int stringMarker;
      int currentScreen = 1;
      //end display keyboard

      void setup()
      {
      genieBegin (GENIE_SERIAL, 9600); //Serial at 9600 baud for display

      keypad.addEventListener(keypadEvent); // Add an event listener.
      keypad.setHoldTime(750); // hold time for buttons is 750mS
      keypad.setDebounceTime(60); // debounce time for buttons is 150mS
      delay(3000);
      genieWriteObject(GENIE_OBJ_FORM, 0x0c, 1);
      genieWriteObject(GENIE_OBJ_USERIMAGES, keyBoardrow[keyBoardkey], 1);
      genieWriteStr(0, "Enter Information Here");
      delay(3000);
      genieWriteStr(0, "");

      }

      void loop() //commands in this function repeat in a loop. Used to monitor events such as keypad and USB events.
      {
      genieDoEvents(); //Command to monitor genie events

      key = keypad.getKey(); //Command to monitor keypad events

      }

      void keypadEvent(KeypadEvent key)
      {
      if (currentScreen == 1){
      switch (keypad.getState()){
      case PRESSED:
      switch(key){
      case '1': ; break;
      case '2': if(keyBoardkey >=11 && keyBoardkey =0 && keyBoardkey =1 && keyBoardkey =12 && keyBoardkey =23 && keyBoardkey =34 && keyBoardkey =1){stringMarker--; userString[stringMarker] = 0x00; updateScreen();}
      else if(keyBoardkey == 41 || keyBoardkey == 43){}; break;
      case '6': if(keyBoardkey >=0 && keyBoardkey =11 && keyBoardkey =22 && keyBoardkey =33 && keyBoardkey =0 && keyBoardkey =33 && keyBoardkey

      Comment

      Working...
      X