Skip to content

Commit

Permalink
Some basic support for ssd1327 #86
Browse files Browse the repository at this point in the history
  • Loading branch information
lexus2k committed Jul 5, 2019
1 parent 06178ed commit d4433fc
Show file tree
Hide file tree
Showing 8 changed files with 538 additions and 0 deletions.
64 changes: 64 additions & 0 deletions examples/demos/ssd1327_demo_compat/sova.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "sova.h"

//------------------------------------------------------------------------------
// File generated by LCD Assistant
// http://en.radzio.dxp.pl/bitmap_converter/
//------------------------------------------------------------------------------

const uint8_t Sova [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x0A, 0x05, 0x0D, 0x01, 0x01, 0x03, 0x87, 0xFE, 0xFE, 0xFC, 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0E,
0x08, 0x0C, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x30,
0x98, 0xDE, 0xE6, 0xE7, 0xF7, 0xD7, 0xD6, 0x56, 0x56, 0xD7, 0xD7, 0x5F, 0xDF, 0x3F, 0x3F, 0x2F,
0x9F, 0xD7, 0xDF, 0x6F, 0x6B, 0x6B, 0x7F, 0xF7, 0xF3, 0xF3, 0xE0, 0xEC, 0x98, 0x30, 0xE0, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x60, 0x70, 0x70, 0x60,
0x40, 0x60, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xE0, 0xF0, 0xE0, 0x40, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFB, 0xE0,
0xDF, 0xB1, 0xEF, 0x5F, 0xB9, 0xB0, 0xA0, 0xE6, 0x6E, 0x2E, 0xB6, 0xB9, 0x9F, 0xAF, 0xA0, 0xA7,
0xBF, 0x99, 0xB6, 0xB6, 0xA6, 0xA6, 0xB0, 0xB0, 0xA9, 0xDF, 0xCF, 0xF0, 0x7F,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EE, 0xE7, 0x67, 0x63, 0x61, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xE0,
0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x71, 0x73, 0x7B,
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7E, 0x7F, 0x77, 0x76, 0x73, 0x73, 0x71, 0x71, 0x70, 0x71, 0x70,
0x70, 0x70, 0x70, 0x70, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xE0, 0xE0,

0x60, 0x60, 0x20, 0x21, 0x31, 0x30, 0x11, 0x1A, 0x1B, 0x0B, 0x0D, 0x0C, 0x04, 0x06, 0x06, 0x06,
0x03, 0x03, 0x03, 0x13, 0x31, 0x71, 0x71, 0x61, 0x81, 0x81, 0x41, 0x20, 0x26, 0x0C, 0x1C, 0x30,
0x78, 0x00, 0x00, 0x84, 0xC4, 0x84, 0x84, 0x0C, 0x04, 0x02, 0x02, 0x01, 0x01, 0x07, 0x0E, 0x0E,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xE0, 0xC0, 0xC0, 0x00, 0x00, 0x81, 0x81, 0x81, 0x41, 0x41,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0C, 0x40, 0xEE, 0x79,
0x35, 0x02, 0x08, 0x08, 0x04, 0x04, 0x02, 0x1F, 0x3D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x04, 0x24, 0x00, 0x0D, 0x30, 0x31, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0xC6, 0xC6, 0x36, 0x68, 0x44,
0xB4, 0xA0, 0x52, 0x62, 0x02, 0x02, 0x02, 0x00, 0x01, 0x03, 0x32, 0x7A, 0x3E, 0x1A, 0x02, 0x02,
0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x1D, 0x3D, 0x1D, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
};
33 changes: 33 additions & 0 deletions examples/demos/ssd1327_demo_compat/sova.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
MIT License
Copyright (c) 2018, Alexey Dynda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef _SOVA_H_
#define _SOVA_H_

#include "ssd1306_hal/io.h"
#include <stdint.h>

extern const uint8_t Sova [] PROGMEM;

#endif
208 changes: 208 additions & 0 deletions examples/demos/ssd1327_demo_compat/ssd1327_demo_compat.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
/*
MIT License
Copyright (c) 2019, Alexey Dynda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Nano/Atmega328 PINS: connect LCD to D5 (D/C), D4 (CS), D3 (RES), D11(DIN), D13(CLK)
* Attiny SPI PINS: connect LCD to D4 (D/C), GND (CS), D3 (RES), D1(DIN), D2(CLK)
* ESP8266: connect LCD to D1(D/C), D2(CS), RX(RES), D7(DIN), D5(CLK)
*/

/* !!! THIS DEMO RUNS in SSD1306 COMPATIBLE MODE */

#include "ssd1306.h"
#include "nano_gfx.h"
#include "sova.h"

#define GRAY_COLOR4(x) (x/16)

/*
* Heart image below is defined directly in flash memory.
* This reduces SRAM consumption.
* The image is defined from bottom to top (bits), from left to
* right (bytes).
*/
const PROGMEM uint8_t heartImage[8] =
{
0B00001110,
0B00011111,
0B00111111,
0B01111110,
0B01111110,
0B00111101,
0B00011001,
0B00001110
};

/*
* Define sprite width. The width can be of any size.
* But sprite height is always assumed to be 8 pixels
* (number of bits in single byte).
*/
const int spriteWidth = sizeof(heartImage);

SAppMenu menu;

const char *menuItems[] =
{
"draw bitmap",
"sprites",
"fonts",
"canvas gfx",
"draw lines",
};

static void bitmapDemo()
{
ssd1306_setColor(GRAY_COLOR4(128));
ssd1306_drawBitmap(0, 0, 96, 64, Sova);
delay(3000);
}

static void spriteDemo()
{
ssd1306_setColor(GRAY_COLOR4(192));
ssd1306_clearScreen();
/* Declare variable that represents our sprite */
SPRITE sprite;
/* Create sprite at 0,0 position. The function initializes sprite structure. */
sprite = ssd1306_createSprite( 0, 0, spriteWidth, heartImage );
for (int i=0; i<250; i++)
{
delay(15);
sprite.x++;
if (sprite.x >= ssd1306_displayWidth())
{
sprite.x = 0;
}
sprite.y++;
if (sprite.y >= ssd1306_displayHeight())
{
sprite.y = 0;
}
/* Erase sprite on old place. The library knows old position of the sprite. */
sprite.eraseTrace();
/* Draw sprite on new place */
sprite.draw();
}
}

static void textDemo()
{
ssd1306_setFixedFont(ssd1306xled_font6x8);
ssd1306_clearScreen();
ssd1306_setColor(GRAY_COLOR4(255));
ssd1306_printFixed(0, 8, "Normal text", STYLE_NORMAL);
ssd1306_setColor(GRAY_COLOR4(192));
ssd1306_printFixed(0, 16, "Bold text", STYLE_BOLD);
ssd1306_setColor(GRAY_COLOR4(128));
ssd1306_printFixed(0, 24, "Italic text", STYLE_ITALIC);
ssd1306_negativeMode();
ssd1306_setColor(GRAY_COLOR4(164));
ssd1306_printFixed(0, 32, "Inverted bold", STYLE_BOLD);
ssd1306_positiveMode();
delay(3000);
}

static void canvasDemo()
{
uint8_t buffer[64*16/8];
NanoCanvas canvas(64,16, buffer);
ssd1306_setColor(GRAY_COLOR4(192));
ssd1306_setFixedFont(ssd1306xled_font6x8);
ssd1306_clearScreen();
canvas.clear();
canvas.fillRect(10, 3, 80, 5, 0xFF);
canvas.blt((ssd1306_displayWidth()-64)/2, 1);
delay(500);
canvas.fillRect(50, 1, 60, 15, 0xFF);
canvas.blt((ssd1306_displayWidth()-64)/2, 1);
delay(1500);
canvas.printFixed(20, 1, " DEMO ", STYLE_BOLD );
canvas.blt((ssd1306_displayWidth()-64)/2, 1);
delay(3000);
}

static void drawLinesDemo()
{
ssd1306_clearScreen();
ssd1306_setColor(GRAY_COLOR4(128));
for (uint8_t y = 0; y < ssd1306_displayHeight(); y += 8)
{
ssd1306_drawLine(0,0, ssd1306_displayWidth() -1, y);
}
ssd1306_setColor(GRAY_COLOR4(255));
for (uint8_t x = ssd1306_displayWidth() - 1; x > 7; x -= 8)
{
ssd1306_drawLine(0,0, x, ssd1306_displayHeight() - 1);
}
delay(3000);
}

void setup()
{
ssd1306_setFixedFont(ssd1306xled_font6x8);
ssd1327_128x128_spi_init(3, 4, 5); // Use this line for Atmega328p
// ssd1327_128x128_spi_init(3, -1, 4); // Use this line for ATTINY
// ssd1327_128x128_spi_init(24, 0, 23); // Use this line for Raspberry (gpio24=RST, 0=CE, gpio23=D/C)

ssd1306_clearScreen( );
ssd1306_createMenu( &menu, menuItems, sizeof(menuItems) / sizeof(char *) );
ssd1306_setColor(GRAY_COLOR4(255));
ssd1306_showMenu( &menu );
}

void loop()
{
delay(1000);
switch (ssd1306_menuSelection(&menu))
{
case 0:
bitmapDemo();
break;

case 1:
spriteDemo();
break;

case 2:
textDemo();
break;

case 3:
canvasDemo();
break;

case 4:
drawLinesDemo();
break;

default:
break;
}
ssd1306_clearScreen( );
ssd1306_setColor(GRAY_COLOR4(255));
ssd1306_showMenu(&menu);
delay(500);
ssd1306_menuDown(&menu);
ssd1306_updateMenu(&menu);
}
1 change: 1 addition & 0 deletions src/Makefile.src
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ SRCS_C = \
lcd/oled_sh1106.c \
lcd/oled_ssd1306.c \
lcd/oled_ssd1325.c \
lcd/oled_ssd1327.c \
lcd/oled_ssd1331.c \
lcd/oled_ssd1351.c \
lcd/oled_template.c \
Expand Down

0 comments on commit d4433fc

Please sign in to comment.