View Single Post
Old 08-19-2011, 01:46 PM   #8 (permalink)
_coldfire_
EcoModding Lurker
 
Join Date: Aug 2011
Location: Portugal
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
based in another code:


static const byte ASCII_Large[][24] =
{{0x00, 0x00, 0xf8, 0x1f, 0xfc, 0x3f, 0x0e, 0x70, 0x07, 0xe0, 0x03, 0xc0, 0x03, 0xc0, 0x07, 0xe0, 0x0e, 0x70, 0xfc, 0x3f, 0xf8, 0x1f, 0x00, 0x00}, // 0
{0x00, 0x00, 0x04, 0x80, 0x04, 0xc0, 0x06, 0xc0, 0x06, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0x80, 0x00, 0x00}, // 1
{0x00, 0x00, 0x18, 0xe0, 0x1c, 0xf0, 0x06, 0xd8, 0x03, 0xcc, 0x03, 0xc6, 0x03, 0xc3, 0x83, 0xc1, 0xc6, 0xc0, 0x7c, 0xc0, 0x38, 0xc0, 0x00, 0x00}, // 2
{0x00, 0x00, 0x08, 0x10, 0x0e, 0x70, 0x87, 0xe1, 0x83, 0xc1, 0x83, 0xc1, 0x83, 0xc1, 0x87, 0xe1, 0xce, 0x73, 0x7c, 0x3e, 0x38, 0x1c, 0x00, 0x00}, // 3
{0x00, 0x00, 0xc0, 0x07, 0xe0, 0x07, 0x70, 0x06, 0x38, 0x06, 0x1c, 0x06, 0x0e, 0x06, 0xff, 0xff, 0xff, 0xff, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00}, // 4
{0x00, 0x00, 0xff, 0x38, 0xff, 0x78, 0xc3, 0xe0, 0xc3, 0xc0, 0xc3, 0xc0, 0xc3, 0xc0, 0xc3, 0xe1, 0x83, 0x73, 0x03, 0x3f, 0x03, 0x0e, 0x00, 0x00}, // 5
{0x00, 0x00, 0xc0, 0x1f, 0xf0, 0x3f, 0x38, 0x63, 0x8c, 0xc1, 0x86, 0xc1, 0x83, 0xc1, 0x83, 0xc1, 0x03, 0x63, 0x00, 0x3e, 0x00, 0x1c, 0x00, 0x00}, // 6
{0x00, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x03, 0xe0, 0x03, 0xfc, 0x03, 0x1f, 0xc3, 0x03, 0xf3, 0x00, 0x3f, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x00, 0x00}, // 7
{0x00, 0x00, 0x18, 0x38, 0x7c, 0x7c, 0xe6, 0xe6, 0x83, 0xc3, 0x83, 0xc1, 0x03, 0xc3, 0x83, 0xc2, 0xc6, 0xe6, 0x7c, 0x7c, 0x38, 0x38, 0x00, 0x00}, // 8
{0x00, 0x00, 0x78, 0x00, 0xfc, 0xc0, 0xc6, 0xc1, 0x83, 0xe1, 0x83, 0x71, 0x83, 0x39, 0x83, 0x1d, 0xc6, 0x0e, 0xfc, 0x07, 0xf8, 0x03, 0x00, 0x00}, // 9
{0x00, 0x00, 0x0c, 0x00, 0x12, 0x00, 0x12, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // deg
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // space
};

// this function is designed to translate
// the 16x16 character string to start at the
// specified pixel origin (x,y) coordinate
void Nokia3310Display::largeStringOriginXYPixel(int x, int y, char *t)
{
byte temp_ASCII_Large[6][36] =
{{0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00}
}; // max four character string translated across three banks
int y_bank;
byte shift_in_a = 0x00;
byte shift_in_b = 0x00;
int x_index;
byte mask_1 = 0x00;
byte mask_2 = 0x00;
int temp_index = 0;
int string_index = 0;
int ascii_lg_index = 0;
// determine the origin y bank
y_bank = y / 8;

// calculate the array layout for the string

for (string_index = 0; string_index < 6; string_index++)
{

// pick out the character in the string, translate to the x dim of ASCII_large
// something like x_dim char[i] - 0x20
// move through ASCII_Large two y dim bytes at a time
int ascii_large_index = 0;
// assign to two most sig bytes of temp_ASCII_Large
if (string_index < 6)
{
if (t[string_index] == 0x20)
ascii_lg_index = 11;
else
ascii_lg_index = t[string_index]-0x30;
}
else
ascii_lg_index = 11;

for (temp_index = 0; temp_index < 36; temp_index++)
{
// shift_in_a = 0x00;
// shift_in_b = 0x00;
/************************************************** ***********
THE PROBLEM IS THAT I AM NOT INCREMENTING THE FIRST DIMENSION OF temp_ASCII_Large
AS I GO THROUGH EACH CHARACTER IN THE STRING
************************************************** ***********/
temp_ASCII_Large[string_index][temp_index] = ASCII_Large[ascii_lg_index][ascii_large_index];
// Serial.print("ascii_large_index: ");
// Serial.print(ascii_large_index, DEC);
// Serial.print("\ttemp_index: ");
// Serial.print(temp_index, DEC);
// Serial.print("\tASCII_Large: ");
// Serial.println(ASCII_Large[0][ascii_large_index], HEX);
// shift_in_a = ASCII_Large[0][ascii_large_index] & 0x01;
temp_index++;
ascii_large_index++;
temp_ASCII_Large[string_index][temp_index] = ASCII_Large[ascii_lg_index][ascii_large_index];
// Serial.print("ascii_large_index: ");
// Serial.print(ascii_large_index, DEC);
// Serial.print("\ttemp_index: ");
// Serial.print(temp_index, DEC);
// Serial.print("\tASCII_Large: ");
// Serial.println(ASCII_Large[0][ascii_large_index], HEX);
// shift_in_b = ASCII_Large[0][ascii_large_index] & 0x01;
temp_index++;
ascii_large_index++;
// Serial.print("temp_index: ");
// Serial.println(temp_index, DEC);

} // for temp_index

// now translate to the new y pixel value
temp_index = 0;
while (temp_index < 36)
{
// first for each of temp_ASCII_Large[_][temp_index to temp_index + 2]
// PROBLEM: The masking steps are wrong when y % 8 = 0; FIGURE THIS OUT
mask_1 = temp_ASCII_Large[string_index][temp_index] >> (8-(y % 8));
mask_2 = temp_ASCII_Large[string_index][temp_index + 1] >> (8-(y % 8));
// Serial.print("temp_index: ");
// Serial.println(temp_index, DEC);

// Serial.print("\t\t");
// Serial.print(temp_ASCII_Large[0][temp_index], HEX);
// Serial.print("\t");
// Serial.print(temp_ASCII_Large[0][temp_index + 1], HEX);
// Serial.print("\t");
// Serial.println(temp_ASCII_Large[0][temp_index + 2], HEX);


temp_ASCII_Large[string_index][temp_index] = temp_ASCII_Large[string_index][temp_index] << (y % 8);
// Serial.print("shifting: \t");
// Serial.print(temp_ASCII_Large[0][temp_index], HEX);
temp_ASCII_Large[string_index][temp_index + 1] = temp_ASCII_Large[string_index][temp_index + 1] << (y % 8);
// Serial.print("\t");
// Serial.print(temp_ASCII_Large[0][temp_index + 1], HEX);
temp_ASCII_Large[string_index][temp_index + 1] = temp_ASCII_Large[string_index][temp_index + 1] | mask_1;
temp_ASCII_Large[string_index][temp_index + 2] = temp_ASCII_Large[string_index][temp_index + 2] << (y % 8);
// Serial.print("\t");
// Serial.println(temp_ASCII_Large[0][temp_index + 2], HEX);
temp_ASCII_Large[string_index][temp_index + 2] = temp_ASCII_Large[string_index][temp_index + 2] | mask_2;
// Serial.print("\t\tmask_1: ");
// Serial.print(mask_1, HEX);
// Serial.print("\tmask_2: ");
// Serial.println(mask_2, HEX);

// Serial.print("masking: \t");
// Serial.print(temp_ASCII_Large[0][temp_index], HEX);
// Serial.print("\t");
// Serial.print(temp_ASCII_Large[0][temp_index + 1], HEX);
// Serial.print("\t");
// Serial.println(temp_ASCII_Large[0][temp_index + 2], HEX);
// Serial.println();
// Serial.println();
temp_index = temp_index + 3;
}
} // for string_index

// display the string using LcdWrite
gotoXY(x, y_bank);
//LcdWrite(LCD_D, 0x00);

for (int char_index = 0; char_index < 6; char_index++)
{
x_index = 0;
while(x_index < 36)
{
// Serial.print("x_index: ");
// Serial.print(x_index, DEC);
LcdWrite(LCD_D, temp_ASCII_Large[char_index][x_index]);
// Serial.print("\t");
// Serial.println(temp_ASCII_Large[0][x_index], HEX);
//LcdWrite(LCD_D, 0x00);
x_index = x_index +3;
}
// Serial.println(" ");
//LcdWrite(LCD_D, 0x00);
}

gotoXY(x, y_bank + 1);
for (int char_index = 0; char_index < 6; char_index++)
{
delay(100);

x_index = 1;
//LcdWrite(LCD_D, 0x00);
while(x_index < 36)
{
// Serial.print("x_index: ");
// Serial.print(x_index, DEC);
LcdWrite(LCD_D, temp_ASCII_Large[char_index][x_index]);
// Serial.print("\t");
// Serial.println(temp_ASCII_Large[0][x_index], HEX);
//LcdWrite(LCD_D, 0x00);
x_index = x_index +3;
}
} // for char_index
// Serial.println(" ");
//LcdWrite(LCD_D, 0x00);

gotoXY(x, y_bank + 2);
for (int char_index = 0; char_index < 6; char_index++)
{

x_index = 2;
//LcdWrite(LCD_D, 0x00);
while(x_index < 36)
{
// Serial.print("x_index: ");
// Serial.print(x_index, DEC);
LcdWrite(LCD_D, temp_ASCII_Large[char_index][x_index]);
// Serial.print("\t");
// Serial.println(temp_ASCII_Large[0][x_index], HEX);
//LcdWrite(LCD_D, 0x00);
x_index = x_index +3;
}
//LcdWrite(LCD_D, 0x00);
} // for char_index
}
  Reply With Quote