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/

hexidraw.h

Committer:
keithm01
Date:
2016-08-19
Revision:
0:2d3fcb6dabd4
Child:
1:82ccc138bbe6

File content as of revision 0:2d3fcb6dabd4:


#ifndef _HEXIDRAW_H_
#define _HEXIDRAW_H_

    #include <mbed.h>
    #include <stdarg.h>
    
    #include "oled_info.h"
    
    #define BLACK 0x0000
    #define WHITE 0xffff
    
    /* borrowed from the Adafruit library at:
        https://developer.mbed.org/teams/ELLA-Robotics-Inc/code/Adafruit_GFX_1351/ 
       Since I don't know enough to make my own function :) */
    uint16_t Color565(uint8_t r, uint8_t g, uint8_t b) ;
    
    class OLED {
        public:
            OLED();
            void writeCommand(uint8_t v);
            void writeData(uint8_t v);
            void begin();
            void sleep();
            void wake();
            void pixel(int16_t x, int16_t y, uint16_t color);
            void cursor(int x, int y);
            void rect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t fillcolor);
        private:
            SPI _spi;
            DigitalOut _cs, _dc, _reset;
        };

#endif