SSD1306 OLED display driver  1.4.12
This library is developed to control SSD1306/SSD1331 RGB i2c/spi OLED displays and spi PCD8544 LED display
ssd1331_api.c
1 /*
2  MIT License
3 
4  Copyright (c) 2018, Alexey Dynda
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 */
24 
25 #include "ssd1306.h"
26 #include "ssd1331_api.h"
27 #include "intf/ssd1306_interface.h"
28 #include "hal/io.h"
29 
30 #include "lcd/ssd1331_commands.h"
31 
32 extern uint16_t ssd1306_color;
33 
34 void ssd1331_setColor(uint16_t color)
35 {
36  ssd1306_color = color;
37 }
38 
39 void ssd1331_setRgbColor(uint8_t r, uint8_t g, uint8_t b)
40 {
41  ssd1306_color = RGB_COLOR8(r,g,b);
42 }
43 
44 void ssd1331_drawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint16_t color)
45 {
47  ssd1306_sendByte(SSD1331_DRAWLINE);
48  ssd1306_sendByte(x1);
49  ssd1306_sendByte(y1);
50  ssd1306_sendByte(x2);
51  ssd1306_sendByte(y2);
52  ssd1306_sendByte( (color & 0x03) << 4 );
53  ssd1306_sendByte( (color & 0x1C) << 2 );
54  ssd1306_sendByte( (color & 0xE0) >> 2 );
56 }
57 
void ssd1331_drawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint16_t color)
Definition: ssd1331_api.c:44
void(* ssd1306_sendByte)(uint8_t data)
void ssd1331_setRgbColor(uint8_t r, uint8_t g, uint8_t b)
Sets default color.
Definition: ssd1331_api.c:39
#define RGB_COLOR8(r, g, b)
Definition: ssd1306.h:48
void ssd1331_setColor(uint16_t color)
Sets default color, generated by RGB_COLOR8 macros.
Definition: ssd1331_api.c:34
void(* ssd1306_endTransmission)(void)
void(* ssd1306_commandStart)(void)