Added display API function to set LCD contrast
This commit is contained in:
parent
e49c6e036c
commit
92870f477f
|
|
@ -48,7 +48,7 @@
|
||||||
*
|
*
|
||||||
* NOTE: framebuffer allocation is the first operation performed, if fails an
|
* NOTE: framebuffer allocation is the first operation performed, if fails an
|
||||||
* error message is printed on the virtual COM port and this function returns
|
* error message is printed on the virtual COM port and this function returns
|
||||||
* prematurely, without configuring the display.
|
* prematurely, without configuring the display.
|
||||||
* Thus, a dark screen can be symptom of failed allocation.
|
* Thus, a dark screen can be symptom of failed allocation.
|
||||||
*/
|
*/
|
||||||
void display_init();
|
void display_init();
|
||||||
|
|
@ -61,7 +61,7 @@ void display_init();
|
||||||
* Changes to the framebuffer will not be reflected on the display until
|
* Changes to the framebuffer will not be reflected on the display until
|
||||||
* display_render() or display_renderRows() are called.
|
* display_render() or display_renderRows() are called.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* WARNING: no bound check is performed! Do not call free() on the pointer
|
* WARNING: no bound check is performed! Do not call free() on the pointer
|
||||||
* returned, doing so will destroy the framebuffer!
|
* returned, doing so will destroy the framebuffer!
|
||||||
* @return pointer to framebuffer.
|
* @return pointer to framebuffer.
|
||||||
|
|
@ -69,7 +69,7 @@ void display_init();
|
||||||
void *display_getFrameBuffer();
|
void *display_getFrameBuffer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When called, this function terminates the display driver
|
* When called, this function terminates the display driver
|
||||||
* and deallocates the framebuffer.
|
* and deallocates the framebuffer.
|
||||||
*/
|
*/
|
||||||
void display_terminate();
|
void display_terminate();
|
||||||
|
|
@ -96,4 +96,12 @@ void display_render();
|
||||||
*/
|
*/
|
||||||
bool display_renderingInProgress();
|
bool display_renderingInProgress();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set display contrast.
|
||||||
|
* NOTE: not all the display controllers support contrast control, thus on some
|
||||||
|
* targets this function has no effect.
|
||||||
|
* @param contrast: display contrast, normalised value with range 0 - 255.
|
||||||
|
*/
|
||||||
|
void display_setContrast(uint8_t contrast);
|
||||||
|
|
||||||
#endif /* DISPLAY_H */
|
#endif /* DISPLAY_H */
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ void display_renderRows(uint8_t startRow, uint8_t endRow)
|
||||||
* this one is made of 16 bit variables.
|
* this one is made of 16 bit variables.
|
||||||
*/
|
*/
|
||||||
DMA2_Stream7->NDTR = (endRow - startRow) * SCREEN_WIDTH * sizeof(uint16_t);
|
DMA2_Stream7->NDTR = (endRow - startRow) * SCREEN_WIDTH * sizeof(uint16_t);
|
||||||
DMA2_Stream7->PAR = ((uint32_t ) frameBuffer + (startRow * SCREEN_WIDTH
|
DMA2_Stream7->PAR = ((uint32_t ) frameBuffer + (startRow * SCREEN_WIDTH
|
||||||
* sizeof(uint16_t)));
|
* sizeof(uint16_t)));
|
||||||
DMA2_Stream7->M0AR = LCD_FSMC_ADDR_DATA;
|
DMA2_Stream7->M0AR = LCD_FSMC_ADDR_DATA;
|
||||||
DMA2_Stream7->CR = DMA_SxCR_CHSEL /* Channel 7 */
|
DMA2_Stream7->CR = DMA_SxCR_CHSEL /* Channel 7 */
|
||||||
|
|
@ -418,3 +418,9 @@ void *display_getFrameBuffer()
|
||||||
{
|
{
|
||||||
return (void *)(frameBuffer);
|
return (void *)(frameBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void display_setContrast(uint8_t contrast)
|
||||||
|
{
|
||||||
|
/* This controller does not support contrast regulation */
|
||||||
|
(void) contrast;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,9 @@ void display_init()
|
||||||
gpio_clearPin(LCD_CS);
|
gpio_clearPin(LCD_CS);
|
||||||
|
|
||||||
gpio_clearPin(LCD_RS); /* RS low -> command mode */
|
gpio_clearPin(LCD_RS); /* RS low -> command mode */
|
||||||
// sendByteToController(0xE2); /* System Reset */
|
|
||||||
sendByteToController(0x2F); /* Voltage Follower On */
|
sendByteToController(0x2F); /* Voltage Follower On */
|
||||||
sendByteToController(0x81); /* Set Electronic Volume = 15 */
|
sendByteToController(0x81); /* Set Electronic Volume */
|
||||||
/* TODO variable contrast */
|
sendByteToController(0x15); /* Contrast, initial setting */
|
||||||
sendByteToController(0x15); /* Contrast */
|
|
||||||
sendByteToController(0xA2); /* Set Bias = 1/9 */
|
sendByteToController(0xA2); /* Set Bias = 1/9 */
|
||||||
sendByteToController(0xA1); /* A0 Set SEG Direction */
|
sendByteToController(0xA1); /* A0 Set SEG Direction */
|
||||||
sendByteToController(0xC0); /* Set COM Direction */
|
sendByteToController(0xC0); /* Set COM Direction */
|
||||||
|
|
@ -130,7 +128,9 @@ void display_renderRow(uint8_t row)
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (uint8_t s = 0; s < 8; s++){
|
|
||||||
|
for (uint8_t s = 0; s < 8; s++)
|
||||||
|
{
|
||||||
sendByteToController(tmp[s]);
|
sendByteToController(tmp[s]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ void display_renderRow(uint8_t row)
|
||||||
|
|
||||||
void display_renderRows(uint8_t startRow, uint8_t endRow)
|
void display_renderRows(uint8_t startRow, uint8_t endRow)
|
||||||
{
|
{
|
||||||
for(uint8_t row = startRow; row < endRow; row++)
|
for(uint8_t row = startRow; row < endRow; row++)
|
||||||
{
|
{
|
||||||
gpio_clearPin(LCD_RS); /* RS low -> command mode */
|
gpio_clearPin(LCD_RS); /* RS low -> command mode */
|
||||||
sendByteToController(0xB0 | row); /* Set Y position */
|
sendByteToController(0xB0 | row); /* Set Y position */
|
||||||
|
|
@ -147,7 +147,7 @@ void display_renderRows(uint8_t startRow, uint8_t endRow)
|
||||||
gpio_setPin(LCD_RS); /* RS high -> data mode */
|
gpio_setPin(LCD_RS); /* RS high -> data mode */
|
||||||
display_renderRow(row);
|
display_renderRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_render()
|
void display_render()
|
||||||
|
|
@ -166,3 +166,10 @@ void *display_getFrameBuffer()
|
||||||
{
|
{
|
||||||
return (void *)(frameBuffer);
|
return (void *)(frameBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void display_setContrast(uint8_t contrast)
|
||||||
|
{
|
||||||
|
gpio_clearPin(LCD_RS); /* RS low -> command mode */
|
||||||
|
sendByteToController(0x81); /* Set Electronic Volume */
|
||||||
|
sendByteToController(contrast >> 2); /* Controller contrast range is 0 - 63 */
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -196,3 +196,9 @@ void *display_getFrameBuffer()
|
||||||
{
|
{
|
||||||
return (void *) (frameBuffer);
|
return (void *) (frameBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void display_setContrast(uint8_t contrast)
|
||||||
|
{
|
||||||
|
printf("Setting display contrast to %d\n", contrast);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue