Announcement

Collapse
No announcement yet.

Reading object problem

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

  • Reading object problem

    hi,

    i have arduino codes below :

    if(Event.reportObject.object==GENIE_OBJ_LED_DIGITS){
    if (Event.reportObject.index == 0x13) {

    Serial.println(genie.ReadObject(GENIE_OBJ_LED_DIGITS,0x13));


    }

    if (Event.reportObject.index == 0x14) {
    int num=genie.ReadObject(GENIE_OBJ_LED_DIGITS,0x14);
    Serial.println(num);


    }


    }
    if(Event.reportObject.object==GENIE_OBJ_WINBUTTON){
    if (Event.reportObject.index == 0x08) {

    Serial.println(genie.ReadObject(GENIE_OBJ_LED_DIGITS,0x00));


    }

    serial prints :

    1
    1
    1
    1
    1
    1
    1


    i cant read led digits, why ?

  • #2
    Hello fatihsipka

    Your code will not work because that is not how you read from an object.
    Genie.ReadObject does not return what you are wanting.
    Please have a read over our Application Note regarding Arduino and the genieArduino library, and also look at the demo that comes with the genieArduino library.

    genie.ReadObject puts in a request for the data, but not not return it immediately. When the data is ready, some ms later, it will appear in the Event Handler function, which you then filter out and handle accordingly. This is all documented in the App Note.

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

    Page 27 of the PDF explains it, but you should read the whole App Note to get a full understanding of how it works, along with looking at the demo code provided.

    Also, your values are in hex. 0x14 is not LED Digit 14, in case you thought it was. 0x14 = 20 in decimal, so LED Digit 20.

    Regards
    James

    Comment


    • #3
      hi james,

      i know abuto hex and dec values. my led digits are leddigits0 leddigits19 leddigits20



      void myGenieEventHandler(void)
      {
      genieFrame Event;
      genie.DequeueEvent(&Event);


      if(Event.reportObject.cmd == GENIE_REPORT_EVENT)
      {

      if (Event.reportObject.object == GENIE_OBJ_ROCKERSW)// If the reported message is from a Winbutton /////working
      {


      if (Event.reportObject.index == 0x00) {

      bool fat=genie.ReadObject(GENIE_OBJ_ROCKERSW,0x00);
      if(isiq==0){

      digitalWrite(ISIK,LOW);
      isikzamani=millis();
      isiq=1;
      }
      else if(isiq==1){

      digitalWrite(ISIK,HIGH);
      isiq=0;
      }
      }
      }

      if(Event.reportObject.object==GENIE_OBJ_LED_DIGITS){
      if (Event.reportObject.index == 0x13) {

      Serial.println(genie.ReadObject(GENIE_OBJ_LED_DIGITS,0x13));


      }

      if (Event.reportObject.index == 0x14) {
      int fatih=genie.ReadObject(GENIE_OBJ_LED_DIGITS,0x14);
      Serial.println(fatih);

      }


      }
      if(Event.reportObject.object==GENIE_OBJ_WINBUTTON){
      if (Event.reportObject.index == 0x08) {

      Serial.println(genie.ReadObject(GENIE_OBJ_LED_DIGITS,0x13));


      }




      }

      }



      }

      and when i want to read leddigit0 (0x00), same problem i see
      Last edited by fatihsipka; 30 June 2015, 03:38 PM.

      Comment


      • #4
        Your code will not work because that is not how you read from an object.
        bool fat=genie.ReadObject(GENIE_OBJ_ROCKERSW,0x00);

        genie.ReadObject does NOT return what you are wanting... as I mentioned above.

        Please read the App Note... It is fully described in there.

        Also, if you have your display connected to Serial0, then you cannot do Serial.print statements to the same serial port, as they are then directed at the display, which will flood the display with plain text which it cannot understand.

        If you need help making what you have, work, please submit your full application, not just a snippet.

        Regards
        James

        Comment


        • #5
          hi james,

          my display has connected to com1 of arduino, and started serial1.begin ,and about rockersw i dont have problem, my problem is with reading led digits .

          Comment


          • #6
            Hi Fatihsipka

            You seem to only read part of my reply each time you respond
            Please read the full thing and do what I have suggested.

            The reason your rockersw is not working is because your code is wrong. genie.ReadObject does not return anything, so the way you are doing it is wrong.
            It is fully written and explained in the App Note I linked to in my first reply.

            Regards
            James

            Comment


            • #7
              dear james,

              i deleted rockersw codes, (so rocker sw was work ) . i was read appnote that you send.

              but only writing there : genie.ReadObject(GENIE_OBJ_LED_DIGITS,0x13);

              i know it. and writing the way of telling in appnote. but again sending me :

              1
              1
              1
              1
              1

              sketch is attached


              edit: i say again : my problem is with leddigits. i want to read leddigits values correctly.
              Attached Files

              Comment


              • #8
                Hello again

                in your setup() you have

                //EKRAN EVENTLERINI ÇALIŞTIRABİLİRİZ
                genie.DoEvents();

                this needs to be in your loop(), not in your setup()

                you need to do this every loop, otherwise the genieArduino library cannot process the data received by the display.

                To read LED Digits, you need to initiate the genie.ReadObject command on the LED Digit and index in question. You then need to structure your myGenieEventHandler to reveive data from a GENIE_REPORT_OBJ. You currently only handle data from GENIE_REPORTED_EVENT.
                GENIE_REPORT_OBJ is data which comes from a genie.ReadObject command
                GENIE_REPORT_EVENT is data which comes from an event which occured on the screen, such as if you move a slider which has its Event set to Reported Message, or a Win button etc.

                I have made some changes - for your reference. I cannot read Turkish so had to use Google Translate, but I hope this is of some help

                Code:
                void myGenieEventHandler(void)
                {
                  genieFrame Event;
                  genie.DequeueEvent(&Event);
                
                  //EĞER EKRANDAN BİLGİ GELDİYSE
                  if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
                  {
                    //EĞER ROCKER SWITCHLERDEN BIRINDEN GELDIYSE
                    if (Event.reportObject.object == GENIE_OBJ_ROCKERSW)// If the reported message is from a Winbutton
                    {
                      //EĞER IŞIK ROCKER SWITCHE BASILMISSA
                      if (Event.reportObject.index == 0x00)    
                      {
                        //DEĞERİ ALALIM
                
                        if (isiq == 0)
                        {
                          //IŞIĞI YAKALIM
                          digitalWrite(ISIK, LOW);
                          isikzamani = millis();
                          isiq = 1;
                        }
                        else if (isiq == 1)
                        {
                          //IŞIĞI KAPATALIM
                          digitalWrite(ISIK, HIGH);
                          isiq = 0;
                        }
                      }
                    }
                    
                    //INCORRECT YANLIŞ
                    
                    //if (Event.reportObject.object == GENIE_OBJ_LED_DIGITS)
                    //{
                     // if (Event.reportObject.index == 0x13)    
                     // {
                        // Serial.println(genie.ReadObject(GENIE_OBJ_LED_DIGITS, 0x13)); // INCORRECT YANLIŞ
                     // }
                
                     // if (Event.reportObject.index == 0x14)    
                     // {
                        //int fatih = genie.ReadObject(GENIE_OBJ_LED_DIGITS, 0x14); // INCORRECT YANLIŞ
                        //Serial.println(fatih);
                     // }
                    //}
                    //if (Event.reportObject.object == GENIE_OBJ_WINBUTTON)
                    //{
                    //  if (Event.reportObject.index == 0x08)    
                    //  {
                        //Serial.println(genie.ReadObject(GENIE_OBJ_LED_DIGITS, 0x13)); // INCORRECT YANLIŞ
                    //  }
                      ////////////gelen bilgi butondan ise
                    //}
                  //}
                  
                  //If information comes from a ReadObject
                  if (Event.reportObject.cmd == GENIE_REPORT_OBJ)  // Fark dikkate alınız - Uygulama nota bakınız
                  {
                    //LED Digits
                    if (Event.reportObject.object == GENIE_OBJ_LED_DIGITS)// If the data comes from an LED Digits
                    {
                      //LED Digits 19
                      if (Event.reportObject.index == 0x13)    
                      {
                        Serial.println(genie.GetEventData(&Event)); // Print data from the Event to the Serial Monitor
                      }
                      //LED Digit 20
                      else if (Event.reportObject.index == 0x14)
                      {
                        int fatih = genie.GetEventData(&Event); // Save data from the Event into a variable
                        Serial.println(fatih);
                      }
                      //LED Digit 8
                      else if (Event.reportObject.index == 0x08)
                      {
                        Serial.println(genie.GetEventData(&Event)); // Print data from the Event to the Serial Monitor
                      }
                    }  
                  }
                }
                You however still need to have the genie.ReadObject in there somewhere, triggered by something. So you need to either do it in your loop somewhere, or you need to do it when you press a Winbutton, or similar object.

                For example, you could do this in your myGenieEventHandler

                Code:
                if (Event.reportObject.object == GENIE_OBJ_WINBUTTON) 
                  {
                    if (Event.reportObject.index == 0x08)    
                    {
                      genie.ReadObject(GENIE_OBJ_LED_DIGITS, 0x13));
                    }
                  }
                So when you press WinButton8, it requests the data from LEDDigits19. The data will then come seperately into the myGenieEventHandler again, and be picked up by the new code I put at the bottom.

                I hope that makes sense

                Regards
                James

                Comment


                • #9
                  dear james,

                  thank you so much

                  when i press button, i read the value of leddigit. thank you for interesting,

                  if i have i problem, i will write again, because my project is the big project for a industrial machine, if i finished it, i will buy a lot of displays from 4dsystems.

                  best regards

                  Comment

                  Working...
                  X