Rainbowduino Hex Code Creator

I’m currently trying to add some characters to the rainbowduino( ie: ?, !, #, $, %, (, ) … ) so I’ve made this little tool to help make the codes. I figured other might find it useful as well if they want to add other characters. i’ll also be adding the updated rainbowduino code later on as well.

I’ve written it in processing. It’s pretty self explanatory. Just hit print to print out the hex string needed to display the object.

//GLOBAL VARIABLES
int[][] LEDGrid = new int[8][8]; //used to remember which led's have been selected

void setup() {
  size(450, 250, P3D); //x, y
  background(0);

  //set up the grid
  for ( int x = 0; x < 8; x++ ) {
    for ( int y = 0; y < 8; y++ ) {
      int xCoord = 20 + 30 * x;
      int yCoord = 20 + 30 * y;
      stroke( 255 );
      fill( 155 );
      ellipse( xCoord, yCoord, 25, 25 );
    }
  }

  //Reset and Print buttons
  fill( 255, 0, 0 );
  quad ( 300, 90, 400, 90, 400, 110, 300, 110 );


  fill( 0, 0, 255 );
  quad ( 300, 150, 400, 150, 400, 170, 300, 170 );

  fill( 255 );
  text( "RESET", 330, 98, 80, 15 );
  text( "PRINT", 330, 158, 80, 15 );
}

void draw() {
  int pcOffset = 300;
}

void mouseClicked() {

  /*
  #### STUFF FOR SELECTING LEDS ####
   */
  int xEllipse = 0;
  int yEllipse = 0;
  int xCenter = 0;
  int yCenter = 0;
  boolean xSet = false;
  boolean ySet = false;
  int buffer = 12;
  for ( int x=0; x<8; x++) {
    if ( mouseX > ( 20 + 30 * x -12 ) && mouseX < (20 + 30 * ( x + 1 ) - 12 ) ) {
      xEllipse = x;
      xCenter = 20 + 30 * x;
      xSet = true;
    }
  }
  for ( int y=0; y<8; y++) {
    if ( mouseY > ( 20 + 30 * y - 12 ) && mouseY < (20 + 30 * ( y + 1 ) - 12 ) ) {
      yEllipse = y;
      yCenter = 20 + 30 * y;
      ySet = true;
    }
  }

  //check if they've clicked in a box, if they have, mark that LED
  if ( xSet && ySet ) {
    LEDGrid[ xEllipse ][ yEllipse ] = 1;
    fill( 0, 255, 0 );
    ellipse( xCenter, yCenter, 25, 25 );
  }

  /*
  #### STUFF TO RESET AND PRINT CODES ####
   */
  if ( mouseX > 300 && mouseX < 400 && mouseY >90 && mouseY<110 ) {
    setup(); //reset the display
    LEDGrid = new int[8][8];
  }

  if ( mouseX > 300 && mouseX < 400 && mouseY >150 && mouseY<170 ) {
    makeInstruction(); //make the code
  }
}

void makeInstruction() {
  int rowTotal = 0;
  String row;
  
  print( "{" );
  
  for ( int y = 7; y >= 0; y-- ) {
    print( "0x" );
    for ( int x = 7; x >= 0; x-- ) {
      if ( LEDGrid[ x ][ y ] == 1 ) {
        rowTotal += pow ( 2, x ); //convert LED values to binary
      }
    }
    row = convertToHex( rowTotal );
    if ( y != 0 ) {
    print( row + "," );
    }
    else {
      print( row );
    }
    rowTotal = 0;
  }
  print( "} \n");
}

String convertToHex( int x ) {
  
  //has to be the mirror opposite!
  //more information about this process available at:
  // http://sites.google.com/site/joetcochran/thejoyliteproject
  
  int firstHex = 0;
  int secondHex = 0;
  String firstHexChar;
  String secondHexChar;
  
  //get the first and second hex values in binary form
  firstHex = x / 16;
  secondHex = x - firstHex * 16;
  
  firstHexChar = hex( firstHex, 1 ); //convert values to hex

  secondHexChar = hex( secondHex, 1 );
  
  //concatenate the strings
  String result = firstHexChar + secondHexChar;
  
  return result;
  
}

Hi, you might want to check out theiling.de/projects/liquid.html as well, they have some 8x8 (and smaller!) fonts there.

I’ve finished adding the symbols to the code, like I said earlier. I fried my usb->serial adapter, so it took longer than anticipated to verify the code :frowning:

Here it is tho. It contains the following ascii characters (link at the bottom):

032 040 020 00100000 SP (Space)
033 041 021 00100001 ! (exclamation mark)
034 042 022 00100010 " (double quote)
035 043 023 00100011 # (number sign)
036 044 024 00100100 $ (dollar sign)
037 045 025 00100101 % (percent)
038 046 026 00100110 & (ampersand)
039 047 027 00100111 ’ (single quote)
040 050 028 00101000 ( (left/open parenthesis)
041 051 029 00101001 ) (right/closing parenth.)
042 052 02A 00101010 * (asterisk)
043 053 02B 00101011 + (plus)
044 054 02C 00101100 , (comma)
045 055 02D 00101101 - (minus or dash)
046 056 02E 00101110 . (dot)
047 057 02F 00101111 / (forward slash)

LINK: megaupload.com/?d=LWZSOR2G