Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
project:esp8266_oledx32 [2019/03/06 09:11] cyberian |
project:esp8266_oledx32 [2019/03/07 08:11] cyberian [Kód programu] |
||
---|---|---|---|
Line 23: | Line 23: | ||
{{ :project:esp8266_nodemcu_v0.9_oled_web.jpg?400 |}} | {{ :project:esp8266_nodemcu_v0.9_oled_web.jpg?400 |}} | ||
- | Kód programu: | + | ===== Vytvoření bitmapy ===== |
+ | Některé konvertory mají problém s určitými rozměry obrázků. | ||
+ | Obrázek je nutno zmenšit ještě před koverzí a ideální je převést ho na stupně šedi nebo monochromatický taktéž před vlastní konverzí. Jako na potvoru pro konverzi malého obrázku 32x29 px fungoval jen Image2Code, který je trochu obtížnější získat | ||
+ | |||
+ | Seznam konvertorů: | ||
+ | * GIMP [[https://www.gimp.org/downloads/]] | ||
+ | * LCD Assisant [[http://en.radzio.dxp.pl/bitmap_converter/]] | ||
+ | * Image2Code https://github.com/adafruit/Adafruit-GFX-Library#useful-resources | ||
+ | |||
+ | Konvertory krom gimpu jsem prověřil na virustotal.com, nicméně i tak doporučuji překontrolovat je znovu. | ||
+ | Image2Code je nástroj poskytnutý v sekci použitelných zdrojů ke knihovně Adafruit GFX napsaný v javě. Je nutno ho zkompilovat přes příkaz "gradle build". Pokud vám to nepůjde, mohu vám v případě windows poslat již sestavenou verzi | ||
+ | |||
+ | Pokud se nepovede konverze z nějakého důvodu ani tak, pak vložte do pole tento obsah: | ||
+ | <code> | ||
+ | { | ||
+ | 0x20,0x0,0x0,0x20, | ||
+ | 0x70,0x0,0x0,0x70, | ||
+ | 0x50,0x0,0x0,0x50, | ||
+ | 0xd8,0x0,0x0,0xd8, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x1,0xc0,0x0,0x0, | ||
+ | 0x3,0x60,0x0,0x0, | ||
+ | 0x2,0x20,0x78,0x0, | ||
+ | 0x2,0x20,0x48,0x0, | ||
+ | 0x2,0x20,0x48,0x0, | ||
+ | 0x3,0x60,0x48,0x0, | ||
+ | 0x1,0xc0,0x38,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x0,0x0,0x0,0x0, | ||
+ | 0x1,0x0,0x8,0x0, | ||
+ | 0x1,0x80,0x8,0x0, | ||
+ | 0x0,0x88,0x98,0x0, | ||
+ | 0x0,0xc5,0x10,0x0, | ||
+ | 0x0,0x42,0x10,0x0, | ||
+ | 0x0,0x65,0x30,0x0, | ||
+ | 0x0,0x28,0xa0,0x0, | ||
+ | 0x0,0x20,0x20,0x0 | ||
+ | }; | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ===== Kód programu ===== | ||
Na začátku je nutno nainstalovat si v Arduino IDE v menu: Nástroje/Spravovat knihovny následující knihovny: | Na začátku je nutno nainstalovat si v Arduino IDE v menu: Nástroje/Spravovat knihovny následující knihovny: | ||
* SSD1306 by adafruit(v mé době ver. 1.28) | * SSD1306 by adafruit(v mé době ver. 1.28) | ||
* Adafruit GFX by adafruit (v mé době ver. 1.36) | * Adafruit GFX by adafruit (v mé době ver. 1.36) | ||
- | Kód je upraveným příkladem pro SSD1306. | + | V kódu je komentář "ZDE VLOZIT hexaznaky bitmapy". |
+ | Pro zkopírování kód stačí dvojklik na kód a ctrl+c | ||
- | <code> | + | <sxh cpp>/* |
- | /************************************************************************** | + | This is an example for our Monochrome OLEDs based on SSD1306 drivers |
- | This is an example for our Monochrome OLEDs based on SSD1306 drivers | + | |
- | Pick one up today in the adafruit shop! | + | Pick one up today in the adafruit shop! |
- | ------> http://www.adafruit.com/category/63_98 | + | ------> http://www.adafruit.com/category/63_98 |
- | This example is for a 128x32 pixel display using I2C to communicate | + | This example is for a 128x32 pixel display using I2C to communicate |
- | 3 pins are required to interface (two I2C and one reset). | + | 3 pins are required to interface (two I2C and one reset). |
- | Adafruit invests time and resources providing this open | + | Adafruit invests time and resources providing this open |
- | source code, please support Adafruit and open-source | + | source code, please support Adafruit and open-source |
- | hardware by purchasing products from Adafruit! | + | hardware by purchasing products from Adafruit! |
- | Written by Limor Fried/Ladyada for Adafruit Industries, | + | Written by Limor Fried/Ladyada for Adafruit Industries, |
- | with contributions from the open source community. | + | with contributions from the open source community. |
- | BSD license, check license.txt for more information | + | BSD license, check license.txt for more information |
- | All text above, and the splash screen below must be | + | All text above, and the splash screen below must be |
- | included in any redistribution. | + | included in any redistribution. |
- | **************************************************************************/ | + | */ |
- | //#include <SPI.h> | ||
#include <Wire.h> | #include <Wire.h> | ||
#include <Adafruit_GFX.h> | #include <Adafruit_GFX.h> | ||
Line 68: | Line 118: | ||
#define MARI_HEIGHT 64 | #define MARI_HEIGHT 64 | ||
- | //bitmapa mé ženy | + | //bitmapa |
static const unsigned char PROGMEM Mari_pole [] = | static const unsigned char PROGMEM Mari_pole [] = | ||
{ | { | ||
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x1c,0x18,0x0,0x0,0x1f,0xff,0xff, | + | // ZDE VLOZIT hexaznaky bitmapy |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x0,0x0,0x0,0x0,0x7,0xff,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0x0,0x0,0x0,0x3,0xff,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0xc0,0x80,0x0,0x1,0xff,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x3,0xc0,0x0,0x0,0x0,0xff,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x17,0x80,0x0,0x0,0x0,0x7f,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xa0,0x13,0x80,0x18,0x0,0x0,0x3f,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x3,0x80,0x3e,0x0,0x0,0x1f,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xfd,0xff,0xff,0x0,0x3,0x80,0x7f,0x0,0x0,0x7,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x3,0xc0,0xff,0xc0,0x0,0x7,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xdf,0xef,0xfe,0x1f,0x63,0xc0,0xff,0xe0,0x0,0x3,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xbf,0xff,0xfe,0xff,0xc3,0xe1,0xff,0xe0,0x0,0x3,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdd,0xff,0xc7,0xf1,0xff,0xe0,0x0,0x3,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,0xff,0xcf,0xf0,0xff,0xe0,0x0,0x3,0xff, | + | |
- | 0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xb7,0xff,0xff,0xf8,0xff,0xe0,0x0,0x1,0xff, | + | |
- | 0x31,0xff,0xff,0xff,0xfe,0x7d,0xff,0x77,0xff,0xff,0xfc,0xff,0xc0,0x0,0x1,0xff, | + | |
- | 0x0,0x1,0xff,0xff,0xe1,0xf3,0xfe,0xef,0xff,0xff,0x9e,0x3f,0xc0,0x0,0x1,0xff, | + | |
- | 0x0,0x0,0x67,0xf8,0xf,0xff,0xff,0xff,0xff,0xff,0xcf,0x1f,0x0,0x0,0x1,0xff, | + | |
- | 0x0,0x0,0x3,0xc1,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x6,0x0,0x0,0x0,0xff, | + | |
- | 0x0,0x0,0x0,0x7,0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0x0,0x0,0x0,0x0,0xff, | + | |
- | 0x0,0x0,0x0,0x7f,0xff,0xff,0xff,0xfe,0x7f,0xff,0x13,0x0,0x0,0x0,0x0,0xff, | + | |
- | 0x0,0x0,0x1,0xff,0xbf,0xff,0xff,0xfe,0x3f,0xfe,0xf,0x0,0x0,0x0,0x0,0xff, | + | |
- | 0x0,0x0,0x7,0xff,0xfe,0x7b,0xff,0xef,0xbf,0xff,0xcd,0x0,0x0,0x0,0x0,0xff, | + | |
- | 0x0,0x0,0x3f,0xff,0xf0,0xc7,0xff,0xc7,0xff,0xff,0xcc,0x0,0x0,0x0,0x0,0xff, | + | |
- | 0x0,0x0,0x7f,0xff,0x81,0x1f,0xee,0x87,0xff,0xff,0x86,0x0,0x0,0x0,0x0,0xff, | + | |
- | 0x0,0x0,0xff,0xff,0x0,0x7f,0xc1,0x83,0xff,0xff,0x86,0x0,0x0,0x0,0x0,0xff, | + | |
- | 0x0,0x3,0xff,0xfe,0x1,0xfe,0x3,0x83,0xff,0xff,0x86,0x0,0x4,0x0,0x0,0xff, | + | |
- | 0x0,0x7,0xff,0xfc,0x7,0xf8,0x7,0x89,0xff,0xff,0x80,0x0,0x0,0x0,0x0,0xff, | + | |
- | 0x0,0x1f,0xff,0xe0,0x1b,0x0,0xf,0x89,0xff,0xff,0xc0,0x0,0x0,0x80,0x0,0xff, | + | |
- | 0x0,0x3f,0xff,0xc0,0x0,0x0,0xf,0xfc,0xff,0xff,0xe0,0x0,0x7,0xe0,0x1,0xff, | + | |
- | 0x0,0xff,0xff,0xe0,0x0,0x2,0xf,0xfe,0xff,0xff,0xf8,0x0,0xf,0xf0,0x1,0xff, | + | |
- | 0x1,0xff,0xff,0xe0,0x0,0x0,0xf,0xfe,0x7f,0xff,0xf8,0x0,0x1f,0xf0,0x3,0xff | + | |
}; | }; | ||
Line 426: | Line 446: | ||
delay(1000); | delay(1000); | ||
} | } | ||
+ | </sxh> | ||
+ | |||
- | </code> |