EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   OpenGauge / MPGuino FE computer (https://ecomodder.com/forum/opengauge-mpguino-fe-computer.html)
-   -   MPGuino with LCD Philips PCD8544 (?) (https://ecomodder.com/forum/showthread.php/mpguino-lcd-philips-pcd8544-18496.html)

_coldfire_ 08-13-2011 11:32 PM

MPGuino with LCD Philips PCD8544 (?)
 
Hi,

i want to make MPGuino work with LCD Philips PCD8544 (Nokia 3310)
it's possible?...or it's possible but hard to adapt MPGuino code? :confused:

sorry, but i'm new at arduino. =/
Thanks

_coldfire_ 08-18-2011 09:43 PM

7 Attachment(s)
70% done :D

30% with error:
can't see "cursor" in SETUP. (foto: 7)
big font with error. (foto: 6)
function names. (foto: 2, 3)
...

need help for big font and for SETUP.

have big font like in (foto: 5) but only for "123456" string.
how to correct big font?

in SETUP how to make "cursor" become visible?

Thanks,
BR

dcb 08-18-2011 10:04 PM

LOL, nice hacking there :) though I don't know anything about that display, does it have built in or user defined fonts/glyphs or is it draw your own characters from bitmaps every time?

For $10 more I would consider this, with 1:1 aspect ratio and a lot more real estate and a backlight.
Graphic LCD 128x64 STN LED Backlight - SparkFun Electronics

_coldfire_ 08-19-2011 11:51 AM

thanks :)
i'm new at all this.
that why i'm using old 3310Lcd.

i think that it is user define font. (normal font 5x7)

dcb 08-19-2011 12:12 PM

Do you have a link to your code example? Not sure where you started. If it is all one file you can cut and paste into a post too.

_coldfire_ 08-19-2011 12:31 PM

despite all the tests..

now i'm using two libraries for Philips PCD8544
you want this or MPGuino code?

dcb 08-19-2011 12:35 PM

I was just curious how you did the 123456 part, I hadn't looked into graphical LCDs much prior.

_coldfire_ 08-19-2011 12:46 PM

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
}

_coldfire_ 08-19-2011 12:48 PM

void display1(int x, int y, char *t){
lcd1.largeStringOriginXYPixel(x, y, t);
}

void doDisplayM() {
display1(0, 0, "123456");
}

dcb 08-19-2011 01:12 PM

ok, it "looks" like you are sending bitmaps for each character to the LCD when you want to display them, and you have bitmaps/fonts defined from 0-9 and degree and space, so if there is still room in memory you might be able to add character fonts to that ASCII_Large array and figure out how to map character values into it when processing a display string. The temp buffer is only good for 6 characters of course.

Did you write this or where did you find it?

I usually use PROGMEM for "large" tables FYI, so that they don't soak up a bunch of RAM. i.e.
//creating the custom fonts:
LcdCommandWrite(0b01001000); // set cgram
static byte chars[] PROGMEM = {
0b11111, 0b00000, 0b11111, 0b11111, 0b00000,
0b11111, 0b00000, 0b11111, 0b11111, 0b00000,
0b00000, 0b00000, 0b00000, 0b11111, 0b00000,
0b00000, 0b00000, 0b00000, 0b11111, 0b00000,
0b00000, 0b00000, 0b00000, 0b11111, 0b00000,
0b00000, 0b00000, 0b00000, 0b11111, 0b01110,
0b00000, 0b11111, 0b11111, 0b11111, 0b01110,
0b00000, 0b11111, 0b11111, 0b11111, 0b01110 };

also using binary notation can allow you to visualize the font in the code sort-of. Here we have 5 8x5 characters. A thick line on top, a thick line on bottom, a thick line on top and bottom, a completely filled font, and a dot.
from: http://opengauge.googlecode.com/svn/...no/mpguino.cpp


All times are GMT -4. The time now is 03:51 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com