Agenst all odds, I got it done

These pictures have couple minutes between them:


When the screen is full, it just drops the last (left) line and starts a new on the right side.
The number is the value of the last line.
The whole thing works by an array. It moves an array value 1 to 0, 2 to 1, 3 to 2, etc...
Then it randoms (this will be the sensor value later) a number to the arrays last value.
Then it takes the array value 0, converts it around (lcd y0 is up) and draws a line to buffer.
Then it takes the value 1, moves one in X and does the same. etc...
Here's the code:
#include <LCD12864.h>
#include <LCDSprite.h>
int viivat[128];
int kaannos = 0;
int uusi = 1;
int paikka = 32;
int tulos = 0;
void setup() {
LCDA.Initialise(); // INIT SCREEN
delay(500); // Some delay
LCDA.Render(); // Start the Rendering process
delay(500);
Serial.begin(9600);
for (int i=0; i <= 127; i++){
viivat[i] = 1;
}
}
void numbertobinary(char num) { // Convert the number to binary for the scores
if (num == 0)
LCDA.setPins(1,0,0,0,1,1,0,0,0,0);
else if (num == 1)
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
else if (num == 2)
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
else if (num == 3)
LCDA.setPins(1,0,0,0,1,1,0,0,1,1);
else if (num == 4)
LCDA.setPins(1,0,0,0,1,1,0,1,0,0);
else if (num == 5)
LCDA.setPins(1,0,0,0,1,1,0,1,0,1);
else if (num == 6)
LCDA.setPins(1,0,0,0,1,1,0,1,1,0);
else if (num == 7)
LCDA.setPins(1,0,0,0,1,1,0,1,1,1);
else if (num == 8)
LCDA.setPins(1,0,0,0,1,1,1,0,0,0);
else if (num == 9)
LCDA.setPins(1,0,0,0,1,1,1,0,0,1);
else if (num == 10){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,0,0,0,0);}
else if (num == 11){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,0,0,0,1); }
else if (num == 12){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,0,0,1,0); }
else if (num == 13){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,0,0,1,1); }
else if (num == 14){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,0,1,0,0); }
else if (num == 15){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,0,1,0,1); }
else if (num == 16){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,0,1,1,0); }
else if (num == 17){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,0,1,1,1); }
else if (num == 18){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,1,0,0,0); }
else if (num == 19){
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);
LCDA.setPins(1,0,0,0,1,1,1,0,0,1); }
else if (num == 20){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,0,0,0,0); }
else if (num == 21){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,0,0,0,1); }
else if (num == 22){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,0,0,1,0); }
else if (num == 23){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,0,0,1,1); }
else if (num == 24){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,0,1,0,0); }
else if (num == 25){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,0,1,0,1); }
else if (num == 26){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,0,1,1,0); }
else if (num == 27){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,0,1,1,1); }
else if (num == 28){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,1,0,0,0); }
else if (num == 29){
LCDA.setPins(1,0,0,0,1,1,0,0,1,0);
LCDA.setPins(1,0,0,0,1,1,1,0,0,1); }
else if (num == 30){
LCDA.setPins(1,0,0,0,1,1,0,0,1,1);
LCDA.setPins(1,0,0,0,1,1,0,0,0,0); }
else if (num == 31){
LCDA.setPins(1,0,0,0,1,1,0,0,1,1);
LCDA.setPins(1,0,0,0,1,1,0,0,0,1);}
}
void loop(){
for (int i = 0; i <= 126; i++){
viivat[i] = viivat[i + 1];
delay(10);
}
viivat[127] = random(1,31);
for (int i = 0; i <= 127; i++){
kaannos = map(viivat[i], 1, 31, 31, 1);
LCDA.DrawBrLine(paikka,kaannos,paikka,32);
delay (10);
paikka++;
}
paikka = 32;
tulos = viivat[127];
delay(10);
LCDA.RenderScreenBuffer(2);
delay(10);
LCDA.DumpScreenBuffer();
delay(10);
LCDA.Draw(false,0,0);
delay(10);
numbertobinary(tulos);
LCDA.Draw(true,0,0);
delay(1000);
LCDA.DumpScreenBuffer();
}
Can I add my numbertobinary-function to the library some how?
How could I identify, how many numbers an integer holds?
How can I brake them to singles so that I can run the numbertobinary, for each number?
This way I would not need to have the binary for each number, like 22, 44, or 249.
I could brake the 249 to 2, 4, and 9. Then I would get the binaries for 2, 4, and 9.
In the real application, the number should represent a ppm value ranging from 600 to 1200...