Library for drawing on the Hexiwear's OLED - more features being actively worked on

Dependents:   Hexidraw_Demo Hexiwear-FinalProject_v2

Discussion: https://developer.mbed.org/forum/team-4615-Hexiwear-community/topic/26595/

Hexidraw is a library for drawing on the Hexiwear's OLED. Be aware that it is not very optimized, so drawing may be slow, especially when drawing on large areas of the screen.

Please see the wiki for API documentation.

Features:

  • Screen fill with a color
  • Drawing filled rectangles
  • Drawing circles with a set radius and line width
  • Setting individual pixels
  • Turning on and off the OLED's sleep mode
  • Drawing images

Example project: https://developer.mbed.org/users/keithm01/code/Hexidraw_Demo/

Committer:
keithm01
Date:
Sat Aug 20 16:35:58 2016 +0000
Revision:
5:00876457cad4
Parent:
2:ef14c6dd6b93
Changed default value to not using the buffer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
keithm01 1:82ccc138bbe6 1
keithm01 1:82ccc138bbe6 2
keithm01 0:2d3fcb6dabd4 3 /* REMAP settings */
keithm01 2:ef14c6dd6b93 4 //Can be used for transition settings
keithm01 0:2d3fcb6dabd4 5 #define REMAP_HORIZONTAL_INCREMENT ( 0 )
keithm01 0:2d3fcb6dabd4 6 #define REMAP_VERTICAL_INCREMENT ( 1 << 0 )
keithm01 0:2d3fcb6dabd4 7
keithm01 0:2d3fcb6dabd4 8 #define REMAP_COLUMNS_LEFT_TO_RIGHT ( 0 )
keithm01 0:2d3fcb6dabd4 9 #define REMAP_COLUMNS_RIGHT_TO_LEFT ( 1 << 1 )
keithm01 0:2d3fcb6dabd4 10
keithm01 2:ef14c6dd6b93 11 //rgb or bgr
keithm01 0:2d3fcb6dabd4 12 #define REMAP_ORDER_ABC ( 0 )
keithm01 0:2d3fcb6dabd4 13 #define REMAP_ORDER_CBA ( 1 << 2 )
keithm01 0:2d3fcb6dabd4 14
keithm01 0:2d3fcb6dabd4 15 #define REMAP_SCAN_UP_TO_DOWN ( 0 )
keithm01 0:2d3fcb6dabd4 16 #define REMAP_SCAN_DOWN_TO_UP ( 1 << 4 )
keithm01 0:2d3fcb6dabd4 17
keithm01 0:2d3fcb6dabd4 18 #define REMAP_COM_SPLIT_ODD_EVEN_DIS ( 0 )
keithm01 0:2d3fcb6dabd4 19 #define REMAP_COM_SPLIT_ODD_EVEN_EN ( 1 << 5 )
keithm01 0:2d3fcb6dabd4 20
keithm01 0:2d3fcb6dabd4 21 #define REMAP_COLOR_RGB565 ( 1 << 6 )
keithm01 0:2d3fcb6dabd4 22
keithm01 0:2d3fcb6dabd4 23 #define OLED_REMAP_SETTINGS ( REMAP_ORDER_ABC | REMAP_COM_SPLIT_ODD_EVEN_EN | REMAP_COLOR_RGB565 | REMAP_COLUMNS_LEFT_TO_RIGHT | REMAP_SCAN_UP_TO_DOWN | REMAP_HORIZONTAL_INCREMENT )
keithm01 0:2d3fcb6dabd4 24
keithm01 0:2d3fcb6dabd4 25 /* ./REMAP settings */
keithm01 0:2d3fcb6dabd4 26
keithm01 0:2d3fcb6dabd4 27 /* Command Lock */
keithm01 0:2d3fcb6dabd4 28
keithm01 0:2d3fcb6dabd4 29 /**
keithm01 0:2d3fcb6dabd4 30 * set lock command
keithm01 0:2d3fcb6dabd4 31 * the locked OLED driver MCU interface prohibits all commands
keithm01 0:2d3fcb6dabd4 32 * and memory access, except the 0xFD command
keithm01 0:2d3fcb6dabd4 33 */
keithm01 0:2d3fcb6dabd4 34 #define OLED_CMD_SET_CMD_LOCK ( 0xFD /* << 8 */ )
keithm01 0:2d3fcb6dabd4 35 // unlock OLED driver MCU interface for entering command (default upon reset)
keithm01 0:2d3fcb6dabd4 36 #define OLED_UNLOCK (0x12)
keithm01 0:2d3fcb6dabd4 37 // lock OLED driver MCU interface for entering command
keithm01 0:2d3fcb6dabd4 38 #define OLED_LOCK (0x16)
keithm01 0:2d3fcb6dabd4 39 // commands 0xA2, 0xB1, 0xB3, 0xBB, 0xBE, 0xC1 are inaccessible in both lock and unlock state (default upon reset)
keithm01 0:2d3fcb6dabd4 40 #define OLED_ACC_TO_CMD_NO (0xB0)
keithm01 0:2d3fcb6dabd4 41 // commands 0xA2, 0xB1, 0xB3, 0xBB, 0xBE, 0xC1 are accessible in unlock state
keithm01 0:2d3fcb6dabd4 42 #define OLED_ACC_TO_CMD_YES (0xB1)
keithm01 0:2d3fcb6dabd4 43
keithm01 0:2d3fcb6dabd4 44 /* ./Command Lock */
keithm01 0:2d3fcb6dabd4 45
keithm01 0:2d3fcb6dabd4 46 // Timing Delays
keithm01 0:2d3fcb6dabd4 47 #define SSD1351_DELAYS_HWFILL (3)
keithm01 0:2d3fcb6dabd4 48 #define SSD1351_DELAYS_HWLINE (1)
keithm01 0:2d3fcb6dabd4 49
keithm01 0:2d3fcb6dabd4 50
keithm01 0:2d3fcb6dabd4 51 #define OLED_CMD_SET_COLUMN ( 0x15 )
keithm01 0:2d3fcb6dabd4 52 #define OLED_CMD_SET_ROW ( 0x75 )
keithm01 0:2d3fcb6dabd4 53
keithm01 0:2d3fcb6dabd4 54 #define OLED_CMD_SET_MUX_RATIO (0xCA)
keithm01 0:2d3fcb6dabd4 55
keithm01 0:2d3fcb6dabd4 56 #define OLED_CMD_SET_REMAP ( 0xA0 )
keithm01 0:2d3fcb6dabd4 57
keithm01 0:2d3fcb6dabd4 58 #define OLED_CMD_SET_OSC_FREQ_AND_CLOCKDIV (0xB3)
keithm01 0:2d3fcb6dabd4 59
keithm01 0:2d3fcb6dabd4 60 #define OLED_CMD_STARTLINE (0xA1)
keithm01 0:2d3fcb6dabd4 61
keithm01 0:2d3fcb6dabd4 62 #define OLED_CMD_WRITERAM (0x5C)
keithm01 0:2d3fcb6dabd4 63 //#define OLED_CMD_READRAM (0x5D)
keithm01 0:2d3fcb6dabd4 64 #define OLED_CMD_DISPLAYOFFSET (0xA2)
keithm01 0:2d3fcb6dabd4 65 //#define OLED_CMD_DISPLAYALLOFF (0xA4)
keithm01 0:2d3fcb6dabd4 66 //#define OLED_CMD_DISPLAYALLON (0xA5)
keithm01 0:2d3fcb6dabd4 67 #define OLED_CMD_NORMALDISPLAY (0xA6)
keithm01 0:2d3fcb6dabd4 68 #define OLED_CMD_INVERTDISPLAY (0xA7)
keithm01 0:2d3fcb6dabd4 69 //#define OLED_CMD_FUNCTIONSELECT (0xAB)
keithm01 0:2d3fcb6dabd4 70 #define OLED_CMD_DISPLAYOFF (0xAE)
keithm01 0:2d3fcb6dabd4 71 #define OLED_CMD_DISPLAYON (0xAF)
keithm01 0:2d3fcb6dabd4 72 #define OLED_CMD_PRECHARGE (0xB1)
keithm01 0:2d3fcb6dabd4 73 //#define OLED_CMD_DISPLAYENHANCE (0xB2)
keithm01 0:2d3fcb6dabd4 74 #define OLED_CMD_SETVSL (0xB4)
keithm01 0:2d3fcb6dabd4 75 //#define OLED_CMD_SETGPIO (0xB5)
keithm01 0:2d3fcb6dabd4 76 #define OLED_CMD_PRECHARGE2 (0xB6)
keithm01 0:2d3fcb6dabd4 77 //#define OLED_CMD_SETGRAY (0xB8)
keithm01 0:2d3fcb6dabd4 78 //#define OLED_CMD_USELUT (0xB9)
keithm01 0:2d3fcb6dabd4 79 #define OLED_CMD_PRECHARGELEVEL (0xBB)
keithm01 0:2d3fcb6dabd4 80 #define OLED_CMD_VCOMH (0xBE)
keithm01 0:2d3fcb6dabd4 81 #define OLED_CMD_CONTRASTABC (0xC1)
keithm01 0:2d3fcb6dabd4 82 #define OLED_CMD_CONTRASTMASTER (0xC7)
keithm01 0:2d3fcb6dabd4 83 #define OLED_CMD_MUXRATIO (0xCA)
keithm01 0:2d3fcb6dabd4 84 #define OLED_CMD_COMMANDLOCK (0xFD)
keithm01 0:2d3fcb6dabd4 85 //#define OLED_CMD_HORIZSCROLL (0x96)
keithm01 0:2d3fcb6dabd4 86 //#define OLED_CMD_STOPSCROLL (0x9E)
keithm01 0:2d3fcb6dabd4 87 //#define OLED_CMD_STARTSCROLL (0x9F)
keithm01 0:2d3fcb6dabd4 88
keithm01 0:2d3fcb6dabd4 89 #define oled_dc_pin PTD15 //Data
keithm01 0:2d3fcb6dabd4 90 #define oled_rst_pin PTE6 //Reset
keithm01 0:2d3fcb6dabd4 91 #define oled_cs_pin PTB20 //Chip Select
keithm01 0:2d3fcb6dabd4 92 #define oled_sck_pin PTB21 //Serial Clock
keithm01 0:2d3fcb6dabd4 93 #define oled_sdi_pin PTB22 //MOSI
keithm01 0:2d3fcb6dabd4 94
keithm01 0:2d3fcb6dabd4 95 #define oled_power_enable PTC13 //Power enable