PSoC 6 Peripheral Driver Library
Frame/Pixel Management Functions

General Description

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. More...
 
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). More...
 
cy_en_seglcd_status_t Cy_SegLCD_WritePixel (LCD_Type *base, uint32_t pixel, bool value)
 Sets or clears a specified pixel. More...
 
bool Cy_SegLCD_ReadPixel (LCD_Type *base, uint32_t pixel)
 Gets the state of a specified pixel. More...
 
__STATIC_INLINE cy_en_seglcd_status_t Cy_SegLCD_SetPixel (LCD_Type *base, uint32_t pixel)
 Sets (turns on) the specified pixel. More...
 
__STATIC_INLINE cy_en_seglcd_status_t Cy_SegLCD_ClrPixel (LCD_Type *base, uint32_t pixel)
 Clears (turns off) the specified pixel. More...
 
__STATIC_INLINE cy_en_seglcd_status_t Cy_SegLCD_InvPixel (LCD_Type *base, uint32_t pixel)
 Inverts the state of the specified pixel. More...
 

Function Documentation

◆ Cy_SegLCD_ClrFrame()

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.

Parameters
baseThe base pointer to the LCD instance registers.
commonsThe 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.
Returns
cy_en_seglcd_status_t.
Function Usage
/* Scenario: Enable an LCD block */
{
.drive = CY_SEGLCD_PWM,
.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 */
if (CY_SEGLCD_SUCCESS == Cy_SegLCD_Init(LCD0, &config))
{
if (CY_SEGLCD_SUCCESS == Cy_SegLCD_ClrFrame(LCD0, commons))
{
/* 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 */
}

◆ Cy_SegLCD_InvFrame()

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).

Parameters
baseThe base pointer to the LCD instance registers.
commonsThe 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.
Returns
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;

◆ Cy_SegLCD_WritePixel()

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

Sets or clears a specified pixel.

Parameters
baseThe base pointer to the LCD instance registers.
pixelThe predefined packed number that points to the pixel location in the frame buffer.
valueSpecifies the pixel on/off state.
Returns
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);

◆ Cy_SegLCD_ReadPixel()

bool Cy_SegLCD_ReadPixel ( LCD_Type *  base,
uint32_t  pixel 
)

Gets the state of a specified pixel.

Parameters
baseThe base pointer to the LCD instance registers.
pixelThe predefined packed number that points to the pixel location in the frame buffer. Each pixel value should be made using CY_SEGLCD_PIXEL macro.
Returns
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);

◆ Cy_SegLCD_SetPixel()

__STATIC_INLINE cy_en_seglcd_status_t Cy_SegLCD_SetPixel ( LCD_Type *  base,
uint32_t  pixel 
)

Sets (turns on) the specified pixel.

Parameters
baseThe base pointer to the LCD instance registers.
pixelThe predefined packed number that points to the pixel location in the frame buffer.
Returns
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) */
{
/* error handling */
}

◆ Cy_SegLCD_ClrPixel()

__STATIC_INLINE cy_en_seglcd_status_t Cy_SegLCD_ClrPixel ( LCD_Type *  base,
uint32_t  pixel 
)

Clears (turns off) the specified pixel.

Parameters
baseThe base pointer to the LCD instance registers.
pixelThe predefined packed number that points to the pixel location in the frame buffer.
Returns
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) */
{
/* error handling */
}

◆ Cy_SegLCD_InvPixel()

__STATIC_INLINE cy_en_seglcd_status_t Cy_SegLCD_InvPixel ( LCD_Type *  base,
uint32_t  pixel 
)

Inverts the state of the specified pixel.

Parameters
baseThe base pointer to the LCD instance registers.
pixelThe predefined packed number that points to the pixel location in the frame buffer.
Returns
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);