Announcement

Collapse
No announcement yet.

43PT-PI Display Time

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

  • 43PT-PI Display Time

    Hello,
    I have a RPi and want to display the time on the 4D 43PT display.
    I have designed the layout with Visi-Genie, but i dont know how i can display the current time of the RPi. This should be a project but this is the first step for starting it.

    The PRi is connected with the 4D-Serrial-PI Adapter to the display.

    Hope you can help me
    Bye

  • #2
    Hi,

    There is a "getting-started" app note for interfacing a 4D display with the Raspberry Pi.

    ViSi-Genie Connecting a 4D Display to the Raspberry Pi
    http://www.4dsystems.com.au/appnote/4D-AN-00023/

    The program running on the Raspberry Pi was written in C. Perhaps you could find a way to "pass" the current time of the RPi to a variable or variables in your C program, and then send the values of these variables to objects on the display module using the commands provided in the library.

    Regards.
    Doff

    Comment


    • #3
      thank you.
      now the display is working.
      can you tell me how i can use a button in the c file ?
      e.g start a script when the button is pressed.

      Comment


      • #4
        nobody knows how this works ?

        Comment


        • #5
          Hi Abxgurd,

          Kindly follow the procedure below.

          1. Add a winbutton object to your ViSi-Genie project. Let's say this is Winbutton0.
          2. Configure the winbutton object to report a message when touched. For this step, please refer to page 11 (left column) of the app note ViSi-Genie Connecting a 4D Display to the Raspberry Pi. The page shows how the slider object was configured to report a message when touched. Apply the same configuration to the winbutton object.
          2.a. Compile the ViSi-Genie project, download the program to the display module, let Workshop copy the supporting files to the uSD card mounted to the PC, unmount the uSD card from the PC and mount it to the display module, etc (please refer to the application note for more details on this step).
          3. In your Raspberry Pi C code, expand the event handler, like as shown below:

          Code:
          //This is the event handler. Messages received from the display
          //are processed here.
          void handleGenieEvent(struct genieReplyStruct * reply)
          {
            if(reply->cmd == GENIE_REPORT_EVENT)    //check if the cmd byte is a report event
            {
              if(reply->object == GENIE_OBJ_SLIDER) //check if the object byte is that of a slider
              {
                  if(reply->index == 0)          //check if the index byte is that of Slider0
                    //write to the LED digits object    
                    genieWriteObj(GENIE_OBJ_LED_DIGITS, 0x00, reply->data);            
              }
                
              else if(reply->object == GENIE_OBJ_WINBUTTON) //check if the message came from a winbutton object
              {
                  if(reply->index == 0)          //check if Winbutton0
                  {  
                      // do something here
                  }
              }
            }
            
            //if the received message is not a report event, print a message on the terminal window
            else
              printf("Unhandled event: command: %2d, object: %2d, index: %d, data: %d \r\n", reply->cmd, reply->object, reply->index, reply->data);
          }
          4. Compile the C code.
          5. Connect the display module to the Raspberry Pi properly. The new application should now run. When Winbutton0 is touched, the code that you inserted in the event handler should execute.

          Please refer to the application note for any missing detail in the procedure outlined above. You can find a list of all the Genie object ID constants in the library file "geniePi.h".

          In case you haven't seen them yet, there are several Raspberry Pi + ViSi-Genie examples in Github:

          ViSi-Genie-RaspPi-Demo-Weather
          https://github.com/4dsystems/ViSi-Ge...i-Demo-Weather

          ViSi-Genie-RaspPi-Demo-Calculator
          https://github.com/4dsystems/ViSi-Ge...emo-Calculator

          ViSi-Genie-RaspPi-Demo-Kitchen
          https://github.com/4dsystems/ViSi-Ge...i-Demo-Kitchen

          ViSi-Genie-RaspPi-Demo-Slider
          https://github.com/4dsystems/ViSi-Ge...Pi-Demo-Slider

          ViSi-Genie-RaspPi-Demo-SliderGauge
          https://github.com/4dsystems/ViSi-Ge...mo-SliderGauge

          ViSi-Genie-RaspPi-Demo-Monitor
          https://github.com/4dsystems/ViSi-Ge...i-Demo-Monitor

          Hope the above helps and regards.
          Doff

          Comment


          • #6
            Hi Abxgurd,

            As suggested by a colleague, you might want to try the code below:

            Code:
            //This is the event handler. Messages received from the display
            //are processed here.
            void handleGenieEvent(struct genieReplyStruct * reply)
            {
              if(reply->cmd == GENIE_REPORT_EVENT)    //check if the cmd byte is a report event
              {
                if(reply->object == GENIE_OBJ_SLIDER) //check if the object byte is that of a slider
                {
                    if(reply->index == 0)          //check if the index byte is that of Slider0
                      //write to the LED digits object    
                      genieWriteObj(GENIE_OBJ_LED_DIGITS, 0x00, reply->data);            
                }
                  
                else if(reply->object == GENIE_OBJ_WINBUTTON) //check if the message came from a winbutton object
                {
                    if(reply->index == 0)          //check if Winbutton0
                    {  
                        // do something here
                        [B]system("./script.sh");[/B]
                    }
                }
              }
              
              //if the received message is not a report event, print a message on the terminal window
              else
                printf("Unhandled event: command: %2d, object: %2d, index: %d, data: %d \r\n", reply->cmd, reply->object, reply->index, reply->data);
            }
            Regards
            Doff

            Comment


            • #7
              thank you i have done it now and its working :-)
              Thanks for the support

              Comment


              • #8
                Originally posted by Doff View Post
                Hi Abxgurd,

                As suggested by a colleague, you might want to try the code below:

                Code:
                //This is the event handler. Messages received from the display
                //are processed here.
                void handleGenieEvent(struct genieReplyStruct * reply)
                {
                if(reply->cmd == GENIE_REPORT_EVENT) //check if the cmd byte is a report event
                {
                if(reply->object == GENIE_OBJ_SLIDER) //check if the object byte is that of a slider
                {
                if(reply->index == 0) //check if the index byte is that of Slider0
                //write to the LED digits object
                genieWriteObj(GENIE_OBJ_LED_DIGITS, 0x00, reply->data);
                }
                
                else if(reply->object == GENIE_OBJ_WINBUTTON) //check if the message came from a winbutton object
                {
                if(reply->index == 0) //check if Winbutton0
                {
                // do something here
                [B]system("./script.sh");[/B]
                }
                }
                }
                
                //if the received message is not a report event, print a message on the terminal window
                else
                printf("Unhandled event: command: %2d, object: %2d, index: %d, data: %d \r\n", reply->cmd, reply->object, reply->index, reply->data);
                }
                Regards

                so now i can start a skript by pushing a button.
                but i have the problem if i press the button 2 times the script is opened two times.
                what can i do that the script is stared only once at the same time?

                Comment


                • #9
                  Hi Abxgurd,

                  You could use a flag for that. To illustrate,

                  Code:
                  [B]boolean scriptRunningFlag = false;[/B]
                  
                  //This is the event handler. Messages received from the display
                  //are processed here.
                  void handleGenieEvent(struct genieReplyStruct * reply)
                  {
                    if(reply->cmd == GENIE_REPORT_EVENT)    //check if the cmd byte is a report event
                    {
                      if(reply->object == GENIE_OBJ_SLIDER) //check if the object byte is that of a slider
                      {
                          if(reply->index == 0)          //check if the index byte is that of Slider0
                            //write to the LED digits object    
                            genieWriteObj(GENIE_OBJ_LED_DIGITS, 0x00, reply->data);            
                      }
                        
                      else if(reply->object == GENIE_OBJ_WINBUTTON) //check if the message came from a winbutton object
                      {
                          if(reply->index == 0)          //check if Winbutton0
                          {  
                              // do something here
                              if([B]!scriptRunningFlag[/B]){
                                  system("./script.sh");
                                  scriptRunningFlag = true;
                              }
                          }
                      }
                    }
                    
                    //if the received message is not a report event, print a message on the terminal window
                    else
                      printf("Unhandled event: command: %2d, object: %2d, index: %d, data: %d \r\n", reply->cmd, reply->object, reply->index, reply->data);
                  }
                  Not sure if "boolean" is the exact data type specifier in Raspberry Pi C, but I trust that you can verify that. If, at any point in your program you wish to enable the execution of the script again when the button is pressed-and-released (perhaps after a certain condition, such as the script completing its task, is met), you can toggle the flag back to its "false" state:

                  Code:
                  scriptRunningFlag = false;


                  Hope the above helps and regards.
                  Doff

                  Comment


                  • #10
                    Hello Doff,

                    thank you ill try it today but i think this will work.

                    i have to add:

                    #include <stdbool.h>

                    Comment

                    Working...
                    X