Announcement

Collapse
No announcement yet.

gen4-uLCD-50DCT with Arduino UNO

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

  • gen4-uLCD-50DCT with Arduino UNO

    I am running the HELLO_WORLD.ino code from the 4D demo and I am not able to print the hello world message on my LCD screen. I am not sure what am I doing wrong right now and the output is just the black screen on the display. Any good advice will be helpful

    This is the message that I am receiving from the Serial Monitor:
    Display Images using an Arduino Host Demo w/ Message Logging
    Serial 4D Library reports an error: NAK
    returned data = 7
    Program cannot proceed further. Please reset the display.

    And this is my current code

    //Setup communication - 1.Hardware serial OR 2.Software serial
    //1. Hardware Serial - choose a serial port
    //---------------------------------------------------------
    //Serial0 cannot be used for the display since it will be used for logging messages
    //#define DisplaySerial Serial
    //#define DisplaySerial Serial1
    //#define DisplaySerial Serial2
    //#define DisplaySerial Serial3
    //---------------------------------------------------------

    //2. Software Serial - set the desired pins
    //----------------------------------------------------------------------
    #include <SoftwareSerial.h>
    SoftwareSerial DisplaySerial(10,11) ; // pin 10 = TX of display, pin 11 = RX
    //SoftwareSerial is not yet supported by the Arduino Due
    //----------------------------------------------------------------------

    //-------PICASO DISPLAYS-------
    /*
    #include "Picaso_Serial_4DLib.h"
    #include "Picaso_const4D.h"

    //use DisplaySerial to communicate with the display.
    Picaso_Serial_4DLib Display(&DisplaySerial);
    */
    //---------END-----------------

    //-------DIABLO16 DISPLAYS-------
    ///*
    #include <Diablo_Const4D.h>
    #include <Diablo_Serial_4DLib.h>

    //use DisplaySerial to communicate with the display.
    Diablo_Serial_4DLib Display(&DisplaySerial);
    //*/
    //---------END-----------------

    //enable message logging
    #define LOG_MESSAGES // <-- to disable message logging, comment out this line
    #ifdef LOG_MESSAGES
    #define HWLOGGING Serial
    #else
    #define HWLOGGING if (1) {} else Serial
    #endif

    //Inser Variables Here
    int disk;


    void setup() {
    //For handling errors
    Display.Callback4D = mycallback ;
    //
    //5 second timeout on all commands
    Display.TimeLimit4D = 5000 ;

    #ifdef LOG_MESSAGES
    HWLOGGING.begin(115200);
    HWLOGGING.println(F("\nDisplay Images using an Arduino Host Demo w/ Message Logging"));
    #endif

    //--------------------------------Optional reset routine-----------------------------------
    //Reset the Display using D4 of the Arduino (if using the new 4D Arduino Adaptor - Rev 2)
    //If using the old 4D Arduino Adaptor (Rev 1), change D4 to D2 below.
    //If using jumper wires, reverse the logic states below.
    //Refer to the accompanying application note for important information.
    pinMode(4, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
    digitalWrite(4, 0); // Reset the Display via D4
    delay(100);
    digitalWrite(4, 1); // unReset the Display via D4
    //-----------------------------------------END---------------------------------------------

    delay (5000); //let the display start up

    //start
    //DisplaySerial.begin(9600) ;
    DisplaySerial.begin(200000) ;
    Display.gfx_ScreenMode(PORTRAIT);
    Display.gfx_Cls(); //clear the screen

    //uSD card mount routine
    Display.putstr("Mounting...\n"); //print a string
    if(!(disk = Display.file_Mount()))
    {
    while(!(disk = Display.file_Mount()))
    {
    Display.putstr("Drive not mounted...");
    delay(200);
    Display.gfx_Cls();
    delay(200);
    }
    }

    //Display.gfx_BGcolour(WHITE) ; //change background color to white



    }

    void loop()
    {
    //Display.putstr("HELLO WORLD\r");
    }

    //Error-handling routine
    //this will execute when a communication error occurs
    void mycallback(int ErrCode, unsigned char Errorbyte)
    {
    #ifdef LOG_MESSAGES
    const char *Error4DText[] = {
    "OK\0", "Timeout\0", "NAK\0", "Length\0", "Invalid\0" }
    ;
    HWLOGGING.print(F("Serial 4D Library reports an error: ")) ;
    HWLOGGING.print(Error4DText[ErrCode]) ;
    HWLOGGING.print(F("\n"));

    if (ErrCode == Err4D_NAK)
    {
    HWLOGGING.print(F("returned data = ")) ;
    HWLOGGING.print(Errorbyte) ;
    HWLOGGING.print(F("\n"));
    }
    else
    HWLOGGING.println(F("")) ;

    HWLOGGING.println(F("Program cannot proceed further. Please reset the display.")) ;
    while(1) ; // you can return here, or you can loop

    #else
    // Pin 13 has an LED connected on most Arduino boards. Just give it a name
    int led = 13;
    pinMode(led, OUTPUT);
    while(1)
    {
    digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(200); // wait for 200 ms
    digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
    delay(200); // wait for 200 ms
    }
    #endif
    }

  • #2
    Hello,


    Welcome to the forum!


    I have attached a simple Arduino sketch that is related to your concern and it's using 4D Arduino Adaptor shield V2.



    For your reference, you can check the forum thread as found here:


    Please, let me know if it works.

    Best regards,
    Kayven
    Attached Files
    Last edited by kayven@4d; 9th November 2018, 12:10 PM.

    Comment

    Working...
    X