Library for drawing on the Hexiwear's OLED - more features being actively worked on
Dependents: Hexidraw_Demo Hexiwear-FinalProject_v2
You are viewing an older revision! See the latest version
API
The API for Hexidraw is made to be simple, with easy to remember function names.
Checkout the official Hexiwear repository for more Hexiwear libraries:
Turning on the OLED¶
include the header file:
#include "hexidraw.h"
Create a new instance of the OLED class:
OLED oled;
And then setup the display, and turn it on:
oled.begin(); oled.wake(); oled.clear(WHITE);
wake() and sleep()¶
The wake() and sleep() functions disable and enable power saving mode on the OLED, which turns on and off the display while retaining the display buffer. It is recommended to turn off the display (sleep()) after a timeout so as to save battery power.
Using colors¶
You can use the function Color565(r,g,b) which was ported from the Adafruit GFX library to convert 0-255 colors into the 16-bit integers you need for passing to the OLED, e.g:
oled.pixel(OLED_WIDTH/2, OLED_HEIGHT/2, Color565(0,255,0)); // draw a green pixel in the center of the screen
Drawing pixels¶
To draw a single pixel on the screen, you use the pixel() function:
oled.pixel(uint16_t x, uint16_t y, uint16_t color)
Drawing Rectangles¶
oled.rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
Drawing Circles¶
Drawing a circle on the screen is a combination of using sine and cosine along with some radian conversions and some for loops.
Luckily for you, I've already written all the necessary code!
oled.circle(uint16_t x, uint16_t y, uint16_t radis, uint16_t color, uint16_t width=1); // You can leave the width parameter undefined and it will default to a width of 1
Roadmap¶
- Function to draw arcs
- Function to draw filled circle
- Function to draw rectangle outline only
- Function for drawing lines
- Drawing Hexiwear image arrays on the screen
- Drawing fonts
- Other types of interesting geometric drawing functions
- Code optimizations