Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 31st October 2009, 01:58 AM   #16
Default

That makes even less sense atom....
RGB....
All 00s == black. All FFs == white. There should be no separate bytes other than R G and B.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 31st October 2009, 02:33 AM   #17
Default

hey guys this is killing me:

Code:
void LCDWriteBMP(unsigned rom char *bmp, unsigned char x, unsigned char y, unsigned char width, unsigned char height) {
unsigned int j;
unsigned int maxPix;
unsigned int xmin, xmax, ymin, ymax;
unsigned int i;

    maxPix = 0;

    //maxPix = (width * height);
    for(j = 0; j < height; j++) {
        maxPix += width;
    }

    xmin = x;
    xmax = x + width;
    ymin = y;
    ymax = y + height;

    LCDCommand(PASETP);
    LCDData(ymin);
    LCDData(ymax);

    LCDCommand(CASETP);
    LCDData(xmin);
    LCDData(xmax);

    LCDCommand(RAMWRP);

    for(j = 0; j < maxPix; j++) {
        LCDData(*bmp++);
    }
}
The above might work well... I call it like:

LCDWriteBMP(bmp444,20,20,50,50);

for some reason the values are mixed up or wrong..

Attached Thumbnails
Nokia 6100 Library-err.jpg  

Last edited by AtomSoft; 31st October 2009 at 02:33 AM.
AtomSoft is offline  
Old 31st October 2009, 02:43 AM   #18
Default

http://www.sparkfun.com/tutorial/Nok...y%20Driver.pdf

Page: 7

Look:
Attached Thumbnails
Nokia 6100 Library-page7.jpg  
AtomSoft is offline  
Old 31st October 2009, 04:53 PM   #19
Default

Quote:
Originally Posted by AtomSoft View Post
heh i mean im trying RED, GREEN, BLUE, WHITE and BLACK color image...


I ran into a issue::
MAX = unsigned long
the width and height = unsigned char
Code:
    max = width * height;
My problem is if width = 50 and height = 50 max should = 2500 but it = 196

any thoughts????
The calculation is being done in unsigned char (i.e. multiples of 256 are being dropped in the result), put another way:

2500 = hex 9C4

Hex C4 = 196

You need to force the calculation to be done in unsigned long
max = width;
max = max * height;
would probably do it or you could probably use explicit type casts.
David James is offline  
Old 31st October 2009, 05:01 PM   #20
Default

the issue was it wasnt getting the data from the call but i fixed it somewhat;

Code:
    width = *bmp++;
    height = *bmp++;

    for(j = 0; j < height; j++) {
        maxPix += width;
    }
but ill try your suggestion for the math tho

UPDATE:

Code:
    width = *bmp++;
    height = *bmp++;

    maxPix = height;
    maxPix = maxPix * width;
Works well! thanks

Last edited by AtomSoft; 31st October 2009 at 05:04 PM.
AtomSoft is offline  
Old 31st October 2009, 06:37 PM   #21
Default

this is very frustrating heh .. in my mind it should be working but in reality it isnt..

My screen is setup to write from

LEFT to Right then top to bottom like:


So in VB im reading from left to right and top to bottom .. placing the data into a listbox and looping through the listbox (visual array)

I divide each pixel RGB by 17 so 255 == 15 (aka 0x0F) which is the max for each RGB (0xFFF)

Now i get black pretty good but i get sukish results with the rest... here is my 50x50 image i want to convert: (i had to convert to jpg to place here)


VB Code:
Code:
Private OnBits(0 To 31) As Long

Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, _
    ByVal y As Long) As Long


    Dim Red As Byte
   Dim Green As Byte
   Dim Blue As Byte
    Dim Color As Long

Public Function LShiftLong(ByVal Value As Long, _
    ByVal Shift As Integer) As Long
  
    MakeOnBits
  
    If (Value And (2 ^ (31 - Shift))) Then GoTo OverFlow
  
    LShiftLong = ((Value And OnBits(31 - Shift)) * (2 ^ Shift))
  
    Exit Function

OverFlow:
  
    LShiftLong = ((Value And OnBits(31 - (Shift + 1))) * _
       (2 ^ (Shift))) Or &H80000000
  
End Function

Public Function RShiftLong(ByVal Value As Long, _
   ByVal Shift As Integer) As Long
    Dim hi As Long
    MakeOnBits
    If (Value And &H80000000) Then hi = &H40000000
  
    RShiftLong = (Value And &H7FFFFFFE) \ (2 ^ Shift)
    RShiftLong = (RShiftLong Or (hi \ (2 ^ (Shift - 1))))
End Function
 


Private Sub MakeOnBits()
    Dim j As Integer, _
        v As Long
  
    For j = 0 To 30
  
        v = v + (2 ^ j)
        OnBits(j) = v
  
    Next j
  
    OnBits(j) = v + &H80000000

End Sub

Private Sub Command1_Click()
'The following code example counts the number of red pixels on the active form:
' assumes that form's ScaleMode
' is set to 3 - Pixels
Text2 = ""
Text4 = ""
Text3 = ""
Dim x As Long, y As Long
Dim h As Long, count As Long
Dim q As Long, w As Long
Dim tmp As Integer
Dim tmpf As Integer
' cache form's hDC property
h = Picture1.hdc

'For y = 0 To Picture1.ScaleHeight - 1
'    For x = 0 To Picture1.ScaleWidth - 1
Dim hMax As Integer, wMax As Integer
hMax = Picture1.ScaleHeight - 1
wMax = Picture1.ScaleWidth - 1

For y = 0 To hMax
    For x = 0 To wMax
        Color = GetPixel(h, x, y)
        Red = Color And &HFF&                    'mind the ampersand at the end of constant
        Green = (Color And &HFF00&) / 256        'bit masking and "shift"
        Blue = (Color And &HFF0000) / 65535      'bit masking and "shift"

        Red = Red / 17
        Green = Green / 17
        Blue = Blue / 17
                
        List1.AddItem Red
        List1.AddItem Green
        List1.AddItem Blue
        
        Text2.Text = Text2.Text & Red & "-" & Green & "-" & Blue & ", "
    Next
Next

h = List1.ListCount - 1
If h Mod 2 = 1 Then List1.AddItem 0
count = List1.ListCount / 2

h = List1.ListCount - 1


For y = 0 To List1.ListCount - 1
    tmpf = 0
    
    For x = 0 To 1
        tmpf = tmpf Or Val(List1.List(y + x))
              
        If tmpf > 9 Then
            Select Case List1.List(y + x)
                Case 10
                    tmpf = tmpf Or &HA
                Case 11
                    tmpf = tmpf Or &HB
                Case 12
                    tmpf = tmpf Or &HC
                Case 13
                    tmpf = tmpf Or &HD
                Case 14
                    tmpf = tmpf Or &HE
                Case 15
                    tmpf = tmpf Or &HF
            End Select
        End If
        If x = 0 Then
            tmpf = LShiftLong(tmpf, 4)
        End If
    Next x
    y = y + 2
    List2.AddItem tmpf
Next y
Text3 = Str(List1.ListCount - 1)
Text4 = Str(List2.ListCount - 1)
End Sub

Private Sub List1_Click()
Dim x As Integer, y As Integer
Text2.Text = ""
For x = 0 To List1.ListCount - 1
    Text2.Text = Text2.Text & List1.List(x) & ","
        y = y + 1
        If y = 40 Then
            y = 0
            Text2.Text = Text2.Text & vbNewLine
        End If
Next x

Text2.Text = Mid$(Text2.Text, 1, (Len(Text2.Text) - 1))

End Sub

Private Sub List2_Click()
Dim x As Integer, y As Integer
Text2.Text = ""
For x = 0 To List2.ListCount - 1
    Text2.Text = Text2.Text & List2.List(x) & ","
    y = y + 1
        If y = 40 Then
            y = 0
            Text2.Text = Text2.Text & vbNewLine
        End If
Next x

Text2.Text = Mid$(Text2.Text, 1, (Len(Text2.Text) - 1))

End Sub

Private Sub Picture1_Click()
Picture1.Picture = LoadPicture("d:\colors.bmp")
End Sub
Attached Thumbnails
Nokia 6100 Library-wrap.jpg  
Attached Images
 
AtomSoft is offline  
Old 31st October 2009, 06:51 PM   #22
Default

Quote:
Originally Posted by AtomSoft View Post
...

I divide each pixel RGB by 17 so 255 == 15 (aka 0x0F) which is the max for each RGB (0xFFF)
...
To convert the pixel properly from 0-255 range down to 0-15 range, use this;
Code:
unsigned char newpixel;   // 8bit var is ok
unsigned int temp;    // must be 16bit var!

  temp = (pixel + 8);
  newpixel = (temp / 16);
The operation of adding half the divisor then dividing will give you the best colour match (ie least possible error).
Mr RB is offline  
Old 31st October 2009, 06:56 PM   #23
Default

Thanks will try
AtomSoft is offline  
Old 31st October 2009, 07:22 PM   #24
Default

Thanks. I also figured out another issue and this is what i get so far:

Attached Thumbnails
Nokia 6100 Library-colors.jpg  
AtomSoft is offline  
Old 31st October 2009, 07:31 PM   #25
Default

Top line looks ok, then you get a 45 degree angle so you have a 1 pixel error on each line.

Check your line length values, and for loops etc. Could be a -1 in the wrong spot...
Mr RB is offline  
Old 31st October 2009, 07:32 PM   #26
Default

OMG YES!!!!!!!! i did it:

Attached Thumbnails
Nokia 6100 Library-colors2.jpg  
AtomSoft is offline  
Old 31st October 2009, 08:08 PM   #27
Default

Look a bear lol:

Attached Thumbnails
Nokia 6100 Library-bear.jpg  
AtomSoft is offline  
Old 31st October 2009, 10:09 PM   #28
Default

The main program... can someone test it out for me to see if it works well on other computers. Like does it seem to work well heh

Tiny Version (NO VB6 RUNTIME FILES INCLUDED) (9kb ZIP)
http://atomsofttech.info/code/Nokia12Bit_tiny.zip

Full Version (VB6 RUNTIME FILES INCLUDED) (1,179kb ZIP)
http://atomsofttech.info/code/Nokia12Bit_full.zip



EDIT: Just noticed they were making txt files instead of h (headers) so i just fixed it and re-uploaded it

heh was bored....




Looks way better live
Attached Thumbnails
Nokia 6100 Library-yay.jpg  

Last edited by AtomSoft; 31st October 2009 at 10:39 PM.
AtomSoft is offline  
Old 1st November 2009, 08:07 PM   #29
Default

I am currently Cleaning up the code and will post a full source and schematic and VB program all in one. This way people can use it.

The VB source will not be shared until i fix it up more...

Also i will be adding the ability to select between 8, 12 and 16 bit color for LCD image conversion and code soon.
AtomSoft is offline  
Old 1st November 2009, 10:16 PM   #30
Default

so if i needed to make a RGB pixel to 8 bit LCD which is RRRGGGBB can i simply
Code:
unsigned char newpixel;   // 8bit var is ok
unsigned int temp;    // must be 16bit var!

  temp = (RED);
  newRED = (temp / (255/7));

  temp = (GREEN);
  newGREEN = (temp / (255/7));

  temp = (BLUE);
  newBLUE = (temp / (255/3));

//NewPixel 8 Bit would be shifted like:

newpixel= (NewRED<<4) | (NewGREEN<<2) | NewBLUE;
Would it be something like that?

Last edited by AtomSoft; 1st November 2009 at 10:17 PM.
AtomSoft is offline  
Reply

Tags
6100, library, nokia

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Multisim Library rahulshah Datasheet/Parts Requests 0 15th March 2009 02:12 PM
Rfid Library ollakalla Micro Controllers 0 18th December 2008 07:02 PM
eagle library fedail General Electronics Chat 19 14th October 2008 07:36 PM
Eagle Library bababui Electronic Projects Design/Ideas/Reviews 13 9th May 2007 01:56 PM
Protothread library Dan East Micro Controllers 0 7th October 2005 04:31 AM



All times are GMT. The time now is 11:06 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker