Digole Display Driver
Display driver for Digole Serial OLED/LCD displays
Defines | Functions
display

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

Detailed Description

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

Reference

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

Author:
James F Dougherty <[email protected]>

Define Documentation

#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

#define delay   ms_delay

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


Function Documentation

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.

Parameters:
xthe x position of the upper left hand corner
ythe yposition of the upper left hand corner
wthe width of the window
hthe 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.

Parameters:
[in]ddata 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.

Parameters:
[in]ddata 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.

Parameters:
[in]vwhen 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.

Parameters:
[in]mwhen 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

Parameters:
xthe x position of the upper left hand corner of the image
ythe y position of the upper left hand corner of the image
wthe width of the image
hthe height of the image
bitmapthe 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

Parameters:
xthe x position of the upper left hand corner of the image
ythe y position of the upper left hand corner of the image
wthe width of the image
hthe height of the image
bitmapthe 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.

Parameters:
[in]xthe x position
[in]ythe y position
[in]wthe width of the box
[in]hthe 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.

Parameters:
xthe x coordinate
ythe y coordinate
rthe radius (in pixels)
fwhether 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.

Parameters:
xthe x coordinate
ythe y coordinate
wthe width of the rectangle
hthe 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.

Parameters:
[in]xthe x position
[in]ythe y position
[in]sthe 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.

Parameters:
xthe starting x coordinate
ythe starting y coordinate
x1the ending x coordinate
y1the 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.

Parameters:
xthe x coordinate
ythe y coordinate
wthe 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.

Parameters:
xthe ending x coordinate
ythe 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.

Parameters:
[in]x0upper left hand x coordinate or region
[in]y0upper left hand y coordinate or region
[in]wwidth of region
[in]hheight of region
[in]xoffsetx displacement to move image
[in]yoffsety 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.

Parameters:
[in]vthe 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

Parameters:
[in]cthe 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.

Parameters:
[in]colthe number of columns
[in]rowsthe 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).

  • 0x55 - draws a dotted line (0b01010101)
  • 0xd7 - draws a dashed line (0b11010111)
Parameters:
[in]patternthe 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:

  1. '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.

  2. ‘|’ - OR the current foreground color with the existing pixel.
  3. ‘!’ - NOT - invert the color of the current pixel.
  4. ‘&’ - AND the current foreground color with the existing pixel.
  5. ‘^’ - XOR the current foreground color with the existing pixel.
  6. 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.

    Parameters:
    [in]mmode 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.

Parameters:
[in]xthe x position
[in]ythe y position
[in]graphwhen 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

Parameters:
[in]d- angle setting (one of the below)
  • 0 - unchanged
  • 1 - 90 degrees rotation
  • 2 - 180 degrees rotation
  • 3 - 270 degrees rotation
NOTE that this setting affects the display, not the currently defined drawing region.
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

Parameters:
[in]xoffsetdisplacement from 0-DISP_W
[in]yoffsetdisplacement 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.

Parameters:
[in]xoffsetdisplacement (positive or negative) in the x plane
[in]yoffsetdisplacement (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

Parameters:
rthe red component of the color (0-255)
gthe green component of the color (0-255)
bthe 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

Parameters:
colorthe 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.

Parameters:
fontthe 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.

Parameters:
xthe x coordinate
ythe y coordinate
colorthe 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

Parameters:
[in]lenthe length of the bitmap (accounting for display mode)
[in]datathe 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

Parameters:
lenthe length of the data
datathe address of the font data buffer
sectthe 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.

Parameters:
xthe x coordinate
ythe y coordinate
hthe 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).

Parameters:
[in]xthe top left x coordinate for where to draw the bitmap
[in]ythe top left y coordinate for where to draw the bitmap
[in]wthe width of the bitmap
[in]hthe height of the bitmap
[in]bitmapimage 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.

Parameters:
[in]usecsthe 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.

Parameters:
[in]usecsthe number of microseconds to sleep
 All Files Functions