Display Driver memory addresses...I think... [solved]

Hi all

I've managed to wire up three seven segment, three digit displays to a HT16K33 running from my Arduino Mega.

My wiring is obviously right as the looped display (see code below) results in a pleasing display as can be seen here;

Displays Running

BUT...I cannot for the life of me figure out how to assign characters from the library in the sketch; when |I try I just get gibberish...even thogh the fact that the pins are set so that segments light up in a sensible "0-9 then the decimal" order would indicate my assignments are right.

I suspect it's somethign to do with the memory addresses I need to reference...can anyone aid me with a few lines that will direct numbers to individual digits on the displays...or better yet, how I can send a number from 0 to 255 to each of the red, green and blue displays?

Many thanks!

//Sketch to control 3x seven segment three digit displays
//each to display values 0-255 from three separate potentiometers.


#include <Wire.h>

const uint8_t addr = 0x70; // HT16K33 default address
uint16_t displayBuffer[8];

const uint8_t SevenSegmentASCII[96] = {
  0b00000000, /* (space) */
  0b10000110, /* ! */
  0b00100010, /* " */
  0b01111110, /* # */
  0b01101101, /* $ */
  0b11010010, /* % */
  0b01000110, /* & */
  0b00100000, /* ' */
  0b00101001, /* ( */
  0b00001011, /* ) */
  0b00100001, /* * */
  0b01110000, /* + */
  0b00010000, /* , */
  0b01000000, /* - */
  0b10000000, /* . */
  0b01010010, /* / */
  0b00111111, /* 0 */
  0b00000110, /* 1 */
  0b01011011, /* 2 */
  0b01001111, /* 3 */
  0b01100110, /* 4 */
  0b01101101, /* 5 */
  0b01111101, /* 6 */
  0b00000111, /* 7 */
  0b01111111, /* 8 */
  0b01101111, /* 9 */
  0b00001001, /* : */
  0b00001101, /* ; */
  0b01100001, /* < */
  0b01001000, /* = */
  0b01000011, /* > */
  0b11010011, /* ? */
  0b01011111, /* @ */
  0b01110111, /* A */
  0b01111100, /* B */
  0b00111001, /* C */
  0b01011110, /* D */
  0b01111001, /* E */
  0b01110001, /* F */
  0b00111101, /* G */
  0b01110110, /* H */
  0b00110000, /* I */
  0b00011110, /* J */
  0b01110101, /* K */
  0b00111000, /* L */
  0b00010101, /* M */
  0b00110111, /* N */
  0b00111111, /* O */
  0b01110011, /* P */
  0b01101011, /* Q */
  0b00110011, /* R */
  0b01101101, /* S */
  0b01111000, /* T */
  0b00111110, /* U */
  0b00111110, /* V */
  0b00101010, /* W */
  0b01110110, /* X */
  0b01101110, /* Y */
  0b01011011, /* Z */
  0b00111001, /* [ */
  0b01100100, /* \ */
  0b00001111, /* ] */
  0b00100011, /* ^ */
  0b00001000, /* _ */
  0b00000010, /* ` */
  0b01011111, /* a */
  0b01111100, /* b */
  0b01011000, /* c */
  0b01011110, /* d */
  0b01111011, /* e */
  0b01110001, /* f */
  0b01101111, /* g */
  0b01110100, /* h */
  0b00010000, /* i */
  0b00001100, /* j */
  0b01110101, /* k */
  0b00110000, /* l */
  0b00010100, /* m */
  0b01010100, /* n */
  0b01011100, /* o */
  0b01110011, /* p */
  0b01100111, /* q */
  0b01010000, /* r */
  0b01101101, /* s */
  0b01111000, /* t */
  0b00011100, /* u */
  0b00011100, /* v */
  0b00010100, /* w */
  0b01110110, /* x */
  0b01101110, /* y */
  0b01011011, /* z */
  0b01000110, /* { */
  0b00110000, /* | */
  0b01110000, /* } */
  0b00000001, /* ~ */
  0b00000000, /* (del) */
};

void setup() {
  Wire.begin();

  Wire.beginTransmission(addr);
  Wire.write(0x20 | 1); // turn on oscillator
  Wire.endTransmission();

  setBrightness(15);
  blink(0);
}

void loop() {
  const int dTime = 50;

  //Trying to write letters to the display, just on the red display - this bit not working so commented out

  // for (int k = 0; k < 96; k++) {
  // writeCharacter(1,SevenSegmentASCII[k]);
  //  show();
  //  delay(1000);
  //  clear();
  //}



  // Loop through all segments

  // I edited this to reverse "k" and "i" - so I've learned that "i" is the segment and "k" the digit position. 
  for (int k = 0; k < 9; k++) {
    for (int i = 0; i < 8; i++) {
      displayBuffer[i] = 1 << k; //my inexperience with C fails me here..what is the shorthand "1<<k" doing?
      show();
      delay(dTime);
    }
    clear();
  }

  // Turn on all segments, one at a time
  for (int i = 0; i < 8; i++) {
    for (int k = 0; k < 9; k++) {
      displayBuffer[i] |= 1 << k;
      show();
      delay(dTime);
    }
  }

  // Test blinking
  for (int i = 3 ; i > 0; i--) {
    blink(i);
    delay(2000);
  }
  blink(0); // Turn blinking off

  // Test blanking
  for (int i = 0; i < 10; i++) {
    blank();
    delay(dTime * 2);
  }

  // Test dimming
  for (int i = 15; i >= 0; i--) {
    setBrightness(i);
    delay(dTime * 2);
  }
  clear();

  setBrightness(15);
}

void show() {
  Wire.beginTransmission(addr);
  Wire.write(0x00); // start at address 0x0

  for (int i = 0; i < 8; i++) {
    Wire.write(displayBuffer[i] & 0xFF);
    Wire.write(displayBuffer[i] >> 8);
  }
  Wire.endTransmission();
}

void clear() {
  for (int i = 0; i < 8; i++) {
    displayBuffer[i] = 0;
  }
}

void setBrightness(uint8_t b) {
  if (b > 15) return;

  Wire.beginTransmission(addr);
  Wire.write(0xE0 | b); // Dimming command
  Wire.endTransmission();
}

void blank() {
  static boolean blankOn;

  Wire.beginTransmission(addr);
  Wire.write(0x80 | blankOn); // Blanking / blinking command
  Wire.endTransmission();

  blankOn = !blankOn;
}

void blink(uint8_t b) {
  if (b > 3) return;

  Wire.beginTransmission(addr);
  Wire.write(0x80 | b << 1 | 1); // Blinking / blanking command
  Wire.endTransmission();
}

void writeCharacter(uint8_t dispNum, char c) {
  uint8_t bufferN = (dispNum + 3) / 2;

  switch (dispNum & 1) {
    case (1): // Odd display #, no shift
      displayBuffer[bufferN] &= 0xFF00;
      displayBuffer[bufferN] |= pgm_read_word_near(SevenSegmentASCII + c) & 0xFF;
      break;
    case (0): // Even display #, shift right by 8
      displayBuffer[bufferN] &= 0x00FF;
      displayBuffer[bufferN] |= (pgm_read_word_near(SevenSegmentASCII + c) & 0xFF) << 8;
      break;
  }
}

void writeNumber(uint32_t n, uint8_t nDisp, uint8_t sDisp) {
  if (sDisp + nDisp > 13) {
    return;
  }

  for (int i = 1; i <= nDisp; i++) {
    writeCharacter(sDisp + nDisp - i, (n % 10) + 48);
    n /= 10;
  }
}

what is the shorthand "1<<k" doing?

<< is the left shift operator. It IS documented on the Reference page.

      displayBuffer[bufferN] |= pgm_read_word_near(SevenSegmentASCII + c) & 0xFF;

You did not put the array in PROGMEM. Why are you trying to read it from there?

Thanks for the hint on left shift...bitwise math is new to me (surprise) but I see what it does...moves registers of a binary number to the left so that 0000001 becomes 00000010, 00000100, 00001000...etc. Plus I can see how that would be useful when dealing with a seven-segment LCD, so thank you very much!

As to PROGMEM...I'll admit I lifted the majority of that sketch from here;

And it was very helpful in proving I at least got my wiring right...plus it's a complete sketch.~

However in the programming section here;

The author resorts to just posting snippets (boy, I see now how annoying that is!)...plus the links to the SevenSegmentASCII library on a different page. He doesn't mention putting it into PROGMEM, and since that's something I've never done before I'm hoping someone can let me know how to edit the commands so that I don't need to use it...

I was in the process of finding a way to read the addresses of my 7 segment LCDs when the power went down...with literally 15 minutes to run on the ten hour print on my 3D printer. I am grumpy this morning.

REALLY grumpy.

He doesn't mention putting it into PROGMEM

But he does:

After making slight modifications to a few characters based on my research, I loaded the character literals from my segmented ASCII library as arrays into the Arduino’s flash memory. Then I wrote a function to set displays to characters.

Not that that's all that helpful without an explanation of HOW.

And, yeah, snippets suck. At least he should have posted the complete program.

I’ve been littering his diode with serial.print commands to see if I can make sense of how it works. So far just adding to the confusion. I got it to output the value of “displayBuffer*” at various points, thinking I’d be able to see a pattern.*
Well, I can...but it’s not helping me that much!
The first demo’s output steps up in a fairly obvious binary progression; 1, 2, 4, 8, 16, 32, 64, 128, 256, 512. That moves a single segment (segment 1, the topmost horizontal) across the characters of the display from left to right. It writes the value first, then seven zero values.
Then it seems to output the same thing, but a “step” later...ie, it outputs one zero first, then the binary value, then seven zeros. Is this the effect of that bit shift?
After that, I get a bit lost...values change, the binary pattern still seems evident, but in an “n-1” kind of way...ie 0,1,3,7,15,31...etc...
I’ll keep playing with it...trying to learn as well as just relying on someone here to deliver a “this is what you need” type solution...

Sorry for the italics, not sure where they came from...

Right..I can now interpret the library codes too...I realised that they are reversed to what I expected...where I thought the segments would be recorded left to right they are in fact recorded right to left...thus where I expected "3" to be "11110010" It's actual "01001111"...

This bitshift things seems to be very clever, but I'm not quite grasping it yet...the statement that's in the "write command of "displaybuffer*>>8"; that's effectively clearing the value isn't it? shifting it eight points to the right moves all the exisiting eight bits completely "off-register", so we are back to "00000000"?*
Still trawling through my serial outputs...I think displaybuffer is holding 8 values of 0 or 1, which corresponds to the segments...just not QUITE sure how it "finds" the right digit/display, or what the difference is between all the other segments going out or staying on when a new one is added...

"There are 10 types of people in the world. Those who understand binary and those who don't." Currently, feet firmly in the latter camp... :frowning:

Currently, feet firmly in the latter camp... :frowning:

That's because you have 10 fingers. But, you only have two hands. So, try counting with your hands, instead of your fingers.

Bit of a light bulb moment with the relationship between hex and binary though...hadn't realised how easily 16bit binary could be displayed using just four hex digits...a real "Aha! So that's why they use it" moment...

But I'm still struggling to understand what that sketch is doing...every time I think I'm getting there, I try and apply what Iive learned to show a simple run of digits 1 to 0 on the dispaly and...no..that's gibberish, so obviously I still dont get it.

I swear I used to be smarter than this.

Still trying, but I can't quite seem to crack it...

This loop;

// Turn on all displays, one digit at a time
  for (int k = 0; k < 9; k++) {  //this controls digit position
    for (int i = 0; i < 8; i++) {    //this controls segment number
      displayBuffer[i] |= 1 << k;  //this puts an (OR) command...so will keep segments on
      Serial.print ("DB");
      Serial.print ("\t");
      Serial.println(displayBuffer[i]);
      delay(dTime);
    }
    show();
  }

followed by this write procedure;

void show() {
  Wire.beginTransmission(addr);
  //Serial.print ("addr: ");
  //Serial.print ("\t");
  //Serial.print (addr);
  Wire.write(0x00); // start at address 0x0

  for (int i = 0; i < 8; i++) {
    Wire.write(displayBuffer[i] & 0xFF);  //& is the "AND" operator and it's working on display buffer and "0xFF" which is 11111111
    Serial.print ("Write i=; ");
    Serial.print (i);
    Serial.print ("\t");
    Serial.print (displayBuffer[i] & 0xff);
    Serial.print ("\t");
    Wire.write(displayBuffer[i] >> 8);   // >>8 shifts the value of displayBuffer 8 places right...is this effectively clearing the value?
    Serial.print (">>8 write; ");
    Serial.print ("\t");
    Serial.print(displayBuffer[i] >> 8);
    Serial.print ("\t");
    Serial.println (displayBuffer[i] >> 8);

  }
  Wire.endTransmission();
}

Works...it turns on all segments in each digit of the display, and lights them up one at a time left to right. SO I thought..."Aha! I have the positions and segments down pat, all I need to do is replace the data in the buffer currently filled by

displayBuffer[i] |= 1 << k;

Which if I understand correctly is an "OR" command between the current contents of the buffer and the value of "1<<k", which is the value "00000001", shifted one place left for each increment in "k", "k" relating to the number of digits in the display.

So...I thought if I replace "1<<k" with something that reads from the appropriate position in the SevenSegment ASCII array - for example;

SevenSegmentASCII(k+17)

then that position in the array should equate to the number for "k" (in the array, digits start at element 16 with zero) - so the plan is to get the display to read "123456789" reading left to right.

However the following loop;

    for (int k = 0; k < 9; k++) {  //this controls digit position
        for (int i = 0; i < 8; i++) {    //this controls segment number
          displayBuffer[i] = SevenSegmentASCII[k + 17] & 1 << i; //Can't seem to get this "bit" right haha
          Serial.print("Alpha:");
          Serial.print(k);
          Serial.print("\t");
          Serial.print(SevenSegmentASCII[k + 17]);
          Serial.print("\t");
          Serial.println (displayBuffer[i]);
          delay(dTime);
        }
        show();
      }
      clear();

Followed by the same write procedure results in all the right segments being lit up - but spread across the display, so the first segment of "1". appears on the leftmost digit...but the second segment is illuminated on the digit one to the right.

What am I doing wrong???

What am I doing wrong???

Here's a clue:

all I need to do is replace the data in the buffer currently filled by displayBuffer |= 1 << k;[/quote]
What buffer is that? What are you starting with in that buffer? What do you WANT to be starting with?

GreyArea:
The author resorts to just posting snippets (boy, I see now how annoying that is!)...

And you still keep on doing that as well :wink:

It's OK to highlight snippets, but please provide full code; if too big, attach.

I've figure out my problem...an assumption on my part that there was consistency in the example code I was using. I thought since "i" filled the segments in the characters at the first stage, "i" was also looping through the segments in the second stage (the "Wire.write" procedure.) I now realise the buffer elements hold whole characters, not segments of one character as I thought.
That said, haven't tried it yet, but with help from my best pal (real life coder and programmer) I'm confident it will work...will post back here when it does.
sterretje; yes I posted snippets...but the whole code is present in this thread. I think if I posted the whole sketch each time, there's bound to be someone on here who'd complain that I don't need to repeat myself.

The tendency here is that we like to see complete code so we don't have to copy from different parts from several posts and run the risk of making mistakes when we want to analyse / test.

Glad you got it working.

sterretje:
The tendency here is that we like to see complete code so we don't have to copy from different parts from several posts and run the risk of making mistakes when we want to analyse / test.

Glad you got it working.

Well, as it turns out it wasn't quite so simple.

I think the problem from the start was that I was expecting some sort of logic from a "logic" system...so get this...

The HT16K33 sends data in 16 bit bursts, preceded by a command nybble. The activation nybble is 0x00. 16 bits of memory that follow it are sequential...meaning you can't just "ignore" a bit...you have to make an acftive decision whether to write a 0 or a 1...

...or possibly other values, but that's a tale for later...

...because if you decide to do a "human" operation, and just say which bits are on in for example a "1" (00000110)...you can't.

(by the way, in terms of the segment numbners you have to read that binary number backkwards (or at least it feels backwards for me) so segment "a" is the rightmost bit, segment "h" (the full stop) the leftmost bit...)

The reason you can't is because the first bit the system expects you to write is the first OFF bit...if you try to tell it bit two is ON first...well you can't, it will just think you're talking about bit one.

And then it goes on to write bit two. Ha. You'd think so wouldn't you?

No. For some totally insane reason, the sequence is that even bits get assigned to the first byte, odd bits to the second...so I'm expecting to tell it the status of character one, bit two...but it's expecting me to tell it the status of character 9, bit one. So the "filling" order is like this

                  Byte one                Byte two
First bit;      x
Second bit;  x                           x
Third bit;     xx                          x 
Fourth bit;   xx                          xx
Fifth bit;      xxx

etc.

Note; I've made no attempt to right or left justify the bits...by judicious use of the << or >> comands I now know I can fill the bytes from either end...though I'[m sure someone will tell me there's a convention as to how you should do it. (not that there should be...these bytes are not numbers. It took me a long time to get that into my head. Sure, you can represent them as numbers...but they are actually patterns...effectively a set of eight two-position switches.)

I'm sorry, but the way it fills just seems extremely awkward. Maybe it's to do with the order of displays with more segments...but for me, it's very (as in unecessarily) complex. It means for an automated system of filling the register, you HAVE to have the "Write" commands in pairs, and there has to be some logic involved when you start writing data to the 9th (or higher) character...because the HT16K33 demands that before you do, you have to RE-Write data to it's partner bit - effectively running the risk of overwriting the character 8 spaces before it.

So...yeah. My programmer friend used to code for professional organisations and hundreds of pounds per hour...he's good. Damn good. And he's been scratching his head about how the displays were behaving just as much as me...so I feel a little less dim than I did before.

It's not over yet.

The sketch attached below (which does have a lot of irrelevant guff in it that I haven't time to edit out) counts from 0 to 9 in each character position...and when it gets to position 9 rewrites a "zero" in position zero.

You have no idea how pleased that made me. By all means look at the code. I think I've come at this in a very "round the houses" way and it's extremely possible that logical functions like AND, OR and SHIFTs are only necessary in the write statements to correct for the way I've chosen to start the loop. If anyone can advise on ways to simplify, I'd be happy to hear them.

Next step is to address the display in it's entirety, so that I can write nine characters of individual data. I can do that in a fashion now...if I take out all the delays, the display will read 012345678...due to persistence orf vision...but with massive flickering.

The thing that attracted me to the demo code from partsnotincluded in the first place was the fact that it doesn't flicker at all. I'm hoping to replicate that, but with the data from my three potentiometers rather than simple sequential assignment of bits.

Watch this space (please!)

LCDsinglewrite.ino (3.31 KB)

Fully functional version below. Will post some video when I can. Extremely pleased with the outcome...zero flicker as desired, and beautifully smooth updates.

//LightBox
//Sketch to control a lightbox consisting of 144 WS2812B LEDs
//arranged in a 12x12 grid
//external controls will allow full control of RGB output
//for the whole set of LEDs and for a selected individual LED.
//by Nigel Coxon 13/4/2018

#include <Wire.h>
#include <Adafruit_NeoPixel.h>
#define N_LEDS           144   //LEDS in grid
#define PIN               8    //output pin for LED data
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

int RedPin = A0;    // set the input pin for red potentiometer control
int GrnPin = A1;    // set the input pin for green potentiometer control
int BluPin = A2;    // set the input pin for blue potentiometer control
int RvalA = 0;     // variable to store the analog values coming from the Red potentiometer
int GvalA = 0;     // variable to store the analog values coming from the Green potentiometer
int BvalA = 0;     // variable to store the analog values coming from the Blue potentiometer
byte Rval = 0;      // Red value for sending to LEDs
byte Gval = 0;      // Green
byte Bval = 0;      // Blue
String RString = String(000);
String GString = String(000);
String BString = String(000);

const uint8_t addr = 0x70;           // HT16K33 default address
uint16_t displayBuffer[9];           // Steve - if this is characters, I need to array to 9 as the loop runs 0 to 8.
uint16_t segmentcode[9];             // this holds the data in segment order for each character (ie segment a state for char 0-0, followed by segment b etc
String displayvals = String(000000000);    // Data for LCD display
long lastread = millis();

const uint8_t NigelNumbers[10] = {

  //binary         hex   dec   displays
  //segment
  //.gfedcba
  0b00111111, // 3F     63   0
  0b00000110, // 06      6   1
  0b01011011, // 58     91   2
  0b01001111, // 4F     79   3
  0b01100110, // 66    102   4
  0b01101101, // 69    109   5
  0b01111101, // 7D    125   6
  0b00000111, // 07      7   7
  0b01111111, // 7F    127   8
  0b01101111, // 6F    111   9

};

byte pixelarray[12][12] = {
  {   0,   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,},
  {  22,  21,  20,  19,  18,  17,  16,  15,  14,  13,  12,  11,},
  {  23,  24,  25,  26,  27,  28,  29,  30,  31,  32,  33,  34,},
  {  46,  45,  44,  43,  42,  41,  40,  39,  38,  37,  36,  35,},
  {  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,},
  {  70,  69,  68,  67,  66,  65,  64,  63,  62,  61,  60,  59,},
  {  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,},
  {  94,  93,  92,  91,  90,  89,  88,  87,  86,  85,  84,  83,},
  {  95,  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106,},
  { 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107,},
  { 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,},
  { 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131,}
};

// The pixelarray is used in the form "pixelarray[x][y]" to return the sequential pixel number in the strip.
// The double zero at the start is intentional as I have one damaged pixel due to a soldering mistake.

int lightpitch = 1; //sometimes I use a grid of 30-pitch LEDS. Changing lightpitch to 2 simulates this (lights every other LED)

void setup() {
  Serial.begin(9600);
  Wire.begin();
  Wire.beginTransmission(addr);
  Wire.write(0x20 | 1); // turn on oscillator
  Wire.endTransmission();

  setBrightness(15);
  blink(0);

  strip.setBrightness(255);
  strip.begin();

  //blank all registers
  Wire.beginTransmission(0x70);
  Wire.write(0x00);
  for (int i = 0; i < 8; i++) {
    Wire.write(0x00);
    Wire.write(0x00);
  }
  Wire.endTransmission();
  Serial.println("Blank step 1/3");
  delay(500);

  //fill all registers
  Wire.beginTransmission(0x70);
  Wire.write(0x00);
  for (int i = 0; i < 8; i++) {
    Wire.write(0xFF);
    Wire.write(0xFF);
  }
  Wire.endTransmission();
  Serial.println("Blank step 2/3");
  delay(500);

  //blank all registers again
  Wire.beginTransmission(0x70);
  Wire.write(0x00);
  for (int i = 0; i < 8; i++) {
    Wire.write(0x00);
    Wire.write(0x00);
  }
  Wire.endTransmission();
  Serial.println("Blank step 3/3");
  delay(500);
}

void loop() {
  Serial.println("New void loop");
  int p = 0;

  // intialise pixels with current values
  for (p = 0; p < N_LEDS; p++) {
    strip.setPixelColor(p, Rval, Gval, Bval);
  }
  strip.show();

  // read the values from the sensors
  analogReference(DEFAULT);
  RvalA = analogRead(RedPin);
  GvalA = analogRead(GrnPin);
  BvalA = analogRead(BluPin);

  //convert from 0-1023 (5v) to 0-255
  Rval = RvalA * 0.25;
  Gval = GvalA * 0.25;
  Bval = BvalA * 0.25;

  //update pixels with new value
  for (p = 0; p < N_LEDS; p++) {
    strip.setPixelColor(p, Rval, Gval, Bval);
  }
  strip.show();

  //update the LCD display with the new value

  RString = String(Rval);
  GString = String(Gval);
  BString = String(Bval);

  while (RString.length() != 3) {
    RString = "0" + RString;
  }

  while (GString.length() != 3) {
    GString = "0" + GString;
  }

  while (BString.length() != 3) {
    BString = "0" + BString;
  }

  displayvals = RString + GString + BString;


  //transfer displayvals to displaybuffer
  for (int i = 0; i < 9; i++) {
    char c = displayvals.charAt(i);
    int x = c - '0';
    displayBuffer[i] = NigelNumbers[x];
  }

  //clear segmentcode
  for (int i = 0; i < 9; i++) {
    segmentcode[i] = 1;
  }

  //populate segmentcode from displayBuffer
  for (int i = 0; i < 9; i++) {
    for (int k = 9; k >= 0; k--) {
      //delay(1000);
      segmentcode[i] = (segmentcode[i] << 1) + ((displayBuffer[k] >> i) & 1);
      //delay(1000);
    }
    segmentcode[i] = segmentcode[i] - 512;
  }

  //output segmentcode to LCDs
  Wire.beginTransmission(0x70);
  Wire.write (0x00);              // initiation nybble
  for (int segment = 0; segment < 8; segment++) { //loops segments to update
    Wire.write(segmentcode[segment]);
    Wire.write((segmentcode[segment] >> 8));
  }
  Wire.endTransmission();

  Serial.print(Bval);
  Serial.print ("\t");
  Serial.print(Rval);
  Serial.print ("\t");
  Serial.println(Gval);
  //Serial.print(Rval);
  //Serial.print ("\t");
  //Serial.print(Gval);
  //Serial.print ("\t");
  //Serial.println(Bval);
  //Serial.println(displayvals);
}

void clear() {
  for (int i = 0; i < 8; i++) {
    displayBuffer[i] = 0;
  }
}

void setBrightness(uint8_t b) {
  if (b > 15) return;

  Wire.beginTransmission(addr);
  Wire.write(0xE0 | b); // Dimming command
  Wire.endTransmission();
}

void blank() {
  static boolean blankOn;

  Wire.beginTransmission(addr);
  Wire.write(0x80 | blankOn); // Blanking / blinking command
  Wire.endTransmission();

  blankOn = !blankOn;
}

void blink(uint8_t b) {
  if (b > 3) return;

  Wire.beginTransmission(addr);
  Wire.write(0x80 | b << 1 | 1); // Blinking / blanking command
  Wire.endTransmission();
}

Video as promised...

RGB display lightbox