1
0

131 Zeilen
3.2 KiB
Markdown

2018-10-01 12:00:47 +02:00
# OLED for AVR mikrocontrollers
2017-12-25 14:48:08 +01:00
Library for oled-displays with SSD1306 or SH1106 display-controller connected with I2C at an AVR Atmel Atmega like Atmega328P.
2017-12-25 14:52:39 +01:00
2018-12-05 08:19:34 +01:00
<img src="https://github.com/Sylaina/oled-display/blob/master/oled.jpg?raw=true" width="500">
2017-12-31 13:48:12 +01:00
This library allows you to display text or/and graphic at oled-display.
2018-12-06 10:58:02 +01:00
The library need less than 2 kilobytes flash-memory and 3 bytes sram in textmode, in graphicmode library need less than 3 kilobytes flash-memory and 1027 bytes static sram so you can use oled-displays e.g with Atmega48PA (only with textmode).
2017-12-25 14:52:39 +01:00
Library is only tested with 128x64 Pixel display, lower resolution not tested but should work too.
2017-12-31 13:48:12 +01:00
2017-12-31 13:52:24 +01:00
If you want to use your own I2C library you have to fit i2c-function at lcd-library.
2017-12-31 13:48:12 +01:00
Settings for I2C-bus have to set at i2c.h
Settings for display have to set at lcd.h
If you want to use characters like e.g. ä set your compiler input-charset to utf-8 and your compiler exec-charset to iso-8859-15 (look at makefile line 115).
2018-09-28 07:29:27 +02:00
Testcondition: Display: SSD1306 OLED, Compiler Optimizelevel: -Os, µC: Atmega328p @ 8 MHz internal RC
2018-09-18 21:05:00 +02:00
Memory:
2018-12-05 08:15:58 +01:00
<table>
<tr>
<th>Modul</th>
<th>Flash</th>
<th>Static RAM</th>
</tr>
<tr>
<td>I2C-Core</td>
2019-09-13 06:18:46 +02:00
<td>234 Bytes</td>
2018-12-05 08:15:58 +01:00
<td>0 Bytes</td>
</tr>
<tr>
<td>FONT</td>
<td>644 Bytes</td>
<td>0 Bytes</td>
</tr>
<tr>
<td>OLED (Text-Mode)</td>
2019-09-13 06:42:23 +02:00
<td>1449 Bytes</td>
2018-12-05 08:15:58 +01:00
<td>3 Bytes</td>
</tr>
<tr>
<td>OLED (Graphic-Mode)</td>
2019-09-13 06:42:23 +02:00
<td>2403 Bytes</td>
2018-12-05 08:15:58 +01:00
<td>1027 Bytes</td>
</tr>
</table>
2018-09-18 21:05:00 +02:00
2018-12-06 11:00:05 +01:00
Speed (print 20 charaters (1 line) in normal size to display):
2018-09-18 21:05:00 +02:00
2018-12-05 08:15:58 +01:00
<table>
<tr>
<th>Mode</th>
<th>Time</th>
<th>I2C-Speed RAM</th>
</tr>
<tr>
<td>OLED (Text-Mode)</td>
2018-12-05 15:33:49 +01:00
<td>4.411 ms</td>
2018-12-05 08:15:58 +01:00
<td>400 kHz</td>
</tr>
<tr>
<td>OLED (Text-Mode)</td>
2018-12-05 15:33:49 +01:00
<td>15.384 ms</td>
2018-12-05 08:15:58 +01:00
<td>100 kHz</td>
</tr>
<tr>
<td>OLED (Graphic-Mode)</td>
<td>26.603 ms</td>
<td>400 kHz</td>
</tr>
<tr>
<td>OLED (Graphic-Mode)</td>
<td>96.294 ms</td>
<td>100 kHz</td>
</tr>
</table>
2018-09-18 21:05:00 +02:00
example:
2017-12-31 13:48:12 +01:00
2018-12-05 08:06:18 +01:00
```c
2017-12-31 13:48:12 +01:00
//****main.c****//
#include "lcd.h"
int main(void){
lcd_init(LCD_DISP_ON); // init lcd and turn on
lcd_puts("Hello World"); // put string from RAM to display (TEXTMODE) or buffer (GRAPHICMODE)
lcd_gotoxy(0,2); // set cursor to first column at line 3
lcd_puts_p(PSTR("String from flash")); // puts string form flash to display (TEXTMODE) or buffer (GRAPHICMODE)
#if defined GRAPHICMODE
lcd_drawCircle(64,32,7,WHITE); // draw circle to buffer
lcd_display(); // send buffer to display
#endif
for(;;){
//main loop
}
return 0;
}
2018-12-05 08:06:18 +01:00
```
2018-12-05 08:04:14 +01:00
example for chars with double height:
2018-12-05 08:06:18 +01:00
```c
2018-12-05 08:04:14 +01:00
//****main.c****//
#include "lcd.h"
int main(void){
lcd_init(LCD_DISP_ON);
lcd_clrscr();
lcd_set_contrast(0x00);
2019-01-02 07:07:53 +01:00
lcd_gotoxy(4,1);
lcd_puts("Normal Size");
lcd_charMode(DOUBLESIZE);
lcd_gotoxy(0,4);
lcd_puts(" Double \r\n Size");
lcd_charMode(NORMALSIZE);
2018-12-05 08:04:14 +01:00
#ifdef GRAPHICMODE
lcd_display();
#endif
2019-01-02 07:07:53 +01:00
for(;;){
//main loop
}
2018-12-05 08:04:14 +01:00
return 0;
}
2019-07-10 11:23:09 +02:00
```
2019-07-10 11:22:26 +02:00
<img src="https://github.com/Sylaina/oled-display/blob/master/bigchars.JPG?raw=true" width="500">