Announcement

Collapse
No announcement yet.

drawing a rectangle problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ESPsupport
    replied


    B takes a lot longer than K as it replaces all occurrences of the current background color on the screen with the new background color. K just sets the new background color for the next 'usage' of the background color.



    I would think the best thing for you, if I understand what you are trying to do, would be to use K to set the background color to white, write your text, then use K to set the background color back to blue

    Leave a comment:


  • sspence65
    replied


    Serial3.print('B'); // K, or B
    Serial3.print((uint16_t)0x001f);

    K & B doesn't seem to work any different. (page 13 & 29)

    Little k works very differently. It allows me to specify the rectangle co-ordinates. (page 37)

    ReplaceColor (x1, y1, x2, y2, old color, new color)

    I'll try that.

    Leave a comment:


  • sspence65
    replied


    I see. I'm currently using "replace color" (0x6B). When should one be used and not the other? Again, I have a blue background, white rectangles, and green or red text inside the white rectangles. I do not want to see the blue background around the text when it refreshes.

    Leave a comment:


  • ESPsupport
    replied


    Have a look at the 'Replace Background color (0x42)' and 'Set Background Color (0x4B)' commands.

    Leave a comment:


  • sspence65
    replied


    How do set the background color of text? I've been using opaque, but I get the blue screen background surrounding my text inside the white box, so the text is not "floating" on the white. I can't find an option to set the text background to white.

    sendData(37, 9, 3, 255, 255, staticl3);

    HTML Code:
    // Send Data
    
    int sendData(int u, int v, int w, int x, int y, int z){ 
    Serial3.print(byte(115)); //command
    Serial3.print(byte(u)); //column
    Serial3.print(byte(v)); //row
    Serial3.print(byte(w)); //font
    Serial3.print(byte(x)); //color
    Serial3.print(byte(y)); //color
    Serial3.print(int(z)); //data
    Serial3.print("     "); // to delete remaining numbers from previous measure
    Serial3.print(byte(00)); //terminator
    a= nacAck();
    
    }

    Leave a comment:


  • meldavia
    replied


    If you use transparent text, only the pixels of the text will be written.
    What you need to do is use opaque text, and set the text background colour to the
    same colour as whatever you are writing over, giving the effect of erasure of the
    prevoius text..

    Leave a comment:


  • sspence65
    replied


    An interesting observation. I have a blue back ground, and white rectangles. Text gets put into the rectangles. The text has a blue background instead of "floating" over the white. I end up with a blue rectangle inside a white rectangle with green or red text in the blue rectangle. I just want the green or red text on the white rect.

    If I turn the text transparent, then it doesn't "go away" when the text changes, and I get leftover artifacts. I am writing a " " to the same place as the text to erase the previous setting.

    Leave a comment:


  • sspence65
    replied


    ah, ok got it.

    I put together a quick spread sheet, that if you input the 4 screen points where you want a box, it outputs the MSB and LSB for each co-ordinate.

    Can't figure out how to attach it though.

    however if your screen coordinate in pixels is in A2

    then in a3 put

    =ROUNDDOWN(A2/256,0)

    and b3 put

    MSB

    in A4 put

    =(((A2/256)-A3)*256)

    and B4 put LSB

    this outputs MSB and LSB in decimal, which works with

    HTML Code:
    drawRect(0, 180, 1, 84, 1, 4, 1, 129, 255, 255);
    drawRect(1, 164, 1, 84, 1, 244, 1, 129, 255, 255);  
    
    
    // Draw Rectangle
    
    byte drawRect(int x10, int x11, int y10, int y11, int x20, int x21, int y20, int y21, int y, int z) {
    
    Serial3.print(byte(114)); //command
    Serial3.print(byte(x10)); //top left horizontal start msb
    Serial3.print(byte(x11)); //top left horizontal start lsb
    Serial3.print(byte(y10)); //top left vertical start msb
    Serial3.print(byte(y11)); //top left vertical start lsb
    Serial3.print(byte(x20)); //bottom right horizontal end msb
    Serial3.print(byte(x21)); //bottom right horizontal end lsb
    Serial3.print(byte(y20)); //bottom right vertical end msb
    Serial3.print(byte(y21)); //bottom right vertical end lsb
    Serial3.print(byte(y)); //color
    Serial3.print(byte(z)); //color
    
    a = nacAck();
    
    }
    
    // check ack / nack
    byte nacAck() {
    byte b=0x00; // 0x06;
    while (!(Serial3.available())) {     
    delay(2);   
    }
    b = Serial3.read();
    return b;
    }

    Leave a comment:


  • Atilla
    replied


    15E = 015E, leading 0 is usually omitted, msb = 01, lsb = 5E

    Leave a comment:


  • sspence65
    replied


    350 = 15E,

    is it msb 15, lsb E,

    or

    msb 1, lsb 5E

    Leave a comment:


  • sspence65
    replied


    That helps a lot. Thanks.

    Leave a comment:


  • Atilla
    replied


    Calculating the msb:lsb is my problem. Is the msb always zero? I do not understand the msb:lsb concept.The concept is not too hard. The serial link works on single bytes of data at a time, where 1 byte = 8 bits which can hold a value of 0 to 255 decimal. The max. screen resolution for the uVGA-II is 800x480. Neither the 800 nor the 480 will fit in to a single byte so these parameters need 2 bytes. 800 decimal = 0320 hex and 480 decimal = 01E0 hex. 2 byte values are represented as a word and a word has a msb (most significant byte) and a lsb (least significant byte). In the case of 800 x 480 resolution this can be represented in the following way:
    800 dec = 0320 hex, where msb = 03, lsb = 20
    480 dec = 01E0 hex, where msb = 01, lsb = E0Since our serial link can only deal with 1 byte at a time, to send the parameter of 800 dec (0320 hex) to the uVGA you would need:
    Serial3.print(byte(03)); //send msbSerial3.print(byte(20)); //send lsb
    The uVGA-II(SGC) command set includes a mixture of single byte and double byte (word) parameters. When ever you see data(msb:lsb) this is a representation for a word size parameter and the uVGA expects 2 bytes of data for this parameter, just follow the brief lesson above to work out the requirements.
    Hope this helps!


    Leave a comment:


  • sspence65
    replied


    Calculating the msb:lsb is my problem. Is the msb always zero? I do not understand the msb:lsb concept.



    I have yet to find a library that works. For my simple needs, I really don't need a library. I have no problem sending text to the screen, but rectangles have been kicking my butt.

    Leave a comment:


  • 4dTechSupport
    replied


    I presume you are using Arduino to control a display module. There are some Arduino libraries developed by third parties for these display modules. See the links below,
    http://sites.google.com/site/vilorei/arduino/13--serial-touch-320x240-lcd-screen
    http://jennylc.com/4d/
    http://nicholasboka.com/?page_id=23
    http://code.google.com/p/displayshield4d/
    http://code.google.com/p/uoled-library/

    I am wondering how you calculated the MSB/LSBs for the parameters of the command. It should be done like this,

    100 dec = 64 hex : MSB = 0, LSB = 64hex
    150 dec = 96 hex: MSB = 0, LSB = 96hex
    200 dec = C8 hex: MSB = 0, LSB = C8hex

    -Bilal

    Leave a comment:


  • sspence65
    started a topic drawing a rectangle problem

    drawing a rectangle problem

    I want to draw a rectangle on the screen, at the following co-ordinates:

    100 TLH
    150 TLV
    200 BRH
    200 BRV

    I get that I have to send 2 bytes for each point, but I don't get how to split a point on the screen into two bytes.

    HTML Code:
    drawRect(6, 4, 9, 6, 12, 8, 12, 8, 255, 255); // does not work
    
    // Draw Rectangle
    
    byte drawRect(int x10, int x11, int y10, int y11, int x20, int x21, int y20, int y21, int y, int z) {
    
    Serial3.print(byte(114)); //command
    Serial3.print(byte(x10)); //top left horizontal msb
    Serial3.print(byte(x11)); //top left horizontal lsb
    Serial3.print(byte(y10)); //top left vertical msb
    Serial3.print(byte(y11)); //top left vertical lsb
    Serial3.print(byte(x20)); //bottom right horizontal msb
    Serial3.print(byte(x21)); //bottom right horizontal lsb
    Serial3.print(byte(y20)); //bottom right vertical msb
    Serial3.print(byte(y21)); //bottom right vertical lsb
    Serial3.print(byte(y)); //color msb
    Serial3.print(byte(z)); //color lsb
    
    a = nacAck();
    
    }
    
    // check ack / nack
    byte nacAck() {
    byte b=0x00; // 0x06;
    while (!(Serial3.available())) {     
    delay(2);   
    }
    b = Serial3.read();
    return b;
    }
    
    
    
    
    
Working...
X