SSD1306 OLED display driver  1.7.2
This library is developed to control SSD1306/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
ssd1306_generic.c
1 /*
2  MIT License
3 
4  Copyright (c) 2016-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 
28 
29 #include "ssd1306.h"
30 #include "ssd1306_fonts.h"
31 #include "lcd/lcd_common.h"
32 #include "intf/i2c/ssd1306_i2c.h"
33 #include "intf/spi/ssd1306_spi.h"
34 #include "intf/ssd1306_interface.h"
35 #include "ssd1306_hal/io.h"
36 
37 // TODO: remove
38 #include "lcd/ssd1306_commands.h"
39 
40 uint16_t ssd1306_color = 0xFFFF;
41 lcduint_t ssd1306_cursorX = 0;
42 lcduint_t ssd1306_cursorY = 0;
44 
46 {
47  return ssd1306_lcd.height;
48 }
49 
51 {
52  return ssd1306_lcd.width;
53 }
54 
55 void ssd1306_setCursor(lcdint_t x, lcdint_t y)
56 {
57  ssd1306_cursorX = x;
58  ssd1306_cursorY = y;
59 }
60 
61 void ssd1306_setFixedFont(const uint8_t * progmemFont)
62 {
63  s_fixedFont.width = pgm_read_byte(&progmemFont[1]);
64  s_fixedFont.height = pgm_read_byte(&progmemFont[2]);
65  s_fixedFont.pages = (s_fixedFont.height + 7) >> 3;
66  s_fixedFont.ascii_offset = pgm_read_byte(&progmemFont[3]);
67  s_fixedFont.data = progmemFont + 4;
68 }
69 
70 void ssd1306_getCharBitmap(char ch, SCharInfo *info)
71 {
72  if (info)
73  {
74  info->width = s_fixedFont.width;
75  info->height = s_fixedFont.height;
77  }
78 }
void ssd1306_setCursor(lcdint_t x, lcdint_t y)
Sets cursor position for text mode print functions.
const uint8_t * data
char data, located in progmem.
uint8_t height
char height in pixels
uint8_t ascii_offset
ascii offset
uint8_t ssd1306_displayWidth()
ssd1306_lcd_t ssd1306_lcd
Definition: lcd_common.c:32
void ssd1306_setFixedFont(const uint8_t *progmemFont)
lcduint_t height
Definition: lcd_common.h:97
uint8_t width
char width in pixels
uint8_t width
width in pixels
SFixedFontInfo s_fixedFont
void ssd1306_getCharBitmap(char ch, SCharInfo *info)
returns char data for currently set (active) font.
uint8_t ssd1306_displayHeight()
lcduint_t width
Definition: lcd_common.h:94
const uint8_t * data
font chars bits
uint8_t pages
height in pages (each page height is 8-pixels)
uint8_t height
height in pixels