Announcement

Collapse
No announcement yet.

Base Sketch for Arduino Picaso Serial Displays

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

  • Base Sketch for Arduino Picaso Serial Displays

    This is what I use for a starting point when I write an Arduino sketch for my display. It's heavily commented to explain what is going on. I'm sharing this because I wish I'd have seen this somewhere when I got started. Hopefully somebody will get some use of it. And do whatever you want with it.

    Code:
    //---------------- Picaso librarys ---------------
    #include "Picaso_Serial_4DLib.h"                //
    #include "Picaso_const4D.h"                     //
    //------------------------------------------------
    
    //-------Various Arduino setups-------------------
    //#define DisplaySerial Serial                  // Uncomment if using AR shield or Pins 0, 1 and comment out Serial2 line
    #define DisplaySerial Serial2                   // Mega 2560 digital pins 16 & 17, no unplugging to upload
    // Uncomment the following 2 lines and comment out Serial2 line if using sofware serial and set pins accordingly
    //#include <SoftwareSerial.h>                   //
    //SoftwareSerial DisplaySerial(2,3) ;           // pin 2 = TX of display, pin3 = RX
    Picaso_Serial_4DLib Display(&DisplaySerial);    //
    //------------------------------------------------
    
    void setup() 
    {
      // ------------ Initialize screen --------------
      //     Call these functions in this order..   //
      //     Do not address the screen before or    //
      //     within this group.                     //
      delay(2000);                                  // wait for screen to power up
      DisplaySerial.begin(255000);                  // set baud to whatever screen is running
      Display.TimeLimit4D = 5000;                   // 5 second timeout on all commands
      Display.gfx_ScreenMode(LANDSCAPE);            // set orientation (PORTRAIT or LANDSCAPE)
      //----------^--- End initialize ---^------------
    
      //----------- Show Display Model ---------------
      char mdl[20];                                 // these lines are just to show the screen model
      Display.sys_GetModel(mdl);                    //   in the upper left corner of the display and
      Display.gfx_MoveTo(0, 0);                     //   can be commented out
      Display.putstr("Model=");                     //
      Display.putstr(mdl);                          //
      delay(1500);                                  //
      //----------------------------------------------
    
      //---Mount uSD-Uncomment if using uSD card------
      int mnt;                                      //
      Display.gfx_Cls();                            //
      Display.putstr("Mounting...");                //
      mnt = Display.file_Mount();                   //
      Display.txt_MoveCursor(1, 0);                 //
      if (mnt) Display.putstr("Mounted");           //
      else Display.putstr("Not Mounted");           //
      delay(1500);                                  // optional pause to display mount status, comment out to skip
      //----------------------------------------------
    
      //--------- Enable touch and touch region-------
      Display.touch_Set(TOUCH_ENABLE);             //
      Display.touch_DetectRegion(0, 0, 399, 239);  // set this to the dimensions and orientation of your screen
      Display.gfx_Cls();                           // clear the screen
      //----------------------------------------------
    
    }
    
    void loop() 
    {
      
    }
    Last edited by James_4DSystems; 4th February 2015, 09:25 AM. Reason: Reformatted code, was unreadable on this forum (from old forum)
Working...
X