diff options
Diffstat (limited to 'drivers/qwiic/micro_oled.h')
| -rw-r--r-- | drivers/qwiic/micro_oled.h | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/drivers/qwiic/micro_oled.h b/drivers/qwiic/micro_oled.h new file mode 100644 index 000000000..5d6a1029e --- /dev/null +++ b/drivers/qwiic/micro_oled.h | |||
| @@ -0,0 +1,134 @@ | |||
| 1 | /* Jim Lindblom @ SparkFun Electronics | ||
| 2 | * October 26, 2014 | ||
| 3 | * https://github.com/sparkfun/Micro_OLED_Breakout/tree/master/Firmware/Arduino/libraries/SFE_MicroOLED | ||
| 4 | * | ||
| 5 | * Modified by: | ||
| 6 | * Emil Varughese @ Edwin Robotics Pvt. Ltd. | ||
| 7 | * July 27, 2015 | ||
| 8 | * https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/ | ||
| 9 | * | ||
| 10 | * This code was heavily based around the MicroView library, written by GeekAmmo | ||
| 11 | * (https://github.com/geekammo/MicroView-Arduino-Library). | ||
| 12 | * | ||
| 13 | * Adapted for QMK by: | ||
| 14 | * Jack Humbert <jack.humb@gmail.com> | ||
| 15 | * October 11, 2018 | ||
| 16 | * | ||
| 17 | * This program is free software: you can redistribute it and/or modify | ||
| 18 | * it under the terms of the GNU General Public License as published by | ||
| 19 | * the Free Software Foundation, either version 3 of the License, or | ||
| 20 | * (at your option) any later version. | ||
| 21 | * | ||
| 22 | * This program is distributed in the hope that it will be useful, | ||
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 25 | * GNU General Public License for more details. | ||
| 26 | * | ||
| 27 | * You should have received a copy of the GNU General Public License | ||
| 28 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 29 | */ | ||
| 30 | #pragma once | ||
| 31 | |||
| 32 | #include "qwiic.h" | ||
| 33 | |||
| 34 | void micro_oled_init(void); | ||
| 35 | |||
| 36 | void send_command(uint8_t command); | ||
| 37 | void send_data(uint8_t data); | ||
| 38 | void set_page_address(uint8_t address); | ||
| 39 | void set_column_address(uint8_t address); | ||
| 40 | void clear_screen(void); | ||
| 41 | void clear_buffer(void); | ||
| 42 | void send_buffer(void); | ||
| 43 | void draw_pixel(uint8_t x, uint8_t y, uint8_t color, uint8_t mode); | ||
| 44 | void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color, uint8_t mode); | ||
| 45 | void draw_line_hori(uint8_t x, uint8_t y, uint8_t width, uint8_t color, uint8_t mode); | ||
| 46 | void draw_line_vert(uint8_t x, uint8_t y, uint8_t height, bool color, uint8_t mode); | ||
| 47 | void draw_rect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode); | ||
| 48 | void draw_rect_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode); | ||
| 49 | void draw_rect_filled(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode); | ||
| 50 | void draw_rect_filled_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode); | ||
| 51 | void draw_char(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode, uint8_t font); | ||
| 52 | void draw_string(uint8_t x, uint8_t y, char * string, uint8_t color, uint8_t mode, uint8_t font); | ||
| 53 | |||
| 54 | #define I2C_ADDRESS_SA0_0 0b0111100 | ||
| 55 | #ifndef I2C_ADDRESS_SA0_1 | ||
| 56 | #define I2C_ADDRESS_SA0_1 0b0111101 | ||
| 57 | #endif | ||
| 58 | #define I2C_COMMAND 0x00 | ||
| 59 | #define I2C_DATA 0x40 | ||
| 60 | #define PIXEL_OFF 0 | ||
| 61 | #define PIXEL_ON 1 | ||
| 62 | |||
| 63 | #ifndef LCDWIDTH | ||
| 64 | #define LCDWIDTH 64 | ||
| 65 | #endif | ||
| 66 | #ifndef LCDWIDTH | ||
| 67 | #define LCDHEIGHT 48 | ||
| 68 | #endif | ||
| 69 | #define FONTHEADERSIZE 6 | ||
| 70 | |||
| 71 | #define NORM 0 | ||
| 72 | #define XOR 1 | ||
| 73 | |||
| 74 | #define PAGE 0 | ||
| 75 | #define ALL 1 | ||
| 76 | |||
| 77 | #define WIDGETSTYLE0 0 | ||
| 78 | #define WIDGETSTYLE1 1 | ||
| 79 | #define WIDGETSTYLE2 2 | ||
| 80 | |||
| 81 | #define SETCONTRAST 0x81 | ||
| 82 | #define DISPLAYALLONRESUME 0xA4 | ||
| 83 | #define DISPLAYALLON 0xA5 | ||
| 84 | #define NORMALDISPLAY 0xA6 | ||
| 85 | #define INVERTDISPLAY 0xA7 | ||
| 86 | #define DISPLAYOFF 0xAE | ||
| 87 | #define DISPLAYON 0xAF | ||
| 88 | #define SETDISPLAYOFFSET 0xD3 | ||
| 89 | #define SETCOMPINS 0xDA | ||
| 90 | #define SETVCOMDESELECT 0xDB | ||
| 91 | #define SETDISPLAYCLOCKDIV 0xD5 | ||
| 92 | #define SETPRECHARGE 0xD9 | ||
| 93 | #define SETMULTIPLEX 0xA8 | ||
| 94 | #define SETLOWCOLUMN 0x00 | ||
| 95 | #define SETHIGHCOLUMN 0x10 | ||
| 96 | #define SETSTARTLINE 0x40 | ||
| 97 | #define MEMORYMODE 0x20 | ||
| 98 | #define COMSCANINC 0xC0 | ||
| 99 | #define COMSCANDEC 0xC8 | ||
| 100 | #define SEGREMAP 0xA0 | ||
| 101 | #define CHARGEPUMP 0x8D | ||
| 102 | #define EXTERNALVCC 0x01 | ||
| 103 | #define SWITCHCAPVCC 0x02 | ||
| 104 | |||
| 105 | // Scroll | ||
| 106 | #define ACTIVATESCROLL 0x2F | ||
| 107 | #define DEACTIVATESCROLL 0x2E | ||
| 108 | #define SETVERTICALSCROLLAREA 0xA3 | ||
| 109 | #define RIGHTHORIZONTALSCROLL 0x26 | ||
| 110 | #define LEFT_HORIZONTALSCROLL 0x27 | ||
| 111 | #define VERTICALRIGHTHORIZONTALSCROLL 0x29 | ||
| 112 | #define VERTICALLEFTHORIZONTALSCROLL 0x2A | ||
| 113 | |||
| 114 | typedef enum CMD { | ||
| 115 | CMD_CLEAR, //0 | ||
| 116 | CMD_INVERT, //1 | ||
| 117 | CMD_CONTRAST, //2 | ||
| 118 | CMD_DISPLAY, //3 | ||
| 119 | CMD_SETCURSOR, //4 | ||
| 120 | CMD_PIXEL, //5 | ||
| 121 | CMD_LINE, //6 | ||
| 122 | CMD_LINEH, //7 | ||
| 123 | CMD_LINEV, //8 | ||
| 124 | CMD_RECT, //9 | ||
| 125 | CMD_RECTFILL, //10 | ||
| 126 | CMD_CIRCLE, //11 | ||
| 127 | CMD_CIRCLEFILL, //12 | ||
| 128 | CMD_DRAWCHAR, //13 | ||
| 129 | CMD_DRAWBITMAP, //14 | ||
| 130 | CMD_GETLCDWIDTH, //15 | ||
| 131 | CMD_GETLCDHEIGHT, //16 | ||
| 132 | CMD_SETCOLOR, //17 | ||
| 133 | CMD_SETDRAWMODE //18 | ||
| 134 | } commCommand_t; \ No newline at end of file | ||
