Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Unicorn GLCD demo.

Status
Not open for further replies.
haxan i sort of fibbed i think its not that simple now that i think of it... you have to make custom characters.... like your own font and just write them out... like a 5x7 font of it would look like

0000000
0000000
0001110
0001110

thats 0-10%

0011110
0011110
0000000
0001110
0001110

thats 10-20%

now you have to write 2 chars the 10-20 and 20-30 which is below:

0000000
0000000
0000000
0111110
0111110

0011110
0011110
0000000
0001110
0001110

that was 20-30%

1111110
1111110
0000000
0111110
0111110

0011110
0011110
0000000
0001110
0001110

thats 30-40%

now40-50 is tricky you have to print 4 characters: NOTE xxxxxxxx is used just to space out characters....
0000000 0000000
0000000 0000000
0000001 1111110
0000001 1111110
0000000 0000000
xxxxxxxx 1111110

xxxxxxxx 1111110
xxxxxxxx 0000000
xxxxxxxx 0111110
xxxxxxxx 0111110
xxxxxxxx 0000000

xxxxxxxx 0011110
xxxxxxxx 0011110
xxxxxxxx 0000000
xxxxxxxx 0001110
xxxxxxxx 0001110

heh you get it???

all together 40-50% looks like

0000000 0000000
0000000 0000000
0000001 1111110 --- this is 41-50%
0000001 1111110--- this is 41-50%
0000000 0000000
xxxxxxxx 1111110 --- this is 31-40%
xxxxxxxx 1111110--- this is 31-40%
xxxxxxxx 0000000
xxxxxxxx 0111110--- this is 21-30%
xxxxxxxx 0111110--- this is 21-30%
xxxxxxxx 0000000
xxxxxxxx 0011110--- this is 11-20%
xxxxxxxx 0011110--- this is 11-20%
xxxxxxxx 0000000
xxxxxxxx 0001110--- this is 1-10%
xxxxxxxx 0001110--- this is 1-10%
 
Last edited:
The coordinate 128 is off screen. The valid coordinates are 0-127.

Your example is also wrong, the parameters are top left coordinate and bottom right.

Mike.
 
Yes Pommie i know that, sorry for that.. I know the box parameters and my example is correct other than the fact that i wrote 128, it should have been 127.

AtomSoft thank you, but that would mean i would need to write a function to which will use this new font i will make correct?
 
Last edited:
not really... you can add it to the end of your current font and just use that... but it would be best to create your own new one... it can be easy as

showBar(1); //for 1-10%

the easy way to use it like that is to make a new font and then just do
Code:
d=Font[data-48][i]; //48 is 0x30 aka 0 ascii

this will allow you to call the the fonts nicely using numbers like :

1 = 1-10%
2 = 11-20%

etc...
 
oh ... anyway here is a picture i gota leave now but i hope you can understand how i think and how this works heh if not ill code it when i get home:


font-jpg.35608
 

Attachments

  • font.jpg
    font.jpg
    53 KB · Views: 651
Last edited:
Thank you AtomSoft.

I have tried to implement the logic but am a little stuck after 60% since it will use two values to construct more values.

You can see the attached image for the result i got so far. The labels have been added afterwards in MS Paint :p

Also this is my font so far:

const rom unsigned char FontBars[][7]={
0xFF, // 1 1 1 1 1 1 1 1 0%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1

0xFF, // 1 1 1 1 1 1 1 1 10%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1

0xFF, // 1 1 1 1 1 1 1 1 20%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xE7, // 1 1 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1

0xFF, // 1 1 1 1 1 1 1 1 30%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFC, // 1 1 1 1 1 1 0 0
0xE4, // 1 1 1 0 0 1 0 0
0x24, // 0 0 1 0 0 1 0 0
0x24, // 0 0 1 0 0 1 0 0

0xFF, // 1 1 1 1 1 1 1 1 40%
0xFF, // 1 1 1 1 1 1 1 1
0x9F, // 1 0 0 1 1 1 1 1
0x9F, // 1 0 0 1 1 1 1 1
0x9F, // 1 0 0 1 1 1 1 1
0x9F, // 1 0 0 1 1 1 1 1
0x9F, // 1 0 0 1 1 1 1 1

0xFF, // 1 1 1 1 1 1 1 1 50%
0xF3, // 1 1 1 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1

0xFE, // 1 1 1 1 1 1 1 0 60%
0xF2, // 1 1 1 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0
};

Code to plot on GLCD:
void ShowBars(unsigned char data){
unsigned char i,d;
if(data<48){
switch(data){
case 13:
XPos=0;
case 10:
XPos=0;
YPos+=8;
YPos=YPos&63;
}
WritePosition();
}
else{
for(i=0;i<7;i++){
d=FontBars[data-48];
if(d!=0x55){
GLCD_Write_Data(d);
MoveRight();
}
}
GLCD_Write_Data(0xff);
MoveRight();
}
}

ShowBars(*"0");
ShowBars(*"1");
ShowBars(*"2");
ShowBars(*"3");
ShowBars(*"4");
ShowBars(*"5");
ShowBars(*"6");

SetPos(120,58);
ShowBars(*"3");
SetPos(120,48);
ShowBars(*"6");


untitled-jpg.35610
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    67.2 KB · Views: 641
I don't understand why PutMessage() gets ROM pointer. Data is data, its value doesn't change whether it is in RAM or ROM, does it?

The parameter that gets passed to the function is the address of the data not the data itself. The function will then read from that address in ROM and so will get random data.

Mike.
 
You could add a function to do a filled in rectange,
Code:
void FilledBox(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2){
unsigned char i;
    for(i=y1;i<y2;i++){
        vline(x1,x2,i);
    }
}
Edit, I really should update this code. I even got vline and hline the wrong way round. Lol.

Mike.
 
Last edited:
Thank you Pommie, however the first problem i was having was that if we build rectangles which are not an offset of 8 pixels each, the other rectangles wont appear. You can try that and you will understand the need of making the font :)


AtomSoft, I have made the bars. A little problem is that i want to give the function numeric values, not character based values, is it possible. My C is really really rusty (has been three or more years when i last coded on C).

Here is the Font i made for bars:
const rom unsigned char FontBars[][14]={
0xFF, // 1 1 1 1 1 1 1 1 0%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1

0xFF, // 1 1 1 1 1 1 1 1 10%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1

0xFF, // 1 1 1 1 1 1 1 1 20%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
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1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xF3, // 1 1 1 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1
0x93, // 1 0 0 1 0 0 1 1

0xFF, // 1 1 1 1 1 1 1 1 60%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFE, // 1 1 1 1 1 1 1 0
0xF2, // 1 1 1 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0
0x92, // 1 0 0 1 0 0 1 0

0xFF, // 1 1 1 1 1 1 1 1 70%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xCF, // 1 1 0 0 1 1 1 1
0x4F, // 0 1 0 0 1 1 1 1
0x4F, // 0 1 0 0 1 1 1 1
0x4F, // 0 1 0 0 1 1 1 1
0x4F, // 0 1 0 0 1 1 1 1
0x4F, // 0 1 0 0 1 1 1 1
0x4F, // 0 1 0 0 1 1 1 1
0x4F, // 0 1 0 0 1 1 1 1

0xFF, // 1 1 1 1 1 1 1 1 80%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xF9, // 1 1 1 1 1 0 0 1
0xC9, // 1 1 0 0 1 0 0 1
0x49, // 0 1 0 0 1 0 0 1
0x49, // 0 1 0 0 1 0 0 1
0x49, // 0 1 0 0 1 0 0 1
0x49, // 0 1 0 0 1 0 0 1
0x49, // 0 1 0 0 1 0 0 1
0x49, // 0 1 0 0 1 0 0 1
0x49, // 0 1 0 0 1 0 0 1

0xFF, // 1 1 1 1 1 1 1 1 90%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1
0x3F, // 0 0 1 1 1 1 1 1

0xFF, // 1 1 1 1 1 1 1 1 100%
0xFF, // 1 1 1 1 1 1 1 1
0xFF, // 1 1 1 1 1 1 1 1
0xE7, // 1 1 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
0x27, // 0 0 1 0 0 1 1 1
};


And this is the code to make the bars display:
void ShowBars(unsigned char data){
unsigned char i,d;
if(data<48){
switch(data){
case 13:
XPos=0;
case 10:
XPos=0;
YPos+=8;
YPos=YPos&63;
}
WritePosition();
}
else{
for(i=0;i<14;i++){
d=FontBars[(data-48)*2];
if(d!=0x55){
GLCD_Write_Data(d);
MoveRight();
}
}
GLCD_Write_Data(0xff);
MoveRight();
}
}


SetPos(112,58);
ShowBars(*"3");
SetPos(112,50);
ShowBars(*"6");
SetPos(112,42);
ShowBars(*"8");
SetPos(112,34);
ShowBars(*":");



Now as you might have noticed, the last line ShowBars(*":"), i put ':' because it comes after 9 and since the function only reads one character, hence it cannot take in 10.

Any advice on how to make this function numaric based like ShowBars(10) or ShowBars(9) etc?

Here is the result image:
untitled-jpg.35615
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    47.3 KB · Views: 588
Last edited:
sure heh

Code:
void ShowBars(unsigned char data){
unsigned char i,d;
if(data<48){
if(data>9){
switch(data){
    case 10:
        data = ':';
        break;
    case 11:
        data = ';';
        break;
    case 12:
        data = '<';
        break;
    case 13:
        data = '=';
        break;
    case 14:
        data = '>';
        break;
}
}
switch(data){
case 13:
XPos=0;
case 10:
XPos=0;
YPos+=8;
YPos=YPos&63;
}
WritePosition();
}
else{
for(i=0;i<14;i++){
d=FontBars[(data-48)[B]*2[/B]][i];
if(d!=0x55){
GLCD_Write_Data(d);
MoveRight();
}
}
GLCD_Write_Data(0xff);
MoveRight();
}
}
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top