Skip to content

Matrix Orbital

Personal tools
You are here: Home » Application Notes » Javelin Stamp » Custom Character » Example #2

Example #2

Document Actions
A more advanced example using while loops and creating animated custom characters in two different ways.
You can redefine custom characters on the fly and even when they are displayed. If you have a custom character displays, you can change they way the all look by resending the information to it!

Stamp: Javelin Stamp
Communication Type: Serial
Display Used: Any Matrix Orbital display that supports serial communication such as the MOS or LK/VK/PK series

Displaying Animated Custom Characters:

We have two examples of code here, they both will do the exact same thing, just in two different ways.

EXAMPLE I

This example uses two custom characters and will display one and then the other to create motion.


public class CustomChar1
{
  static Uart txUart = new Uart(Uart.dirTransmit, CPU.pin0, Uart.dontInvert, Uart.speed19200, Uart.stop1 );

  public static void main()
  {
    txUart.sendByte(0xFE);
    txUart.sendByte('X');       //clear screen

    txUart.sendByte(0xFE);    //command prefix
    txUart.sendByte('N');     //custom character command
    txUart.sendByte(0x00);    //custom character value 0-7
    txUart.sendByte(14);      //8 bytes to create the custom character
    txUart.sendByte(14);
    txUart.sendByte(4);
    txUart.sendByte(31);
    txUart.sendByte(4);
    txUart.sendByte(4);
    txUart.sendByte(10);
    txUart.sendByte(17);

    txUart.sendByte(0xFE);    //command prefix
    txUart.sendByte('N');     //custom character command
    txUart.sendByte(0x01);    //custom character value 0-7
    txUart.sendByte(14);      //8 bytes to create the custom character
    txUart.sendByte(14);
    txUart.sendByte(21);
    txUart.sendByte(14);
    txUart.sendByte(4);
    txUart.sendByte(4);
    txUart.sendByte(10);
    txUart.sendByte(10);

    while (true)
    {
      txUart.sendByte(0xFE);    //command prefix
      txUart.sendByte('H');     //send cursor home
      txUart.sendByte(0x00);    //display custom character 0x00
      CPU.delay(5000);          //pause
      txUart.sendByte(0xFE);    //command prefix
      txUart.sendByte('H');     //send cursor home
      txUart.sendByte(0x01);    //display custom character 0x01
      CPU.delay(5000);          //pause
    }
   }


EXAMPLE II

This example uses only one custom character, but redefines the data of it every single time.




public class CustomChar2
{
  static Uart txUart = new Uart(Uart.dirTransmit, CPU.pin0, Uart.dontInvert, Uart.speed19200, Uart.stop1 );

  public static void main()
  {

    txUart.sendByte(0xFE);
    txUart.sendByte('X');       //clear screen
    txUart.sendByte(0x00);     //display custom character 0

    while (true)
    {
      CustomChar2.Char1();
      CPU.delay(5000);
      CustomChar2.Char2();
      CPU.delay(5000);
    }
   }

  public static void Char1()
    {
    txUart.sendByte(0xFE);    //command prefix
    txUart.sendByte('N');     //custom characer command
    txUart.sendByte(0x00);    //custom character value 0-7
    txUart.sendByte(14);      //8 bytes to create the custom caharacter
    txUart.sendByte(14);
    txUart.sendByte(4);
    txUart.sendByte(31);
    txUart.sendByte(4);
    txUart.sendByte(4);
    txUart.sendByte(10);
    txUart.sendByte(17);
    }

  public static void Char2()
    {
    txUart.sendByte(0xFE);    //command prefix
    txUart.sendByte('N');     //custom character command
    txUart.sendByte(0x00);    //custom character value 0-7
    txUart.sendByte(14);      //8 bytes to create the custom character
    txUart.sendByte(14);
    txUart.sendByte(21);
    txUart.sendByte(14);
    txUart.sendByte(4);
    txUart.sendByte(4);
    txUart.sendByte(10);
    txUart.sendByte(10);
    }
}



For technical discussions and questions, please visit our forums
Created by Henry
Last modified 2005-08-06 08:51 PM
 

Powered by Plone

This site conforms to the following standards: