Frame/Pixel Management Functions

group group_seglcd_functions_frame

Functions

cy_en_seglcd_status_t Cy_SegLCD_ClrFrame(LCD_Type *base, uint32_t const *commons)

Clears the frame buffer and initiates the common lines.

In general case it is recommended to be called after Cy_SegLCD_Init and before Cy_SegLCD_Enable.

Return

cy_en_seglcd_status_t.

Function Usage

/* Scenario: Enable an LCD block */

cy_stc_seglcd_config_t config =
{
    .speed = CY_SEGLCD_SPEED_HIGH,
    .wave = CY_SEGLCD_TYPE_B,
    .drive = CY_SEGLCD_PWM,
    .bias = CY_SEGLCD_BIAS_FOURTH,
    .lsClk = CY_SEGLCD_LSCLK_LF,
    .comNum = 8,
    .frRate = 70,
    .contrast = 70,
  /*.clkFreq is unknown here */
};

const uint32_t commons[8] =
{
    CY_SEGLCD_COMMON(LCD_COM_0, 0UL),
    CY_SEGLCD_COMMON(LCD_COM_1, 1UL),
    CY_SEGLCD_COMMON(LCD_COM_2, 2UL),
    CY_SEGLCD_COMMON(LCD_COM_3, 3UL),
    CY_SEGLCD_COMMON(LCD_COM_4, 4UL),
    CY_SEGLCD_COMMON(LCD_COM_5, 5UL),
    CY_SEGLCD_COMMON(LCD_COM_6, 6UL),
    CY_SEGLCD_COMMON(LCD_COM_7, 7UL)
};
    /* Then in executable code: */

    /* Get the frequency of the assigned peripheral clock divider */
    config.clkFreq  = Cy_SysClk_PeriphGetFrequency(CY_SYSCLK_DIV_8_BIT, 0U);

    if (CY_SEGLCD_SUCCESS == Cy_SegLCD_Init(LCD0, &config))
    {
        if (CY_SEGLCD_SUCCESS == Cy_SegLCD_ClrFrame(LCD0, commons))
        {
            Cy_SegLCD_Enable(LCD0);
            
           /* Now the block generates LCD signals (all the pixels are off) and is ready to turn on any pixel
            * (or many pixels) using any of the frame/pixel/character/display management API functions.
            */
        }
        else
        {
            /* error handling */
        }
    }
    else
    {
        /* error handling */
    }

Parameters
  • base: The base pointer to the LCD instance registers.

  • commons: The pointer to array of common lines. The array size is specified by cy_stc_seglcd_config_t::comNum. Each common line value should be made using CY_SEGLCD_COMMON macro.

cy_en_seglcd_status_t Cy_SegLCD_InvFrame(LCD_Type *base, uint32_t const *commons)

Inverts the frame buffer (all the connected pixel states are inverted).

Return

cy_en_seglcd_status_t.

Function Usage

    /* Scenario: Toggle the state of each pixel to opposite: */
    if (CY_SEGLCD_SUCCESS != Cy_SegLCD_InvFrame(LCD0, commons))
    {
        /* error handling */
    }
    /* Now all the pixels are inverted statically, however the display/character
     * management API functions will remain to write symbols non-inverted
     * until the correspondent display property is also inverted:
     */
    display.invert = !display.invert;

Parameters
  • base: The base pointer to the LCD instance registers.

  • commons: The pointer to an array of common lines. The array size is specified by cy_stc_seglcd_config_t::comNum. Each common line value should be made using CY_SEGLCD_COMMON macro.

cy_en_seglcd_status_t Cy_SegLCD_WritePixel(LCD_Type *base, uint32_t pixel, bool value)

Sets or clears a specified pixel.

Return

cy_en_seglcd_status_t.

Function Usage

/* Scenario: There is a heart-shaped sign on an LCD glass: */
#define HEART (CY_SEGLCD_PIXEL(LCD_P11_6, 7UL)) /* Seg: P11_6, Com: 7 */
    /* Scenario: Read a pixel value, do some action with it and write it back into the frame */
    bool pixelValue = Cy_SegLCD_ReadPixel(LCD0, HEART);
    Cy_SegLCD_WritePixel(LCD0, HEART, !pixelValue);

Parameters
  • base: The base pointer to the LCD instance registers.

  • pixel: The predefined packed number that points to the pixel location in the frame buffer.

  • value: Specifies the pixel on/off state.

bool Cy_SegLCD_ReadPixel(LCD_Type *base, uint32_t pixel)

Gets the state of a specified pixel.

Return

Boolean pixel state. If pixel value is invalid - the ‘false’ is returned.

Function Usage

/* Scenario: There is a heart-shaped sign on an LCD glass: */
#define HEART (CY_SEGLCD_PIXEL(LCD_P11_6, 7UL)) /* Seg: P11_6, Com: 7 */
    /* Scenario: Read a pixel value, do some action with it and write it back into the frame */
    bool pixelValue = Cy_SegLCD_ReadPixel(LCD0, HEART);
    Cy_SegLCD_WritePixel(LCD0, HEART, !pixelValue);

Parameters
  • base: The base pointer to the LCD instance registers.

  • pixel: The predefined packed number that points to the pixel location in the frame buffer. Each pixel value should be made using CY_SEGLCD_PIXEL macro.

__STATIC_INLINE cy_en_seglcd_status_t Cy_SegLCD_SetPixel (LCD_Type *base, uint32_t pixel)

Sets (turns on) the specified pixel.

Return

cy_en_seglcd_status_t.

Function Usage

/* Scenario: There is a heart-shaped sign on an LCD glass: */
#define HEART (CY_SEGLCD_PIXEL(LCD_P11_6, 7UL)) /* Seg: P11_6, Com: 7 */
    /* Scenario: Set a pixel (write a true value) */
    if (CY_SEGLCD_SUCCESS != Cy_SegLCD_SetPixel(LCD0, HEART))
    {
        /* error handling */
    }

Parameters
  • base: The base pointer to the LCD instance registers.

  • pixel: The predefined packed number that points to the pixel location in the frame buffer.

__STATIC_INLINE cy_en_seglcd_status_t Cy_SegLCD_ClrPixel (LCD_Type *base, uint32_t pixel)

Clears (turns off) the specified pixel.

Return

cy_en_seglcd_status_t.

Function Usage

/* Scenario: There is a heart-shaped sign on an LCD glass: */
#define HEART (CY_SEGLCD_PIXEL(LCD_P11_6, 7UL)) /* Seg: P11_6, Com: 7 */
    /* Scenario: Clear a pixel (write a false value) */
    if (CY_SEGLCD_SUCCESS != Cy_SegLCD_ClrPixel(LCD0, HEART))
    {
        /* error handling */
    }

Parameters
  • base: The base pointer to the LCD instance registers.

  • pixel: The predefined packed number that points to the pixel location in the frame buffer.

__STATIC_INLINE cy_en_seglcd_status_t Cy_SegLCD_InvPixel (LCD_Type *base, uint32_t pixel)

Inverts the state of the specified pixel.

Return

cy_en_seglcd_status_t.

Function Usage

/* Scenario: There is a heart-shaped sign on an LCD glass: */
#define HEART (CY_SEGLCD_PIXEL(LCD_P11_6, 7UL)) /* Seg: P11_6, Com: 7 */
    /* Scenario: Invert a pixel (change the value to opposite) */
    Cy_SegLCD_InvPixel(LCD0, HEART);

Parameters
  • base: The base pointer to the LCD instance registers.

  • pixel: The predefined packed number that points to the pixel location in the frame buffer.