bigboystoys13
Published

1Sheeld GLCD Scrolling Text

Sample project to show how to display text on the new GLDC shield for 1Sheeld.

BeginnerProtip2,033
1Sheeld GLCD Scrolling Text

Things used in this project

Story

Read more

Code

Arduino UNO Code

C/C++
/* 1Sheeld related */
#define CUSTOM_SETTINGS
#define INCLUDE_GLCD_SHIELD
#include <OneSheeld.h>

/* GLCD Setup */
GLCDTextBox textBoxTitle(1, 5, "Title");
GLCDTextBox textBox1(5, 20, "L1");
GLCDTextBox textBox2(5, 30, "L2");
GLCDTextBox textBox3(5, 40, "L3");
GLCDTextBox textBox4(5, 50, "L4");
GLCDTextBox textBox5(5, 60, "L5");
GLCDTextBox textBox6(5, 70, "L6");
GLCDTextBox textBox7(5, 80, "L7");
GLCDTextBox textBox8(5, 90, "L8");
GLCDTextBox textBox9(5, 100, "L9");
GLCDTextBox textBox10(5,110, "L10");

/* Setup variables */
char * line1 = ".";
char * line2 = ".";
char * line3 = ".";
char * line4 = ".";
char * line5 = ".";
char * line6 = ".";
char * line7 = ".";
char * line8 = ".";
char * line9 = ".";
char * line10 = ".";

void setup() {
  /* Start communication with 1Sheeld. */
  OneSheeld.begin();

  /* Clear the 1Sheeld GLCD, and draw the text boxes */
  GLCD.clear();
  GLCD.draw(textBoxTitle);
  GLCD.draw(textBox1);
  GLCD.draw(textBox2);
  GLCD.draw(textBox3);
  GLCD.draw(textBox4);
  GLCD.draw(textBox5);
  GLCD.draw(textBox6);
  GLCD.draw(textBox7);
  GLCD.draw(textBox8);
  GLCD.draw(textBox9);
  GLCD.draw(textBox10);

  /*
   * The first line of the GLCD on this project doesn't not scroll.
   * You can change the title (top line) when you want using the line below
   */
  textBoxTitle.setText("Set your title here");
}

void loop() {
  /*
   * The code below is simply to show the scrolling in progress.
   */
  delay(1000);
  textBoxTitle.setText("Days of the week");
  ScrollMsg("Sunday");
  ScrollMsg("Monday");
  ScrollMsg("Tuesday");
  ScrollMsg("Wednesday");
  ScrollMsg("Thursday");
  ScrollMsg("Friday");
  ScrollMsg("Saturday");
}

void ScrollMsg(char * a)
{
  /* The lines below shift the text to the prior line's variable
   * For example, what was line on line8 is copied to line9's variable
  */
  line10 = line9;
  line9 = line8;
  line8 = line7;
  line7 = line6;
  line6 = line5;
  line5 = line4;
  line4 = line3;
  line3 = line2;
  line2 = line1;
  line1 = a;

  /*
   * This code actually updates the text for each of the lines
   */
  textBox1.setText(line1);
  textBox2.setText(line2);
  textBox3.setText(line3);
  textBox4.setText(line4);
  textBox5.setText(line5);
  textBox6.setText(line6);
  textBox7.setText(line7);
  textBox8.setText(line8);
  textBox9.setText(line9);
  textBox10.setText(line10);
}

Credits

bigboystoys13

bigboystoys13

11 projects • 46 followers

Comments