|
Digole Display Driver
Display driver for Digole Serial OLED/LCD displays
|
Display Driver for Digole OLED Displays. More...
Defines | |
| #define | DISP_W (160) |
| #define | DISP_H (128) |
| #define | delay ms_delay |
| #define | INTERNAL_DELAY (800) |
| #define | USE_DIGOLE_SERIAL_SPI |
| #define | print(x) print_com(com_fd, (x)) |
| #define | preprint() print("TT") |
| #define | dd_set_rot90() print("SD1") |
| #define | dd_set_rot180() print("SD2") |
| #define | dd_set_rot_270() print("SD3") |
| #define | dd_undo_rot() print("SD0") |
Functions | |
| void | us_delay (unsigned int usecs) |
| microsecond delay | |
| void | ms_delay (unsigned int usecs) |
| millisecond delay | |
| void | dd_println (unsigned char *v) |
| Print a line of text. | |
| void | dd_disable_cursor (void) |
| Disable cursor. | |
| void | dd_enable_cursor (void) |
| Enable cursor. | |
| void | dd_draw_str (unsigned char x, unsigned char y, unsigned char *s) |
| Draw string. | |
| void | dd_set_printpos (unsigned char x, unsigned char y, unsigned char graph) |
| Setting Drawing Position. | |
| void | dd_clear_screen (void) |
| Clear Screen. | |
| void | dd_set_lcd_colrow (unsigned char col, unsigned char row) |
| Set number of columns and rows for text-mode. | |
| void | dd_display_config (unsigned char v) |
| Display the display configuration on boot. | |
| void | dd_display_startscreen (unsigned char m) |
| Display the start screen on power-up/boot. | |
| void | dd_set_mode (unsigned char m) |
| Set the Display Drawing Mode. | |
| void | dd_set_text_pos_back (void) |
| Set text position back one character (BS) | |
| void | dd_set_text_pos_offset (unsigned char xoffset, unsigned char yoffset) |
| Adjust the current text position by specified offset. | |
| void | dd_set_text_pos_abs (unsigned char x, unsigned char y) |
| Adjust the current text position to absolute offset. | |
| void | dd_set_line_pattern (unsigned char pattern) |
| Set the line pattern for line drawing operations. | |
| void | dd_digital_output (unsigned char x) |
| digital port output | |
| void | draw_bitmap (unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char *bitmap) |
| Draw monochrome bitmap. | |
| void | dd_set_rot (unsigned char d) |
| Set display rotation. | |
| void | dd_set_contrast (unsigned char c) |
| set the display contrast | |
| void | dd_draw_box (unsigned char x, unsigned char y, unsigned char w, unsigned char h) |
| draw a box | |
| void | dd_draw_circle (int8_t x, unsigned char y, unsigned char r, unsigned char f) |
| draw a circle | |
| void | dd_draw_frame (unsigned char x, unsigned char y, unsigned char w, unsigned char h) |
| draw a frame (rectangle) | |
| void | dd_setpixel (unsigned char x, unsigned char y, unsigned char color) |
| set a pixel a specified color | |
| void | dd_drawline (unsigned char x, unsigned char y, unsigned char x1, unsigned char y1) |
| draw a line | |
| void | dd_lineto (unsigned char x, unsigned char y) |
| draw a line from the current position to a new position | |
| void | dd_hline (unsigned char x, unsigned char y, unsigned char w) |
| draw a horizontal line at specified position and width | |
| void | dd_vline (unsigned char x, unsigned char y, unsigned char h) |
| draw a vertical line at specified position and height | |
| void | dd_next_text_line (void) |
| move text cursor to new line | |
| void | dd_setfont (unsigned char font) |
| set the font to be used from preloaded flash locations | |
| void | dd_setcolor (unsigned char color) |
| set the drawing color | |
| void | dd_setbgcolor (unsigned char color) |
| set the current color as the background color | |
| void | dd_backlight_on (void) |
| turn on backlight | |
| void | dd_backlight_off (void) |
| turn off backlight | |
| void | dd_set_screen_on (void) |
| turn on screen | |
| void | dd_set_screen_off (void) |
| turn off screen | |
| void | dd_direct_command (unsigned char d) |
| send direct command to display | |
| void | dd_direct_data (unsigned char d) |
| send direct data to display | |
| void | dd_move_area (unsigned char x0, unsigned char y0, unsigned char w, unsigned char h, unsigned char xoffset, unsigned char yoffset) |
| move screen memory area from one location to another | |
| void | dd_upload_start_screen (int lon, unsigned char *data) |
| download startup screen data to display controller | |
| void | dd_upload_user_font (int lon, unsigned char *data, unsigned char sect) |
| upload font data | |
| void | dd_draw_bitmap256 (unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char *bitmap) |
| draw a 256-color bitmap | |
| void | dd_draw_bitmap262K (unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char *bitmap) |
| draw a 262K-color bitmap | |
| void | dd_set_truecolor (unsigned char r, unsigned char g, unsigned char b) |
| set the drawing color in 24-bit mode | |
| void | dd_reset_draw_win (void) |
| reset the drawing window to full screen | |
| void | dd_clean_win (void) |
| clear drawing window | |
| void | dd_define_win (unsigned char x, unsigned char y, unsigned char h, unsigned char w) |
| define drawing window | |
Display Driver for Digole OLED Displays.
This module implements Text and Graphics functionality for the Digole Serial OLED Display modules made by Digole . Tested and verified with Digole 1.8" Serial: UART/I2C/SPI True Color OLED160x128 OLED Module DS160128COLED-46
See also: http://www.digole.com/index.php?productID=859
See also: http://www.digole.com//images/file/Tech_Data/Digole_Serial_Display_Adapter-Manual.pdf
| #define dd_set_rot180 | ( | ) | print("SD2") |
Rotate orientation of display 180 degrees
| #define dd_set_rot90 | ( | ) | print("SD1") |
Rotate orientation of display 90 degrees
| #define dd_undo_rot | ( | ) | print("SD0") |
Restore orientation of display rotation to normal defaults
delays for x milliseconds
This is the delay value needed for loading 262K color bmp
| #define DISP_H (128) |
screen height in pixels
| #define DISP_W (160) |
screen width in pixels
| #define INTERNAL_DELAY (800) |
Defined when using Serial or SPI communication interface on module
| #define print | ( | x | ) | print_com(com_fd, (x)) |
output string data x to display
| void dd_clean_win | ( | void | ) |
clear drawing window
This routine will clear the defined drawing window.
| void dd_clear_screen | ( | void | ) |
Clear Screen.
Clear display and present empty framebuffer
| void dd_define_win | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | h, | ||
| unsigned char | w | ||
| ) |
define drawing window
To facilitate drawing to separate regions of the display, this routine lets you define the active drawing window of the display. All coordinate accesses are bound to this region once it is defined.
| x | the x position of the upper left hand corner |
| y | the yposition of the upper left hand corner |
| w | the width of the window |
| h | the height of the window |
| void dd_digital_output | ( | unsigned char | x | ) |
digital port output
This command sends a byte out of the digital port. It is largely undocumented, the reference only says "Send a Byte to output head on board, the current driving ability for each pin is: 25mA (Sink/Source)"
| void dd_direct_command | ( | unsigned char | d | ) |
send direct command to display
Send a direct command to the display and bypass the display controller.
| [in] | d | data command byte to transmit |
| void dd_direct_data | ( | unsigned char | d | ) |
send direct data to display
Send direct data to the display and bypass the display controller.
| [in] | d | data byte to transmit |
| void dd_disable_cursor | ( | void | ) |
Disable cursor.
Disable the HW cursor
| void dd_display_config | ( | unsigned char | v | ) |
Display the display configuration on boot.
This is an enable/disable to show the OLED display configuration at power-up/boot.
| [in] | v | when non-zero, will program the controller to show display configuration on power-up/boot |
| void dd_display_startscreen | ( | unsigned char | m | ) |
Display the start screen on power-up/boot.
This is an enable/disable to show the start-up screen on boot. The start-up screen can be programmed to the display memory.
| [in] | m | when non-zero, will program the controller to show startup screen on power-up/boot. |
| void dd_draw_bitmap256 | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | w, | ||
| unsigned char | h, | ||
| unsigned char * | bitmap | ||
| ) |
draw a 256-color bitmap
This routine will render a 256-color bitmap of the specified width and height to the specified location
| x | the x position of the upper left hand corner of the image |
| y | the y position of the upper left hand corner of the image |
| w | the width of the image |
| h | the height of the image |
| bitmap | the address of the bitmap data in memory, each byte is a pixel |
This routine handles 1-byte per pixel (256 color indexed palette) format bitmaps.
There are online conversion utilities available here to convert the data.
| void dd_draw_bitmap262K | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | w, | ||
| unsigned char | h, | ||
| unsigned char * | bitmap | ||
| ) |
draw a 262K-color bitmap
This routine will render a 262K-color bitmap of the specified width and height to the specified location
| x | the x position of the upper left hand corner of the image |
| y | the y position of the upper left hand corner of the image |
| w | the width of the image |
| h | the height of the image |
| bitmap | the address of the bitmap data in memory, every 3 bytes represents on pixel value |
This routine handles 3-byte per pixel format bitmaps.
There are online conversion utilities available here to convert the data.
| void dd_draw_box | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | w, | ||
| unsigned char | h | ||
| ) |
draw a box
This command draws a filled rectangle at the specified x,y coordinate with the specified width and height. The current drawing color is used to draw the box.
| [in] | x | the x position |
| [in] | y | the y position |
| [in] | w | the width of the box |
| [in] | h | the height of the box |
| void dd_draw_circle | ( | int8_t | x, |
| unsigned char | y, | ||
| unsigned char | r, | ||
| unsigned char | f | ||
| ) |
draw a circle
Draws a circle (optionally) filled at specified x,y coordinate with specified radius.
| x | the x coordinate |
| y | the y coordinate |
| r | the radius (in pixels) |
| f | whether to fill with foreground (current drawing) color |
| void dd_draw_frame | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | w, | ||
| unsigned char | h | ||
| ) |
draw a frame (rectangle)
This routine will draw a rectangle at the specified x,y coordinate with the specified width and height.
| x | the x coordinate |
| y | the y coordinate |
| w | the width of the rectangle |
| h | the height of the rectangle |
| void dd_draw_str | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char * | s | ||
| ) |
Draw string.
Draws a string at specified x/y location where (0,0) is the origin and the display framebuffer extends to (DISP_W,DISP_H). Note that the display will require different values for x/y to offset depending on which font is loaded.
| [in] | x | the x position |
| [in] | y | the y position |
| [in] | s | the string to display |
| void dd_drawline | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | x1, | ||
| unsigned char | y1 | ||
| ) |
draw a line
This routine will draw a line from x,y to x1,y1 using the currently specified color and graphics position. When the line is done drawing the current graphics position is updated to x1,y1.
| x | the starting x coordinate |
| y | the starting y coordinate |
| x1 | the ending x coordinate |
| y1 | the ending y coordinate |
| void dd_enable_cursor | ( | void | ) |
Enable cursor.
Enable the HW cursor
| void dd_hline | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | w | ||
| ) | [inline] |
draw a horizontal line at specified position and width
This routine will draw a horizontal line from the specified position using the specified width. When the line is done drawing the current graphics position is updated to x+w,y.
| x | the x coordinate |
| y | the y coordinate |
| w | the width of the line |
| void dd_lineto | ( | unsigned char | x, |
| unsigned char | y | ||
| ) |
draw a line from the current position to a new position
This routine will draw a line from the current position (last graphics position x,y) to a new position using the currently specified color. When the line is done drawing the current graphics position is updated to x1,y1.
| x | the ending x coordinate |
| y | the ending y coordinate |
| void dd_move_area | ( | unsigned char | x0, |
| unsigned char | y0, | ||
| unsigned char | w, | ||
| unsigned char | h, | ||
| unsigned char | xoffset, | ||
| unsigned char | yoffset | ||
| ) |
move screen memory area from one location to another
This command emulates a bit block transfer function to move display pixels from one area of the display memory to another.
| [in] | x0 | upper left hand x coordinate or region |
| [in] | y0 | upper left hand y coordinate or region |
| [in] | w | width of region |
| [in] | h | height of region |
| [in] | xoffset | x displacement to move image |
| [in] | yoffset | y displacement to move image |
| void dd_next_text_line | ( | void | ) |
move text cursor to new line
This routine moves the text cursor to the next printable line
| void dd_println | ( | unsigned char * | v | ) |
Print a line of text.
Print one line of null-terminated text. The current cursor position is automatically advanced to the next location.
| [in] | v | the string to output |
| void dd_reset_draw_win | ( | void | ) |
reset the drawing window to full screen
This routine will reset the drawing window to full screen mode.
| void dd_set_contrast | ( | unsigned char | c | ) |
set the display contrast
This command sets the display contrast but is only supported on displays which have the ST7565 LCD Controller
| [in] | c | the contrast value (0-255) |
| void dd_set_lcd_colrow | ( | unsigned char | col, |
| unsigned char | row | ||
| ) |
Set number of columns and rows for text-mode.
This routine will configure the universal character LCD adapter with the STCR command. Note that this routine is not needed for normal operational mode.
| [in] | col | the number of columns |
| [in] | rows | the number of rows |
| void dd_set_line_pattern | ( | unsigned char | pattern | ) |
Set the line pattern for line drawing operations.
This command allows you to specify a byte which represents a bitmask for drawing operations to affect the line drawing style. When line-drawing operations are performed, the display controller will repeat every 8 bits represented in the line pattern to allow programming a configurable dotted or dashed line style (the internal operation is an AND function as bits which are zero will not be displayed).
| [in] | pattern | the byte value representing the bitmap |
| void dd_set_mode | ( | unsigned char | m | ) |
Set the Display Drawing Mode.
This is a command (DM) to the display controller which takes a single byte specifying the drawing mode. The command byte is defined as only the following letters {C,|,!,~,&,^}. Where the meaning of the drawing mode is defined as one of the 6 modes available defined below:
'C'- Copy mode, it doesn’t matter what pixels exist on the screen;this mode uses the current foreground color to over write the pixel. For text displayed in any variant of the TT command, it will also clear the character box to the background color. Note that all other modes will not clear the character box.
ANY - Note that using any other letter will default to over-write mode (like 'C') except the character box will not be cleared when using text commands via the TT command. This is recommended to display text on a picture.
| [in] | m | mode character as described above |
| void dd_set_printpos | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | graph | ||
| ) |
Setting Drawing Position.
Set the current drawing position for text or graphics mode. When resetting both the graphics and text drawing positions this routine should be called twice, once for graphics and another time for text.
| [in] | x | the x position |
| [in] | y | the y position |
| [in] | graph | when non-zero will reset the graphics drawing position, otherwise the text drawing position will be modified. |
| void dd_set_rot | ( | unsigned char | d | ) |
Set display rotation.
Set's the display rotation to one of the four specified angles
| [in] | d | - angle setting (one of the below)
|
| void dd_set_text_pos_abs | ( | unsigned char | x, |
| unsigned char | y | ||
| ) |
Adjust the current text position to absolute offset.
Move HW text cursor to the the specified x/y offsets
| [in] | xoffset | displacement from 0-DISP_W |
| [in] | yoffset | displacement from 0-DIP_H |
| void dd_set_text_pos_back | ( | void | ) |
Set text position back one character (BS)
This virtual backspace allows you to repeatedly update one character
| void dd_set_text_pos_offset | ( | unsigned char | xoffset, |
| unsigned char | yoffset | ||
| ) |
Adjust the current text position by specified offset.
This command will add the specified x/y offsets to the controllers internal HW cursor position to adjust the cursor position by the specified offsets.
| [in] | xoffset | displacement (positive or negative) in the x plane |
| [in] | yoffset | displacement (positive or negative) in the y plane |
| void dd_set_truecolor | ( | unsigned char | r, |
| unsigned char | g, | ||
| unsigned char | b | ||
| ) |
set the drawing color in 24-bit mode
This routine sets the current drawing color in 24bpp mode
| r | the red component of the color (0-255) |
| g | the green component of the color (0-255) |
| b | the blue component of the color (0-255) |
| void dd_setbgcolor | ( | unsigned char | color | ) |
set the current color as the background color
This routine will set the current (foreground) color to the background color.
The color table is defined as below for 255 (indexed) color mode and can be found here
| color | the color to set |
| void dd_setcolor | ( | unsigned char | color | ) |
set the drawing color
This routine will set the color (0/1) for monochrome or (0-255) for color displays.
The color table is defined as below for 255 (indexed) color mode and can be found here
| void dd_setfont | ( | unsigned char | font | ) |
set the font to be used from preloaded flash locations
This routine sets which character set should be loaded from the Character graphics ram (CGRAM). The RAM is implemented as FLASH and font graphics can be saved into user defined regions.
| font | the font to use -preloaded font #'s are(6,10,18,51,120,123, and 0(default)); user font #'s are (200,201,202,203) maps to 4 user fonts |
| void dd_setpixel | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | color | ||
| ) |
set a pixel a specified color
This routine sets a pixel at the provided x,y coordinate to the specified color value.
| x | the x coordinate |
| y | the y coordinate |
| color | the color value |
| void dd_upload_start_screen | ( | int | len, |
| unsigned char * | data | ||
| ) |
download startup screen data to display controller
Upload display bitmap for startup screen
| [in] | len | the length of the bitmap (accounting for display mode) |
| [in] | data | the address of the data buffer |
| void dd_upload_user_font | ( | int | len, |
| unsigned char * | data, | ||
| unsigned char | sect | ||
| ) |
upload font data
This routine allows for updating the font data onboard CGRAM
| len | the length of the data |
| data | the address of the font data buffer |
| sect | the section of memory to update |
| void dd_vline | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | h | ||
| ) | [inline] |
draw a vertical line at specified position and height
This routine will draw a vertical line from the specified position using the specified height. When the line is done drawing the current graphics position is updated to x,y+h.
| x | the x coordinate |
| y | the y coordinate |
| h | the height of the line |
| void draw_bitmap | ( | unsigned char | x, |
| unsigned char | y, | ||
| unsigned char | w, | ||
| unsigned char | h, | ||
| unsigned char * | bitmap | ||
| ) |
Draw monochrome bitmap.
This routine draws a black & white image at the specified x,y coordinates. Note that the image is represented in 1bpp format and is affected by the foreground color and drawing mode (e.g. you can set a different foreground color before drawing and make a different color image).
| [in] | x | the top left x coordinate for where to draw the bitmap |
| [in] | y | the top left y coordinate for where to draw the bitmap |
| [in] | w | the width of the bitmap |
| [in] | h | the height of the bitmap |
| [in] | bitmap | image data (...d...), each bit represent a pixel in the image. Data in one byte can’t cross different lines, that means, if the width of image is 12 pixels, you need 2 bytes for each line. The MSB is on the left side. |
NOTE: the current graphics HW cursor positin (CGP) is unchanged.
| void ms_delay | ( | unsigned int | usecs | ) |
millisecond delay
Delay specified number of milliseconds, the processor will wait this amount of time before continuing execution.
| [in] | usecs | the number of milliseconds to sleep |
| void us_delay | ( | unsigned int | usecs | ) |
microsecond delay
Delay specified number of microseconds, the processor will wait this amount of time before continuing execution.
| [in] | usecs | the number of microseconds to sleep |
1.7.6.1