> For the complete documentation index, see [llms.txt](https://robolink.gitbook.io/codrone-edu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://robolink.gitbook.io/codrone-edu/codrone_lib/codrone_protocol_main/structs-display.md).

# Structs display

Display 제어와 관련된 정의 및 구조체들을 소개합니다.

## Definitions <a href="#heading-definitions" id="heading-definitions"></a>

## Display::Pixel::Type

픽셀 색상 .

```python
namespace Display
{
    namespace Pixel
    {
        enum Type
        {
            Black,
            White,
            Inverse
        };
    }
}
```

## Display::Font::Type

폰트.

```python
namespace Display
{
    namespace Font
    {
        enum Type
        {
            LiberationMono5x8,
            LiberationMono10x16,
        };
    }
}
```

## Display::Align::Type

문자열 정렬.

```python
namespace Display
{
    namespace Align
    {
        enum Type
        {
            Left,
            Center,
            Right
        };
    }
}
```

## Display::Line::Type

선.

```python
namespace Display
{
    namespace Line
    {
        enum Type
        {
            Solid,
            Dotted,
            Dashed,
        };
    }
}
```

## Structs <a href="#heading-definitions" id="heading-definitions"></a>

## Protocol::Display::ClearAll

화면 전체 지우기.

```python
namespace Protocol
{
    namespace Display
    {
        struct ClearAll
        {
            u8      pixel;
        };
    }
}
```

| 변수 이름. | 형식.                  | 크기.    | 범위. | 설명.    |
| ------ | -------------------- | ------ | --- | ------ |
| pixel  | Display::Pixel::Type | 1 Byte | -   | 채울 색상. |

## Protocol::Display::Clear

선택 영역 지우기.

```python
namespace Protocol
{
    namespace Display
    {
        struct Clear
        {
            s16     x;
            s16     y;
            s16     width;
            s16     height;
            u8      pixel;
        };
    }
}
```

| 변수 이름. | 형식.                  | 크기.    | 범위.           | 설명.       |
| ------ | -------------------- | ------ | ------------- | --------- |
| x      | int16\_t             | 2 Byte | -2000 \~ 2000 | X축 시작 위치. |
| y      | int16\_t             | 2 Byte | -2000 \~ 2000 | Y축 시작 위치. |
| width  | int16\_t             | 2 Byte | -2000 \~ 2000 | 너비.       |
| height | int16\_t             | 2 Byte | -2000 \~ 2000 | 높이.       |
| pixel  | Display::Pixel::Type | 1 Byte |               | 채울 색상.    |

## Protocol::Display::Invert

선택 영역 반전.

```python
namespace Protocol
{
    namespace Display
    {
        struct Invert
        {
            s16     x;
            s16     y;
            s16     width;
            s16     height;
        };
    }
}
```

| 변수 이름. | 형식.      | 크기.    | 범위.           | 설명.       |
| ------ | -------- | ------ | ------------- | --------- |
| x      | int16\_t | 2 Byte | -2000 \~ 2000 | X축 시작 위치. |
| y      | int16\_t | 2 Byte | -2000 \~ 2000 | Y축 시작 위치. |
| width  | int16\_t | 2 Byte | -2000 \~ 2000 | 너비.       |
| height | int16\_t | 2 Byte | -2000 \~ 2000 | 높이.       |

## Protocol::Display::DrawPoint

점 찍기 .

```python
namespace Protocol
{
    namespace Display
    {
        struct DrawPoint
        {
            s16     x;
            s16     y;
            u8      pixel;
        };
    }
}
```

| 변수 이름. | 형식.                  | 크기.    | 범위.           | 설명.       |
| ------ | -------------------- | ------ | ------------- | --------- |
| x      | int16\_t             | 2 Byte | -2000 \~ 2000 | X축 시작 위치. |
| y      | int16\_t             | 2 Byte | -2000 \~ 2000 | Y축 시작 위치. |
| pixel  | Display::Pixel::Type | 1 Byte | -             | 점 색상.     |

## Protocol::Display::DrawRect

네모 상자 그리기 .

```python
namespace Protocol
{
    namespace Display
    {
        struct DrawRect
        {
            s16     x;
            s16     y;
            s16     width;
            s16     height;
            u8      pixel;
            u8      flagFill;
            u8      line;
        };
    }
}
```

| 변수 이름.   | 형식.                  | 크기.    | 범위.           | 설명.              |
| -------- | -------------------- | ------ | ------------- | ---------------- |
| x        | int16\_t             | 2 Byte | -2000 \~ 2000 | X축 시작 위치.        |
| y        | int16\_t             | 2 Byte | -2000 \~ 2000 | Y축 시작 위치.        |
| width    | int16\_t             | 2 Byte | -2000 \~ 2000 | 너비.              |
| height   | int16\_t             | 2 Byte | -2000 \~ 2000 | 높이.              |
| pixel    | Display::Pixel::Type | 1 Byte | -             | 색상.              |
| flagFill | uint8\_t             | 1 Byte | -             | 0(채우지 않음), 1(채움) |
| line     | Display::Line::Type  | 1 Byte | -             | 선 형태.            |

## Protocol::Display::DrawCircle

원 그리기.

```python
namespace Protocol
{
    namespace Display
    {
        struct DrawCircle
        {
            s16     x;
            s16     y;
            s16     radius;
            u8      pixel;
            u8      flagFill;
        };
    }
}
```

| 변수 이름.   | 형식.                  | 크기.    | 범위.           | 설명.              |
| -------- | -------------------- | ------ | ------------- | ---------------- |
| x        | int16\_t             | 2 Byte | -2000 \~ 2000 | X축 중심점 위치.       |
| y        | int16\_t             | 2 Byte | -2000 \~ 2000 | Y축 중심점 위치.       |
| radius   | int16\_t             | 2 Byte | 1 \~ 2000     | 반지름.             |
| pixel    | Display::Pixel::Type | 1 Byte | -             | 색상.              |
| flagFill | uint8\_t             | 1 Byte | -             | 0(채우지 않음), 1(채움) |

## Protocol::Display::DrawString

문자열 그리기.

화면에 표시할 문자열은 DrawString 구조체 뒤에 이어서 ASCII 문자열을 붙여서 전송.                                     헤더의 length는 (Protocol::Display::DrawString의 길이 + 화면에 표시할 문자열의 길이) 값을 넣어야 합니다.

```python
namespace Protocol
{
    namespace Display
    {
        struct DrawString
        {
            s16     x;
            s16     y;
            u8      font;
            u8      pixel;
        };
    }
}
```

| 변수 이름.  | 형식.                  | 크기.     | 범위.           | 설명.      |
| ------- | -------------------- | ------- | ------------- | -------- |
| x       | int16\_t             | 2 Byte  | -2000 \~ 2000 | X축 위치.   |
| y       | int16\_t             | 2 Byte  | -2000 \~ 2000 | Y축 위치.   |
| font    | Display::Font::Type  | 1 Byte  |               | 폰트.      |
| pixel   | Display::Pixel::Type | 1 Byte  | -             | 색상.      |
| message | ASCII String         | 30 Byte | -             | 표시할 문자열. |

## Protocol::Display::DrawStringAlign

문자열 정렬하여 그리기.

화면에 문자열 쓰기. 문자열은 xStart와 xEnd 사이에서 align으로 지정한 위치에 놓입니다.                                     화면에 표시할 문자열은 DrawStringAlign 구조체 뒤에 이어서 ASCII 문자열을 붙여서 전송합니다.               헤더의 length는 (Protocol::Display::DrawStringAlign의 길이 + 화면에 표시할 문자열의 길이) 값을 넣어야 합니다.

```python
namespace Protocol
{
    namespace Display
    {
        struct DrawStringAlign
        {
            s16     xStart;
            s16     xEnd;
            s16     y;
            u8      align;
            u8      font;
            u8      pixel;
        };
    }
}
```

| 변수 이름.  | 형식.                  | 크기.     | 범위.           | 설명.       |
| ------- | -------------------- | ------- | ------------- | --------- |
| xStart  | int16\_t             | 2 Byte  | -2000 \~ 2000 | X축 시작 위치. |
| yEND    | int16\_t             | 2 Byte  | -2000 \~ 2000 | Y축 끝 위치.  |
| y       | int16\_t             | 2 Byte  | -2000 \~ 2000 | Y축 위치     |
| align   | Display::Align::Type | 1 Byte  | -             | 정렬.       |
| font    | Display::Font::Type  | 1 Byte  | -             | 폰트.       |
| pixel   | Display::Pixel::Type | 1 Byte  | -             | 색상.       |
| message | ASCII String         | 30 Byte | -             | 표시할 문자열.  |

## Protocol::Display::DrawImage

이미지 그리기.

LCD에 기본 문자열 이외의 모양이나 그림을 넣을 때 사용합니다.                                                                         세로 8픽셀이 한 바이트이며, 최하위 비트부터 위에서 아래로 그려집니다.                                                          화면에 표시할 이미지 데이터는 DrawImage 구조체 뒤에 이어붙이면 됩니다.                                                   헤더의 length는 (Protocol::Display::DrawImage의 길이 + imageArray의 길이) 값을 넣어야 합니다.                   아래는 직각 삼각형을 배열에 담은 예제입니다.

```python
// ********
    //  *******
    //   ******
    //    *****
    //     ****
    //      ***
    //       **
    //        *
    const u8 triangle[] = { 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF };
```

```python
namespace Protocol
{
    namespace Display
    {
        struct DrawImage
        {
            s16     x;
            s16     y;
            s16     width;
            s16     height;
        };
    }
}
```

| 변수 이름.     | 형식.            | 크기.      | 범위.           | 설명.       |
| ---------- | -------------- | -------- | ------------- | --------- |
| x          | int16\_t       | 2 Byte   | -2000 \~ 2000 | X축 시작 위치. |
| y          | int16\_t       | 2 Byte   | -2000 \~ 2000 | Y축 시작 위치. |
| width      | int16\_t       | 2 Byte   | -2000 \~ 2000 | 너비.       |
| height     | int16\_t       | 2 Byte   | -2000 \~ 2000 | 높이.       |
| imageArray | uint8\_t Array | 128 Byte | -             | 이미지 .     |
