Keith Mitchell / Hexidraw

Dependents:   Hexidraw_Demo Hexiwear-FinalProject_v2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers hexidraw.h Source File

hexidraw.h

00001 
00002 #ifndef _HEXIDRAW_H_
00003 #define _HEXIDRAW_H_
00004 
00005     #include <mbed.h>
00006     #include <stdarg.h>
00007     
00008     #include "oled_info.h"
00009     
00010     #define BLACK 0x0000
00011     #define WHITE 0xffff
00012     
00013     #define OLED_WIDTH 96
00014     #define OLED_HEIGHT 96
00015     
00016     #define OLED_BYTES_PER_PIXEL ( 2 )
00017     
00018     #define OLED_COL_OFFSET 16
00019     
00020     #define OLED_IMAGE_SIZE ( OLED_WIDTH * OLED_HEIGHT * OLED_BYTES_PER_PIXEL )
00021     #define OLED_BMP_HEADER_BYTE_SIZE (6)
00022     
00023     #define OLED_SPI_CHUNK (511)
00024     
00025     #define OLED_SKIP_IMAGE_HEADER( imgPtr ) ( (const uint8_t*)(imgPtr) + OLED_BMP_HEADER_BYTE_SIZE )
00026     
00027     #define USE_BUFFER 0
00028         
00029     /* borrowed from the Adafruit library at:
00030         https://developer.mbed.org/teams/ELLA-Robotics-Inc/code/Adafruit_GFX_1351/ 
00031        Since I don't know enough to make my own function :) */
00032     uint16_t Color565(uint8_t r, uint8_t g, uint8_t b) ;
00033     
00034     class OLED {
00035         public:
00036             OLED();
00037             void writeCommand(uint8_t v);
00038             void writeData(uint8_t v);
00039             void begin();
00040             void sleep();
00041             void wake();
00042             void pixel(int16_t x, int16_t y, uint16_t color);
00043             void cursor(int x, int y);
00044             void rect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t fillcolor);
00045             void dim();
00046             void clear(uint16_t color);
00047             void circle(uint16_t x, uint16_t y, uint16_t radius, uint16_t color, uint16_t width = 1);
00048             void image (uint16_t x, uint16_t y, const uint8_t* image);
00049             void hline(uint16_t x, uint16_t y, uint16_t width, uint16_t color, uint16_t thickness = 1);
00050             void vline(uint16_t x, uint16_t y, uint16_t height, uint16_t color, uint16_t thickness = 1);
00051             void draw();
00052         private:
00053             SPI _spi;
00054             DigitalOut _cs, _dc, _reset;
00055             uint16_t displayBuffer[OLED_WIDTH * OLED_HEIGHT];
00056             void text(uint16_t x, uint16_t y, const uint8_t* text, const uint8_t* font, uint16_t color = WHITE);
00057         };
00058 
00059 #endif