LCD#

The display of the calculator is a 400 (width) by 240 (height) LCD. The hardware abstraction layer provides functions to draw a filled rectangle and to manipulate individual pixels. On a simulator these should only modify the contents of the LCD part of the simulator (which should still be 400 by 240). All functions use the origin at the top left.

Functions#

LCD related functions.

Defines

LCD_SET_VALUE#
LCD_EMPTY_VALUE#

Functions

void lcd_fill_rect(uint32_t x, uint32_t y, uint32_t dx, uint32_t dy, int val)#

Fills a rectangle with either black or white.

Parameters
  • x[in] x coordinate from 0 (left) to 399 (right)

  • y[in] y coordinate from 0 (top) to 239 (bottom)

  • dx[in] width of the rect (inclusive of the ends)

  • dy[in] height of the rect (inclusive of the ends)

  • val[in] LCD_SET_VALUE (black) or LCD_EMPTY_VALUE (white) for the filled rectangle

void lcd_refresh(void)#

Refresh the LCD with the draw buffer contents.

void setBlackPixel(uint32_t x, uint32_t y)#

Sets a single black pixel on the screen.

Parameters
  • x[in] x coordinate from 0 (left) to 399 (right)

  • y[in] y coordinate from 0 (top) to 239 (bottom)

void setWhitePixel(uint32_t x, uint32_t y)#

Sets a single white pixel on the screen.

Parameters
  • x[in] x coordinate from 0 (left) to 399 (right)

  • y[in] y coordinate from 0 (top) to 239 (bottom)

void flipPixel(uint32_t x, uint32_t y)#

Turns a single black pixel to a white pixel or vice versa on the screen.

Parameters
  • x[in] x coordinate from 0 (left) to 399 (right)

  • y[in] y coordinate from 0 (top) to 239 (bottom)

Example#

LCD operations update the contents of the screen such that the latest operation “wins”. You can draw on top of previous state and the state remains until changed.

// draw a black 20x20 rectangle starting offset just from the top right
lcd_fill_rect(20, 20, 20, 20, LCD_SET_VALUE);
// draw a white 10x10 rectangle inside this
lcd_fill_rect(30, 30, 10, 10, LCD_EMPTY_VALUE);