Draws the image obtained by GetScreen in a rectangular area of the LCD screen.

Syntax

int SetScreen(
  int x, 
  int y,
  int width, 
  int height, 
  unsigned char *buffer
);

Parameters

x
[in] Specifies the x-coordinate position of the left edge of the rectangle.
y
[in] Specifies the y-coordinate position of the top edge of the rectangle.
width
[in] [in] Specifies the horizontal width of the rectangle.
height
[in] Specifies the vertical width of the rectangle.
buffer
[in] Specifies the buffer for the image to draw.

Return value

Returns OK if the function succeeds, ERROR otherwise.

Remarks

The values ​​that can be set are as follows.
variablelower limitupper limit
x 0 DISP_WIDTH - 1
y 0 DISP_HEIGHT - 1
width 1 DISP_WIDTH - x
height 1 DISP_HEIGHT-y
 When the status bar display is set, an error is not returned even if the status bar range value is specified, but the status bar area is not drawn.
When the display of the status bar is set, the Y coordinate values ​​that can be set are as follows.
variablelower limitupper limit
x 0 DISP_WIDTH - 1
y 0 DISP_HEIGHT - 17
width 1 DISP_WIDTH - x
height 1 DISP_HEIGHT - 16 - y
ValueDescription
DISP_WIDTH 128 pixels
DISP_HEIGHT 160 pixels
 1 dot data is 3 bytes, and the color data is arranged in order of red, green, and blue for each byte.
 1-dot data is arranged in order horizontally from the origin. After the end of the horizontal data, continue to the leftmost data one dot below vertically. The origin of screen coordinates is the top left.
Please note that the origin of coordinates and the order of color data are different from Windows bitmap.

Requirements

Header file:
lib.h
Library file:
libSTARTUPOPH5000.a

Sample

#include <stdio.h>
#include <stdlib.h>
#include "lib.h"
void main(void)
{
    int lvIndex;
    unsigned char *buffer = malloc(DISP_WIDTH * DISP_HEIGHT * 3);
    FillCircle(DISP_WIDTH/2, DISP_HEIGHT/2, DISP_WIDTH/4, RGB_BLUE);
    printf("[SetScreen]\n");
    if (buffer == NULL){
        printf("malloc error\n");
        return;
    }
    GetScreen(0, 0, DISP_WIDTH, DISP_HEIGHT, buffer);
    ResetKey();
    GotoXY(0, 0);
    printf("Press to clear\r\n");
    while(!kbhit()){
        Idle();
    }
    ClearDisplay();
    ResetKey();
    GotoXY(0, 0);
    printf("Press to redraw\r\n");
    while(!kbhit()){
        Idle();
    }
    SetScreen(0, 0, DISP_WIDTH, DISP_HEIGHT, buffer);
    free(buffer);
    while(1){
        Idle();
    }
}

Last updated: 2023/01/16