Announcement

Collapse
No announcement yet.

String objects disappearing when writing to, then switching forms. Using a uC host.

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

  • String objects disappearing when writing to, then switching forms. Using a uC host.

    Hey there.

    I'm writing a program for your 4.3" LCD using Visi Genie and a Particle Photon (newer Spark Core) development board.

    When using genie.WriteStr() (visi genie arduino library) I am able to write char* arrays to a string object on Form0. However writing to any other string object off that form does not work nor does switching to the new form and then writing to a string object directly on that active form. It either causes the string object to disappear completely or it doesn't update, just a default black background.

    For example:

    char* ssid = (char*)(WiFi.SSID());
    genie.WriteStr(3, ssid); //this part works just fine
    genie.WriteObject(GENIE_OBJ_FORM, 6, 0);
    genie.WriteStr(4, ssid); //this causes string 4 to disappear or not update


    Thanks. Do you have any idea what could be causing this? It seems like an issue that could come up a lot but I can't find any other examples of others with this problem. The code seems simple enough to not be a software issue, and the LCD is connected correctly to my micro controller which I have been able to easily read and write variables to "led digits" so far.

  • #2
    Hi kbecker

    Welcome to the forum.

    Are you using the latest version of the genieArduino library which was released just a few days ago?
    If so, you don't need to write Char Arrays anymore, it has been opened up to allow many more formats to be written to strings.

    In terms of your current problem though, strings are held in RAM and thus when you change form, the string is cleared - hence why if you write to a string on another form and then change to that form, the string is blank. However changing form, then writing to the string (as per your example), is the correct way to do it.
    Are you sure you are writing to the correct string index?
    You haven't provided your genie Code, so its a bit hard for me to verify that.
    I assume you have set the colours correctly, and you don't have a black font on a black background or anything like that.... ?

    Regards
    James

    Comment


    • #3
      @James_4DSystems

      I am working with KBecker on the same project. We have verified it's not a font issue, and we make sure the form is active before updating string values.

      Let me expand on the code for you:

      Code:
      Genie genie;
      
      void setup() {
      //some code here
      }
      
      void loop() {
      //some code
      genie.DoEvents();
      
      //write string to current form
      genie.WriteStr(3, "some text");
      delay(1000);
      
      //switch to next form and write string there
      genie.WriteObject(GENIE_OBJ_FORM, 6, 0); //switching to form 6
      genie.WriteString(4, "other text"); //<----- this makes the string object either disappear or the text simply is ignored.
      delay(1000);
      }
      
      void myGenieEventHandler(void) { //we actually haven't done anything in here. It pretty much looks exactly like this. Should we do something?
      genieFrame Event;
      genie.DequeueEvent(&Event);
      
      }
      The forms/objects itself only have OnChange handles. Is there a setting we need to check there too?

      Comment


      • #4
        Hello

        Sorry you are going to have to provide your full application, I cannot debug an issue for you with a parial snippet of Arduino only code. I need both sides, Arduino and Workshop4 application.

        If you do not wish to post on the forum, please email to me directly. james at 4dsystems dot com dot au

        Please open your application in Workshop4, go to File, Zip Project and send the ZIP either on the forum or to my email, along with the ino file of the Arduino code.

        "genie.WriteString" is not a valid command. I assume this is just sudo code you wrote.

        The problem will be simple to solve once I see both sides of the code.

        Regards
        James

        Comment


        • #5
          Hi james, thanks for helping us.

          What we have been using is a Particle Photon board not the Arduino (www.particle.io). Someone has rewritten the GenieArduino library to compile for the Particle IDE, also called Spark. https://github.com/pkourany/VisiGenieSpark_IDE This library is what we have been using so far and it has worked up until this issue.

          However the newly released library you mentioned does not compile correctly. Even though this may not be the solution to the original issue, I'd like to figure out what's going on. I have modified the new libraries to #include "application.h" which is Particle/Spark's replacement for Arduino's Arduino.h and WProgram.h. Those are the only changes I did to the new versions and I am getting these compile errors in the Particle web IDE:

          Code:
          genieArduino.cpp: In member function 'void Genie::WaitForIdle()':
          genieArduino.cpp:139:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
               for ( ; millis() < timeout;) {
                                  ^
          genieArduino.cpp: In member function 'uint8_t Genie::Getchar()':
          genieArduino.cpp:426:14: warning: unused variable 'result' [-Wunused-variable]
               uint16_t result;
                        ^
          genieArduino.cpp: In member function 'uint16_t Genie::GetcharSerial()':
          genieArduino.cpp:446:1: warning: no return statement in function returning non-void [-Wreturn-type]
           }
           ^
          genieArduino.cpp: In member function 'uint16_t Genie::WriteObject(uint16_t, uint16_t, uint16_t)':
          genieArduino.cpp:644:1: warning: no return statement in function returning non-void [-Wreturn-type]
           }
           ^
          genieArduino.cpp: In member function 'uint16_t Genie::WriteStr(uint16_t, const __FlashStringHelper*)':
          genieArduino.cpp:701:2: error: 'PGM_P' was not declared in this scope
            PGM_P p = reinterpret_cast<PGM_P>(ifsh);
            ^
          
          genieArduino.cpp:701:8: error: expected ';' before 'p'
            PGM_P p = reinterpret_cast<PGM_P>(ifsh);
                  ^
          
          genieArduino.cpp:702:8: error: expected ';' before 'p2'
            PGM_P p2 = reinterpret_cast<PGM_P>(ifsh);
                  ^
          In file included from ../wiring/inc/spark_wiring.h:37:0,
                           from ./inc/application.h:36,
                           from genieArduino.h:40,
                           from genieArduino.cpp:42:
          genieArduino.cpp:706:35: error: 'p2' was not declared in this scope
             unsigned char d = pgm_read_byte(p2++);
                                             ^
          ../wiring/inc/spark_wiring_arduino.h:32:30: note: in definition of macro 'pgm_read_byte'
           #define pgm_read_byte(x)  (*(x))
                                        ^
          genieArduino.cpp:715:35: error: 'p' was not declared in this scope
             unsigned char c = pgm_read_byte(p++);
                                             ^
          ../wiring/inc/spark_wiring_arduino.h:32:30: note: in definition of macro 'pgm_read_byte'
           #define pgm_read_byte(x)  (*(x))
                                        ^
          genieArduino.cpp:703:9: warning: unused variable 'n' [-Wunused-variable]
            size_t n = 0;
                   ^
          genieArduino.cpp: In member function 'uint16_t Genie::WriteStr(uint16_t, double)':
          genieArduino.cpp:838:1: warning: no return statement in function returning non-void [-Wreturn-type]
           }
           ^
          make[1]: *** [../build/target/user/platform-6genieArduino.o] Error 1
          make: *** [user] Error 2

          Comment


          • #6

            Secondly, as far as the original problem with the strings disappearing here is our Particle's C code. As a fully functioning program is it incomplete and most of the stuff on there is irrelevant but you can see where we have tried to test writing strings to the separate forms. Visually, nothing on the Workshop 4 program should causing a problem. I haven't changed any code whatsoever on that program, as I'm using the Visi Genie designer. Nothing seems abnormal about the objects or string objects. It's a program written for a client so I can not send it to you, sorry. If there is anything about it you need to know though let me know.


            Code:
            /******INCLUDE DEFINTIONS FOR LIBRARIES******/
            #include <VisiGenieSpark/VisiGenieSpark.h> // library associated with uLCD communication
            #include <application.h>
            #include <stdio.h>
            #include <stdint.h>
            #include <ctype.h>
            
            /*HARDWARE PIN DEFINTIONS*/
            /*based on pinout design for Particle Photon V1*/
            //
            //i
            /*ClearPath motor pin definitions*/
            #define MOTOR_HLFB_PIN A6 // feedback from ClearPath motor
            #define MOTOR_B_PIN A4
            #define MOTOR_A_PIN A5
            #define MOTOR_EN_PIN A3 // motor enable (digital pin 1 or 0)
            
            /*Encoder knob pin definitions*/
            #define ENCODER_PIN_A D0 // D2 in PCB rev2
            #define ENCODER_PIN_B D1 // D3 in PCB rev2
            
            /*Temperature sensor pin definition*/
            #define TEMP_PIN D5
            
            /*Load cell sensor pin definition*/
            #define LOADCELL_PIN D7
            
            /*LCD HMI screen pin definitions*/
            #define LCD_TX 18 // TX from LCD
            #define LCD_RX 19 // data from microcontroller
            #define LCD_RESET_PIN A7
            
            /*Stepper motor pin defintions*/ // *****TO DO*****
            #define STEP_TX D2 // D0 in PCB rev2
            #define STEP_RX D3 // D1 in PCB rev2
            
            /*Capacitive touch sensors pin defitions*/ // *****TO DO*****
            #define CAP_SDA_PIN D4
            #define CAP_SCL_PIN A7
            
            /******HARDWARE GLOBAL VARIABLE DECLARATIONS******/
            //
            //
            /*Clearpath motor variable declarations*/
            bool motor_initializing = true;
            int motor_value = 0;
            int set_motor_rpm = 0;
            int set_motor_torque = 0;
            int motor_sense_rpm = 0;
            
            /*const int LOOP_DELAY = 1; //used for motor feedback data *****TO DO*****
            const int ENABLE_DELAY = 20;
            const int HLFB_STABILIZE = 20;
            const int HLFB_OFF_SLEEPER = 1;
            const int LOW_VOLTAGE = 199;
            const int HLFB_CHECK = 20;
            */
            
            /*Encoder knob variable declarations*/
            int encoder_range = 0;
            int encoder_min = 0;
            int encoder_max = 0;
            int encoder_range_scaled = 0;
            int encoder_value = 0;
            
            /*Temperature PT100 variable declarations*/
            int temp_sensor_value = 0;
            int temp_sensor_voltage = 0;
            double tempinC = 0.0;
            double tempinF = 0.0;
            double temperature_setpoint_C = 0.0;
            double temperature_setpoint_F = 0.0;
            double temperature_breakpoint_C = 0.0;
            double temperature_breakpoint_F = 0.0;
             
            /*Load Cell variable declarations*/
            int loadcell_sensor_value = 0;
            int loadcell_sesnor_voltage = 0;
            double loadcell_sense_weight_grams = 0.0;
            double loadcell_finish_weight_grams = 0.0;
            double loadcell_weight_setpoint_grams = 0.0;
            int loadcell_full_scale_range = 3000; //3 KG full scale
            
            /*Capacitive Touch variable declarations*/ // *****TO DO*****
            
            /******OTHER GLOBAL VARIABLES******/
            //
            //
            int LCD_backlight_value = 1;
            
            Genie genie; // setup Genie Object from library VisiGenieSpark.h for communication to 4D Systems uLCD
            
            
            /******SETUP FUNCTION******/
            //
            //
            void setup() {
                Serial1.begin(115200);  // Serial1 @ 200000 (200K) Baud
                genie.Begin(Serial1);   // use Serial1 for talking to the Genie Library, and to the 4D Systems display
                // Serial 1 (TX and RX pins)
                // Serial 2 (D1/TX and D0/RX) add #include "Serial2/Serial2.h"
                // Serial 0 (USB port as virtual COM)
                
            /*Pin Mode setup functions*/
                pinMode(MOTOR_EN_PIN, OUTPUT);
                pinMode(MOTOR_A_PIN, OUTPUT);
                pinMode(MOTOR_B_PIN, OUTPUT);
                pinMode(MOTOR_HLFB_PIN, INPUT);
                pinMode(ENCODER_PIN_A, INPUT_PULLUP); 
                pinMode(ENCODER_PIN_B, INPUT_PULLUP);
                pinMode(TEMP_PIN, INPUT);
                pinMode(LOADCELL_PIN, INPUT);
                pinMode(LCD_RESET_PIN, OUTPUT);
            
            
            /*Photon cloud variables for data exporting*/ // *****TO DO*****
                Spark.variable("temp_in_C", &tempinC, DOUBLE);
                Spark.variable("temp_in_F", &tempinF, DOUBLE);
                Spark.variable("loadcell_finish_weight", &loadcell_finish_weight_grams, DOUBLE);
            
            /*LCD Genie functions for setupping up/starting up LCD*/
                genie.AttachEventHandler(myGenieEventHandler); // attach the user function Event Handler for processing events
                digitalWrite(LCD_RESET_PIN, 0);  // Reset the Display via D4
                delay(100);
                digitalWrite(LCD_RESET_PIN, 1);  // unReset the Display via D4
                delay (3500); //let the display start up after the reset 
                
                genie.WriteContrast(LCD_backlight_value); // 1 = Display ON, 0 = Display OFF (1-15 for brightness control)
                genie.WriteStr(3, GENIE_VERSION); // test string on splash page for LCD communication verification
            
            /*OTHER startup functions*/
                digitalWrite(MOTOR_EN_PIN, LOW); // make sure startup motor disabled OFF
                
                attachInterrupt(ENCODER_PIN_A, adjust_counter, FALLING);
                attachInterrupt(ENCODER_PIN_B, adjust_counter, RISING);
                wirelessSettings();
            }
            
            /******MAIN LOOP FUNCTION******/
            //
            //
            void loop() {
                
                genie.DoEvents(); // This calls the library each loop to process the queued responses from the display
            
            /*Call functions to loop*/
                hardwareTests();
            
            
            /*UPDATE all neccessary HMI objects*/ // *****TO DO*****
                genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x06, loadcell_sense_weight_grams); // side bar info
                genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x05, motor_sense_rpm); // side bar info
                genie.WriteObject(GENIE_OBJ_METER, 0x00, motor_sense_rpm); // meter graph on manual mode
                genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x08, encoder_value); // info on hardware test mode
                genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
            }
            
            /******HMI OBJECT CALLS AND MESSAGES TO FUNCTIONS******/
            //
            //
            //Event.reportObject.cmd is used to determine the command of that event, such as an reported event
            //Event.reportObject.object is used to determine the object type, such as a Slider
            //Event.reportObject.index is used to determine the index of the object, such as Slider0
            //genie.GetEventData(&Event) us used to save the data from the Event, into a variable.
            //
            //
            
            
            void myGenieEventHandler(void) { // *****TO DO*****
              genieFrame Event;
              genie.DequeueEvent(&Event);
            
            // //If the cmd received is from a Reported Event (Events triggered from the Events tab of Visi Genie objects)
              if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
              {
            
              }
            }
            
            /******ROTARY ENCODER KNOB FUNCTION******/
            //
            //
            void adjust_counter() {
                if (digitalRead(ENCODER_PIN_B)) {
                    encoder_value-- ;
                }
                else {
                    encoder_value++ ;
                }
            }
            
            /******LCD BACKLIGHT******/
            //
            //
            void backlightToggle(int) {
                genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, LCD_backlight_value);
                genie.WriteContrast(LCD_backlight_value);
            }
            
            /******WIRELESS SETTINGS MENU******/
            //
            //
            void wirelessSettings() {
                char* ssid = (char*)(WiFi.SSID()); // wireless network name
                genie.WriteStr(3, ssid);
                delay(1000);
                
                //THIS IS THE PROBLEM. When this string writes, it deletes the string or it is just ignored
                genie.WriteObject(GENIE_OBJ_FORM, 6, 0);
                genie.WriteStr(19, "Connected");
                
            }
            
            /******HARDWARE TEST MENU******/
            //
            //
            void hardwareTests() {
            /*Temperature sensor tests*/
                temp_sensor_value = analogRead(TEMP_PIN); // 0-4095
                temp_sensor_voltage = (temp_sensor_value * 3.3)/4095; // value to voltage function
                tempinC = (temp_sensor_voltage - 0.5)*100*10; // voltage to Celcius temperature function
                tempinF = ((tempinC * 9/5) + 32)*10; // Fahrrenheit function
                
                genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x01, temp_sensor_value);
                genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x02, tempinF);
                
            /*Power LEDS on HMI*/
                genie.WriteObject(GENIE_OBJ_LED, 0x00, 1);
                genie.WriteObject(GENIE_OBJ_LED, 0x01, 1);
                genie.WriteObject(GENIE_OBJ_LED, 0x04, 1);
                
            /*Loadcell sensor tests*/
                loadcell_sensor_value = analogRead(LOADCELL_PIN);
                loadcell_sense_weight_grams = (loadcell_sensor_value * loadcell_full_scale_range) / 4095;
                
                genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x04, loadcell_sensor_value);
                genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x03, loadcell_sense_weight_grams);
                
            /*ClearPath motor tests*/
                if (MOTOR_EN_PIN != 1) {
                    genie.WriteObject(GENIE_OBJ_LED, 0x05, 0);
                }
                else {
                    genie.WriteObject(GENIE_OBJ_LED, 0x05, 1);
                }
                    
                if (temp_sensor_value > 1020) // Safety check for motor temperature shutoff
                {
                    digitalWrite(MOTOR_EN_PIN, LOW);
                    digitalWrite(MOTOR_A_PIN, LOW);
                    digitalWrite(MOTOR_B_PIN, LOW);
                }
            }
            Thank you for helping us!

            Comment


            • #7
              Hi again

              Its not so much that your WS4 application doesnt have anything wrong in it, its the fact I cannot see and line things up with your code.
              If you can attach that, it would be great, else email it if possible.

              Regarding the errors you are getting with the new library, some seem to be related to one of the new functions which allow you to print strings from Flash of the Arduino.

              You could just try commenting out this function:

              uint16_t Genie::WriteStr(uint16_t index, const __FlashStringHelper *ifsh)

              Obviously that would disable this ability, but see if that helps you get any further ahead.

              Regarding all of the objects you are writing to on the display from your Spark program, they are actually present on the display, right?
              I mean, in your Setup() you are writing to String3 and writing the Genie Version. Does String3 exist in your program? etc etc
              You have to ensure that everything you are writing to from your Spark program, is actually in your WS4 application. Its table driven, so if you write to something which doesnt exist, then it will write to memory which could be used for something else, and that's when things start to display corrupt, or odd behavior happens.

              I cant verifiy if this is what is going on, as I cant see your WS4 application.

              Has this problem always been the case, or did it just start happening?
              Have you tried simplifying your code somewhat, even making a new program and just doing form changes and writing to the strings, and see if that works correctly?

              Just trying to narrow things down for you.

              Regards
              James

              Comment


              • #8
                Hi again

                We just noticed, your spark version of the library is based on the July 2014 release of our genieArduino library.
                This had a problem with the strings disappearing, and I wonder if that is what you are seeing in your library.

                If you get our latest version, remove that FlashStringHelper version of the WriteStr function, and its declaration, then hopefully that will allow you to compile and use the new version, as there were quite a lot of fixes done between the latest one and the July 2014 version you seem to have based your library on.
                Even if you go back 1 version from the latest, it will still hopefully solve the missing strings you are experiencing now.

                Please let me know how you get on

                Regards
                James

                Comment


                • #9
                  Our library on github has been updated, allowing the Flash Strings only for AVR's at the moment, until we figure out how to make it more compatible for other variants.

                  Hopefully this allows you to get it working on your Spark too.

                  Regards
                  James

                  Comment


                  • #10
                    James, thanks again.

                    I've attached a very simple two screen Visi Genie W4 program for you to take a look at. Unfortunately we are not even able to get strings written any more, using the same code and a simple test program .ino:

                    Code:
                    // This #include statement was automatically added by the Particle IDE.
                    #include "genieArduino.h"
                    
                    // This #include statement was automatically added by the Particle IDE.
                    //#include "VisiGenieSpark/VisiGenieSpark.h"
                    #include <application.h>
                    #define LCD_RESET_PIN A7
                    
                    
                    Genie genie;
                    
                    void setup() {
                        Serial1.begin(115200);  // Serial1 @ 200000 (200K) Baud
                        genie.Begin(Serial1);   // use Serial1 for talking to the Genie Library, and to the 4D Systems display
                        pinMode(LCD_RESET_PIN, OUTPUT);
                        genie.AttachEventHandler(myGenieEventHandler); // attach the user function Event Handler for processing events
                        digitalWrite(LCD_RESET_PIN, 0);  // Reset the Display via D4
                        delay(100);
                        digitalWrite(LCD_RESET_PIN, 1);  // unReset the Display via D4
                        delay (3500); //let the display start up after the reset 
                    
                    }
                    
                    void loop() {
                        genie.DoEvents(); 
                        genie.WriteStr(0, "hello!");
                        genie.WriteStr(1, "hi!");
                    }
                    
                    void myGenieEventHandler(void) { // *****TO DO*****
                      genieFrame Event;
                      genie.DequeueEvent(&Event);
                    }
                    All it is supposed to do is write these strings to the first form. Nothing seems to happen. The LCD is connected in the exact same way through Serial 1 RX/TX ports on the Particle. See the .zip file.

                    I was able to get the newest version of your library to compile through the Particle IDE. I did not need to comment out the function you mentioned to get it to compile. All I needed to do with comment out the #include statements for Arduino, add #include "application.h" and variables for low/high byte as it was giving me an error for not having those in the library:

                    .h code changes
                    Code:
                     *********************************************************************/
                    //#include <Streaming.h>
                    #include "genieArduino.h"
                    #include <math.h>
                    #include <string.h>
                    
                    #define DEC 10
                    #define HEX 16
                    #define OCT 8
                    #define BIN 2
                    
                    /*
                    #if (ARDUINO >= 100)
                    # include "Arduino.h" // for Arduino 1.0
                    #else
                    # include "WProgram.h" // for Arduino 23
                    #endif
                    */
                    .cpp code changes
                    Code:
                    *********************************************************************/
                    /*#if defined(ARDUINO) && ARDUINO >= 100
                    #include "Arduino.h"
                    #else
                    #include "WProgram.h"
                    #endif
                    */
                    #include "application.h"
                    
                    #include <inttypes.h>
                    
                    #include <stdint.h>
                    
                    #ifndef genieArduino_h
                    #define genieArduino_h
                    
                    #define lowByte(w) ((uint8_t)((w) & 0xFF))
                    #define highByte(w) ((uint8_t)((w) >> 8))
                    
                    #undef GENIE_DEBUG
                    
                    #define GENIE_VERSION    "GenieArduino 28-08-2015"
                    
                    // Genie commands & replys:
                    Do you see any abnormal here? We are basically doing the exact same thing.

                    Again, thanks.
                    Attached Files

                    Comment


                    • #11
                      Hi again.

                      Well the Baud Rate in your WS4 Application is 9600, and the Baud in your Spark is 115200.
                      They obviously need to match.

                      If that is just due to making a quick example, then can you try the following ino program - just cutting it down one step further:

                      Code:
                      // This #include statement was automatically added by the Particle IDE.
                      #include "genieArduino.h"
                      
                      // This #include statement was automatically added by the Particle IDE.
                      //#include "VisiGenieSpark/VisiGenieSpark.h"
                      #include <application.h>
                      
                      #define LCD_RESET_PIN A7
                      
                      Genie genie;
                      
                      void setup()
                      {
                        Serial1.begin(115200);  // Serial1 @ 115200 Baud
                        genie.Begin(Serial1);   // use Serial1 for talking to the Genie Library, and to the 4D Systems display
                      
                        pinMode(LCD_RESET_PIN, OUTPUT);
                        digitalWrite(LCD_RESET_PIN, 0);  // Reset the Display via D4
                        delay(100);
                        digitalWrite(LCD_RESET_PIN, 1);  // unReset the Display via D4
                        delay (3500); //let the display start up after the reset
                      }
                      
                      void loop()
                      {
                        genie.WriteStr(0, "hello!");
                        genie.WriteStr(1, "hi!");
                        delay(1000);
                      }
                      Just wondering if there is something in the DoEvents which may be slightly incompatible with the Spark still, and locking things up. Unsure.

                      Yeah the genieArduino library I put up yesterday, had a #ifdef for AVR's to load that Flash String function for the WriteStr, so you wouldnt need to comment anything out regarding that now.

                      Let me know how you get on

                      Regards
                      James

                      Comment


                      • #12
                        It sure was the baud rate. Just an oversight on the problem. I reflashed everything with the code example you have above and writing to string 0 "hello" works. However writing "hi" to string 1 seems to do nothing, just a black background. It's gotta be some problem with writing multiple strings? Does it need some delay? Let me know what you think.

                        Comment


                        • #13
                          There shouldnt be the need for a delay at all no.

                          Very odd.

                          Maybe try this. Non blocking delay version. Not pretty code - just a hack.

                          Code:
                          // This #include statement was automatically added by the Particle IDE.
                          #include "genieArduino.h"
                          
                          // This #include statement was automatically added by the Particle IDE.
                          //#include "VisiGenieSpark/VisiGenieSpark.h"
                          #include <application.h>
                          
                          #define LCD_RESET_PIN A7
                          
                          Genie genie;
                          
                          long print1, print2, print3;
                          
                          void setup()
                          {
                            Serial1.begin(115200);  // Serial1 @ 115200 Baud
                            genie.Begin(Serial1);   // use Serial1 for talking to the Genie Library, and to the 4D Systems display
                          
                            pinMode(LCD_RESET_PIN, OUTPUT);
                            digitalWrite(LCD_RESET_PIN, 0);  // Reset the Display via D4
                            delay(100);
                            digitalWrite(LCD_RESET_PIN, 1);  // unReset the Display via D4
                            delay (3500); //let the display start up after the reset
                          
                            print1 = millis();
                            print2 = millis() + 300;
                            print3 = millis() + 600;
                          }
                          
                          void loop()
                          {
                            if (millis() > print1)
                            {
                              genie.WriteStr(0, "hello!");
                              print1 = millis() + 1000;
                            }
                            
                            if (millis() > print2)
                            {
                              genie.WriteStr(1, "hi!");
                              print2 = millis() + 1000;
                            }
                          
                            if (millis() > print3)
                            {
                              genie.WriteStr(2, "greetings!");
                              print3 = millis() + 1000;
                            }
                          }
                          James

                          Comment


                          • #14
                            We have done a bit of playing around with some ESP8266 modules a little while ago, with the firmware that you can write Arduino Code directly into the ESP8266 IC. Dont know if this Spark/Proton device is similar or not, but the ESP8266 we did have to put delays between the genie commands to the display, due to how the watchdog for the Wifi was set up. They have a yeild() function, which basically takes the focus away from the main loop, and deals with the wifi comms, then returns. The theory is, if you are doing something in your code which takes a while, then you need to yeild() in your code, so it can tend to the Wifi, else it ends up disrupting the comms in some way. yeild() is basically the same as doing a delay(0), as the effect was the same, both triggered the loop to pause and for the processor to go off and tend to the Wifi.

                            Just curious if the Proton has something similar, and doing successive genie.WriteStr's is taking too long, making the loop last longer than is allowed, meaning the Proton is resetting due to WDT or something like that.

                            Dunno, just an idea.

                            The NodeMCU modules with the ESP8266 are rather neat devices, very similar in ways to this Proton.

                            Regards
                            James

                            Comment


                            • #15
                              James:

                              I made a video to show you the issue we are having. We added in the delay(0) you see in the video, but the problem persists with or without that, although I don't think it needs the delay since I haven't seen that in place in any examples on the internet.

                              To further verify that it isn't a hardware issue, we swapped out the Particle board for a brand new one and still have the same issue.

                              https://www.youtube.com/watch?v=RW61Fkv4AUg (unlisted, will be removed after this thread is resolved).

                              Thanks for your prompt replies and working with us!

                              -David

                              Comment

                              Working...
                              X