pull request #220
This commit is contained in:
parent
3c8706a250
commit
45dea5b1ca
|
@ -108,4 +108,6 @@ https://github.com/olikraus/u8g2 ChangeLog
|
|||
* Support for SSD1329 128x96 OLED (issue 208)
|
||||
* Support for LC7981 240x128 (issue 193)
|
||||
* Performance improvement for the ST7920 (issue 200)
|
||||
|
||||
2017-xx-xx v2.15.x olikraus@gmail.com
|
||||
* Added setBitmapMode (pull request 220)
|
||||
Warning: Default behavior of drawXBM has changed in this release.
|
|
@ -57,7 +57,7 @@
|
|||
// U8g2 Contructor List (Picture Loop Page Buffer)
|
||||
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp
|
||||
// Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected
|
||||
//U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition)
|
||||
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
|
||||
|
|
|
@ -97,7 +97,7 @@ COMMON_FLAGS += -Os
|
|||
# memcpy still works, but might be required for __aeabi_uidiv
|
||||
# COMMON_FLAGS += -nostdlib
|
||||
# remove unused data and function
|
||||
COMMON_FLAGS += -ffunction-sections -fdata-sections
|
||||
COMMON_FLAGS += -ffunction-sections -fdata-sections -fshort-wchar
|
||||
# C flags
|
||||
CFLAGS:=$(COMMON_FLAGS) -std=gnu99
|
||||
# LD flags
|
||||
|
|
|
@ -97,7 +97,7 @@ COMMON_FLAGS += -Os
|
|||
# memcpy still works, but might be required for __aeabi_uidiv
|
||||
# COMMON_FLAGS += -nostdlib
|
||||
# remove unused data and function
|
||||
COMMON_FLAGS += -ffunction-sections -fdata-sections
|
||||
COMMON_FLAGS += -ffunction-sections -fdata-sections -fshort-wchar
|
||||
# C flags
|
||||
CFLAGS:=$(COMMON_FLAGS) -std=gnu99
|
||||
# LD flags
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include <chip.h>
|
||||
#include <delay.h>
|
||||
#include "u8g2.h"
|
||||
|
||||
|
||||
/*=======================================================================*/
|
||||
|
@ -8,6 +9,11 @@
|
|||
#define SYS_TICK_PERIOD_IN_MS 100
|
||||
|
||||
|
||||
/*=======================================================================*/
|
||||
/* external functions */
|
||||
uint8_t u8x8_gpio_and_delay_lpc824(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
|
||||
|
||||
/*=======================================================================*/
|
||||
/* system procedures and sys tick master task */
|
||||
|
||||
|
@ -21,6 +27,35 @@ void __attribute__ ((interrupt)) SysTick_Handler(void)
|
|||
sys_tick_irq_cnt++;
|
||||
}
|
||||
|
||||
/*=======================================================================*/
|
||||
|
||||
u8g2_t u8g2;
|
||||
|
||||
void draw(u8g2_t *u8g2)
|
||||
{
|
||||
u8g2_SetFontMode(u8g2, 1); // Transparent
|
||||
u8g2_SetFontDirection(u8g2, 0);
|
||||
u8g2_SetFont(u8g2, u8g2_font_inb24_mf);
|
||||
u8g2_DrawStr(u8g2, 0, 30, "U");
|
||||
|
||||
u8g2_SetFontDirection(u8g2, 1);
|
||||
u8g2_SetFont(u8g2, u8g2_font_inb30_mn);
|
||||
u8g2_DrawStr(u8g2, 21,8,"8");
|
||||
|
||||
u8g2_SetFontDirection(u8g2, 0);
|
||||
u8g2_SetFont(u8g2, u8g2_font_inb24_mf);
|
||||
u8g2_DrawStr(u8g2, 51,30,"g");
|
||||
u8g2_DrawStr(u8g2, 67,30,"\xb2");
|
||||
|
||||
u8g2_DrawHLine(u8g2, 2, 35, 47);
|
||||
u8g2_DrawHLine(u8g2, 3, 36, 47);
|
||||
u8g2_DrawVLine(u8g2, 45, 32, 12);
|
||||
u8g2_DrawVLine(u8g2, 46, 33, 12);
|
||||
|
||||
u8g2_SetFont(u8g2, u8g2_font_4x6_tr);
|
||||
u8g2_DrawStr(u8g2, 1,54,"github.com/olikraus/u8g2");
|
||||
}
|
||||
|
||||
/*=======================================================================*/
|
||||
/*
|
||||
setup the hardware and start interrupts.
|
||||
|
@ -48,10 +83,23 @@ int __attribute__ ((noinline)) main(void)
|
|||
//Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 15, IOCON_FUNC1); /* RxD */
|
||||
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 15);
|
||||
|
||||
/* setup display */
|
||||
u8g2_Setup_ssd1306_i2c_128x64_noname_2(&u8g2, U8G2_R0, u8x8_byte_sw_i2c, u8x8_gpio_and_delay_lpc824);
|
||||
u8g2_InitDisplay(&u8g2);
|
||||
u8g2_SetPowerSave(&u8g2, 0);
|
||||
|
||||
|
||||
for(;;)
|
||||
{
|
||||
Chip_GPIO_SetPinOutHigh(LPC_GPIO_PORT, 0, 15);
|
||||
delay_micro_seconds(1000000);
|
||||
|
||||
u8g2_FirstPage(&u8g2);
|
||||
do
|
||||
{
|
||||
draw(&u8g2);
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
|
||||
Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 0, 15);
|
||||
delay_micro_seconds(1000000);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#define I2C_DATA_PIN 11
|
||||
#define I2C_DATA_PORT 0
|
||||
|
||||
uint8_t u8x8_gpio_and_delay_lpc11u3x(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
uint8_t u8x8_gpio_and_delay_lpc824(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
|
|
|
@ -69,6 +69,67 @@ u8x8_t u8x8;
|
|||
u8g2_t u8g2;
|
||||
u8g2_t desc;
|
||||
|
||||
#define u8g2_logo_97x51_width 97
|
||||
#define u8g2_logo_97x51_height 51
|
||||
static unsigned char u8g2_logo_97x51_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
|
||||
0x03, 0x00, 0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0x03, 0x00, 0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x80, 0xcf, 0x07, 0x00, 0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0x83, 0x07, 0x00, 0x00, 0x3c, 0x80, 0x07, 0xf8, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x81, 0x07, 0x00, 0x00, 0x3c, 0x80, 0x07, 0xfc, 0x03,
|
||||
0x1c, 0x00, 0x3e, 0x1c, 0xc0, 0x03, 0x00, 0x00, 0x3c, 0x80, 0x07, 0xff,
|
||||
0x07, 0x7f, 0x80, 0xff, 0x3f, 0xe0, 0x01, 0x00, 0x00, 0x3c, 0x80, 0x07,
|
||||
0xff, 0x8f, 0xff, 0xc1, 0xff, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x3c, 0x80,
|
||||
0x87, 0xff, 0xdf, 0xff, 0xc1, 0xc3, 0x07, 0x7c, 0x00, 0x00, 0x00, 0x3c,
|
||||
0x80, 0x87, 0x0f, 0xfe, 0xff, 0xe3, 0x81, 0x03, 0x1e, 0x00, 0x00, 0x00,
|
||||
0x3c, 0x80, 0xc7, 0x07, 0xfc, 0xe3, 0xe3, 0x81, 0x07, 0x0f, 0x00, 0x00,
|
||||
0x00, 0x3c, 0x80, 0xc7, 0x07, 0xf8, 0xc1, 0xe7, 0x81, 0x87, 0xff, 0x07,
|
||||
0x00, 0x00, 0x3c, 0x80, 0xc7, 0x03, 0xf0, 0x80, 0xe7, 0xc3, 0x87, 0xff,
|
||||
0x07, 0x00, 0x00, 0x3c, 0x80, 0xc7, 0x03, 0x70, 0x80, 0xc7, 0xe7, 0x83,
|
||||
0xff, 0x07, 0x00, 0x00, 0x3c, 0x80, 0xc7, 0x03, 0x78, 0x80, 0xc7, 0xff,
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x80, 0xc7, 0x03, 0xf8, 0xc0, 0x87,
|
||||
0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x80, 0xc7, 0x07, 0xfc, 0xc1,
|
||||
0xc7, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xc0, 0x87, 0x0f, 0xfe,
|
||||
0xff, 0xe3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xc0, 0x83, 0xff,
|
||||
0xdf, 0xff, 0xe3, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xf1, 0x03,
|
||||
0xff, 0x8f, 0xff, 0xe1, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
|
||||
0x01, 0xfe, 0x0f, 0xff, 0xc0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0,
|
||||
0xff, 0x00, 0xfc, 0x03, 0x7c, 0xc0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
|
||||
0x80, 0x3f, 0x00, 0xf8, 0x01, 0x00, 0xe0, 0x01, 0x1e, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x1e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x1e, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xf0, 0xc7, 0x0f,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xe0, 0xff,
|
||||
0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xc0,
|
||||
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 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, 0x40, 0x24, 0x20, 0x00,
|
||||
0x00, 0x08, 0x46, 0x02, 0x00, 0x80, 0xc0, 0x40, 0x00, 0x0c, 0x6e, 0x6a,
|
||||
0xc0, 0xa4, 0x48, 0x04, 0xaa, 0xac, 0x8c, 0xaa, 0xac, 0x00, 0x6a, 0xa4,
|
||||
0xaa, 0x20, 0xea, 0xa4, 0x64, 0x66, 0xaa, 0x46, 0x4a, 0x8a, 0x00, 0x4c,
|
||||
0xa4, 0xaa, 0x20, 0xaa, 0xa2, 0x44, 0x2a, 0xaa, 0x28, 0xaa, 0x4c, 0x00,
|
||||
0xe8, 0xa8, 0x6c, 0xc4, 0xa4, 0x42, 0xee, 0x2a, 0xcc, 0x26, 0x6c, 0xe8,
|
||||
0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 };
|
||||
|
||||
|
||||
void ra(uint16_t tx, uint16_t ty, const char *s)
|
||||
{
|
||||
int x,y, i, w;
|
||||
|
@ -655,6 +716,80 @@ int main(void)
|
|||
tga_save_png("u8g2_xor.png");
|
||||
|
||||
|
||||
/*=========================================*/
|
||||
/* u8g2_bitmap_solid.png */
|
||||
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
|
||||
u8g2_SetFontMode(&u8g2, 1);
|
||||
u8g2_SetFontPosBaseline(&u8g2);
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_FirstPage(&u8g2);
|
||||
do
|
||||
{
|
||||
u8g2_SetDrawColor(&u8g2, 1);
|
||||
u8g2_SetBitmapMode(&u8g2, 0);
|
||||
u8g2_DrawXBM(&u8g2, 4,3, u8g2_logo_97x51_width, u8g2_logo_97x51_height, u8g2_logo_97x51_bits);
|
||||
u8g2_DrawXBM(&u8g2, 12,11, u8g2_logo_97x51_width, u8g2_logo_97x51_height, u8g2_logo_97x51_bits);
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
u8g2_SetDrawColor(&u8g2, 1);
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(4,3, "(4, 3)");
|
||||
ra(12,11, "(12, 11)");
|
||||
|
||||
|
||||
//vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
|
||||
tga_is_transparent = 0;
|
||||
u8g2_SetFontPosBaseline(&u8g2);
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
|
||||
tga_save_png("u8g2_bitmap_solid.png");
|
||||
|
||||
|
||||
/*=========================================*/
|
||||
/* u8g2_bitmap_transparent.png */
|
||||
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
|
||||
u8g2_SetFontMode(&u8g2, 1);
|
||||
u8g2_SetFontPosBaseline(&u8g2);
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_FirstPage(&u8g2);
|
||||
do
|
||||
{
|
||||
u8g2_SetDrawColor(&u8g2, 1);
|
||||
u8g2_SetBitmapMode(&u8g2, 1);
|
||||
u8g2_DrawXBM(&u8g2, 4,3, u8g2_logo_97x51_width, u8g2_logo_97x51_height, u8g2_logo_97x51_bits);
|
||||
u8g2_DrawXBM(&u8g2, 12,11, u8g2_logo_97x51_width, u8g2_logo_97x51_height, u8g2_logo_97x51_bits);
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
u8g2_SetDrawColor(&u8g2, 1);
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(4,3, "(4, 3)");
|
||||
ra(12,11, "(12, 11)");
|
||||
|
||||
|
||||
//vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
|
||||
tga_is_transparent = 0;
|
||||
u8g2_SetFontPosBaseline(&u8g2);
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
|
||||
tga_save_png("u8g2_bitmap_transparent.png");
|
||||
|
||||
|
||||
/*=========================================*/
|
||||
/* u8g2_color.png */
|
||||
|
||||
|
|
Loading…
Reference in New Issue