mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-01-30 21:12:55 +08:00
Submodulify ucg and update to v1.5.2 (#2503)
* turn ucg into submodule * update ucg to 1.5.2 * add license note to doc * align docs with esp32 * move ucg hal into platform folder adapt examples
This commit is contained in:
parent
5f67de8d48
commit
67567af959
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +1,6 @@
|
||||
[submodule "app/u8g2lib/u8g2"]
|
||||
path = app/u8g2lib/u8g2
|
||||
url = https://github.com/olikraus/U8g2_Arduino.git
|
||||
[submodule "app/ucglib/ucg"]
|
||||
path = app/ucglib/ucg
|
||||
url = https://github.com/olikraus/Ucglib_Arduino.git
|
||||
|
@ -27,8 +27,10 @@
|
||||
// Uncomment the UCG_DISPLAY_TABLE_ENTRY for the device(s) you want to
|
||||
// compile into the firmware.
|
||||
//
|
||||
// UCG_DISPLAY_TABLE_ENTRY(hx8352c_18x240x400_hw_spi, ucg_dev_hx8352c_18x240x400, ucg_ext_hx8352c_18) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(ili9163_18x128x128_hw_spi, ucg_dev_ili9163_18x128x128, ucg_ext_ili9163_18) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(ili9341_18x240x320_hw_spi, ucg_dev_ili9341_18x240x320, ucg_ext_ili9341_18) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(ili9486_18x320x480_hw_spi, ucg_dev_ili9486_18x320x480, ucg_ext_ili9486_18) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(pcf8833_16x132x132_hw_spi, ucg_dev_pcf8833_16x132x132, ucg_ext_pcf8833_16) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(seps225_16x128x128_uvis_hw_spi, ucg_dev_seps225_16x128x128_univision, ucg_ext_seps225_16) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(ssd1351_18x128x128_hw_spi, ucg_dev_ssd1351_18x128x128_ilsoft, ucg_ext_ssd1351_18) \
|
||||
|
@ -44,7 +44,7 @@ INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../coap
|
||||
INCLUDES += -I ../mqtt
|
||||
INCLUDES += -I ../u8g2lib/u8g2/src/clib
|
||||
INCLUDES += -I ../ucglib
|
||||
INCLUDES += -I ../ucglib/ucg/src/clib
|
||||
INCLUDES += -I ../lua
|
||||
INCLUDES += -I ../pcm
|
||||
INCLUDES += -I ../platform
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -44,6 +44,7 @@ INCLUDES += -I ../spiffs
|
||||
INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../lua
|
||||
INCLUDES += -I ../u8g2lib/u8g2/src/clib
|
||||
INCLUDES += -I ../ucglib/ucg/src/clib
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
|
129
app/platform/ucg_nodemcu_hal.c
Normal file
129
app/platform/ucg_nodemcu_hal.c
Normal file
@ -0,0 +1,129 @@
|
||||
// Do not use the code from ucg submodule and skip the complete source here
|
||||
// if the ucg module is not selected.
|
||||
// Reason: The whole ucg submodule code tree might not even exist in this case.
|
||||
#include "user_modules.h"
|
||||
#ifdef LUA_USE_MODULES_UCG
|
||||
|
||||
#include <string.h>
|
||||
#include "c_stdlib.h"
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#define USE_PIN_LIST
|
||||
#include "ucg_nodemcu_hal.h"
|
||||
|
||||
#define delayMicroseconds os_delay_us
|
||||
|
||||
|
||||
static spi_data_type cache;
|
||||
static uint8_t cached;
|
||||
|
||||
#define CACHED_TRANSFER(dat, num) cache = cached = 0; \
|
||||
while( arg > 0 ) { \
|
||||
if (cached == 4) { \
|
||||
platform_spi_transaction( 1, 0, 0, 32, cache, 0, 0, 0 ); \
|
||||
cache = cached = 0; \
|
||||
} \
|
||||
cache = (cache << num*8) | dat; \
|
||||
cached += num; \
|
||||
arg--; \
|
||||
} \
|
||||
if (cached > 0) { \
|
||||
platform_spi_transaction( 1, 0, 0, cached * 8, cache, 0, 0, 0 ); \
|
||||
}
|
||||
|
||||
|
||||
int16_t ucg_com_nodemcu_hw_spi(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_COM_MSG_POWER_UP:
|
||||
/* "data" is a pointer to ucg_com_info_t structure with the following information: */
|
||||
/* ((ucg_com_info_t *)data)->serial_clk_speed value in nanoseconds */
|
||||
/* ((ucg_com_info_t *)data)->parallel_clk_speed value in nanoseconds */
|
||||
|
||||
/* setup pins */
|
||||
|
||||
// we assume that the SPI interface was already initialized
|
||||
// just care for the /CS and D/C pins
|
||||
//platform_gpio_write( ucg->pin_list[0], value );
|
||||
|
||||
if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE )
|
||||
platform_gpio_mode( ucg->pin_list[UCG_PIN_RST], PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_FLOAT );
|
||||
platform_gpio_mode( ucg->pin_list[UCG_PIN_CD], PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_FLOAT );
|
||||
|
||||
if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE )
|
||||
platform_gpio_mode( ucg->pin_list[UCG_PIN_CS], PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_FLOAT );
|
||||
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_POWER_DOWN:
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_DELAY:
|
||||
delayMicroseconds(arg);
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_CHANGE_RESET_LINE:
|
||||
if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE )
|
||||
platform_gpio_write( ucg->pin_list[UCG_PIN_RST], arg );
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_CHANGE_CS_LINE:
|
||||
if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE )
|
||||
platform_gpio_write( ucg->pin_list[UCG_PIN_CS], arg );
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_CHANGE_CD_LINE:
|
||||
platform_gpio_write( ucg->pin_list[UCG_PIN_CD], arg );
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_SEND_BYTE:
|
||||
platform_spi_send( 1, 8, arg );
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_REPEAT_1_BYTE:
|
||||
CACHED_TRANSFER(data[0], 1);
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_REPEAT_2_BYTES:
|
||||
CACHED_TRANSFER((data[0] << 8) | data[1], 2);
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_REPEAT_3_BYTES:
|
||||
while( arg > 0 ) {
|
||||
platform_spi_transaction( 1, 0, 0, 24, (data[0] << 16) | (data[1] << 8) | data[2], 0, 0, 0 );
|
||||
arg--;
|
||||
}
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_SEND_STR:
|
||||
CACHED_TRANSFER(*data++, 1);
|
||||
break;
|
||||
|
||||
case UCG_COM_MSG_SEND_CD_DATA_SEQUENCE:
|
||||
while(arg > 0)
|
||||
{
|
||||
if ( *data != 0 )
|
||||
{
|
||||
/* set the data line directly, ignore the setting from UCG_CFG_CD */
|
||||
if ( *data == 1 )
|
||||
{
|
||||
platform_gpio_write( ucg->pin_list[UCG_PIN_CD], 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
platform_gpio_write( ucg->pin_list[UCG_PIN_CD], 1 );
|
||||
}
|
||||
}
|
||||
data++;
|
||||
platform_spi_send( 1, 8, *data );
|
||||
data++;
|
||||
arg--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* LUA_USE_MODULES_UCG */
|
17
app/platform/ucg_nodemcu_hal.h
Normal file
17
app/platform/ucg_nodemcu_hal.h
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
#ifndef _UCG_NODEMCU_HAL_H
|
||||
#define _UCG_NODEMCU_HAL_H
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
// extend standard ucg_t struct with info that's needed in the communication callbacks
|
||||
typedef struct {
|
||||
ucg_t ucg;
|
||||
void *hal;
|
||||
} ucg_nodemcu_t;
|
||||
|
||||
|
||||
int16_t ucg_com_nodemcu_hw_spi(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *data);
|
||||
|
||||
#endif /* _UCG_NODEMCU_HAL_H */
|
@ -24,7 +24,7 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
|
||||
# makefile at its root level - these are then overridden
|
||||
# for a subtree within the makefile rooted therein
|
||||
#
|
||||
#DEFINES +=
|
||||
DEFINES += -DUSE_PIN_LIST
|
||||
|
||||
#############################################################
|
||||
# Recursion Magic - Don't touch this!!
|
||||
@ -38,7 +38,10 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
|
||||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
CSRCS := $(wildcard ucg/src/clib/*.c *.c)
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ucg/src/clib
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I ../libc
|
||||
PDIR := ../$(PDIR)
|
||||
|
1
app/ucglib/ucg
Submodule
1
app/ucglib/ucg
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit e21641a6c1ddb0e71f7b9e01501fa739786c68b1
|
2164
app/ucglib/ucg.h
2164
app/ucglib/ucg.h
File diff suppressed because it is too large
Load Diff
@ -1,87 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_bitmap.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
void ucg_DrawTransparentBitmapLine(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t dir, ucg_int_t len, const unsigned char *bitmap)
|
||||
{
|
||||
ucg->arg.pixel.rgb.color[0] = ucg->arg.rgb[0].color[0];
|
||||
ucg->arg.pixel.rgb.color[1] = ucg->arg.rgb[0].color[1];
|
||||
ucg->arg.pixel.rgb.color[2] = ucg->arg.rgb[0].color[2];
|
||||
ucg->arg.pixel.pos.x = x;
|
||||
ucg->arg.pixel.pos.y = y;
|
||||
ucg->arg.dir = dir;
|
||||
ucg->arg.len = len;
|
||||
ucg->arg.bitmap = bitmap;
|
||||
ucg->arg.pixel_skip = 0;
|
||||
ucg_DrawL90TCWithArg(ucg);
|
||||
}
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
void ucg_DrawBitmapLine(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t dir, ucg_int_t len, const unsigned char *bitmap)
|
||||
{
|
||||
/*
|
||||
ucg->arg.pixel.rgb.color[0] = ucg->arg.rgb[0].color[0];
|
||||
ucg->arg.pixel.rgb.color[1] = ucg->arg.rgb[0].color[1];
|
||||
ucg->arg.pixel.rgb.color[2] = ucg->arg.rgb[0].color[2];
|
||||
*/
|
||||
ucg->arg.pixel.pos.x = x;
|
||||
ucg->arg.pixel.pos.y = y;
|
||||
ucg->arg.dir = dir;
|
||||
ucg->arg.len = len;
|
||||
ucg->arg.bitmap = bitmap;
|
||||
ucg->arg.pixel_skip = 0;
|
||||
//ucg->arg.scale = 0;
|
||||
ucg_DrawL90BFWithArg(ucg);
|
||||
}
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
|
||||
#ifdef ON_HOLD
|
||||
void ucg_DrawRLBitmap(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t dir, const unsigned char *rl_bitmap)
|
||||
{
|
||||
ucg->arg.pixel.rgb.color[0] = ucg->arg.rgb[0].color[0];
|
||||
ucg->arg.pixel.rgb.color[1] = ucg->arg.rgb[0].color[1];
|
||||
ucg->arg.pixel.rgb.color[2] = ucg->arg.rgb[0].color[2];
|
||||
ucg->arg.pixel.pos.x = x;
|
||||
ucg->arg.pixel.pos.y = y;
|
||||
ucg->arg.dir = dir;
|
||||
ucg->arg.len = 0;
|
||||
ucg->arg.bitmap = rl_bitmap;
|
||||
ucg_DrawL90RLWithArg(ucg);
|
||||
}
|
||||
#endif
|
@ -1,215 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_box.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
void ucg_DrawBox(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t w, ucg_int_t h)
|
||||
{
|
||||
while( h > 0 )
|
||||
{
|
||||
ucg_DrawHLine(ucg, x, y, w);
|
||||
h--;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- clear the screen with black color
|
||||
- reset clip range to max
|
||||
- set draw color to white
|
||||
*/
|
||||
void ucg_ClearScreen(ucg_t *ucg)
|
||||
{
|
||||
ucg_SetColor(ucg, 0, 0, 0, 0);
|
||||
ucg_SetMaxClipRange(ucg);
|
||||
ucg_DrawBox(ucg, 0, 0, ucg_GetWidth(ucg), ucg_GetHeight(ucg));
|
||||
ucg_SetColor(ucg, 0, 255, 255, 255);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ucg_DrawRBox(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t w, ucg_int_t h, ucg_int_t r)
|
||||
{
|
||||
ucg_int_t xl, yu;
|
||||
ucg_int_t yl, xr;
|
||||
|
||||
xl = x;
|
||||
xl += r;
|
||||
yu = y;
|
||||
yu += r;
|
||||
|
||||
xr = x;
|
||||
xr += w;
|
||||
xr -= r;
|
||||
xr -= 1;
|
||||
|
||||
yl = y;
|
||||
yl += h;
|
||||
yl -= r;
|
||||
yl -= 1;
|
||||
|
||||
ucg_DrawDisc(ucg, xl, yu, r, UCG_DRAW_UPPER_LEFT);
|
||||
ucg_DrawDisc(ucg, xr, yu, r, UCG_DRAW_UPPER_RIGHT);
|
||||
ucg_DrawDisc(ucg, xl, yl, r, UCG_DRAW_LOWER_LEFT);
|
||||
ucg_DrawDisc(ucg, xr, yl, r, UCG_DRAW_LOWER_RIGHT);
|
||||
|
||||
{
|
||||
ucg_int_t ww, hh;
|
||||
|
||||
ww = w;
|
||||
ww -= r;
|
||||
ww -= r;
|
||||
ww -= 2;
|
||||
hh = h;
|
||||
hh -= r;
|
||||
hh -= r;
|
||||
hh -= 2;
|
||||
|
||||
xl++;
|
||||
yu++;
|
||||
h--;
|
||||
ucg_DrawBox(ucg, xl, y, ww, r+1);
|
||||
ucg_DrawBox(ucg, xl, yl, ww, r+1);
|
||||
ucg_DrawBox(ucg, x, yu, w, hh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ucg_ccs_t ucg_ccs_box[6]; /* color component sliders used by GradientBox */
|
||||
|
||||
void ucg_DrawGradientBox(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t w, ucg_int_t h)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
/* 8. Jan 2014: correct? */
|
||||
|
||||
//printf("%d %d %d\n", ucg->arg.rgb[3].color[0], ucg->arg.rgb[3].color[1], ucg->arg.rgb[3].color[2]);
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg_ccs_box+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[2].color[i], h);
|
||||
ucg_ccs_init(ucg_ccs_box+i+3, ucg->arg.rgb[1].color[i], ucg->arg.rgb[3].color[i], h);
|
||||
}
|
||||
|
||||
|
||||
while( h > 0 )
|
||||
{
|
||||
ucg->arg.rgb[0].color[0] = ucg_ccs_box[0].current;
|
||||
ucg->arg.rgb[0].color[1] = ucg_ccs_box[1].current;
|
||||
ucg->arg.rgb[0].color[2] = ucg_ccs_box[2].current;
|
||||
ucg->arg.rgb[1].color[0] = ucg_ccs_box[3].current;
|
||||
ucg->arg.rgb[1].color[1] = ucg_ccs_box[4].current;
|
||||
ucg->arg.rgb[1].color[2] = ucg_ccs_box[5].current;
|
||||
//printf("%d %d %d\n", ucg_ccs_box[0].current, ucg_ccs_box[1].current, ucg_ccs_box[2].current);
|
||||
//printf("%d %d %d\n", ucg_ccs_box[3].current, ucg_ccs_box[4].current, ucg_ccs_box[5].current);
|
||||
ucg->arg.pixel.pos.x = x;
|
||||
ucg->arg.pixel.pos.y = y;
|
||||
ucg->arg.len = w;
|
||||
ucg->arg.dir = 0;
|
||||
ucg_DrawL90SEWithArg(ucg);
|
||||
for ( i = 0; i < 6; i++ )
|
||||
ucg_ccs_step(ucg_ccs_box+i);
|
||||
h--;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* restrictions: w > 0 && h > 0 */
|
||||
void ucg_DrawFrame(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t w, ucg_int_t h)
|
||||
{
|
||||
ucg_int_t xtmp = x;
|
||||
|
||||
ucg_DrawHLine(ucg, x, y, w);
|
||||
ucg_DrawVLine(ucg, x, y, h);
|
||||
x+=w;
|
||||
x--;
|
||||
ucg_DrawVLine(ucg, x, y, h);
|
||||
y+=h;
|
||||
y--;
|
||||
ucg_DrawHLine(ucg, xtmp, y, w);
|
||||
}
|
||||
|
||||
void ucg_DrawRFrame(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t w, ucg_int_t h, ucg_int_t r)
|
||||
{
|
||||
ucg_int_t xl, yu;
|
||||
|
||||
xl = x;
|
||||
xl += r;
|
||||
yu = y;
|
||||
yu += r;
|
||||
|
||||
{
|
||||
ucg_int_t yl, xr;
|
||||
|
||||
xr = x;
|
||||
xr += w;
|
||||
xr -= r;
|
||||
xr -= 1;
|
||||
|
||||
yl = y;
|
||||
yl += h;
|
||||
yl -= r;
|
||||
yl -= 1;
|
||||
|
||||
ucg_DrawCircle(ucg, xl, yu, r, UCG_DRAW_UPPER_LEFT);
|
||||
ucg_DrawCircle(ucg, xr, yu, r, UCG_DRAW_UPPER_RIGHT);
|
||||
ucg_DrawCircle(ucg, xl, yl, r, UCG_DRAW_LOWER_LEFT);
|
||||
ucg_DrawCircle(ucg, xr, yl, r, UCG_DRAW_LOWER_RIGHT);
|
||||
}
|
||||
|
||||
{
|
||||
ucg_int_t ww, hh;
|
||||
|
||||
ww = w;
|
||||
ww -= r;
|
||||
ww -= r;
|
||||
ww -= 2;
|
||||
hh = h;
|
||||
hh -= r;
|
||||
hh -= r;
|
||||
hh -= 2;
|
||||
|
||||
xl++;
|
||||
yu++;
|
||||
h--;
|
||||
w--;
|
||||
ucg_DrawHLine(ucg, xl, y, ww);
|
||||
ucg_DrawHLine(ucg, xl, y+h, ww);
|
||||
ucg_DrawVLine(ucg, x, yu, hh);
|
||||
ucg_DrawVLine(ucg, x+w, yu, hh);
|
||||
}
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_ccs.c
|
||||
|
||||
color component slide sub library
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
e: end
|
||||
n: steps
|
||||
|
||||
|
||||
f(0) = s
|
||||
f(n) = e
|
||||
f(x) = m*x + s
|
||||
f(n-1) = m*(n-1) + s =!= e
|
||||
--> m = (e-s)/n
|
||||
f(x) = (e-s)/(n-1) * x + s
|
||||
f(0) = s
|
||||
f(1) = s + (e-s)/(n-1)
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
/*
|
||||
Setup change from "start" to "end" with a specified amount of "steps".
|
||||
After calling this procedure, ccs->current will contain the "start" value.
|
||||
*/
|
||||
void ucg_ccs_init(ucg_ccs_t *ccs, uint8_t start, uint8_t end, ucg_int_t steps)
|
||||
{
|
||||
ccs->start = start;
|
||||
ccs->num = end-start;
|
||||
ccs->den = steps-1;
|
||||
ccs->dir = 1;
|
||||
|
||||
ccs->quot = ccs->num / ccs->den;
|
||||
if ( ccs->num < 0 )
|
||||
{
|
||||
ccs->num = -ccs->num;
|
||||
ccs->dir = -1;
|
||||
}
|
||||
ccs->rem = ccs->num % ccs->den;
|
||||
|
||||
ccs->frac = ccs->den/2;
|
||||
ccs->current = start;
|
||||
}
|
||||
|
||||
/*
|
||||
Make one step towards the "end" value.
|
||||
ccs->curront will contain the updated value.
|
||||
*/
|
||||
void ucg_ccs_step(ucg_ccs_t *ccs)
|
||||
{
|
||||
|
||||
ccs->current += ccs->quot;
|
||||
ccs->frac += ccs->rem;
|
||||
if ( ccs->frac >= ccs->den )
|
||||
{
|
||||
ccs->current += ccs->dir;
|
||||
ccs->frac -= ccs->den;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
f(x) = (e-s)/(n-1) * x + s
|
||||
current = (num / den) * (pos / den)
|
||||
|
||||
Seek to the specified "pos"ition.
|
||||
"pos" must be between 0 and "end"-1
|
||||
*/
|
||||
void ucg_ccs_seek(ucg_ccs_t *ccs, ucg_int_t pos)
|
||||
{
|
||||
ucg_int_t p;
|
||||
ccs->current = ccs->quot;
|
||||
ccs->current *= pos;
|
||||
p = ccs->rem * pos + ccs->den/2;
|
||||
if ( ccs->dir >= 0 )
|
||||
ccs->current += p / ccs->den;
|
||||
else
|
||||
ccs->current -= p / ccs->den;
|
||||
ccs->frac = p % ccs->den;
|
||||
ccs->current += ccs->start;
|
||||
}
|
||||
|
@ -1,217 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_circle.c
|
||||
|
||||
Circle Drawing Procedures
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
static void ucg_draw_circle_section(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t x0, ucg_int_t y0, uint8_t option) UCG_NOINLINE;
|
||||
|
||||
static void ucg_draw_circle_section(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t x0, ucg_int_t y0, uint8_t option)
|
||||
{
|
||||
/* upper right */
|
||||
if ( option & UCG_DRAW_UPPER_RIGHT )
|
||||
{
|
||||
ucg_DrawPixel(ucg, x0 + x, y0 - y);
|
||||
ucg_DrawPixel(ucg, x0 + y, y0 - x);
|
||||
}
|
||||
|
||||
/* upper left */
|
||||
if ( option & UCG_DRAW_UPPER_LEFT )
|
||||
{
|
||||
ucg_DrawPixel(ucg, x0 - x, y0 - y);
|
||||
ucg_DrawPixel(ucg, x0 - y, y0 - x);
|
||||
}
|
||||
|
||||
/* lower right */
|
||||
if ( option & UCG_DRAW_LOWER_RIGHT )
|
||||
{
|
||||
ucg_DrawPixel(ucg, x0 + x, y0 + y);
|
||||
ucg_DrawPixel(ucg, x0 + y, y0 + x);
|
||||
}
|
||||
|
||||
/* lower left */
|
||||
if ( option & UCG_DRAW_LOWER_LEFT )
|
||||
{
|
||||
ucg_DrawPixel(ucg, x0 - x, y0 + y);
|
||||
ucg_DrawPixel(ucg, x0 - y, y0 + x);
|
||||
}
|
||||
}
|
||||
|
||||
void ucg_draw_circle(ucg_t *ucg, ucg_int_t x0, ucg_int_t y0, ucg_int_t rad, uint8_t option)
|
||||
{
|
||||
ucg_int_t f;
|
||||
ucg_int_t ddF_x;
|
||||
ucg_int_t ddF_y;
|
||||
ucg_int_t x;
|
||||
ucg_int_t y;
|
||||
|
||||
f = 1;
|
||||
f -= rad;
|
||||
ddF_x = 1;
|
||||
ddF_y = 0;
|
||||
ddF_y -= rad;
|
||||
ddF_y *= 2;
|
||||
x = 0;
|
||||
y = rad;
|
||||
|
||||
ucg_draw_circle_section(ucg, x, y, x0, y0, option);
|
||||
|
||||
while ( x < y )
|
||||
{
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
ucg_draw_circle_section(ucg, x, y, x0, y0, option);
|
||||
}
|
||||
}
|
||||
|
||||
void ucg_DrawCircle(ucg_t *ucg, ucg_int_t x0, ucg_int_t y0, ucg_int_t rad, uint8_t option)
|
||||
{
|
||||
/* check for bounding box */
|
||||
/*
|
||||
{
|
||||
ucg_int_t radp, radp2;
|
||||
|
||||
radp = rad;
|
||||
radp++;
|
||||
radp2 = radp;
|
||||
radp2 *= 2;
|
||||
|
||||
if ( ucg_IsBBXIntersection(ucg, x0-radp, y0-radp, radp2, radp2) == 0)
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
/* draw circle */
|
||||
ucg_draw_circle(ucg, x0, y0, rad, option);
|
||||
}
|
||||
|
||||
static void ucg_draw_disc_section(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t x0, ucg_int_t y0, uint8_t option) UCG_NOINLINE;
|
||||
|
||||
static void ucg_draw_disc_section(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t x0, ucg_int_t y0, uint8_t option)
|
||||
{
|
||||
/* upper right */
|
||||
if ( option & UCG_DRAW_UPPER_RIGHT )
|
||||
{
|
||||
ucg_DrawVLine(ucg, x0+x, y0-y, y+1);
|
||||
ucg_DrawVLine(ucg, x0+y, y0-x, x+1);
|
||||
}
|
||||
|
||||
/* upper left */
|
||||
if ( option & UCG_DRAW_UPPER_LEFT )
|
||||
{
|
||||
ucg_DrawVLine(ucg, x0-x, y0-y, y+1);
|
||||
ucg_DrawVLine(ucg, x0-y, y0-x, x+1);
|
||||
}
|
||||
|
||||
/* lower right */
|
||||
if ( option & UCG_DRAW_LOWER_RIGHT )
|
||||
{
|
||||
ucg_DrawVLine(ucg, x0+x, y0, y+1);
|
||||
ucg_DrawVLine(ucg, x0+y, y0, x+1);
|
||||
}
|
||||
|
||||
/* lower left */
|
||||
if ( option & UCG_DRAW_LOWER_LEFT )
|
||||
{
|
||||
ucg_DrawVLine(ucg, x0-x, y0, y+1);
|
||||
ucg_DrawVLine(ucg, x0-y, y0, x+1);
|
||||
}
|
||||
}
|
||||
|
||||
void ucg_draw_disc(ucg_t *ucg, ucg_int_t x0, ucg_int_t y0, ucg_int_t rad, uint8_t option)
|
||||
{
|
||||
ucg_int_t f;
|
||||
ucg_int_t ddF_x;
|
||||
ucg_int_t ddF_y;
|
||||
ucg_int_t x;
|
||||
ucg_int_t y;
|
||||
|
||||
f = 1;
|
||||
f -= rad;
|
||||
ddF_x = 1;
|
||||
ddF_y = 0;
|
||||
ddF_y -= rad;
|
||||
ddF_y *= 2;
|
||||
x = 0;
|
||||
y = rad;
|
||||
|
||||
ucg_draw_disc_section(ucg, x, y, x0, y0, option);
|
||||
|
||||
while ( x < y )
|
||||
{
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
ucg_draw_disc_section(ucg, x, y, x0, y0, option);
|
||||
}
|
||||
}
|
||||
|
||||
void ucg_DrawDisc(ucg_t *ucg, ucg_int_t x0, ucg_int_t y0, ucg_int_t rad, uint8_t option)
|
||||
{
|
||||
/* check for bounding box */
|
||||
/*
|
||||
{
|
||||
ucg_int_t radp, radp2;
|
||||
|
||||
radp = rad;
|
||||
radp++;
|
||||
radp2 = radp;
|
||||
radp2 *= 2;
|
||||
|
||||
if ( ucg_IsBBXIntersection(ucg, x0-radp, y0-radp, radp2, radp2) == 0)
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
/* draw disc */
|
||||
ucg_draw_disc(ucg, x0, y0, rad, option);
|
||||
}
|
||||
|
@ -1,252 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_clip.c
|
||||
|
||||
Clipping procedures for the device funktions
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
static ucg_int_t ucg_clip_is_x_visible(ucg_t *ucg) UCG_NOINLINE;
|
||||
static ucg_int_t ucg_clip_is_y_visible(ucg_t *ucg) UCG_NOINLINE;
|
||||
|
||||
static ucg_int_t ucg_clip_is_x_visible(ucg_t *ucg)
|
||||
{
|
||||
ucg_int_t t;
|
||||
t = ucg->arg.pixel.pos.x;
|
||||
t -= ucg->clip_box.ul.x;
|
||||
if ( t < 0 )
|
||||
return 0;
|
||||
if ( t >= ucg->clip_box.size.w )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static ucg_int_t ucg_clip_is_y_visible(ucg_t *ucg)
|
||||
{
|
||||
ucg_int_t t;
|
||||
t = ucg->arg.pixel.pos.y;
|
||||
t -= ucg->clip_box.ul.y;
|
||||
if ( t < 0 )
|
||||
return 0;
|
||||
if ( t >= ucg->clip_box.size.h )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
Description:
|
||||
clip range from a (included) to b (excluded) agains c (included) to d (excluded)
|
||||
Assumptions:
|
||||
a <= b
|
||||
c <= d
|
||||
*/
|
||||
static ucg_int_t ucg_clip_intersection(ucg_int_t *ap, ucg_int_t *bp, ucg_int_t c, ucg_int_t d)
|
||||
{
|
||||
ucg_int_t a = *ap;
|
||||
ucg_int_t b = *bp;
|
||||
|
||||
if ( a >= d )
|
||||
return 0;
|
||||
if ( b <= c )
|
||||
return 0;
|
||||
if ( a < c )
|
||||
*ap = c;
|
||||
if ( b > d )
|
||||
*bp = d;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ucg_int_t ucg_clip_is_pixel_visible(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_is_x_visible(ucg) == 0 )
|
||||
return 0;
|
||||
if ( ucg_clip_is_y_visible(ucg) == 0 )
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
assumes, that ucg->arg contains data for l90fx and does clipping
|
||||
against ucg->clip_box
|
||||
*/
|
||||
ucg_int_t ucg_clip_l90fx(ucg_t *ucg)
|
||||
{
|
||||
ucg_int_t a;
|
||||
ucg_int_t b;
|
||||
ucg->arg.offset = 0;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
if ( ucg_clip_is_y_visible(ucg) == 0 )
|
||||
return 0;
|
||||
a = ucg->arg.pixel.pos.x;
|
||||
b = a;
|
||||
b += ucg->arg.len;
|
||||
|
||||
if ( ucg_clip_intersection(&a, &b, ucg->clip_box.ul.x, ucg->clip_box.ul.x+ucg->clip_box.size.w) == 0 )
|
||||
return 0;
|
||||
|
||||
ucg->arg.offset = a - ucg->arg.pixel.pos.x;
|
||||
ucg->arg.pixel.pos.x = a;
|
||||
b -= a;
|
||||
ucg->arg.len = b;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
if ( ucg_clip_is_x_visible(ucg) == 0 )
|
||||
return 0;
|
||||
|
||||
a = ucg->arg.pixel.pos.y;
|
||||
b = a;
|
||||
b += ucg->arg.len;
|
||||
|
||||
if ( ucg_clip_intersection(&a, &b, ucg->clip_box.ul.y, ucg->clip_box.ul.y+ucg->clip_box.size.h) == 0 )
|
||||
return 0;
|
||||
|
||||
ucg->arg.offset = a - ucg->arg.pixel.pos.y;
|
||||
ucg->arg.pixel.pos.y = a;
|
||||
b -= a;
|
||||
ucg->arg.len = b;
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if ( ucg_clip_is_y_visible(ucg) == 0 )
|
||||
return 0;
|
||||
|
||||
b = ucg->arg.pixel.pos.x;
|
||||
b++;
|
||||
|
||||
a = b;
|
||||
a -= ucg->arg.len;
|
||||
|
||||
|
||||
if ( ucg_clip_intersection(&a, &b, ucg->clip_box.ul.x, ucg->clip_box.ul.x+ucg->clip_box.size.w) == 0 )
|
||||
return 0;
|
||||
|
||||
ucg->arg.len = b-a;
|
||||
|
||||
b--;
|
||||
ucg->arg.offset = ucg->arg.pixel.pos.x-b;
|
||||
ucg->arg.pixel.pos.x = b;
|
||||
|
||||
break;
|
||||
case 3:
|
||||
if ( ucg_clip_is_x_visible(ucg) == 0 )
|
||||
return 0;
|
||||
|
||||
b = ucg->arg.pixel.pos.y;
|
||||
b++;
|
||||
|
||||
a = b;
|
||||
a -= ucg->arg.len;
|
||||
|
||||
|
||||
if ( ucg_clip_intersection(&a, &b, ucg->clip_box.ul.y, ucg->clip_box.ul.y+ucg->clip_box.size.h) == 0 )
|
||||
return 0;
|
||||
|
||||
ucg->arg.len = b-a;
|
||||
|
||||
b--;
|
||||
ucg->arg.offset = ucg->arg.pixel.pos.y-b;
|
||||
ucg->arg.pixel.pos.y = b;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
ucg_int_t ucg_clip_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90fx(ucg) == 0 )
|
||||
return 0;
|
||||
ucg->arg.pixel_skip = ucg->arg.offset & 0x07;
|
||||
ucg->arg.bitmap += (ucg->arg.offset >>3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* old code
|
||||
ucg_int_t ucg_clip_l90tc(ucg_t *ucg)
|
||||
{
|
||||
ucg_int_t t;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
t = ucg->arg.pixel.pos.x;
|
||||
if ( ucg_clip_l90fx(ucg) == 0 )
|
||||
return 0;
|
||||
t = ucg->arg.pixel.pos.x - t;
|
||||
break;
|
||||
case 1:
|
||||
t = ucg->arg.pixel.pos.y;
|
||||
if ( ucg_clip_l90fx(ucg) == 0 )
|
||||
return 0;
|
||||
t = ucg->arg.pixel.pos.y - t;
|
||||
break;
|
||||
case 2:
|
||||
t = ucg->arg.pixel.pos.x;
|
||||
if ( ucg_clip_l90fx(ucg) == 0 )
|
||||
return 0;
|
||||
t -= ucg->arg.pixel.pos.x;
|
||||
break;
|
||||
case 3:
|
||||
t = ucg->arg.pixel.pos.y;
|
||||
if ( ucg_clip_l90fx(ucg) == 0 )
|
||||
return 0;
|
||||
t -= ucg->arg.pixel.pos.y;
|
||||
break;
|
||||
}
|
||||
ucg->arg.pixel_skip = t & 0x07;
|
||||
ucg->arg.bitmap += (t >>3);
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
ucg_int_t ucg_clip_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
if ( ucg_clip_l90fx(ucg) == 0 )
|
||||
return 0;
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_seek(ucg->arg.ccs_line+i, ucg->arg.offset);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,406 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_com_msg_api.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
int16_t ucg_com_template_cb(ucg_t *ucg, int16_t msg, uint32_t arg, uint8_t *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_COM_MSG_POWER_UP:
|
||||
break;
|
||||
case UCG_COM_MSG_POWER_DOWN:
|
||||
break;
|
||||
case UCG_COM_MSG_DELAY:
|
||||
break;
|
||||
case UCG_COM_MSG_CHANGE_RESET_LINE:
|
||||
break;
|
||||
case UCG_COM_MSG_CHANGE_CS_LINE:
|
||||
break;
|
||||
case UCG_COM_MSG_CHANGE_CD_LINE:
|
||||
break;
|
||||
case UCG_COM_MSG_SEND_BYTE:
|
||||
break;
|
||||
case UCG_COM_MSG_REPEAT_1_BYTE:
|
||||
break;
|
||||
case UCG_COM_MSG_REPEAT_2_BYTES:
|
||||
break;
|
||||
case UCG_COM_MSG_REPEAT_3_BYTES:
|
||||
break;
|
||||
case UCG_COM_MSG_SEND_STR:
|
||||
break;
|
||||
case UCG_COM_MSG_SEND_CD_DATA_SEQUENCE:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void ucg_com_PowerDown(ucg_t *ucg)
|
||||
{
|
||||
if ( (ucg->com_status & UCG_COM_STATUS_MASK_POWER) != 0 )
|
||||
ucg->com_cb(ucg, UCG_COM_MSG_POWER_DOWN, 0, NULL);
|
||||
ucg->com_status &= ~UCG_COM_STATUS_MASK_POWER;
|
||||
}
|
||||
|
||||
/*
|
||||
clk_speed in nano-seconds, range: 0..4095
|
||||
*/
|
||||
int16_t ucg_com_PowerUp(ucg_t *ucg, uint16_t serial_clk_speed, uint16_t parallel_clk_speed)
|
||||
{
|
||||
int16_t r;
|
||||
ucg_com_info_t com_info;
|
||||
com_info.serial_clk_speed = serial_clk_speed;
|
||||
com_info.parallel_clk_speed = parallel_clk_speed;
|
||||
|
||||
ucg_com_PowerDown(ucg);
|
||||
ucg->com_initial_change_sent = 0;
|
||||
r = ucg->com_cb(ucg, UCG_COM_MSG_POWER_UP, 0UL, (uint8_t *)&com_info);
|
||||
if ( r != 0 )
|
||||
{
|
||||
ucg->com_status |= UCG_COM_STATUS_MASK_POWER;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void ucg_com_SetLineStatus(ucg_t *ucg, uint8_t level, uint8_t mask, uint8_t msg)
|
||||
{
|
||||
if ( level == 0 )
|
||||
{
|
||||
if ( (ucg->com_initial_change_sent & mask) == 0 || (ucg->com_status & mask) == mask )
|
||||
{
|
||||
ucg->com_cb(ucg, msg, level, NULL);
|
||||
ucg->com_status &= ~mask;
|
||||
ucg->com_initial_change_sent |= mask;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (ucg->com_initial_change_sent & mask) == 0 || (ucg->com_status & mask) == 0 )
|
||||
{
|
||||
ucg->com_cb(ucg, msg, level, NULL);
|
||||
ucg->com_status |= mask;
|
||||
ucg->com_initial_change_sent |= mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ucg_com_SetResetLineStatus(ucg_t *ucg, uint8_t level)
|
||||
{
|
||||
ucg_com_SetLineStatus(ucg, level, UCG_COM_STATUS_MASK_RESET, UCG_COM_MSG_CHANGE_RESET_LINE);
|
||||
}
|
||||
|
||||
void ucg_com_SetCSLineStatus(ucg_t *ucg, uint8_t level)
|
||||
{
|
||||
ucg_com_SetLineStatus(ucg, level, UCG_COM_STATUS_MASK_CS, UCG_COM_MSG_CHANGE_CS_LINE);
|
||||
}
|
||||
|
||||
void ucg_com_SetCDLineStatus(ucg_t *ucg, uint8_t level)
|
||||
{
|
||||
ucg_com_SetLineStatus(ucg, level, UCG_COM_STATUS_MASK_CD, UCG_COM_MSG_CHANGE_CD_LINE);
|
||||
}
|
||||
|
||||
/* delay in microseconds */
|
||||
void ucg_com_DelayMicroseconds(ucg_t *ucg, uint16_t delay)
|
||||
{
|
||||
ucg->com_cb(ucg, UCG_COM_MSG_DELAY, delay, NULL);
|
||||
}
|
||||
|
||||
/* delay in milliseconds */
|
||||
void ucg_com_DelayMilliseconds(ucg_t *ucg, uint16_t delay)
|
||||
{
|
||||
while( delay > 0 )
|
||||
{
|
||||
ucg_com_DelayMicroseconds(ucg, 1000);
|
||||
delay--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef ucg_com_SendByte
|
||||
void ucg_com_SendByte(ucg_t *ucg, uint8_t byte)
|
||||
{
|
||||
ucg->com_cb(ucg, UCG_COM_MSG_SEND_BYTE, byte, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ucg_com_SendRepeatByte(ucg_t *ucg, uint16_t cnt, uint8_t byte)
|
||||
{
|
||||
ucg->com_cb(ucg, UCG_COM_MSG_REPEAT_1_BYTE, cnt, &byte);
|
||||
}
|
||||
|
||||
void ucg_com_SendRepeat2Bytes(ucg_t *ucg, uint16_t cnt, uint8_t *byte_ptr)
|
||||
{
|
||||
ucg->com_cb(ucg, UCG_COM_MSG_REPEAT_2_BYTES, cnt, byte_ptr);
|
||||
}
|
||||
|
||||
|
||||
#ifndef ucg_com_SendRepeat3Bytes
|
||||
void ucg_com_SendRepeat3Bytes(ucg_t *ucg, uint16_t cnt, uint8_t *byte_ptr)
|
||||
{
|
||||
ucg->com_cb(ucg, UCG_COM_MSG_REPEAT_3_BYTES, cnt, byte_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ucg_com_SendString(ucg_t *ucg, uint16_t cnt, const uint8_t *byte_ptr)
|
||||
{
|
||||
ucg->com_cb(ucg, UCG_COM_MSG_SEND_STR, cnt, (uint8_t *)byte_ptr);
|
||||
}
|
||||
|
||||
void ucg_com_SendStringP(ucg_t *ucg, uint16_t cnt, const ucg_pgm_uint8_t *byte_ptr)
|
||||
{
|
||||
uint8_t b;
|
||||
while( cnt > 0 )
|
||||
{
|
||||
b = ucg_pgm_read(byte_ptr);
|
||||
//b = *byte_ptr;
|
||||
ucg->com_cb(ucg, UCG_COM_MSG_SEND_BYTE, b, NULL);
|
||||
byte_ptr++;
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ucg_com_SendCmdDataSequence(ucg_t *ucg, uint16_t cnt, const uint8_t *byte_ptr, uint8_t cd_line_status_at_end)
|
||||
{
|
||||
ucg->com_cb(ucg, UCG_COM_MSG_SEND_CD_DATA_SEQUENCE, cnt, (uint8_t *)byte_ptr);
|
||||
ucg_com_SetCDLineStatus(ucg, cd_line_status_at_end); // ensure that the status is set correctly for the CD line */
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Command-Sequence Language
|
||||
|
||||
CMD10 1x CMD Byte, 0x Argument Data Bytes
|
||||
CMD20 2x CMD Byte, 0x Argument Data Bytes
|
||||
CMD11 1x CMD Byte, 1x Argument Data Bytes
|
||||
CMD21 2x CMD Byte, 1x Argument Data Bytes
|
||||
CMD12 1x CMD Byte, 2x Argument Data Bytes
|
||||
CMD22 2x CMD Byte, 2x Argument Data Bytes
|
||||
CMD13 1x CMD Byte, 3x Argument Data Bytes
|
||||
CMD23 2x CMD Byte, 3x Argument Data Bytes
|
||||
CMD14 1x CMD Byte, 4x Argument Data Bytes
|
||||
CMD24 2x CMD Byte, 4x Argument Data Bytes
|
||||
|
||||
DATA1 1x Data Bytes
|
||||
DATA2 2x Data Bytes
|
||||
DATA3 3x Data Bytes
|
||||
DATA4 4x Data Bytes
|
||||
DATA5 5x Data Bytes
|
||||
DATA6 6x Data Bytes
|
||||
|
||||
RST_LOW Output 0 on reset line
|
||||
RST_HIGH Output 1 on reset line
|
||||
|
||||
CS_LOW Output 0 on chip select line
|
||||
CS_HIGH Output 1 on chip select line
|
||||
|
||||
DLY_MS Delay for specified amount of milliseconds (0..2000)
|
||||
DLY_US Delay for specified amount of microconds (0..2000)
|
||||
|
||||
Configuration
|
||||
|
||||
CFG_CD(c,a) Configure CMD/DATA line: "c" logic level CMD, "a" logic level CMD Args
|
||||
|
||||
|
||||
0000xxxx End Marker
|
||||
0001xxxx 1x CMD Byte, 0..15 Argument Data Bytes
|
||||
0010xxxx 2x CMD Byte, 0..15 Argument Data Bytes
|
||||
0011xxxx 3x CMD Byte, 0..15 Argument Data Bytes
|
||||
0100xxxx
|
||||
0101xxxx
|
||||
0110xxxx Arg Bytes 0..15
|
||||
0111xxxx Data Bytes 0...15
|
||||
1000xxxx xxxxxxxx DLY MS
|
||||
1001xxxx xxxxxxxx DLY US
|
||||
1010sssss aaaaaaaa oooooooo (var0>>s)&a|o, send as argument
|
||||
1011sssss aaaaaaaa oooooooo (var1>>s)&a|o, send as argument
|
||||
1100xxxx
|
||||
1101xxxx
|
||||
1110xxxx
|
||||
11110000 RST_LOW
|
||||
11110001 RST_HIGH
|
||||
1111001x
|
||||
11110100 CS_LOW
|
||||
11110101 CS_HIGH
|
||||
1111011x
|
||||
111110xx
|
||||
111111ca CFG_CD(c,a)
|
||||
|
||||
#define C10(c0) 0x010, (c0)
|
||||
#define C20(c0,c1) 0x020, (c0),(c1)
|
||||
#define C11(c0,a0) 0x011, (c0),(a0)
|
||||
#define C21(c0,c1,a0) 0x021, (c0),(c1),(a0)
|
||||
#define C12(c0,a0,a1) 0x012, (c0),(a0),(a1)
|
||||
#define C22(c0,c1,a0,a1) 0x022, (c0),(c1),(a0),(a1)
|
||||
#define C13(c0,a0,a1,a2) 0x013, (c0),(a0),(a1),(a2)
|
||||
#define C23(c0,c1,a0,a1,a2) 0x023, (c0),(c1),(a0),(a1),(a2)
|
||||
#define C14(c0,a0,a1,a2,a3) 0x013, (c0),(a0),(a1),(a2),(a3)
|
||||
#define C24(c0,c1,a0,a1,a2,a3) 0x023, (c0),(c1),(a0),(a1),(a2),(a3)
|
||||
|
||||
#define UCG_DATA() 0x070
|
||||
#define D1(d0) 0x071, (d0)
|
||||
#define D2(d0,d1) 0x072, (d0),(d1)
|
||||
#define D3(d0,d1,d3) 0x073, (d0),(d1),(d2)
|
||||
#define D4(d0,d1,d3,d4) 0x074, (d0),(d1),(d2),(d3)
|
||||
#define D5(d0,d1,d3,d4,d5) 0x075, (d0),(d1),(d2),(d3),(d5)
|
||||
#define D6(d0,d1,d3,d4,d5,d6) 0x076, (d0),(d1),(d2),(d3),(d5),(d6)
|
||||
|
||||
#define DLY_MS(t) 0x080 | (((t)>>8)&15), (t)&255
|
||||
#define DLY_US(t) 0x090 | (((t)>>8)&15), (t)&255
|
||||
|
||||
s: Shift right
|
||||
a: And mask
|
||||
o: Or mask
|
||||
#define UCG_VARX(s,a,o) 0x0a0 | ((s)&15), (a), (o)
|
||||
#define UCG_VARY(s,a,o) 0x0b0 | ((s)&15), (a), (o)
|
||||
|
||||
#define RST(level) 0x0f0 | ((level)&1)
|
||||
#define CS(level) 0x0f4 | ((level)&1)
|
||||
#define CFG_CD(c,a) 0x0fc | (((c)&1)<<1) | ((a)&1)
|
||||
|
||||
#define END() 0x00
|
||||
|
||||
*/
|
||||
|
||||
static void ucg_com_SendCmdArg(ucg_t *ucg, const ucg_pgm_uint8_t *data, uint8_t cmd_cnt, uint8_t arg_cnt)
|
||||
{
|
||||
ucg_com_SetCDLineStatus(ucg, (ucg->com_cfg_cd>>1)&1 );
|
||||
ucg_com_SendStringP(ucg, cmd_cnt, data);
|
||||
if ( arg_cnt > 0 )
|
||||
{
|
||||
data += cmd_cnt;
|
||||
ucg_com_SetCDLineStatus(ucg, (ucg->com_cfg_cd)&1 );
|
||||
ucg_com_SendStringP(ucg, arg_cnt, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//void ucg_com_SendCmdSeq(ucg_t *ucg, const ucg_pgm_uint8_t *data)
|
||||
void ucg_com_SendCmdSeq(ucg_t *ucg, const ucg_pgm_uint8_t *data)
|
||||
{
|
||||
uint8_t b;
|
||||
uint8_t bb;
|
||||
uint8_t hi;
|
||||
uint8_t lo;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
b = ucg_pgm_read(data);
|
||||
//b = *data;
|
||||
hi = (b) >> 4;
|
||||
lo = (b) & 0x0f;
|
||||
switch( hi )
|
||||
{
|
||||
case 0:
|
||||
return; /* end marker */
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
ucg_com_SendCmdArg(ucg, data+1, hi, lo);
|
||||
data+=1+hi+lo;
|
||||
break;
|
||||
case 6:
|
||||
ucg_com_SetCDLineStatus(ucg, (ucg->com_cfg_cd)&1 );
|
||||
ucg_com_SendStringP(ucg, lo, data+1);
|
||||
data+=1+lo;
|
||||
break;
|
||||
case 7: /* note: 0x070 is used to set data line status */
|
||||
ucg_com_SetCDLineStatus(ucg, ((ucg->com_cfg_cd>>1)&1)^1 );
|
||||
if ( lo > 0 )
|
||||
ucg_com_SendStringP(ucg, lo, data+1);
|
||||
data+=1+lo;
|
||||
break;
|
||||
case 8:
|
||||
data++;
|
||||
b = ucg_pgm_read(data);
|
||||
//b = *data;
|
||||
ucg_com_DelayMilliseconds(ucg, (((uint16_t)lo)<<8) + b );
|
||||
data++;
|
||||
break;
|
||||
case 9:
|
||||
data++;
|
||||
b = ucg_pgm_read(data);
|
||||
//b = *data;
|
||||
ucg_com_DelayMicroseconds(ucg, (((uint16_t)lo)<<8) + b );
|
||||
data++;
|
||||
break;
|
||||
case 10:
|
||||
data++;
|
||||
b = ucg_pgm_read(data);
|
||||
data++;
|
||||
bb = ucg_pgm_read(data);
|
||||
data++;
|
||||
//b = data[0];
|
||||
//bb = data[1];
|
||||
ucg_com_SetCDLineStatus(ucg, (ucg->com_cfg_cd)&1 );
|
||||
ucg_com_SendByte(ucg, (((uint8_t)(((ucg->arg.pixel.pos.x)>>lo)))&b)|bb );
|
||||
//data+=2;
|
||||
break;
|
||||
case 11:
|
||||
data++;
|
||||
b = ucg_pgm_read(data);
|
||||
data++;
|
||||
bb = ucg_pgm_read(data);
|
||||
data++;
|
||||
//b = data[0];
|
||||
//bb = data[1];
|
||||
ucg_com_SetCDLineStatus(ucg, (ucg->com_cfg_cd)&1 );
|
||||
ucg_com_SendByte(ucg, (((uint8_t)(((ucg->arg.pixel.pos.y)>>lo)))&b)|bb );
|
||||
//data+=2;
|
||||
break;
|
||||
case 15:
|
||||
hi = lo >> 2;
|
||||
lo &= 3;
|
||||
switch(hi)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SetResetLineStatus(ucg, lo&1);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SetCSLineStatus(ucg, lo&1);
|
||||
break;
|
||||
case 3:
|
||||
ucg->com_cfg_cd = lo;
|
||||
break;
|
||||
}
|
||||
data++;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,304 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_default_cb.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
/*
|
||||
default device callback
|
||||
this should be (finally) called by any other device callback to handle
|
||||
messages, which are not yet handled.
|
||||
*/
|
||||
|
||||
ucg_int_t ucg_dev_default_cb(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
case UCG_MSG_SET_CLIP_BOX:
|
||||
ucg->clip_box = *(ucg_box_t *)data;
|
||||
break;
|
||||
}
|
||||
return 1; /* all ok */
|
||||
}
|
||||
|
||||
/*
|
||||
will be used as default cb if no extentions callback is provided
|
||||
*/
|
||||
ucg_int_t ucg_ext_none(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
return 1; /* all ok */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
handle UCG_MSG_DRAW_L90FX message and make calls to "dev_cb" with UCG_MSG_DRAW_PIXEL
|
||||
return 1 if something has been drawn
|
||||
*/
|
||||
ucg_int_t ucg_handle_l90fx(ucg_t *ucg, ucg_dev_fnptr dev_cb)
|
||||
{
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0: dx = 1; dy = 0; break;
|
||||
case 1: dx = 0; dy = 1; break;
|
||||
case 2: dx = -1; dy = 0; break;
|
||||
case 3: dx = 0; dy = -1; break;
|
||||
default: dx = 1; dy = 0; break; /* avoid compiler warning */
|
||||
}
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
dev_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
handle UCG_MSG_DRAW_L90TC message and make calls to "dev_cb" with UCG_MSG_DRAW_PIXEL
|
||||
return 1 if something has been drawn
|
||||
*/
|
||||
ucg_int_t ucg_handle_l90tc(ucg_t *ucg, ucg_dev_fnptr dev_cb)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0: dx = 1; dy = 0; break;
|
||||
case 1: dx = 0; dy = 1; break;
|
||||
case 2: dx = -1; dy = 0; break;
|
||||
case 3: dx = 0; dy = -1; break;
|
||||
default: dx = 1; dy = 0; break; /* avoid compiler warning */
|
||||
}
|
||||
//pixmap = *(ucg->arg.bitmap);
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
dev_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
//pixmap = *(ucg->arg.bitmap);
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
handle UCG_MSG_DRAW_L90FB message and make calls to "dev_cb" with UCG_MSG_DRAW_PIXEL
|
||||
return 1 if something has been drawn
|
||||
*/
|
||||
ucg_int_t ucg_handle_l90bf(ucg_t *ucg, ucg_dev_fnptr dev_cb)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i, y;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0: dx = 1; dy = 0; break;
|
||||
case 1: dx = 0; dy = 1; break;
|
||||
case 2: dx = -1; dy = 0; break;
|
||||
case 3: dx = 0; dy = -1; break;
|
||||
default: dx = 1; dy = 0; break; /* avoid compiler warning */
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
for( y = 0; y < ucg->arg.scale; y++ )
|
||||
{
|
||||
if ( (pixmap & 128) == 0 )
|
||||
{
|
||||
ucg->arg.pixel.rgb = ucg->arg.rgb[1];
|
||||
dev_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ucg->arg.pixel.rgb = ucg->arg.rgb[0];
|
||||
dev_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
|
||||
}
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
}
|
||||
pixmap<<=1;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
handle UCG_MSG_DRAW_L90SE message and make calls to "dev_cb" with UCG_MSG_DRAW_PIXEL
|
||||
return 1 if something has been drawn
|
||||
*/
|
||||
|
||||
ucg_int_t ucg_handle_l90se(ucg_t *ucg, ucg_dev_fnptr dev_cb)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i, j;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0: dx = 1; dy = 0; break;
|
||||
case 1: dx = 0; dy = 1; break;
|
||||
case 2: dx = -1; dy = 0; break;
|
||||
case 3: dx = 0; dy = -1; break;
|
||||
default: dx = 1; dy = 0; break; /* avoid compiler warning */
|
||||
}
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
ucg->arg.pixel.rgb.color[0] = ucg->arg.ccs_line[0].current;
|
||||
ucg->arg.pixel.rgb.color[1] = ucg->arg.ccs_line[1].current;
|
||||
ucg->arg.pixel.rgb.color[2] = ucg->arg.ccs_line[2].current;
|
||||
dev_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
for ( j = 0; j < 3; j++ )
|
||||
{
|
||||
ucg_ccs_step(ucg->arg.ccs_line+j);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
l90rl run lenth encoded constant color pattern
|
||||
|
||||
yyllllll wwwwbbbb wwwwbbbb wwwwbbbb wwwwbbbb ...
|
||||
sequence terminates if wwwwbbbb = 0
|
||||
wwww: number of pixel to skip
|
||||
bbbb: number of pixel to draw with color
|
||||
llllll: number of bytes which follow, can be 0
|
||||
*/
|
||||
|
||||
#ifdef ON_HOLD
|
||||
void ucg_handle_l90rl(ucg_t *ucg, ucg_dev_fnptr dev_cb)
|
||||
{
|
||||
ucg_int_t dx, dy;
|
||||
uint8_t i, cnt;
|
||||
uint8_t rl_code;
|
||||
ucg_int_t skip;
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0: dx = 1; dy = 0; break;
|
||||
case 1: dx = 0; dy = 1; break;
|
||||
case 2: dx = -1; dy = 0; break;
|
||||
case 3: dx = 0; dy = -1; break;
|
||||
default: dx = 1; dy = 0; break; /* avoid compiler warning */
|
||||
}
|
||||
|
||||
cnt = ucg_pgm_read(ucg->arg.bitmap);
|
||||
cnt &= 63;
|
||||
ucg->arg.bitmap++;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
rl_code = ucg_pgm_read(ucg->arg.bitmap);
|
||||
if ( rl_code == 0 )
|
||||
break;
|
||||
|
||||
skip = (ucg_int_t)(rl_code >> 4);
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0: ucg->arg.pixel.pos.x+=skip; break;
|
||||
case 1: ucg->arg.pixel.pos.y+=skip; break;
|
||||
case 2: ucg->arg.pixel.pos.x-=skip; break;
|
||||
default:
|
||||
case 3: ucg->arg.pixel.pos.y-=skip; break;
|
||||
}
|
||||
|
||||
rl_code &= 15;
|
||||
while( rl_code )
|
||||
{
|
||||
dev_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
rl_code--;
|
||||
}
|
||||
ucg->arg.bitmap++;
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,402 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_ili9163.c
|
||||
|
||||
Specific code for the ili9163 controller (TFT displays)
|
||||
|
||||
Code is for 128x128 display which is shifted by 32 pixel within the controller RAM
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2015, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9163_set_pos_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11( 0x036, 0x008),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_D2(0x000, 0x07f), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_D2(0x000, 0x0a1), /* set y position */
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9163_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* 0x008 horizontal increment (dir = 0) */
|
||||
/* 0x008 vertical increment (dir = 1) */
|
||||
/* 0x048 horizontal deccrement (dir = 2) */
|
||||
/* 0x088 vertical deccrement (dir = 3) */
|
||||
UCG_C11( 0x036, 0x008),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_D2(0x000, 0x083), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_D2(0x000, 0x0a1), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9163_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
/* 0x008 horizontal increment (dir = 0) */
|
||||
/* 0x008 vertical increment (dir = 1) */
|
||||
/* 0x048 horizontal deccrement (dir = 2) */
|
||||
/* 0x088 vertical deccrement (dir = 3) */
|
||||
UCG_C11( 0x036, 0x008),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_D2(0x000, 0x0a1), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9163_set_pos_dir2_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* 0x008 horizontal increment (dir = 0) */
|
||||
/* 0x008 vertical increment (dir = 1) */
|
||||
/* 0x048 horizontal deccrement (dir = 2) */
|
||||
/* 0x088 vertical deccrement (dir = 3) */
|
||||
|
||||
UCG_C11( 0x036, 0x048),
|
||||
UCG_C11( 0x036, 0x048), /* it seems that this command needs to be sent twice */
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_D2(0x000, 0x083), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_D2(0x000, 0x0a1), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9163_set_pos_dir3_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* 0x008 horizontal increment (dir = 0) */
|
||||
/* 0x008 vertical increment (dir = 1) */
|
||||
/* 0x0c8 horizontal deccrement (dir = 2) */
|
||||
/* 0x0c8 vertical deccrement (dir = 3) */
|
||||
UCG_C11( 0x036, 0x088),
|
||||
UCG_C11( 0x036, 0x088), /* it seems that this command needs to be sent twice */
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_D2(0x000, 0x0a1), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
ucg_int_t ucg_handle_ili9163_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_int_t tmp;
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg->arg.pixel.pos.y += 32;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_dir0_seq);
|
||||
ucg->arg.pixel.pos.y -= 32;
|
||||
break;
|
||||
case 1:
|
||||
ucg->arg.pixel.pos.y += 32;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_dir1_seq);
|
||||
ucg->arg.pixel.pos.y -= 32;
|
||||
break;
|
||||
case 2:
|
||||
tmp = ucg->arg.pixel.pos.x;
|
||||
ucg->arg.pixel.pos.x = 127-tmp;
|
||||
ucg->arg.pixel.pos.y += 32;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_dir2_seq);
|
||||
ucg->arg.pixel.pos.y -= 32;
|
||||
ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
tmp = ucg->arg.pixel.pos.y;
|
||||
ucg->arg.pixel.pos.y = 127-tmp;
|
||||
//ucg->arg.pixel.pos.y += 32;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_dir3_seq);
|
||||
ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Glyph Output)
|
||||
|
||||
*/
|
||||
|
||||
/* with CmdDataSequence */
|
||||
ucg_int_t ucg_handle_ili9163_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[16];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
ucg->arg.pixel.pos.y += 32;
|
||||
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_seq);
|
||||
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x02a; // set x
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // upper part x
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // will be overwritten by x value
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x02c; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
buf[1] = 0x02a; // set x
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
buf[1] = 0x02b; // set y
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
buf[1] = 0x02a; // set x
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
buf[1] = 0x02b; // set y
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
buf[9] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[11] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[13] = ucg->arg.pixel.rgb.color[2];
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[5] = ucg->arg.pixel.pos.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.y>>8;
|
||||
buf[5] = ucg->arg.pixel.pos.y&255;
|
||||
}
|
||||
ucg_com_SendCmdDataSequence(ucg, 7, buf, 0);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_ili9163_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
ucg_int_t tmp;
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t i;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg->arg.pixel.pos.y += 32;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_dir0_seq);
|
||||
ucg->arg.pixel.pos.y -= 32;
|
||||
break;
|
||||
case 1:
|
||||
ucg->arg.pixel.pos.y += 32;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_dir1_seq);
|
||||
ucg->arg.pixel.pos.y -= 32;
|
||||
break;
|
||||
case 2:
|
||||
tmp = ucg->arg.pixel.pos.x;
|
||||
ucg->arg.pixel.pos.x = 127-tmp;
|
||||
ucg->arg.pixel.pos.y += 32;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_dir2_seq);
|
||||
ucg->arg.pixel.pos.y -= 32;
|
||||
ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
tmp = ucg->arg.pixel.pos.y;
|
||||
ucg->arg.pixel.pos.y = 127-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_dir3_seq);
|
||||
ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
c[0] = ucg->arg.ccs_line[0].current;
|
||||
c[1] = ucg->arg.ccs_line[1].current;
|
||||
c[2] = ucg->arg.ccs_line[2].current;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+0);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+1);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+2);
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9163_power_down_seq[] = {
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x010), /* sleep in */
|
||||
UCG_C10(0x28), /* display off */
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_ili9163_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 100, 66);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_power_down_seq);
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 128;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg->arg.pixel.pos.y += 32;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9163_set_pos_seq);
|
||||
ucg->arg.pixel.pos.y -= 32;
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_ili9163_18);
|
||||
ucg_handle_ili9163_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
//ucg_handle_l90tc(ucg, ucg_dev_ic_ili9163_18);
|
||||
ucg_handle_ili9163_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_ili9163_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_ili9163_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_ili9163_18);
|
||||
ucg_handle_ili9163_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,484 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_ili9325.c
|
||||
|
||||
Specific code for the ili9325 controller (TFT displays)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C22(0x000, 0x003, 0xc0 | 0x010, 0x030), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C22(0x000, 0x003, 0xc0 | 0x010, 0x038), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_dir2_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C22(0x000, 0x003, 0xc0 | 0x010, 0x000), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_dir3_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C22(0x000, 0x003, 0xc0 | 0x010, 0x008), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static ucg_int_t ucg_handle_ili9325_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir2_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir3_seq);
|
||||
break;
|
||||
}
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Glyph Output)
|
||||
Because of this for vertical lines the x min and max values in
|
||||
"ucg_ili9325_set_pos_for_y_seq" are identical to avoid changes of the x position
|
||||
|
||||
*/
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_x_pos_seq[] =
|
||||
{
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_y_pos_seq[] =
|
||||
{
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
/* without CmdDataSequence */
|
||||
ucg_int_t xxxxxx_ucg_handle_ili9325_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[3];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
const uint8_t *seq;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq);
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
seq = ucg_ili9325_set_x_pos_seq;
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
seq = ucg_ili9325_set_y_pos_seq;
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
seq = ucg_ili9325_set_x_pos_seq;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
seq = ucg_ili9325_set_y_pos_seq;
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
buf[0] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[1] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[2] = ucg->arg.pixel.rgb.color[2];
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
ucg_com_SendCmdSeq(ucg, seq);
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, buf);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* with CmdDataSequence */
|
||||
static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[20];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq);
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x020; // set x
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // upper part x
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // will be overwritten by x value
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x022; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x021; // set y
|
||||
buf[8] = 0x002; // change to 1 (arg mode)
|
||||
buf[9] = 0x000; // upper part y
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // will be overwritten by y value
|
||||
buf[12] = 0x001; // change to 0 (cmd mode)
|
||||
buf[13] = 0x022; // write data
|
||||
buf[14] = 0x002; // change to 1 (data mode)
|
||||
buf[15] = 0x000; // red value
|
||||
buf[16] = 0x000; // no change
|
||||
buf[17] = 0x000; // green value
|
||||
buf[18] = 0x000; // no change
|
||||
buf[19] = 0x000; // blue value
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x022; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x021; // set y
|
||||
buf[8] = 0x002; // change to 1 (arg mode)
|
||||
buf[9] = 0x000; // upper part y
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // will be overwritten by y value
|
||||
buf[12] = 0x001; // change to 0 (cmd mode)
|
||||
buf[13] = 0x022; // write data
|
||||
buf[14] = 0x002; // change to 1 (data mode)
|
||||
buf[15] = 0x000; // red value
|
||||
buf[16] = 0x000; // no change
|
||||
buf[17] = 0x000; // green value
|
||||
buf[18] = 0x000; // no change
|
||||
buf[19] = 0x000; // blue value
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[9] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[11] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[13] = ucg->arg.pixel.rgb.color[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[15] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[17] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[19] = ucg->arg.pixel.rgb.color[2];
|
||||
}
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[5] = ucg->arg.pixel.pos.x;
|
||||
ucg_com_SendCmdDataSequence(ucg, 7, buf, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[5] = ucg->arg.pixel.pos.x;
|
||||
buf[9] = (ucg->arg.pixel.pos.y>>8)&1;
|
||||
buf[11] = ucg->arg.pixel.pos.y&255;
|
||||
ucg_com_SendCmdDataSequence(ucg, 10, buf, 1);
|
||||
}
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static ucg_int_t ucg_handle_ili9325_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t i;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir2_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir3_seq);
|
||||
break;
|
||||
}
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
c[0] = ucg->arg.ccs_line[0].current;
|
||||
c[1] = ucg->arg.ccs_line[1].current;
|
||||
c[2] = ucg->arg.ccs_line[2].current;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+0);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+1);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+2);
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_ili9325_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 40, 100);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* not yet implemented */
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 240;
|
||||
((ucg_wh_t *)data)->h = 320;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq);
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_ili9325_18);
|
||||
ucg_handle_ili9325_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
//ucg_handle_l90tc(ucg, ucg_dev_ic_ili9325);
|
||||
ucg_handle_ili9325_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_ili9325_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_ili9325_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_ili9325);
|
||||
ucg_handle_ili9325_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,484 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_ili9325_spi.c
|
||||
|
||||
Specific code for the ili9325 controller (TFT displays) with SPI mode (IM3=0, IM2=1, IM1=1, IM0=1)
|
||||
1 May 2014: Currently, this is not working
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C12(0x003, 0xc0 | 0x010, 0x030), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C12(0x003, 0xc0 | 0x010, 0x038), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_dir2_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C12(0x003, 0xc0 | 0x010, 0x000), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_pos_dir3_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C12(0x003, 0xc0 | 0x010, 0x008), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static ucg_int_t ucg_handle_ili9325_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir2_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir3_seq);
|
||||
break;
|
||||
}
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Glyph Output)
|
||||
Because of this for vertical lines the x min and max values in
|
||||
"ucg_ili9325_set_pos_for_y_seq" are identical to avoid changes of the x position
|
||||
|
||||
*/
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_x_pos_seq[] =
|
||||
{
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9325_set_y_pos_seq[] =
|
||||
{
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
/* without CmdDataSequence */
|
||||
static ucg_int_t xxxxxx_ucg_handle_ili9325_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[3];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
const uint8_t *seq;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq);
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
seq = ucg_ili9325_set_x_pos_seq;
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
seq = ucg_ili9325_set_y_pos_seq;
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
seq = ucg_ili9325_set_x_pos_seq;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
seq = ucg_ili9325_set_y_pos_seq;
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
buf[0] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[1] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[2] = ucg->arg.pixel.rgb.color[2];
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
ucg_com_SendCmdSeq(ucg, seq);
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, buf);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* with CmdDataSequence */
|
||||
static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[20];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq);
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x020; // set x
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // upper part x
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // will be overwritten by x value
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x022; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x021; // set y
|
||||
buf[8] = 0x002; // change to 1 (arg mode)
|
||||
buf[9] = 0x000; // upper part y
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // will be overwritten by y value
|
||||
buf[12] = 0x001; // change to 0 (cmd mode)
|
||||
buf[13] = 0x022; // write data
|
||||
buf[14] = 0x002; // change to 1 (data mode)
|
||||
buf[15] = 0x000; // red value
|
||||
buf[16] = 0x000; // no change
|
||||
buf[17] = 0x000; // green value
|
||||
buf[18] = 0x000; // no change
|
||||
buf[19] = 0x000; // blue value
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x022; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x021; // set y
|
||||
buf[8] = 0x002; // change to 1 (arg mode)
|
||||
buf[9] = 0x000; // upper part y
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // will be overwritten by y value
|
||||
buf[12] = 0x001; // change to 0 (cmd mode)
|
||||
buf[13] = 0x022; // write data
|
||||
buf[14] = 0x002; // change to 1 (data mode)
|
||||
buf[15] = 0x000; // red value
|
||||
buf[16] = 0x000; // no change
|
||||
buf[17] = 0x000; // green value
|
||||
buf[18] = 0x000; // no change
|
||||
buf[19] = 0x000; // blue value
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[9] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[11] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[13] = ucg->arg.pixel.rgb.color[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[15] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[17] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[19] = ucg->arg.pixel.rgb.color[2];
|
||||
}
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[5] = ucg->arg.pixel.pos.x;
|
||||
ucg_com_SendCmdDataSequence(ucg, 7, buf, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[5] = ucg->arg.pixel.pos.x;
|
||||
buf[9] = (ucg->arg.pixel.pos.y>>8)&1;
|
||||
buf[11] = ucg->arg.pixel.pos.y&255;
|
||||
ucg_com_SendCmdDataSequence(ucg, 10, buf, 1);
|
||||
}
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static ucg_int_t ucg_handle_ili9325_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t i;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir2_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_dir3_seq);
|
||||
break;
|
||||
}
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
c[0] = ucg->arg.ccs_line[0].current;
|
||||
c[1] = ucg->arg.ccs_line[1].current;
|
||||
c[2] = ucg->arg.ccs_line[2].current;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+0);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+1);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+2);
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_ili9325_spi_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 40, 100);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* not yet implemented */
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 240;
|
||||
((ucg_wh_t *)data)->h = 320;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq);
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_ili9325_18);
|
||||
ucg_handle_ili9325_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
//ucg_handle_l90tc(ucg, ucg_dev_ic_ili9325);
|
||||
ucg_handle_ili9325_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_ili9325_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_ili9325_spi_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_ili9325);
|
||||
ucg_handle_ili9325_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,382 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_ili9341.c
|
||||
|
||||
Specific code for the ili9341 controller (TFT displays)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9341_set_pos_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11( 0x036, 0x008),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x001, 0x03f), /* set y position */
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9341_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* 0x008 horizontal increment (dir = 0) */
|
||||
/* 0x008 vertical increment (dir = 1) */
|
||||
/* 0x048 horizontal deccrement (dir = 2) */
|
||||
/* 0x088 vertical deccrement (dir = 3) */
|
||||
UCG_C11( 0x036, 0x008),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x001, 0x03f), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9341_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
/* 0x008 horizontal increment (dir = 0) */
|
||||
/* 0x008 vertical increment (dir = 1) */
|
||||
/* 0x048 horizontal deccrement (dir = 2) */
|
||||
/* 0x088 vertical deccrement (dir = 3) */
|
||||
UCG_C11( 0x036, 0x008),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x001, 0x03f), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9341_set_pos_dir2_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* 0x008 horizontal increment (dir = 0) */
|
||||
/* 0x008 vertical increment (dir = 1) */
|
||||
/* 0x048 horizontal deccrement (dir = 2) */
|
||||
/* 0x088 vertical deccrement (dir = 3) */
|
||||
|
||||
UCG_C11( 0x036, 0x048),
|
||||
UCG_C11( 0x036, 0x048), /* it seems that this command needs to be sent twice */ /* should be check again */
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x001, 0x03f), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ili9341_set_pos_dir3_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* 0x008 horizontal increment (dir = 0) */
|
||||
/* 0x008 vertical increment (dir = 1) */
|
||||
/* 0x0c8 horizontal deccrement (dir = 2) */
|
||||
/* 0x0c8 vertical deccrement (dir = 3) */
|
||||
UCG_C11( 0x036, 0x088),
|
||||
UCG_C11( 0x036, 0x088), /* it seems that this command needs to be sent twice */ /* should be check again */
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x001, 0x03f), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
ucg_int_t ucg_handle_ili9341_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_int_t tmp;
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
tmp = ucg->arg.pixel.pos.x;
|
||||
ucg->arg.pixel.pos.x = 239-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_dir2_seq);
|
||||
ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
tmp = ucg->arg.pixel.pos.y;
|
||||
ucg->arg.pixel.pos.y = 319-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_dir3_seq);
|
||||
ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Glyph Output)
|
||||
|
||||
*/
|
||||
|
||||
/* with CmdDataSequence */
|
||||
ucg_int_t ucg_handle_ili9341_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[16];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_seq);
|
||||
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x02a; // set x
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // upper part x
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // will be overwritten by x value
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x02c; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
buf[1] = 0x02a; // set x
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
buf[1] = 0x02b; // set y
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
buf[1] = 0x02a; // set x
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
buf[1] = 0x02b; // set y
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
buf[9] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[11] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[13] = ucg->arg.pixel.rgb.color[2];
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[5] = ucg->arg.pixel.pos.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.y>>8;
|
||||
buf[5] = ucg->arg.pixel.pos.y&255;
|
||||
}
|
||||
ucg_com_SendCmdDataSequence(ucg, 7, buf, 0);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_ili9341_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
ucg_int_t tmp;
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t i;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
tmp = ucg->arg.pixel.pos.x;
|
||||
ucg->arg.pixel.pos.x = 239-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_dir2_seq);
|
||||
ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
tmp = ucg->arg.pixel.pos.y;
|
||||
ucg->arg.pixel.pos.y = 319-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_dir3_seq);
|
||||
ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
c[0] = ucg->arg.ccs_line[0].current;
|
||||
c[1] = ucg->arg.ccs_line[1].current;
|
||||
c[2] = ucg->arg.ccs_line[2].current;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+0);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+1);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+2);
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ili9341_power_down_seq[] = {
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x010), /* sleep in */
|
||||
UCG_C10(0x28), /* display off */
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_ili9341_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 100, 66);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_power_down_seq);
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 240;
|
||||
((ucg_wh_t *)data)->h = 320;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ili9341_set_pos_seq);
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_ili9341_18);
|
||||
ucg_handle_ili9341_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
//ucg_handle_l90tc(ucg, ucg_dev_ic_ili9341_18);
|
||||
ucg_handle_ili9341_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_ili9341_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_ili9341_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_ili9341_18);
|
||||
ucg_handle_ili9341_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,358 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_ld50t6160.c
|
||||
|
||||
Specific code for the ld50t6160 controller (OLED displays)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2015, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
/*
|
||||
Graphics Memory Writing Direction: 0x05
|
||||
Bit 3: RGB/BGR
|
||||
Bit 0-2: Direction
|
||||
0x05, 0x00 dir 0
|
||||
0x05, 0x05 dir 1
|
||||
0x05, 0x03 dir 2
|
||||
0x05, 0x06 dir 3
|
||||
|
||||
Data Reading/Writing Box: 0x0a
|
||||
8 bytes as arguments: xs, ys, xe, ye
|
||||
|
||||
*/
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ld50t6160_set_pos_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11(0x05, 0x00),
|
||||
UCG_C10(0x0a), UCG_VARX(4,0x0f, 0), UCG_VARX(0,0x0f, 0), UCG_A2(0x007, 0x0f), /* set x position */
|
||||
UCG_VARY(4,0x0f, 0), UCG_VARY(0,0x0f, 0), UCG_A2(0x09, 0x0f), /* set y position */
|
||||
UCG_C10(0x0c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ld50t6160_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C11(0x05, 0x00),
|
||||
UCG_C10(0x0a),
|
||||
UCG_VARX(4,0x0f, 0), UCG_VARX(0,0x0f, 0), UCG_A2(0x007, 0x0f), /* set x position */
|
||||
UCG_VARY(4,0x0f, 0), UCG_VARY(0,0x0f, 0), UCG_A2(0x09, 0x0f), /* set y position */
|
||||
UCG_C10(0x0c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ld50t6160_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11(0x05, 0x05),
|
||||
UCG_C10(0x0a),
|
||||
//UCG_VARX(4,0x0f, 0), UCG_VARX(0,0x0f, 0), UCG_D2(0x007, 0x0f), /* set x position */
|
||||
UCG_A2(0x00, 0x00), UCG_VARX(4,0x0f, 0), UCG_VARX(0,0x0f, 0), /* set x position */
|
||||
UCG_VARY(4,0x0f, 0), UCG_VARY(0,0x0f, 0), UCG_A2(0x09, 0x0f), /* set y position */
|
||||
UCG_C10(0x0c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ld50t6160_set_pos_dir2_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C11(0x05, 0x03),
|
||||
UCG_C10(0x0a),
|
||||
UCG_A2(0x00, 0x00), UCG_VARX(4,0x0f, 0), UCG_VARX(0,0x0f, 0), /* set x position */
|
||||
UCG_A2(0x00, 0x00), UCG_VARY(4,0x0f, 0), UCG_VARY(0,0x0f, 0), /* set y position */
|
||||
UCG_C10(0x0c), /* write to RAM */
|
||||
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ld50t6160_set_pos_dir3_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C11(0x05, 0x06),
|
||||
UCG_C10(0x0a),
|
||||
UCG_VARX(4,0x0f, 0), UCG_VARX(0,0x0f, 0), UCG_A2(0x07, 0x0f), /* set x position */
|
||||
UCG_A2(0x00, 0x00), UCG_VARY(4,0x0f, 0), UCG_VARY(0,0x0f, 0), /* set y position */
|
||||
UCG_C10(0x0c), /* write to RAM */
|
||||
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static ucg_int_t ucg_handle_ld50t6160_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
//ucg_int_t tmp;
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
//tmp = ucg->arg.pixel.pos.x;
|
||||
//ucg->arg.pixel.pos.x = 127-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_set_pos_dir2_seq);
|
||||
//ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
//tmp = ucg->arg.pixel.pos.y;
|
||||
//ucg->arg.pixel.pos.y = 159-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_set_pos_dir3_seq);
|
||||
//ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
c[0] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
c[1] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
c[2] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
ucg_com_SendRepeat3Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Glyph Output)
|
||||
*/
|
||||
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
static ucg_int_t ucg_handle_ld50t6160_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[3];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
const uint8_t *seq;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
seq = ucg_ld50t6160_set_pos_dir0_seq;
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
seq = ucg_ld50t6160_set_pos_dir1_seq;
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
seq = ucg_ld50t6160_set_pos_dir2_seq;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
seq = ucg_ld50t6160_set_pos_dir3_seq;
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
buf[0] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
buf[1] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
buf[2] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
ucg_com_SendCmdSeq(ucg, seq);
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, buf);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
|
||||
ucg_int_t ucg_handle_ld50t6160_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
//ucg_int_t tmp;
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t i;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
//tmp = ucg->arg.pixel.pos.x;
|
||||
//ucg->arg.pixel.pos.x = 239-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_set_pos_dir2_seq);
|
||||
//ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
//tmp = ucg->arg.pixel.pos.y;
|
||||
//ucg->arg.pixel.pos.y = 319-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_set_pos_dir3_seq);
|
||||
//ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
c[0] = ucg->arg.ccs_line[0].current>>2;
|
||||
c[1] = ucg->arg.ccs_line[1].current>>2;
|
||||
c[2] = ucg->arg.ccs_line[2].current>>2;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+0);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+1);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+2);
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ld50t6160_power_down_seq[] = {
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11(0x02, 0x00), /* display off */
|
||||
UCG_C11(0x20, 0x00), /* all ICON off */
|
||||
UCG_C11(0x20, 0x01), /* stop OSCB */
|
||||
|
||||
|
||||
UCG_C10(0x010), /* sleep in */
|
||||
UCG_C10(0x28), /* display off */
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_ld50t6160_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 100, 66);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_power_down_seq);
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 160;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ld50t6160_set_pos_seq);
|
||||
c[0] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
c[1] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
c[2] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_ld50t6160_18);
|
||||
ucg_handle_ld50t6160_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
//ucg_handle_l90tc(ucg, ucg_dev_ic_ld50t6160_18);
|
||||
ucg_handle_ld50t6160_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_ld50t6160_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_ld50t6160_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_ld50t6160_18);
|
||||
ucg_handle_ld50t6160_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,409 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_pcf8833.c
|
||||
|
||||
Specific code for the pcf8833 controller (TFT displays)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
#define XOFFSET 0
|
||||
|
||||
#define WIDTH 132
|
||||
#define HEIGHT 132
|
||||
|
||||
const ucg_pgm_uint8_t ucg_pcf8833_set_pos_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11( 0x036, 0x000),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x0ff, 0), UCG_A1(WIDTH-1), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x0ff, 0), UCG_A1(HEIGHT-1), /* set y position */
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_pcf8833_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/*
|
||||
bit 7: my
|
||||
bit 6: mx
|
||||
bit 5: x or y increment
|
||||
bit 4: line order
|
||||
bit 3: rgb
|
||||
*/
|
||||
UCG_C11( 0x036, 0x000),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x0ff, 0), UCG_A1(WIDTH-1), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x0ff, 0), UCG_A1(HEIGHT-1), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_pcf8833_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
/*
|
||||
bit 7: my
|
||||
bit 6: mx
|
||||
bit 5: x or y increment
|
||||
bit 4: line order
|
||||
bit 3: rgb
|
||||
*/
|
||||
UCG_C11( 0x036, 0x000),
|
||||
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x0ff, 0), UCG_A1(HEIGHT-1), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_pcf8833_set_pos_dir2_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/*
|
||||
bit 7: my
|
||||
bit 6: mx
|
||||
bit 5: x or y increment
|
||||
bit 4: line order
|
||||
bit 3: rgb
|
||||
*/
|
||||
UCG_C11( 0x036, 0x040),
|
||||
//UCG_C11( 0x036, 0x020), /* it seems that this command needs to be sent twice */
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x0ff, 0), UCG_A1(WIDTH-1), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x0ff, 0), UCG_A1(HEIGHT-1), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_pcf8833_set_pos_dir3_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/*
|
||||
bit 7: my
|
||||
bit 6: mx
|
||||
bit 5: x or y increment
|
||||
bit 4: line order
|
||||
bit 3: rgb
|
||||
*/
|
||||
UCG_C11( 0x036, 0x080),
|
||||
//UCG_C11( 0x036, 0x0d0), /* it seems that this command needs to be sent twice */
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x0ff, 0), UCG_A1(HEIGHT-1), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static uint8_t ucg_pcf8833_get_color_high_byte(ucg_t *ucg)
|
||||
{
|
||||
return (ucg->arg.pixel.rgb.color[0]&0x0f8) | (((ucg->arg.pixel.rgb.color[1]) >>5));
|
||||
}
|
||||
|
||||
static uint8_t ucg_pcf8833_get_color_low_byte(ucg_t *ucg)
|
||||
{
|
||||
return ((((ucg->arg.pixel.rgb.color[1]))<<3)&0x0e0) | (((ucg->arg.pixel.rgb.color[2]) >>3));
|
||||
}
|
||||
|
||||
ucg_int_t ucg_handle_pcf8833_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_int_t tmp;
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
tmp = ucg->arg.pixel.pos.x;
|
||||
ucg->arg.pixel.pos.x = WIDTH-1-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_dir2_seq);
|
||||
ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
tmp = ucg->arg.pixel.pos.y;
|
||||
ucg->arg.pixel.pos.y = HEIGHT-1-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_dir3_seq);
|
||||
ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
c[0] = ucg_pcf8833_get_color_high_byte(ucg);
|
||||
c[1] = ucg_pcf8833_get_color_low_byte(ucg);
|
||||
ucg_com_SendRepeat2Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Glyph Output)
|
||||
|
||||
*/
|
||||
|
||||
/* with CmdDataSequence */
|
||||
ucg_int_t ucg_handle_pcf8833_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[16];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_seq);
|
||||
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x02a; // set x
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // x/y
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // end value
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x02c; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = ucg_pcf8833_get_color_high_byte(ucg);
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = ucg_pcf8833_get_color_low_byte(ucg);
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
buf[1] = 0x02a; // set x
|
||||
buf[5] = WIDTH-1; // end value
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
buf[1] = 0x02b; // set y
|
||||
buf[5] = HEIGHT-1; // end value
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
buf[1] = 0x02a; // set x
|
||||
buf[5] = WIDTH-1; // end value
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
buf[1] = 0x02b; // set y
|
||||
buf[5] = HEIGHT-1; // end value
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.y;
|
||||
}
|
||||
ucg_com_SendCmdDataSequence(ucg, 6, buf, 0);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_pcf8833_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
ucg_int_t tmp;
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t i;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
tmp = ucg->arg.pixel.pos.x;
|
||||
ucg->arg.pixel.pos.x = WIDTH-1-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_dir2_seq);
|
||||
ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
tmp = ucg->arg.pixel.pos.y;
|
||||
ucg->arg.pixel.pos.y = HEIGHT-1-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_dir3_seq);
|
||||
ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
|
||||
c[0] = (ucg->arg.ccs_line[0].current&0x0f8) | (((ucg->arg.ccs_line[1].current) >>5));
|
||||
c[1] = ((((ucg->arg.ccs_line[1].current))<<3)&0x0e0) | (((ucg->arg.ccs_line[2].current) >>3));
|
||||
|
||||
ucg_com_SendRepeat2Bytes(ucg, 1, c);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+0);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+1);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+2);
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_pcf8833_power_down_seq[] = {
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x28), /* display off */
|
||||
UCG_C10(0x10), /* sleep in */
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_pcf8833_16(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
//ucg->display_offset.x = 2;
|
||||
//ucg->display_offset.y = 2;
|
||||
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 150, 160);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_power_down_seq);
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = WIDTH;
|
||||
((ucg_wh_t *)data)->h = HEIGHT;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_pcf8833_set_pos_seq);
|
||||
c[0] = ucg_pcf8833_get_color_high_byte(ucg);
|
||||
c[1] = ucg_pcf8833_get_color_low_byte(ucg);
|
||||
ucg_com_SendRepeat2Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_pcf8833_16);
|
||||
ucg_handle_pcf8833_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
//ucg_handle_l90tc(ucg, ucg_dev_ic_pcf8833_16);
|
||||
ucg_handle_pcf8833_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_pcf8833_16);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_pcf8833_16(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_pcf8833_16);
|
||||
ucg_handle_pcf8833_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,321 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_seps225.c
|
||||
|
||||
Specific code for the SEPS225 controller (OLED displays)
|
||||
128x128x18 display buffer
|
||||
Note: Only 65K color support, because 262K mode is not possible with 8 Bit SPI.
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2015, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
static uint8_t ucg_seps225_get_color_high_byte(ucg_t *ucg)
|
||||
{
|
||||
return (ucg->arg.pixel.rgb.color[0]&0x0f8) | (((ucg->arg.pixel.rgb.color[1]) >>5));
|
||||
}
|
||||
|
||||
static uint8_t ucg_seps225_get_color_low_byte(ucg_t *ucg)
|
||||
{
|
||||
return ((((ucg->arg.pixel.rgb.color[1]))<<3)&0x0e0) | (((ucg->arg.pixel.rgb.color[2]) >>3));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Write Memory Mode 0x016
|
||||
Bit 0: HV
|
||||
HV= 0, data is continuously written horizontally
|
||||
HV= 1, data is continuously written vertically
|
||||
Bit 1: VC
|
||||
VC= 0, vertical address counter is decreased
|
||||
VC= 1, vertical address counter is increased
|
||||
Bit 2: HC
|
||||
HC= 0, horizontal address counter is decreased
|
||||
HC= 1, horizontal address counter is increased
|
||||
Bit 4..6: Dual Transfer, 65K Mode (Bit 4 = 0, Bit 5 = 1, Bit 6 = 1)
|
||||
*/
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_seps255_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x07f, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(0,0x07f, 0), /* set y position */
|
||||
UCG_C11(0x016, 0x064), /* Memory Mode */
|
||||
UCG_C10(0x022), /* prepare for data */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_seps255_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11(0x016, 0x063), /* Memory Mode */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x07f, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(0,0x07f, 0), /* set y position */
|
||||
UCG_C10(0x022), /* prepare for data */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
#ifdef NOT_USED
|
||||
static const ucg_pgm_uint8_t ucg_seps255_pos_dir2_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11(0x016, 0x060), /* Memory Mode */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_C10(0x022), /* prepare for data */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
/* it seems that this mode does not work*/
|
||||
static const ucg_pgm_uint8_t ucg_seps255_pos_dir3_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11(0x016, 0x061), /* Memory Mode */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_C10(0x022), /* prepare for data */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
#endif
|
||||
|
||||
ucg_int_t ucg_handle_seps225_l90fx(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
ucg->arg.pixel.pos.x -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.x++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir0_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ucg->arg.pixel.pos.y -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.y++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir1_seq);
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
uint8_t c[2];
|
||||
c[0] = ucg_seps225_get_color_high_byte(ucg);
|
||||
c[1] = ucg_seps225_get_color_low_byte(ucg);
|
||||
ucg_com_SendRepeat2Bytes(ucg, ucg->arg.len, c);
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
L2TC (Bitmap Output)
|
||||
|
||||
Not implemented for this controller, fallback to standard. However this msg is not used
|
||||
at all at the moment (Jul 2015)
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
L2SE Color Change
|
||||
|
||||
*/
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_seps225_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[1].color[i], ucg->arg.rgb[0].color[i], ucg->arg.len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i, j;
|
||||
//uint8_t r, g, b;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0: dx = 1; dy = 0;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir0_seq);
|
||||
break;
|
||||
case 1: dx = 0; dy = 1;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir1_seq);
|
||||
break;
|
||||
case 2: dx = 1; dy = 0;
|
||||
ucg->arg.pixel.pos.x -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.x++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir0_seq);
|
||||
break;
|
||||
case 3: dx = 0; dy = 1;
|
||||
ucg->arg.pixel.pos.y -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.y++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir1_seq);
|
||||
break;
|
||||
default: dx = 1; dy = 0; break; /* avoid compiler warning */
|
||||
}
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
/*
|
||||
r = ucg->arg.ccs_line[0].current;
|
||||
r &= 0x0f8;
|
||||
g = ucg->arg.ccs_line[1].current;
|
||||
c[0] = g;
|
||||
c[0] >>= 5;
|
||||
c[0] |= r;
|
||||
g <<= 3;
|
||||
g &= 0x0e0;
|
||||
b = ucg->arg.ccs_line[2].current;
|
||||
b >>= 3;
|
||||
c[1] = g;
|
||||
c[1] |= b;
|
||||
*/
|
||||
c[0] = (ucg->arg.ccs_line[0].current&0x0f8) | (((ucg->arg.ccs_line[1].current) >>5));
|
||||
c[1] = ((((ucg->arg.ccs_line[1].current))<<3)&0x0e0) | (((ucg->arg.ccs_line[2].current) >>3));
|
||||
ucg_com_SendRepeat2Bytes(ucg, 1, c);
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
for ( j = 0; j < 3; j++ )
|
||||
{
|
||||
ucg_ccs_step(ucg->arg.ccs_line+j);
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_seps225_power_down_seq[] = {
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11(0x006, 0x000), /* SEPS225: display off */
|
||||
UCG_C11(0x004, 0x001), /* reduce current, power down */
|
||||
UCG_CS(1), /* disable chip */
|
||||
/* delay of 100ms is suggested here for full power down */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_seps225_16(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 50, 200); /* adjusted for SEPS225 */
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps225_power_down_seq);
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 128;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir0_seq);
|
||||
c[0] = ucg_seps225_get_color_high_byte(ucg);
|
||||
c[1] = ucg_seps225_get_color_low_byte(ucg);
|
||||
ucg_com_SendRepeat2Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_seps225_16);
|
||||
ucg_handle_seps225_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
ucg_handle_l90tc(ucg, ucg_dev_ic_seps225_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_seps225_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_seps225_16(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_seps225_16);
|
||||
ucg_handle_seps225_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,480 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_ssd1289.c
|
||||
|
||||
Specific code for the ssd1289 controller (TFT displays)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
#ifdef NOT_YET_IMPLEMENTED
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ssd1289_set_pos_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x04e), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x04f), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ssd1289_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C22(0x000, 0x011, 0x048, 0x030), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x04e), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x04f), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ssd1289_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C22(0x000, 0x011, 0x048, 0x038), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x04e), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x04f), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1289_set_pos_dir2_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C22(0x000, 0x011, 0x048, 0x000), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1289_set_pos_dir3_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* last byte: 0x030 horizontal increment (dir = 0) */
|
||||
/* last byte: 0x038 vertical increment (dir = 1) */
|
||||
/* last byte: 0x000 horizontal deccrement (dir = 2) */
|
||||
/* last byte: 0x008 vertical deccrement (dir = 3) */
|
||||
UCG_C22(0x000, 0x011, 0x048, 0x008), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
ucg_int_t ucg_handle_ssd1289_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_dir2_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_dir3_seq);
|
||||
break;
|
||||
}
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Glyph Output)
|
||||
Because of this for vertical lines the x min and max values in
|
||||
"ucg_ssd1289_set_pos_for_y_seq" are identical to avoid changes of the x position
|
||||
|
||||
*/
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1289_set_x_pos_seq[] =
|
||||
{
|
||||
UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1289_set_y_pos_seq[] =
|
||||
{
|
||||
UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_C10(0x022), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
/* without CmdDataSequence */
|
||||
ucg_int_t xxxxxx_ucg_handle_ssd1289_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[3];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
const uint8_t *seq;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_seq);
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
seq = ucg_ssd1289_set_x_pos_seq;
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
seq = ucg_ssd1289_set_y_pos_seq;
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
seq = ucg_ssd1289_set_x_pos_seq;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
seq = ucg_ssd1289_set_y_pos_seq;
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
buf[0] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[1] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[2] = ucg->arg.pixel.rgb.color[2];
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
ucg_com_SendCmdSeq(ucg, seq);
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, buf);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* with CmdDataSequence */
|
||||
ucg_int_t ucg_handle_ssd1289_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[16];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_seq);
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x020; // set x
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // upper part x
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // will be overwritten by x value
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x022; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x020; // set y
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // upper part y
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // will be overwritten by y value
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x022; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x020; // set x
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // upper part x
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // will be overwritten by x value
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x022; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x020; // set y
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // upper part y
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // will be overwritten by y value
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x022; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
buf[9] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[11] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[13] = ucg->arg.pixel.rgb.color[2];
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[5] = ucg->arg.pixel.pos.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.y>>8;
|
||||
buf[5] = ucg->arg.pixel.pos.y&255;
|
||||
}
|
||||
ucg_com_SendCmdDataSequence(ucg, 7, buf);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_ssd1289_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t i;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_dir2_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_dir3_seq);
|
||||
break;
|
||||
}
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
c[0] = ucg->arg.ccs_line[0].current;
|
||||
c[1] = ucg->arg.ccs_line[1].current;
|
||||
c[2] = ucg->arg.ccs_line[2].current;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+0);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+1);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+2);
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_ssd1289_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 40, 100);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* not yet implemented */
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 240;
|
||||
((ucg_wh_t *)data)->h = 320;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1289_set_pos_seq);
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
ucg_handle_l90fx(ucg, ucg_dev_ic_ssd1289_18);
|
||||
//ucg_handle_ssd1289_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
ucg_handle_l90tc(ucg, ucg_dev_ic_ssd1289);
|
||||
//ucg_handle_ssd1289_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_ssd1289);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_ssd1289_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
ucg_handle_l90se(ucg, ucg_dev_ic_ssd1289);
|
||||
//ucg_handle_ssd1289_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,372 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_ssd1331.c
|
||||
|
||||
Specific code for the SSD1331 controller (OLED displays)
|
||||
96x64x16 display buffer, however 3-byte 18 bit mode is used
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2015, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
//ucg_int_t u8g_dev_ic_ssd1331(ucg_t *ucg, ucg_int_t msg, void *data);
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1331_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x015), UCG_VARX(0,0x0ff, 0), UCG_A1(0x07f), /* set x position */
|
||||
UCG_C10(0x075), UCG_VARY(0,0x0ff, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1331_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x015), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x075), UCG_VARY(0,0x0ff, 0), UCG_A1(0x07f), /* set y position */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
ucg_int_t ucg_handle_ssd1331_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
ucg->arg.pixel.pos.x -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.x++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_dir0_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ucg->arg.pixel.pos.y -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.y++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_dir1_seq);
|
||||
break;
|
||||
}
|
||||
c[0] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
c[1] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
c[2] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
ucg_com_SendRepeat3Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Bitmap Output)
|
||||
Because of this for vertical lines the x min and max values in
|
||||
"ucg_ssd1331_set_pos_for_y_seq" are identical to avoid changes of the x position
|
||||
|
||||
*/
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1331_set_pos_for_x_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x015), UCG_VARX(0,0x0ff, 0), UCG_A1(0x07f), /* set x position */
|
||||
UCG_C10(0x075), UCG_VARY(0,0x0ff, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1331_set_pos_for_y_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x015), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x075), UCG_VARY(0,0x0ff, 0), UCG_A1(0x07f), /* set y position */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_ssd1331_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
|
||||
uint8_t buf[16];
|
||||
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x015; // set x
|
||||
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // will be overwritten by x/y value
|
||||
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x07f; // max value
|
||||
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x05c; // write data
|
||||
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
|
||||
buf[14] = 0x001; // change to 0 (cmd mode)
|
||||
buf[15] = 0x05c; // change to 0 (cmd mode)
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
buf[1] = 0x015;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_for_x_seq);
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
buf[1] = 0x075;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_for_y_seq);
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
buf[1] = 0x015;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_for_x_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
buf[1] = 0x075;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_for_y_seq);
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
|
||||
buf[9] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
buf[11] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
buf[13] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.y;
|
||||
}
|
||||
//ucg_com_SendCmdSeq(ucg, seq);
|
||||
//buf[0] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
//buf[1] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
//buf[2] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
//ucg_com_SendRepeat3Bytes(ucg, 1, buf);
|
||||
ucg_com_SendCmdDataSequence(ucg, 7, buf, 1);
|
||||
//ucg_com_SetCDLineStatus(ucg, 1);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_ssd1331_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[1].color[i], ucg->arg.rgb[0].color[i], ucg->arg.len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i, j;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0: dx = 1; dy = 0;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1: dx = 0; dy = 1;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2: dx = 1; dy = 0;
|
||||
ucg->arg.pixel.pos.x -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.x++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_dir0_seq);
|
||||
break;
|
||||
case 3: dx = 0; dy = 1;
|
||||
ucg->arg.pixel.pos.y -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.y++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_dir1_seq);
|
||||
break;
|
||||
default: dx = 1; dy = 0; break; /* avoid compiler warning */
|
||||
}
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
c[0] = ucg->arg.ccs_line[0].current >> 2;
|
||||
c[1] = ucg->arg.ccs_line[1].current >> 2;
|
||||
c[2] = ucg->arg.ccs_line[2].current >> 2;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
for ( j = 0; j < 3; j++ )
|
||||
{
|
||||
ucg_ccs_step(ucg->arg.ccs_line+j);
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ssd1331_power_down_seq[] = {
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x0a6), /* Set display: All pixel off */
|
||||
UCG_C10(0x0ae), /* Set display off: sleep mode */
|
||||
//UCG_C11(0x0b0, 0x01a), /* Power Save Mode */
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_ssd1331_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 50, 300);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_power_down_seq);
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 96;
|
||||
((ucg_wh_t *)data)->h = 64;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1331_set_pos_dir0_seq);
|
||||
c[0] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
c[1] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
c[2] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_ssd1331_18);
|
||||
ucg_handle_ssd1331_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
//ucg_handle_l90tc(ucg, ucg_dev_ic_ssd1331_18);
|
||||
ucg_handle_ssd1331_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_ssd1331_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_ssd1331_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_ssd1331_18);
|
||||
ucg_handle_ssd1331_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,372 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_ssd1351.c
|
||||
|
||||
Specific code for the SSD1351 controller (OLED displays)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
//ucg_int_t u8g_dev_ic_ssd1351(ucg_t *ucg, ucg_int_t msg, void *data);
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1351_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x015), UCG_VARX(0,0x0ff, 0), UCG_D1(0x07f), /* set x position */
|
||||
UCG_C10(0x075), UCG_VARY(0,0x0ff, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_C10(0x05c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1351_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x015), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x075), UCG_VARY(0,0x0ff, 0), UCG_D1(0x07f), /* set y position */
|
||||
UCG_C10(0x05c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
ucg_int_t ucg_handle_ssd1351_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
ucg->arg.pixel.pos.x -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.x++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_dir0_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ucg->arg.pixel.pos.y -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.y++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_dir1_seq);
|
||||
break;
|
||||
}
|
||||
c[0] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
c[1] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
c[2] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
ucg_com_SendRepeat3Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Glyph Output)
|
||||
Because of this for vertical lines the x min and max values in
|
||||
"ucg_ssd1351_set_pos_for_y_seq" are identical to avoid changes of the x position
|
||||
|
||||
*/
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1351_set_pos_for_x_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x015), UCG_VARX(0,0x0ff, 0), UCG_D1(0x07f), /* set x position */
|
||||
UCG_C10(0x075), UCG_VARY(0,0x0ff, 0), UCG_VARY(0,0x0ff, 0), /* set y position */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_ssd1351_set_pos_for_y_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x015), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x075), UCG_VARY(0,0x0ff, 0), UCG_D1(0x07f), /* set y position */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_ssd1351_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
|
||||
uint8_t buf[16];
|
||||
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x015; // set x
|
||||
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // will be overwritten by x/y value
|
||||
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x07f; // max value
|
||||
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x05c; // write data
|
||||
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
|
||||
buf[14] = 0x001; // change to 0 (cmd mode)
|
||||
buf[15] = 0x05c; // change to 0 (cmd mode)
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
buf[1] = 0x015;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_for_x_seq);
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
buf[1] = 0x075;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_for_y_seq);
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
buf[1] = 0x015;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_for_x_seq);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
buf[1] = 0x075;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_for_y_seq);
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
|
||||
buf[9] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
buf[11] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
buf[13] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.y;
|
||||
}
|
||||
//ucg_com_SendCmdSeq(ucg, seq);
|
||||
//buf[0] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
//buf[1] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
//buf[2] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
//ucg_com_SendRepeat3Bytes(ucg, 1, buf);
|
||||
ucg_com_SendCmdDataSequence(ucg, 7, buf, 1);
|
||||
//ucg_com_SetCDLineStatus(ucg, 1);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_ssd1351_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[1].color[i], ucg->arg.rgb[0].color[i], ucg->arg.len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i, j;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0: dx = 1; dy = 0;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1: dx = 0; dy = 1;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2: dx = 1; dy = 0;
|
||||
ucg->arg.pixel.pos.x -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.x++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_dir0_seq);
|
||||
break;
|
||||
case 3: dx = 0; dy = 1;
|
||||
ucg->arg.pixel.pos.y -= ucg->arg.len;
|
||||
ucg->arg.pixel.pos.y++;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_dir1_seq);
|
||||
break;
|
||||
default: dx = 1; dy = 0; break; /* avoid compiler warning */
|
||||
}
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
c[0] = ucg->arg.ccs_line[0].current >> 2;
|
||||
c[1] = ucg->arg.ccs_line[1].current >> 2;
|
||||
c[2] = ucg->arg.ccs_line[2].current >> 2;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
for ( j = 0; j < 3; j++ )
|
||||
{
|
||||
ucg_ccs_step(ucg->arg.ccs_line+j);
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_ssd1351_power_down_seq[] = {
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11(0x0c7, 0x000), /* Set Master Contrast (0..15), reset default: 0x05 */
|
||||
UCG_C10(0x0ae), /* Set Display Off */
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ic_ssd1351_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 50, 300);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_power_down_seq);
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 128;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ssd1351_set_pos_dir0_seq);
|
||||
c[0] = ucg->arg.pixel.rgb.color[0]>>2;
|
||||
c[1] = ucg->arg.pixel.rgb.color[1]>>2;
|
||||
c[2] = ucg->arg.pixel.rgb.color[2]>>2;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_ssd1351_18);
|
||||
ucg_handle_ssd1351_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
//ucg_handle_l90tc(ucg, ucg_dev_ic_ssd1351_18);
|
||||
ucg_handle_ssd1351_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_ssd1351_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_ssd1351_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_ssd1351_18);
|
||||
ucg_handle_ssd1351_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,383 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_ic_st7735.c
|
||||
|
||||
Specific code for the st7735 controller (TFT displays)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_st7735_set_pos_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11( 0x036, 0x000),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_A2(0x000, 0x07f), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x09f), /* set y position */
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
|
||||
const ucg_pgm_uint8_t ucg_st7735_set_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* 0x000 horizontal increment (dir = 0) */
|
||||
/* 0x000 vertical increment (dir = 1) */
|
||||
/* 0x040 horizontal deccrement (dir = 2) */
|
||||
/* 0x080 vertical deccrement (dir = 3) */
|
||||
UCG_C11( 0x036, 0x000),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_A2(0x000, 0x07f), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x09f), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_st7735_set_pos_dir1_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
/* 0x000 horizontal increment (dir = 0) */
|
||||
/* 0x000 vertical increment (dir = 1) */
|
||||
/* 0x040 horizontal deccrement (dir = 2) */
|
||||
/* 0x080 vertical deccrement (dir = 3) */
|
||||
UCG_C11( 0x036, 0x000),
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x09f), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_st7735_set_pos_dir2_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* 0x000 horizontal increment (dir = 0) */
|
||||
/* 0x000 vertical increment (dir = 1) */
|
||||
/* 0x040 horizontal deccrement (dir = 2) */
|
||||
/* 0x080 vertical deccrement (dir = 3) */
|
||||
|
||||
UCG_C11( 0x036, 0x040),
|
||||
UCG_C11( 0x036, 0x040), /* it seems that this command needs to be sent twice */
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_A2(0x000, 0x07f), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x09f), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
const ucg_pgm_uint8_t ucg_st7735_set_pos_dir3_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
/* 0x000 horizontal increment (dir = 0) */
|
||||
/* 0x000 vertical increment (dir = 1) */
|
||||
/* 0x0c0 horizontal deccrement (dir = 2) */
|
||||
/* 0x0c0 vertical deccrement (dir = 3) */
|
||||
UCG_C11( 0x036, 0x080),
|
||||
UCG_C11( 0x036, 0x080), /* it seems that this command needs to be sent twice */
|
||||
UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */
|
||||
UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x09f), /* set y position */
|
||||
|
||||
UCG_C10(0x02c), /* write to RAM */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
ucg_int_t ucg_handle_st7735_l90fx(ucg_t *ucg)
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_int_t tmp;
|
||||
if ( ucg_clip_l90fx(ucg) != 0 )
|
||||
{
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
tmp = ucg->arg.pixel.pos.x;
|
||||
ucg->arg.pixel.pos.x = 127-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_dir2_seq);
|
||||
ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
tmp = ucg->arg.pixel.pos.y;
|
||||
ucg->arg.pixel.pos.y = 159-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_dir3_seq);
|
||||
ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, ucg->arg.len, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
L2TC (Glyph Output)
|
||||
|
||||
*/
|
||||
|
||||
/* with CmdDataSequence */
|
||||
ucg_int_t ucg_handle_st7735_l90tc(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg_clip_l90tc(ucg) != 0 )
|
||||
{
|
||||
uint8_t buf[16];
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t i;
|
||||
unsigned char pixmap;
|
||||
uint8_t bitcnt;
|
||||
ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_seq);
|
||||
|
||||
buf[0] = 0x001; // change to 0 (cmd mode)
|
||||
buf[1] = 0x02a; // set x
|
||||
buf[2] = 0x002; // change to 1 (arg mode)
|
||||
buf[3] = 0x000; // upper part x
|
||||
buf[4] = 0x000; // no change
|
||||
buf[5] = 0x000; // will be overwritten by x value
|
||||
buf[6] = 0x001; // change to 0 (cmd mode)
|
||||
buf[7] = 0x02c; // write data
|
||||
buf[8] = 0x002; // change to 1 (data mode)
|
||||
buf[9] = 0x000; // red value
|
||||
buf[10] = 0x000; // no change
|
||||
buf[11] = 0x000; // green value
|
||||
buf[12] = 0x000; // no change
|
||||
buf[13] = 0x000; // blue value
|
||||
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
dx = 1; dy = 0;
|
||||
buf[1] = 0x02a; // set x
|
||||
break;
|
||||
case 1:
|
||||
dx = 0; dy = 1;
|
||||
buf[1] = 0x02b; // set y
|
||||
break;
|
||||
case 2:
|
||||
dx = -1; dy = 0;
|
||||
buf[1] = 0x02a; // set x
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dx = 0; dy = -1;
|
||||
buf[1] = 0x02b; // set y
|
||||
break;
|
||||
}
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = ucg->arg.pixel_skip;
|
||||
pixmap <<= bitcnt;
|
||||
buf[9] = ucg->arg.pixel.rgb.color[0];
|
||||
buf[11] = ucg->arg.pixel.rgb.color[1];
|
||||
buf[13] = ucg->arg.pixel.rgb.color[2];
|
||||
//ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
if ( (pixmap & 128) != 0 )
|
||||
{
|
||||
if ( (ucg->arg.dir&1) == 0 )
|
||||
{
|
||||
buf[5] = ucg->arg.pixel.pos.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[3] = ucg->arg.pixel.pos.y>>8;
|
||||
buf[5] = ucg->arg.pixel.pos.y&255;
|
||||
}
|
||||
ucg_com_SendCmdDataSequence(ucg, 7, buf, 0);
|
||||
}
|
||||
pixmap<<=1;
|
||||
ucg->arg.pixel.pos.x+=dx;
|
||||
ucg->arg.pixel.pos.y+=dy;
|
||||
bitcnt++;
|
||||
if ( bitcnt >= 8 )
|
||||
{
|
||||
ucg->arg.bitmap++;
|
||||
pixmap = ucg_pgm_read(ucg->arg.bitmap);
|
||||
bitcnt = 0;
|
||||
}
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_handle_st7735_l90se(ucg_t *ucg)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t c[3];
|
||||
ucg_int_t tmp;
|
||||
|
||||
/* Setup ccs for l90se. This will be updated by ucg_clip_l90se if required */
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ucg_ccs_init(ucg->arg.ccs_line+i, ucg->arg.rgb[0].color[i], ucg->arg.rgb[1].color[i], ucg->arg.len);
|
||||
}
|
||||
|
||||
/* check if the line is visible */
|
||||
|
||||
if ( ucg_clip_l90se(ucg) != 0 )
|
||||
{
|
||||
ucg_int_t i;
|
||||
switch(ucg->arg.dir)
|
||||
{
|
||||
case 0:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_dir0_seq);
|
||||
break;
|
||||
case 1:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_dir1_seq);
|
||||
break;
|
||||
case 2:
|
||||
tmp = ucg->arg.pixel.pos.x;
|
||||
ucg->arg.pixel.pos.x = 127-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_dir2_seq);
|
||||
ucg->arg.pixel.pos.x = tmp;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
tmp = ucg->arg.pixel.pos.y;
|
||||
ucg->arg.pixel.pos.y = 159-tmp;
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_dir3_seq);
|
||||
ucg->arg.pixel.pos.y = tmp;
|
||||
break;
|
||||
}
|
||||
|
||||
for( i = 0; i < ucg->arg.len; i++ )
|
||||
{
|
||||
c[0] = ucg->arg.ccs_line[0].current;
|
||||
c[1] = ucg->arg.ccs_line[1].current;
|
||||
c[2] = ucg->arg.ccs_line[2].current;
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+0);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+1);
|
||||
ucg_ccs_step(ucg->arg.ccs_line+2);
|
||||
}
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_st7735_power_down_seq[] = {
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C10(0x010), /* sleep in */
|
||||
UCG_C10(0x28), /* display off */
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_ic_st7735_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* setup com interface and provide information on the clock speed */
|
||||
/* of the serial and parallel interface. Values are nanoseconds. */
|
||||
return ucg_com_PowerUp(ucg, 100, 66);
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_power_down_seq);
|
||||
return 1;
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 160;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
if ( ucg_clip_is_pixel_visible(ucg) !=0 )
|
||||
{
|
||||
uint8_t c[3];
|
||||
ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_seq);
|
||||
c[0] = ucg->arg.pixel.rgb.color[0];
|
||||
c[1] = ucg->arg.pixel.rgb.color[1];
|
||||
c[2] = ucg->arg.pixel.rgb.color[2];
|
||||
ucg_com_SendRepeat3Bytes(ucg, 1, c);
|
||||
ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */
|
||||
}
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
//ucg_handle_l90fx(ucg, ucg_dev_ic_st7735_18);
|
||||
ucg_handle_st7735_l90fx(ucg);
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
//ucg_handle_l90tc(ucg, ucg_dev_ic_st7735_18);
|
||||
ucg_handle_st7735_l90tc(ucg);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
ucg_handle_l90bf(ucg, ucg_dev_ic_st7735_18);
|
||||
return 1;
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
|
||||
/* msg UCG_MSG_DRAW_L90SE is handled by ucg_dev_default_cb */
|
||||
/*
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
return ucg->ext_cb(ucg, msg, data);
|
||||
*/
|
||||
}
|
||||
return ucg_dev_default_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
ucg_int_t ucg_ext_st7735_18(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//ucg_handle_l90se(ucg, ucg_dev_ic_st7735_18);
|
||||
ucg_handle_st7735_l90se(ucg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_msg_api.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
#include <stddef.h>
|
||||
|
||||
void ucg_PowerDown(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg->is_power_up != 0 )
|
||||
{
|
||||
ucg->device_cb(ucg, UCG_MSG_DEV_POWER_DOWN, NULL);
|
||||
ucg->is_power_up = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ucg_int_t ucg_PowerUp(ucg_t *ucg)
|
||||
{
|
||||
ucg_int_t r;
|
||||
/* power down first. will do nothing if power is already down */
|
||||
ucg_PowerDown(ucg);
|
||||
/* now try to power up the display */
|
||||
r = ucg->device_cb(ucg, UCG_MSG_DEV_POWER_UP, NULL);
|
||||
if ( r != 0 )
|
||||
{
|
||||
ucg->is_power_up = 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void ucg_SetClipBox(ucg_t *ucg, ucg_box_t *clip_box)
|
||||
{
|
||||
ucg->device_cb(ucg, UCG_MSG_SET_CLIP_BOX, (void *)(clip_box));
|
||||
}
|
||||
|
||||
void ucg_SetClipRange(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t w, ucg_int_t h)
|
||||
{
|
||||
ucg_box_t clip_box;
|
||||
clip_box.ul.x = x;
|
||||
clip_box.ul.y = y;
|
||||
clip_box.size.w = w;
|
||||
clip_box.size.h = h;
|
||||
ucg_SetClipBox(ucg, &clip_box);
|
||||
}
|
||||
|
||||
void ucg_SetMaxClipRange(ucg_t *ucg)
|
||||
{
|
||||
ucg_box_t new_clip_box;
|
||||
new_clip_box.size = ucg->dimension;
|
||||
new_clip_box.ul.x = 0;
|
||||
new_clip_box.ul.y = 0;
|
||||
ucg_SetClipBox(ucg, &new_clip_box);
|
||||
}
|
||||
|
||||
/*
|
||||
Query the display dimension from the driver, reset clip window to maximum
|
||||
new dimension
|
||||
*/
|
||||
void ucg_GetDimension(ucg_t *ucg)
|
||||
{
|
||||
ucg->device_cb(ucg, UCG_MSG_GET_DIMENSION, &(ucg->dimension));
|
||||
ucg_SetMaxClipRange(ucg);
|
||||
}
|
||||
|
||||
void ucg_DrawPixelWithArg(ucg_t *ucg)
|
||||
{
|
||||
ucg->device_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
|
||||
}
|
||||
|
||||
void ucg_DrawL90FXWithArg(ucg_t *ucg)
|
||||
{
|
||||
ucg->device_cb(ucg, UCG_MSG_DRAW_L90FX, &(ucg->arg));
|
||||
}
|
||||
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
void ucg_DrawL90TCWithArg(ucg_t *ucg)
|
||||
{
|
||||
ucg->device_cb(ucg, UCG_MSG_DRAW_L90TC, &(ucg->arg));
|
||||
}
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
void ucg_DrawL90BFWithArg(ucg_t *ucg)
|
||||
{
|
||||
ucg->device_cb(ucg, UCG_MSG_DRAW_L90BF, &(ucg->arg));
|
||||
}
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
|
||||
void ucg_DrawL90SEWithArg(ucg_t *ucg)
|
||||
{
|
||||
ucg->device_cb(ucg, UCG_MSG_DRAW_L90SE, &(ucg->arg));
|
||||
}
|
||||
|
||||
/*
|
||||
void ucg_DrawL90RLWithArg(ucg_t *ucg)
|
||||
{
|
||||
ucg->device_cb(ucg, UCG_MSG_DRAW_L90RL, &(ucg->arg));
|
||||
}
|
||||
*/
|
||||
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_oled_128x128_ft.c
|
||||
|
||||
Specific code for the FREETRONIC 128x128 OLED module
|
||||
(differs from the ILSOFT only by GPIO output)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
//static const uint8_t ucg_dev_ssd1351_128x128_init_seq[] PROGMEM = {
|
||||
static const ucg_pgm_uint8_t ucg_ft_ssd1351_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
//UCG_C11(0x0fd, 0x012), /* Unlock normal commands, reset default: unlocked */
|
||||
UCG_C11(0x0fd, 0x0b1), /* Unlock extra commands, reset default: locked */
|
||||
|
||||
//UCG_C10(0x0ae), /* Set Display Off */
|
||||
UCG_C10(0x0af), /* Set Display On */
|
||||
UCG_C10(0x0a6), /* Set Display Mode Reset */
|
||||
UCG_C11(0x0a0, 0x0b4), /* Set Colour Depth */
|
||||
UCG_C11(0x0a1, 0x000), /* Set Display Start Line */
|
||||
UCG_C11(0x0a2, 0x000), /* Set Display Offset */
|
||||
UCG_C12(0x015, 0x000, 0x07f), /* Set Column Address */
|
||||
UCG_C12(0x075, 0x000, 0x07f), /* Set Row Address */
|
||||
|
||||
UCG_C11(0x0b3, 0x0f1), /* Front Clock Div */
|
||||
//UCG_C11(0x0ca, 0x07f), /* Set Multiplex Ratio, reset default: 0x7f */
|
||||
UCG_C11(0x0b5, 0x003), /* Set GPIO for Freetronics OLED Module */
|
||||
//UCG_C11(0x0ab, 0x001), /* Set Function Selection, reset default: 0x01 */
|
||||
UCG_C11(0x0b1, 0x032), /* Set Phase Length, reset default: 0x82 */
|
||||
UCG_C13(0x0b4, 0xa0,0xb5,0x55), /* Set Segment Low Voltage, reset default: 0xa2 0xb5 0x55 */
|
||||
//UCG_C11(0x0bb, 0x017), /* Set Precharge Voltage, reset default: 0x17 */
|
||||
//UCG_C11(0x0be, 0x005), /* Set VComH Voltage, reset default: 0x05 */
|
||||
UCG_C13(0x0c1, 0xc8, 0x80, 0xc8), /* Set Contrast */
|
||||
UCG_C11(0x0c7, 0x00f), /* Set Master Contrast (0..15), reset default: 0x05 */
|
||||
UCG_C11(0x0b6, 0x001), /* Set Second Precharge Period */
|
||||
|
||||
// UCG_C10(0x0b8), /* Set CMD Grayscale Lookup, 63 Bytes follow */
|
||||
// UCG_A8(0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c),
|
||||
// UCG_A8(0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14),
|
||||
// UCG_A8(0x15,0x16,0x18,0x1a,0x1b,0x1C,0x1D,0x1F),
|
||||
// UCG_A8(0x21,0x23,0x25,0x27,0x2A,0x2D,0x30,0x33),
|
||||
// UCG_A8(0x36,0x39,0x3C,0x3F,0x42,0x45,0x48,0x4C),
|
||||
// UCG_A8(0x50,0x54,0x58,0x5C,0x60,0x64,0x68,0x6C),
|
||||
// UCG_A8(0x70,0x74,0x78,0x7D,0x82,0x87,0x8C,0x91),
|
||||
// UCG_A7(0x96,0x9B,0xA0,0xA5,0xAA,0xAF,0xB4),
|
||||
|
||||
|
||||
UCG_C10(0x05c), /* Write RAM */
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_ssd1351_18x128x128_ft(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_ssd1351_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ft_ssd1351_init_seq);
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the conroller procedures */
|
||||
return ucg_dev_ic_ssd1351_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 128;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_ssd1351_18(ucg, msg, data);
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_oled_128x128_ilsoft.c
|
||||
|
||||
Specific code for the ILSOFT 128x128 OLED module
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
//static const uint8_t ucg_dev_ssd1351_128x128_init_seq[] PROGMEM = {
|
||||
static const ucg_pgm_uint8_t ucg_ilsoft_ssd1351_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
//UCG_C11(0x0fd, 0x012), /* Unlock normal commands, reset default: unlocked */
|
||||
UCG_C11(0x0fd, 0x0b1), /* Unlock extra commands, reset default: locked */
|
||||
|
||||
//UCG_C10(0x0ae), /* Set Display Off */
|
||||
UCG_C10(0x0af), /* Set Display On */
|
||||
UCG_C10(0x0a6), /* Set Display Mode Reset */
|
||||
UCG_C11(0x0a0, 0x0b4), /* Set Colour Depth */
|
||||
UCG_C11(0x0a1, 0x000), /* Set Display Start Line */
|
||||
UCG_C11(0x0a2, 0x000), /* Set Display Offset */
|
||||
UCG_C12(0x015, 0x000, 0x07f), /* Set Column Address */
|
||||
UCG_C12(0x075, 0x000, 0x07f), /* Set Row Address */
|
||||
|
||||
UCG_C11(0x0b3, 0x0f1), /* Front Clock Div */
|
||||
//UCG_C11(0x0ca, 0x07f), /* Set Multiplex Ratio, reset default: 0x7f */
|
||||
UCG_C11(0x0b5, 0x000), /* Set GPIO */
|
||||
//UCG_C11(0x0ab, 0x001), /* Set Function Selection, reset default: 0x01 */
|
||||
UCG_C11(0x0b1, 0x032), /* Set Phase Length, reset default: 0x82 */
|
||||
UCG_C13(0x0b4, 0xa0,0xb5,0x55), /* Set Segment Low Voltage, reset default: 0xa2 0xb5 0x55 */
|
||||
//UCG_C11(0x0bb, 0x017), /* Set Precharge Voltage, reset default: 0x17 */
|
||||
//UCG_C11(0x0be, 0x005), /* Set VComH Voltage, reset default: 0x05 */
|
||||
UCG_C13(0x0c1, 0xc8, 0x80, 0xc8), /* Set Contrast */
|
||||
UCG_C11(0x0c7, 0x00f), /* Set Master Contrast (0..15), reset default: 0x05 */
|
||||
UCG_C11(0x0b6, 0x001), /* Set Second Precharge Period */
|
||||
|
||||
// UCG_C10(0x0b8), /* Set CMD Grayscale Lookup, 63 Bytes follow */
|
||||
// UCG_A8(0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c),
|
||||
// UCG_A8(0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14),
|
||||
// UCG_A8(0x15,0x16,0x18,0x1a,0x1b,0x1C,0x1D,0x1F),
|
||||
// UCG_A8(0x21,0x23,0x25,0x27,0x2A,0x2D,0x30,0x33),
|
||||
// UCG_A8(0x36,0x39,0x3C,0x3F,0x42,0x45,0x48,0x4C),
|
||||
// UCG_A8(0x50,0x54,0x58,0x5C,0x60,0x64,0x68,0x6C),
|
||||
// UCG_A8(0x70,0x74,0x78,0x7D,0x82,0x87,0x8C,0x91),
|
||||
// UCG_A7(0x96,0x9B,0xA0,0xA5,0xAA,0xAF,0xB4),
|
||||
|
||||
|
||||
UCG_C10(0x05c), /* Write RAM */
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_ssd1351_18x128x128_ilsoft(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_ssd1351_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_ilsoft_ssd1351_init_seq);
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the conroller procedures */
|
||||
return ucg_dev_ic_ssd1351_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 128;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_ssd1351_18(ucg, msg, data);
|
||||
}
|
@ -1,268 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_oled_128x128_univision.c
|
||||
|
||||
Specific code for the Univision 1.5" OLED (UG2828, 128x128 pixel, 65K Colors, SEPS225)
|
||||
Note: Only 65K color support, because 262K mode is not possible with 8 Bit SPI.
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2015, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
/* the following code is from the UG2828GDEAF02 Datasheet */
|
||||
static const ucg_pgm_uint8_t aaa_ucg_univision_seps225_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* First arg: level for commands, Second arg: level for command arguments */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C11(0x002, 0x001), /* OSC_CTL: external resistor, internal OSC */
|
||||
UCG_C11(0x004, 0x000), /* REDUCE_CURRENT: normal operation, no current reduction */
|
||||
UCG_C11(0x003, 0x030), /* CLK_DIV: 90Hz, ratio 1 */
|
||||
|
||||
UCG_C11(0x008, 0x000), /* Precharge time red */
|
||||
UCG_C11(0x009, 0x000), /* Precharge time green */
|
||||
UCG_C11(0x00a, 0x000), /* Precharge time blue */
|
||||
|
||||
UCG_C11(0x00b, 0x000), /* Precharge current red */
|
||||
UCG_C11(0x00c, 0x000), /* Precharge current green */
|
||||
UCG_C11(0x00d, 0x000), /* Precharge current blue */
|
||||
|
||||
|
||||
UCG_C11(0x010, 0x04a), /* Driving current red */
|
||||
UCG_C11(0x011, 0x025), /* Driving current green, original value 0x011 replaced by 0x025 */
|
||||
UCG_C11(0x012, 0x02f), /* Driving current blue */
|
||||
|
||||
UCG_C11(0x013, 0x000), /* Display mode: RGB,column=0..127,column data display control=Normal Dispaly */
|
||||
UCG_C11(0x014, 0x001), /* External interface: 18 bit, MPU, Bit size does not matter if MPU is selected*/
|
||||
//UCG_C11(0x016, 0x076), /* Memory Mode: 6bits triple transfer (would require 6bit words on SPI, 262K support, horizontal inc., vertical inc., data continuously written horizontally */
|
||||
UCG_C11(0x016, 0x066), /* Memory Mode: dual transfer (2x 8Bit), 65K support, horizontal inc., vertical inc., data continuously written horizontally */
|
||||
|
||||
/* memory window */
|
||||
UCG_C11(0x017, 0x000), /* x0 */
|
||||
UCG_C11(0x018, 0x07f), /* x1 */
|
||||
UCG_C11(0x019, 0x000), /* y0 */
|
||||
UCG_C11(0x01a, 0x07f), /* y1 */
|
||||
|
||||
/* memory start */
|
||||
UCG_C11(0x020, 0x000), /* x */
|
||||
UCG_C11(0x021, 0x000), /* y */
|
||||
|
||||
UCG_C11(0x028, 0x07f), /* Duty */
|
||||
UCG_C11(0x029, 0x000), /* Display start line */
|
||||
|
||||
/* DDRAM start */
|
||||
UCG_C11(0x02e, 0x000), /* x */
|
||||
UCG_C11(0x02f, 0x000), /* y */
|
||||
|
||||
UCG_C11(0x033, 0x000), /* Display Screen Saver x0 */
|
||||
UCG_C11(0x034, 0x07f), /* Display Screen Saver x1 */
|
||||
UCG_C11(0x035, 0x000), /* Display Screen Saver y0 */
|
||||
UCG_C11(0x036, 0x07f), /* Display Screen Saver y1 */
|
||||
|
||||
UCG_C11(0x080, 0x000), /* IREF: External */
|
||||
|
||||
UCG_DLY_MS(100), /* as suggested in the Univision manual */
|
||||
|
||||
UCG_C11(0x006, 0x001), /* Display on */
|
||||
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
/* init seq. from the .ino example from ZhangFeng, PRC. http://vfdclock.jimdo.com */
|
||||
static const ucg_pgm_uint8_t ucg_univision_seps225_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* First arg: level for commands, Second arg: level for command arguments */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C11(0x006, 0x000), /* Display off */
|
||||
|
||||
UCG_C11(0x002, 0x001), /* OSC_CTL: external resistor, internal OSC */
|
||||
UCG_C11(0x004, 0x000), /* REDUCE_CURRENT: normal operation, no current reduction */
|
||||
UCG_C11(0x003, 0x030), /* CLK_DIV: 90Hz, ratio 1 */
|
||||
|
||||
UCG_C11(0x005, 0x000), /* Software Reset */
|
||||
|
||||
|
||||
UCG_C11(0x008, 0x003), /* Precharge time red */
|
||||
UCG_C11(0x009, 0x004), /* Precharge time green */
|
||||
UCG_C11(0x00a, 0x005), /* Precharge time blue */
|
||||
|
||||
UCG_C11(0x00b, 0x00b), /* Precharge current red */
|
||||
UCG_C11(0x00c, 0x00b), /* Precharge current green */
|
||||
UCG_C11(0x00d, 0x00e), /* Precharge current blue */
|
||||
|
||||
|
||||
UCG_C11(0x010, 0x03e), /* Driving current red */
|
||||
UCG_C11(0x011, 0x032), /* Driving current green, original value 0x011 replaced by 0x025 */
|
||||
UCG_C11(0x012, 0x03d), /* Driving current blue */
|
||||
|
||||
UCG_C11(0x013, 0x000), /* Display mode: RGB,column=0..127,column data display control=Normal Dispaly */
|
||||
UCG_C11(0x014, 0x001), /* External interface: 18 bit, MPU, Bit size does not matter if MPU is selected*/
|
||||
//UCG_C11(0x016, 0x076), /* Memory Mode: 6bits triple transfer (would require 6bit words on SPI, 262K support, horizontal inc., vertical inc., data continuously written horizontally */
|
||||
UCG_C11(0x015, 0x000),
|
||||
UCG_C11(0x016, 0x066), /* Memory Mode: dual transfer (2x 8Bit), 65K support, horizontal inc., vertical inc., data continuously written horizontally */
|
||||
|
||||
/* memory window */
|
||||
UCG_C11(0x017, 0x000), /* x0 */
|
||||
UCG_C11(0x018, 0x07f), /* x1 */
|
||||
UCG_C11(0x019, 0x000), /* y0 */
|
||||
UCG_C11(0x01a, 0x07f), /* y1 */
|
||||
|
||||
/* memory start */
|
||||
UCG_C11(0x020, 0x000), /* x */
|
||||
UCG_C11(0x021, 0x000), /* y */
|
||||
|
||||
UCG_C11(0x028, 0x07f), /* Duty */
|
||||
UCG_C11(0x029, 0x000), /* Display start line */
|
||||
|
||||
/* DDRAM start */
|
||||
UCG_C11(0x02e, 0x000), /* x */
|
||||
UCG_C11(0x02f, 0x000), /* y */
|
||||
|
||||
UCG_C11(0x031, 0x000),
|
||||
UCG_C11(0x032, 0x000),
|
||||
|
||||
UCG_C11(0x033, 0x000), /* Display Screen Saver x0 */
|
||||
UCG_C11(0x034, 0x07f), /* Display Screen Saver x1 */
|
||||
UCG_C11(0x035, 0x000), /* Display Screen Saver y0 */
|
||||
UCG_C11(0x036, 0x07f), /* Display Screen Saver y1 */
|
||||
|
||||
UCG_C11(0x080, 0x000), /* IREF: External */
|
||||
|
||||
UCG_DLY_MS(100), /* as suggested in the Univision manual */
|
||||
|
||||
UCG_C11(0x006, 0x001), /* Display on */
|
||||
//UCG_C10(0x022),
|
||||
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
//UCG_DATA(),
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_seps255_pos_dir0_seq[] =
|
||||
{
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C11(0x016, 0x066), /* Memory Mode */
|
||||
UCG_C11(0x020, 0), /* set x position */
|
||||
UCG_C11(0x021, 0), /* set y position */
|
||||
UCG_C10(0x022), /* prepare for data */
|
||||
UCG_DATA(), /* change to data mode */
|
||||
UCG_END()
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_seps225_16x128x128_univision(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_seps225_16(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_univision_seps225_init_seq);
|
||||
|
||||
/* demonstration of the OLED error */
|
||||
/*
|
||||
{
|
||||
uint8_t r,g,b, i;
|
||||
uint8_t c[3];
|
||||
|
||||
ucg_com_SendCmdSeq(ucg, ucg_seps255_pos_dir0_seq);
|
||||
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 80;
|
||||
c[0] = (r&0x0f8) | (((g) >>5));
|
||||
c[1] = ((((g))<<3)&0x0e0) | (((b) >>3));
|
||||
ucg_com_SendRepeat2Bytes(ucg, 128, c);
|
||||
|
||||
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 0;
|
||||
c[0] = (r&0x0f8) | (((g) >>5));
|
||||
c[1] = ((((g))<<3)&0x0e0) | (((b) >>3));
|
||||
|
||||
for( i = 0; i < 126; i++ )
|
||||
{
|
||||
ucg_com_SendRepeat2Bytes(ucg, 128, c);
|
||||
}
|
||||
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 255;
|
||||
c[0] = (r&0x0f8) | (((g) >>5));
|
||||
c[1] = ((((g))<<3)&0x0e0) | (((b) >>3));
|
||||
|
||||
ucg_com_SendRepeat2Bytes(ucg, 40, c);
|
||||
|
||||
|
||||
for(;;)
|
||||
;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the controller procedures */
|
||||
return ucg_dev_ic_seps225_16(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 128;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_seps225_16(ucg, msg, data);
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_oled_160x128_samsung.c
|
||||
|
||||
Specific code for the Samsung 160x128 OLED (LD50T6160 Controller)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2015, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
/*
|
||||
Samsung 1.8" OLED
|
||||
VCC_R (4) connected to 4.7uF
|
||||
VCC_R1 (41) connected to 4.7uF
|
||||
VCC connected to 18V
|
||||
VCC3 connected to 18V
|
||||
|
||||
==> Internal regulator mit be enabled
|
||||
==> DC-DC must be switched off
|
||||
|
||||
From the Samsung 1.8" OLED datasheet:
|
||||
|
||||
PREC_WIDTH = 06h, (pre charge width?)
|
||||
PEAKDELAY = 01h,
|
||||
Frame Freq.(*1)) = 02h(90Hz)
|
||||
|
||||
Red : PEAKWIDTH = 03h,
|
||||
Green : PEAKWIDTH = 05h,
|
||||
Blue : PEAKWIDTH = 03h
|
||||
|
||||
Red : DOT CURRENT = 9Ah,
|
||||
Green : DOT CURRENT = 5Ch,
|
||||
Blue : DOT CURRENT = B1h
|
||||
|
||||
*/
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_samsung_160x128_init_seq[] = {
|
||||
/* init sequence for the Samsung OLED with LD50T6160 controller */
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(150),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
|
||||
UCG_C10(0x01), /* software reset */
|
||||
UCG_C11(0x02, 0x00), /* display on/off: display off */
|
||||
UCG_C11(0x03, 0x00), /* standby off, OSCA start */
|
||||
UCG_C11(0x04, 0x02), /* set frame rate: 0..7, 60Hz to 150Hz, default is 2=90Hz */
|
||||
UCG_C11(0x05, 0x00), /* write dir, bit 3: RGB/BGR */
|
||||
UCG_C11(0x06, 0x00), /* row scan dir (0=default) */
|
||||
|
||||
UCG_C11(0x06, 0x00), /* row scan dir (0=default) */
|
||||
|
||||
UCG_C10(0x07), /* set screen size */
|
||||
UCG_A2(0x00, 0x00), /* x min = 0 */
|
||||
UCG_A2(0x07, 0x0f), /* x max = 127 */
|
||||
UCG_A2(0x00, 0x00), /* y min = 0 */
|
||||
UCG_A2(0x09, 0x0f), /* y max = 159 */
|
||||
|
||||
UCG_C11(0x08, 0x00), /* interface bus width: 6 bit */
|
||||
UCG_C11(0x09, 0x07), /* no data (RGB) masking (default) */
|
||||
|
||||
|
||||
UCG_C10(0x0a), /* write box (probably not req. during init */
|
||||
UCG_A2(0x00, 0x00), /* x min = 0 */
|
||||
UCG_A2(0x07, 0x0f), /* x max = 127 */
|
||||
UCG_A2(0x00, 0x00), /* y min = 0 */
|
||||
UCG_A2(0x09, 0x0f), /* y max = 159 */
|
||||
|
||||
UCG_C10(0x0e), /* set some minimal dot current first */
|
||||
UCG_A2(0x00, 0x03), /* red */
|
||||
UCG_A2(0x00, 0x03), /* green */
|
||||
UCG_A2(0x00, 0x03), /* blue */
|
||||
|
||||
UCG_C11(0x1b, 0x03), /* Pre-Charge Mode Select:Enable Pre-Charge and Peakboot for the Samsung OLED */
|
||||
UCG_C12(0x1c, 0x00, 0x06), /* Pre-Charge Width, Samsung OLED: 0x06, controller default is 0x08 */
|
||||
|
||||
UCG_C10(0x1d), /* Peak Pulse Width Set */
|
||||
UCG_A2(0x00, 0x03), /* red */
|
||||
UCG_A2(0x00, 0x05), /* green */
|
||||
UCG_A2(0x00, 0x03), /* blue */
|
||||
|
||||
UCG_C11(0x1e, 0x01), /* Peak Pulse Delay Set, Samsung OLED: 0x01, controller default is 0x05 */
|
||||
|
||||
/*
|
||||
Row Scan Operation Set (cmd 0x1f)
|
||||
|
||||
bits 0, 1: scan mode
|
||||
mode 00: alternate scan mode (Oliver: not sure if this is true, prob. this is seq. mode)
|
||||
mode 01: seq. scan mode (Oliver: could be mode 00)
|
||||
mode 10: simultaneous scan mode (Oliver: No idea what this is)
|
||||
Samsung OLED: probably mode 00
|
||||
bit 3:
|
||||
if set to 1, then all rows are connected to GND
|
||||
Samsung OLED: must be 0 for normal operation
|
||||
bit 4,5: row timing setting
|
||||
00: none
|
||||
01: pre charge
|
||||
10: pre charge + peak delay
|
||||
11: pre charge + peak delay + peak boot
|
||||
Samsung OLED: No idea, maybe 11 must be set here
|
||||
*/
|
||||
UCG_C11(0x1f, 0x30), /* Samsung OLED: pre charge + peak delay + peak boot */
|
||||
|
||||
UCG_C11(0x2d, 0x00), /* Write data through system interface (bit 4 = 0) */
|
||||
|
||||
/*
|
||||
ICON Display control
|
||||
bit 0/1 = 01: ALL ICON ON
|
||||
bit 0/1 = 10: normal display mode (depends on ICON data)
|
||||
*/
|
||||
UCG_C11(0x20, 0x01), /* ICON Display control */
|
||||
UCG_C11(0x21, 0x00), /* ICON Stand-by Setting, bit 0 = 0: no standby, start OSCB */
|
||||
UCG_C11(0x29, 0x00), /* DC-DC Control for ICON: bit 0&1 = 01: stop DC-DC, use VICON (Samsung OLED has external 18V) */
|
||||
UCG_C11(0x2a, 0x04), /* ICON Frame Frequency Set: 89Hz */
|
||||
|
||||
UCG_C11(0x30, 0x13), /* Internal Regulator for Row Scan, value taken from Samsung OLED flow chart */
|
||||
|
||||
/*
|
||||
Set full dot current
|
||||
Red : DOT CURRENT = 9Ah,
|
||||
Green : DOT CURRENT = 5Ch,
|
||||
Blue : DOT CURRENT = B1h
|
||||
*/
|
||||
UCG_DLY_MS(10),
|
||||
UCG_C10(0x0e), /* set dot current */
|
||||
UCG_A2(0x09, 0x0a), /* red */
|
||||
UCG_A2(0x05, 0x0c), /* green */
|
||||
UCG_A2(0x0b, 0x01), /* blue */
|
||||
UCG_DLY_MS(10),
|
||||
|
||||
UCG_C11(0x02, 0x01), /* Display on */
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_ld50t6160_18x160x128_samsung(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_ld50t6160_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_samsung_160x128_init_seq);
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the controller procedures */
|
||||
return ucg_dev_ic_ld50t6160_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 160;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_ld50t6160_18(ucg, msg, data);
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_oled_96x64_univision.c
|
||||
|
||||
Specific code for the Univision 0.95" OLED (UG-9664, 96x94 pixel, 65536 Colors, SSD1331)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2015, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_univision_ssd1331_init_seq[] = {
|
||||
UCG_CFG_CD(0,0), /* First arg: level for commands, Second arg: level for command arguments */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(1),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
//UCG_C11(0x0fd, 0x012), /* Unlock normal commands, reset default: unlocked */
|
||||
UCG_C10(0x0ae), /* Set Display Off */
|
||||
//UCG_C10(0x0af), /* Set Display On */
|
||||
UCG_C11(0x0a0, 0x0b2), /* 65k format 2, RGB Mode */
|
||||
UCG_C11(0x0a1, 0x000), /* Set Display Start Line */
|
||||
UCG_C11(0x0a2, 0x000), /* Set Display Offset */
|
||||
UCG_C11(0x0a8, 0x03f), /* Multiplex, reset value = 0x03f */
|
||||
UCG_C11(0x0ad, 0x08e), /* select supply (must be set before 0x0af) */
|
||||
|
||||
UCG_C11(0x0b0, 0x00b), /* Disable power save mode */
|
||||
UCG_C11(0x0b1, 0x031), /* Set Phase Length, reset default: 0x74 */
|
||||
UCG_C11(0x0b3, 0x0f0), /* Display Clock Divider/Osc, reset value=0x0d0 */
|
||||
|
||||
UCG_C12(0x015, 0x000, 0x05f), /* Set Column Address */
|
||||
UCG_C12(0x075, 0x000, 0x03f), /* Set Row Address */
|
||||
|
||||
UCG_C11(0x081, 0x080), /* contrast red, Adafruit: 0x091, UC9664: 0x080 */
|
||||
UCG_C11(0x082, 0x080), /* contrast green, Adafruit: 0x050, UC9664: 0x080 */
|
||||
UCG_C11(0x083, 0x080), /* contrast blue, Adafruit: 0x07d, UC9664: 0x080 */
|
||||
UCG_C11(0x087, 0x00f), /* master current/contrast 0x00..0x0f UG-9664: 0x0f, Adafruit: 0x06 */
|
||||
UCG_C11(0x08a, 0x064), /* second precharge speed red */
|
||||
UCG_C11(0x08b, 0x078), /* second precharge speed green */
|
||||
UCG_C11(0x08c, 0x064), /* second precharge speed blue */
|
||||
UCG_C11(0x0bb, 0x03c), /* set shared precharge level, default = 0x03e */
|
||||
UCG_C11(0x0be, 0x03e), /* voltage select, default = 0x03e */
|
||||
|
||||
UCG_C10(0x0b9), /* Reset internal grayscale lookup */
|
||||
// UCG_C10(0x0b8), /* Set CMD Grayscale Lookup, 63 Bytes follow */
|
||||
// UCG_A8(0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c),
|
||||
// UCG_A8(0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14),
|
||||
// UCG_A8(0x15,0x16,0x18,0x1a,0x1b,0x1C,0x1D,0x1F),
|
||||
// UCG_A8(0x21,0x23,0x25,0x27,0x2A,0x2D,0x30,0x33),
|
||||
// UCG_A8(0x36,0x39,0x3C,0x3F,0x42,0x45,0x48,0x4C),
|
||||
// UCG_A8(0x50,0x54,0x58,0x5C,0x60,0x64,0x68,0x6C),
|
||||
// UCG_A8(0x70,0x74,0x78,0x7D,0x82,0x87,0x8C,0x91),
|
||||
// UCG_A7(0x96,0x9B,0xA0,0xA5,0xAA,0xAF,0xB4),
|
||||
|
||||
UCG_C10(0x0a4), /* Normal display mode */
|
||||
UCG_C10(0x0af), /* Set Display On */
|
||||
|
||||
|
||||
//UCG_C12(0x015, 0x030, 0x05f), /* Set Column Address */
|
||||
//UCG_C12(0x075, 0x010, 0x03f), /* Set Row Address */
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
//UCG_D3(0x0ff, 0, 0),
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_ssd1331_18x96x64_univision(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_ssd1331_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_univision_ssd1331_init_seq);
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the controller procedures */
|
||||
return ucg_dev_ic_ssd1331_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 96;
|
||||
((ucg_wh_t *)data)->h = 64;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_ssd1331_18(ucg, msg, data);
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_tft_128x128_ili9163.c
|
||||
|
||||
ILI9341 with 4-Wire SPI (SCK, SDI, CS, D/C and optional reset)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2015, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_tft_128x128_ili9163_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C10(0x011), /* sleep out */
|
||||
UCG_DLY_MS(10),
|
||||
//UCG_C10(0x038), /* idle mode off */
|
||||
UCG_C10(0x013), /* normal display on */
|
||||
|
||||
//UCG_C14(0x0ed, 0x055, 0x001, 0x023, 0x001), /* power on sequence control (POR values) */
|
||||
//UCG_C11(0x0f7, 0x020), /* pump ratio control (POR value) */
|
||||
|
||||
|
||||
UCG_C10(0x20), /* not inverted */
|
||||
//UCG_C10(0x21), /* inverted */
|
||||
|
||||
UCG_C11(0x03a, 0x066), /* set pixel format to 18 bit */
|
||||
//UCG_C11(0x03a, 0x055), /* set pixel format to 16 bit */
|
||||
|
||||
//UCG_C12(0x0b1, 0x000, 0x01b), /* frame rate control (POR values) */
|
||||
|
||||
//UCG_C14(0x0b6, 0x00a, 0x082 | (1<<5), 0x027, 0x000), /* display function control (POR values, except for shift direction bit) */
|
||||
|
||||
//UCG_C11(0x0b7, 0x006), /* entry mode, bit 0: Low voltage detection control (0=off) */
|
||||
|
||||
UCG_C12(0x0c0, 0x00a, 0x002), /* power control 1 */
|
||||
UCG_C11(0x0c1, 0x002), /* power control 2 (step up factor), POR=2 */
|
||||
UCG_C11(0x0c7, 0x0d0), /* VCOM control 2, enable VCOM control 1 */
|
||||
UCG_C12(0x0c5, 0x040, 0x04a), /* VCOM control 1, POR=31,3C */
|
||||
|
||||
// UCG_C15(0x0cb, 0x039, 0x02c, 0x000, 0x034, 0x002), /* power control A (POR values) */
|
||||
// UCG_C13(0x0cf, 0x000, 0x081, 0x030), /* power control B (POR values) */
|
||||
|
||||
// UCG_C13(0x0e8, 0x084, 0x011, 0x07a), /* timer driving control A (POR values) */
|
||||
|
||||
// UCG_C12(0x0ea, 0x066, 0x000), /* timer driving control B (POR values) */
|
||||
//UCG_C12(0x0ea, 0x000, 0x000), /* timer driving control B */
|
||||
|
||||
//UCG_C10(0x28), /* display off */
|
||||
//UCG_C11(0x0bf, 0x003), /* backlight control 8 */
|
||||
UCG_C10(0x029), /* display on */
|
||||
//UCG_C11(0x051, 0x07f), /* brightness */
|
||||
//UCG_C11(0x053, 0x02c), /* control brightness */
|
||||
//UCG_C10(0x028), /* display off */
|
||||
|
||||
|
||||
UCG_C11( 0x036, 0x008),
|
||||
|
||||
UCG_C14( 0x02a, 0x000, 0x000, 0x000, 0x07f), /* Horizontal GRAM Address Set */
|
||||
UCG_C14( 0x02b, 0x000, 0x000, 0x000, 0x07f), /* Vertical GRAM Address Set */
|
||||
UCG_C10( 0x02c), /* Write Data to GRAM */
|
||||
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_ili9163_18x128x128(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_ili9163_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_tft_128x128_ili9163_init_seq);
|
||||
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the conroller procedures */
|
||||
return ucg_dev_ic_ili9163_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 128;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_ili9163_18(ucg, msg, data);
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_tft_128x160_st7735.c
|
||||
|
||||
ST7735 with 4-Wire SPI (SCK, SDI, CS, D/C and optional reset)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
//static const uint8_t ucg_dev_ssd1351_128x128_init_seq[] PROGMEM = {
|
||||
static const ucg_pgm_uint8_t ucg_tft_128x160_st7735_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C10(0x011), /* sleep out */
|
||||
UCG_DLY_MS(10),
|
||||
//UCG_C10(0x038), /* idle mode off */
|
||||
UCG_C10(0x013), /* normal display on */
|
||||
|
||||
|
||||
|
||||
UCG_C10(0x20), /* not inverted */
|
||||
//UCG_C10(0x21), /* inverted */
|
||||
|
||||
UCG_C11(0x03a, 0x006), /* set pixel format to 18 bit */
|
||||
//UCG_C11(0x03a, 0x005), /* set pixel format to 16 bit */
|
||||
|
||||
//UCG_C12(0x0b1, 0x000, 0x01b), /* frame rate control (POR values) */
|
||||
//UCG_C10(0x28), /* display off */
|
||||
//UCG_C11(0x0bf, 0x003), /* backlight control 8 */
|
||||
UCG_C10(0x029), /* display on */
|
||||
//UCG_C11(0x051, 0x07f), /* brightness */
|
||||
//UCG_C11(0x053, 0x02c), /* control brightness */
|
||||
//UCG_C10(0x028), /* display off */
|
||||
|
||||
|
||||
UCG_C11( 0x036, 0x000), /* memory control */
|
||||
|
||||
UCG_C14( 0x02a, 0x000, 0x000, 0x000, 0x07f), /* Horizontal GRAM Address Set */
|
||||
UCG_C14( 0x02b, 0x000, 0x000, 0x000, 0x09f), /* Vertical GRAM Address Set */
|
||||
UCG_C10( 0x02c), /* Write Data to GRAM */
|
||||
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_st7735_18x128x160(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_st7735_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_tft_128x160_st7735_init_seq);
|
||||
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the conroller procedures */
|
||||
return ucg_dev_ic_st7735_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 128;
|
||||
((ucg_wh_t *)data)->h = 160;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_st7735_18(ucg, msg, data);
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_tft_132x132_pcf8833.c
|
||||
|
||||
pcf8833 with 3-Wire SPI (SCK, SDI, CS and optional reset)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
//static const uint8_t ucg_dev_ssd1351_132x132_init_seq[] PROGMEM = {
|
||||
static const ucg_pgm_uint8_t ucg_tft_132x132_pcf8833_init_seq_OBSOLETE[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C10(0x01), /* reset */
|
||||
UCG_DLY_MS(199),
|
||||
|
||||
UCG_C10(0x011), /* sleep out */
|
||||
UCG_DLY_MS(10),
|
||||
|
||||
UCG_C10(0x038), /* idle mode off */
|
||||
|
||||
//UCG_C10(0x0b5), /* mirror */
|
||||
//UCG_C10(0x0b7), /* mirror */
|
||||
|
||||
UCG_C10(0x013), /* normal display on */
|
||||
UCG_C10(0x020), /* not inverted */
|
||||
UCG_C10(0x029), /* display on */
|
||||
|
||||
UCG_C11(0x025, 0x03f), /* set contrast -64 ... 63 */
|
||||
|
||||
|
||||
//UCG_C11(0x03a, 0x003), /* set pixel format to 12 bit per pixel */
|
||||
UCG_C11(0x03a, 0x005),
|
||||
|
||||
//UCG_C10(0x003), /* booster on */
|
||||
|
||||
UCG_C10(0x023), /* all pixel on */
|
||||
UCG_DLY_MS(199),
|
||||
UCG_C10(0x013), /* normal display on */
|
||||
|
||||
UCG_C11( 0x036, 0x000), /* memory control */
|
||||
|
||||
UCG_C12( 0x02a, 0x000, 0x07f), /* Horizontal GRAM Address Set */
|
||||
UCG_C12( 0x02b, 0x000, 0x07f), /* Vertical GRAM Address Set */
|
||||
UCG_C10( 0x02c), /* Write Data to GRAM */
|
||||
|
||||
UCG_DLY_MS(10),
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_tft_132x132_pcf8833_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C10(0x01), /* reset */
|
||||
UCG_DLY_MS(199),
|
||||
|
||||
UCG_C10(0x011), /* sleep out */
|
||||
UCG_C10(0x013), /* normal display on */
|
||||
UCG_C10(0x020), /* not inverted */
|
||||
UCG_C10(0x029), /* display on */
|
||||
|
||||
UCG_C11(0x025, 0x03f), /* set contrast -64 ... 63 */
|
||||
|
||||
//UCG_C11(0x03a, 0x003), /* set pixel format to 12 bit per pixel */
|
||||
UCG_C11(0x03a, 0x005), /* set pixel format to 16 bit per pixel */
|
||||
|
||||
UCG_C11( 0x036, 0x000), /* memory control */
|
||||
|
||||
UCG_C12( 0x02a, 0x000, 0x07f), /* Horizontal GRAM Address Set */
|
||||
UCG_C12( 0x02b, 0x000, 0x07f), /* Vertical GRAM Address Set */
|
||||
UCG_C10( 0x02c), /* Write Data to GRAM */
|
||||
|
||||
|
||||
// UCG_DLY_MS(10),
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_pcf8833_16x132x132(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_pcf8833_16(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_tft_132x132_pcf8833_init_seq);
|
||||
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the conroller procedures */
|
||||
return ucg_dev_ic_pcf8833_16(ucg, msg, data);
|
||||
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_pcf8833_16(ucg, msg, data);
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_tft_240x320_ili9325_spi.c
|
||||
|
||||
Device for the ILI9325 in 8 bit SPI mode (IM3=0, IM2=1, IM1=1, IM0=1)
|
||||
All commands are 8 bit width only.
|
||||
1 May 2014: Currently, this is not working
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
//static const uint8_t ucg_dev_ssd1351_128x128_init_seq[] PROGMEM = {
|
||||
static const ucg_pgm_uint8_t ucg_tft_240x320_ili9325_spi_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_DLY_MS(1), /* delay 1 ms */
|
||||
UCG_C12(0x001,0x001, 0x000), /* Driver Output Control, bits 8 & 10 */
|
||||
UCG_C12(0x002, 0x007, 0x000), /* LCD Driving Wave Control, bit 9: Set line inversion */
|
||||
//UCG_C12(0x003, 0x010, 0x030), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1 (16 bit transfer, 65K Mode)*/
|
||||
UCG_C12(0x003, 0xc0 | 0x010, 0x030), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
//UCG_C12(0x004, 0x000, 0x000), /* Resize register, all 0: no resize */
|
||||
UCG_C12(0x008, 0x002, 0x007), /* Display Control 2: set the back porch and front porch */
|
||||
//UCG_C12(0x009, 0x000, 0x000), /* Display Control 3: normal scan */
|
||||
//UCG_C12(0x00a, 0x000, 0x000), /* Display Control 4: set to "no FMARK output" */
|
||||
UCG_C12(0x00c, 0x000, 0x000), /* RGB Display Interface Control 1, RIM=10 (3x6 Bit), 12 Jan 14: RIM=00 */
|
||||
//UCG_C12(0x00d, 0x000, 0x000), /* Frame Maker Position */
|
||||
//UCG_C12(0x00f, 0x000, 0x000), /* RGB Display Interface Control 2 */
|
||||
UCG_C12(0x010, 0x000, 0x000), /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB, actual setting is done below */
|
||||
UCG_C12(0x011, 0x000, 0x007), /* Power Control 2: DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
UCG_C12(0x012, 0x000, 0x000), /* Power Control 3: VREG1OUT voltage */
|
||||
UCG_C12(0x013, 0x000, 0x000), /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
//UCG_C12(0x007, 0x000, 0x001), /* Display Control 1: Operate, but do not display */
|
||||
UCG_C12( 0x007, 0x001, 0x033), /* Display Control 1: Operate, display ON, Partial image off */
|
||||
UCG_DLY_MS(100), /* delay 100 ms */ /* ITDB02 none D verion: 50ms */
|
||||
UCG_C12( 0x010, 0x010, 0x090), /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
/* 12. Jan 14. Prev value: 0x016, 0x090 */
|
||||
/* ITDB02 none D verion: 0x010, 0x090 */
|
||||
//UCG_C12( 0x010, 0x017, 0x0f0), /* Power Control 1: Setting for max quality & power consumption: SAP(Bit 12)=1, BT[3:0]=7 (max), APE (Bit 8)=1, AP=7 (max), disable sleep: SLP=0, STB=0 */
|
||||
UCG_C12( 0x011, 0x002, 0x027), /* Power Control 2 VCI ration, step up circuits 1 & 2 */
|
||||
UCG_DLY_MS(50), /* delay 50 ms */
|
||||
|
||||
UCG_C12( 0x012, 0x000, 0x01f), /* Power Control 3: VCI: External, VCI*1.80 */
|
||||
/* 12. Jan 14. Prev value: 0x000, 0x00d */
|
||||
UCG_DLY_MS(50), /* delay 50 ms */
|
||||
UCG_C12( 0x013, 0x015, 0x000), /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
/* 12. Jan 14. Prev value: 0x012, 0x009 */
|
||||
UCG_C12( 0x029, 0x000, 0x027), /* Power Control 7 */
|
||||
/* 12. Jan 14. Prev value: 0x000, 0x00a */
|
||||
UCG_C12( 0x02b, 0x000, 0x00d), /* Frame Rate: 93 */
|
||||
//UCG_C12( 0x02b, 0x000, 0x00b), /* Frame Rate: 70, too less, some flicker visible */
|
||||
UCG_DLY_MS(50), /* delay 50 ms */
|
||||
|
||||
/* Gamma Control, values from iteadstudio.com reference software on google code */
|
||||
/*
|
||||
UCG_C12(0x30,0x00,0x00),
|
||||
UCG_C12(0x31,0x07,0x07),
|
||||
UCG_C12(0x32,0x03,0x07),
|
||||
UCG_C12(0x35,0x02,0x00),
|
||||
UCG_C12(0x36,0x00,0x08),
|
||||
UCG_C12(0x37,0x00,0x04),
|
||||
UCG_C12(0x38,0x00,0x00),
|
||||
UCG_C12(0x39,0x07,0x07),
|
||||
UCG_C12(0x3C,0x00,0x02),
|
||||
UCG_C12(0x3D,0x1D,0x04),
|
||||
*/
|
||||
|
||||
UCG_C12( 0x020, 0x000, 0x000), /* Horizontal GRAM Address Set */
|
||||
UCG_C12( 0x021, 0x000, 0x000), /* Vertical GRAM Address Set */
|
||||
|
||||
UCG_C12( 0x050, 0x000, 0x000), /* Horizontal GRAM Start Address */
|
||||
UCG_C12( 0x051, 0x000, 0x0EF), /* Horizontal GRAM End Address: 239 */
|
||||
UCG_C12( 0x052, 0x000, 0x000), /* Vertical GRAM Start Address */
|
||||
UCG_C12( 0x053, 0x001, 0x03F), /* Vertical GRAM End Address: 319 */
|
||||
|
||||
UCG_C12( 0x060, 0x0a7, 0x000), /* Driver Output Control 2, NL = 0x027 = 320 lines, GS (bit 15) = 1 */
|
||||
UCG_C12( 0x061, 0x000, 0x001), /* Base Image Display Control: NDL,VLE = 0 (Disbale Vertical Scroll), REV */
|
||||
//UCG_C12( 0x06a, 0x000, 0x000), /* Vertical Scroll Control */
|
||||
//UCG_C12( 0x080, 0x000, 0x000), /* Partial Image 1 Display Position */
|
||||
//UCG_C12( 0x081, 0x000, 0x000), /* Partial Image 1 RAM Start Address */
|
||||
//UCG_C12( 0x082, 0x000, 0x000), /* Partial Image 1 RAM End Address */
|
||||
//UCG_C12( 0x083, 0x000, 0x000), /* Partial Image 2 Display Position */
|
||||
//UCG_C12( 0x084, 0x000, 0x000), /* Partial Image 2 RAM Start Address */
|
||||
//UCG_C12( 0x085, 0x000, 0x000), /* Partial Image 2 RAM End Address */
|
||||
UCG_C12( 0x090, 0x000, 0x010), /* Panel Interface Control 1 */
|
||||
UCG_C12( 0x092, 0x000, 0x000), /* Panel Interface Control 2 */
|
||||
/* 0x006, 0x000 */
|
||||
UCG_C12( 0x007, 0x001, 0x033), /* Display Control 1: Operate, display ON, Partial image off */
|
||||
UCG_DLY_MS(10), /* delay 10 ms */
|
||||
/* write test pattern */
|
||||
//UCG_C12( 0x020, 0x000, 0x000), /* Horizontal GRAM Address Set */
|
||||
//UCG_C12( 0x021, 0x000, 0x011), /* Vertical GRAM Address Set */
|
||||
UCG_C10( 0x022), /* Write Data to GRAM */
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_ili9325_spi_18x240x320(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_ili9325_spi_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_tft_240x320_ili9325_spi_init_seq);
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the conroller procedures */
|
||||
return ucg_dev_ic_ili9325_spi_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 240;
|
||||
((ucg_wh_t *)data)->h = 320;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_ili9325_spi_18(ucg, msg, data);
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_tft_240x320_ili9341.c
|
||||
|
||||
ILI9341 with 4-Wire SPI (SCK, SDI, CS, D/C and optional reset)
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
//static const uint8_t ucg_dev_ssd1351_128x128_init_seq[] PROGMEM = {
|
||||
static const ucg_pgm_uint8_t ucg_tft_240x320_ili9341_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
UCG_C10(0x011), /* sleep out */
|
||||
UCG_DLY_MS(10),
|
||||
//UCG_C10(0x038), /* idle mode off */
|
||||
UCG_C10(0x013), /* normal display on */
|
||||
|
||||
//UCG_C14(0x0ed, 0x055, 0x001, 0x023, 0x001), /* power on sequence control (POR values) */
|
||||
//UCG_C11(0x0f7, 0x020), /* pump ratio control (POR value) */
|
||||
|
||||
|
||||
UCG_C10(0x20), /* not inverted */
|
||||
//UCG_C10(0x21), /* inverted */
|
||||
|
||||
UCG_C11(0x03a, 0x066), /* set pixel format to 18 bit */
|
||||
//UCG_C11(0x03a, 0x055), /* set pixel format to 16 bit */
|
||||
|
||||
//UCG_C12(0x0b1, 0x000, 0x01b), /* frame rate control (POR values) */
|
||||
|
||||
UCG_C14(0x0b6, 0x00a, 0x082 | (1<<5), 0x027, 0x000), /* display function control (POR values, except for shift direction bit) */
|
||||
|
||||
//UCG_C11(0x0b7, 0x006), /* entry mode, bit 0: Low voltage detection control (0=off) */
|
||||
|
||||
UCG_C11(0x0c0, 0x021), /* power control 1 (reference voltage level), POR=21 */
|
||||
UCG_C11(0x0c1, 0x002), /* power control 2 (step up factor), POR=2 */
|
||||
UCG_C11(0x0c7, 0x0c0), /* VCOM control 2, enable VCOM control 1 */
|
||||
UCG_C12(0x0c5, 0x031, 0x03c), /* VCOM control 1, POR=31,3C */
|
||||
|
||||
UCG_C15(0x0cb, 0x039, 0x02c, 0x000, 0x034, 0x002), /* power control A (POR values) */
|
||||
UCG_C13(0x0cf, 0x000, 0x081, 0x030), /* power control B (POR values) */
|
||||
|
||||
UCG_C13(0x0e8, 0x084, 0x011, 0x07a), /* timer driving control A (POR values) */
|
||||
|
||||
UCG_C12(0x0ea, 0x066, 0x000), /* timer driving control B (POR values) */
|
||||
//UCG_C12(0x0ea, 0x000, 0x000), /* timer driving control B */
|
||||
|
||||
//UCG_C10(0x28), /* display off */
|
||||
//UCG_C11(0x0bf, 0x003), /* backlight control 8 */
|
||||
UCG_C10(0x029), /* display on */
|
||||
//UCG_C11(0x051, 0x07f), /* brightness */
|
||||
//UCG_C11(0x053, 0x02c), /* control brightness */
|
||||
//UCG_C10(0x028), /* display off */
|
||||
|
||||
|
||||
UCG_C11( 0x036, 0x008),
|
||||
|
||||
UCG_C14( 0x02a, 0x000, 0x000, 0x000, 0x0ef), /* Horizontal GRAM Address Set */
|
||||
UCG_C14( 0x02b, 0x000, 0x000, 0x001, 0x03f), /* Vertical GRAM Address Set */
|
||||
UCG_C10( 0x02c), /* Write Data to GRAM */
|
||||
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
ucg_int_t ucg_dev_ili9341_18x240x320(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_ili9341_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_tft_240x320_ili9341_init_seq);
|
||||
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the conroller procedures */
|
||||
return ucg_dev_ic_ili9341_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 240;
|
||||
((ucg_wh_t *)data)->h = 320;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_ili9341_18(ucg, msg, data);
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_tft_240x320_itdb02.c
|
||||
|
||||
ITDB02 Module Shield
|
||||
Documentation: code.google.com/p/itdb02/
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
//static const uint8_t ucg_dev_ssd1351_128x128_init_seq[] PROGMEM = {
|
||||
static const ucg_pgm_uint8_t ucg_tft_240x320_ili9325_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
|
||||
//UCG_C22(0x000, 0x001,0x001, 0x000), /* Driver Output Control, bits 8 & 10 */
|
||||
//UCG_C22( 0x000, 0x007, 0x001, 0x033), /* Display Control 1: Operate, display ON, Partial image off */
|
||||
//UCG_CS(1), /* disable chip */
|
||||
//UCG_END(), /* end of sequence */
|
||||
|
||||
|
||||
UCG_C22(0x000, 0x001,0x001, 0x000), /* Driver Output Control, bits 8 & 10 */
|
||||
UCG_C22(0x000, 0x002, 0x007, 0x000), /* LCD Driving Wave Control, bit 9: Set line inversion */
|
||||
//UCG_C22(0x000, 0x003, 0x010, 0x030), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1 (16 bit transfer, 65K Mode)*/
|
||||
UCG_C22(0x000, 0x003, 0xc0 | 0x010, 0x030), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1, set TRI (Bit 15) and DFM (Bit 14) --> three byte transfer */
|
||||
//UCG_C22(0x000, 0x004, 0x000, 0x000), /* Resize register, all 0: no resize */
|
||||
UCG_C22(0x000, 0x008, 0x002, 0x007), /* Display Control 2: set the back porch and front porch */
|
||||
//UCG_C22(0x000, 0x009, 0x000, 0x000), /* Display Control 3: normal scan */
|
||||
//UCG_C22(0x000, 0x00a, 0x000, 0x000), /* Display Control 4: set to "no FMARK output" */
|
||||
UCG_C22(0x000, 0x00c, 0x000, 0x000), /* RGB Display Interface Control 1, RIM=10 (3x6 Bit), 12 Jan 14: RIM=00 */
|
||||
//UCG_C22(0x000, 0x00d, 0x000, 0x000), /* Frame Maker Position */
|
||||
//UCG_C22(0x000, 0x00f, 0x000, 0x000), /* RGB Display Interface Control 2 */
|
||||
UCG_C22(0x000, 0x010, 0x000, 0x000), /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB, actual setting is done below */
|
||||
UCG_C22(0x000, 0x011, 0x000, 0x007), /* Power Control 2: DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
UCG_C22(0x000, 0x012, 0x000, 0x000), /* Power Control 3: VREG1OUT voltage */
|
||||
UCG_C22(0x000, 0x013, 0x000, 0x000), /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
UCG_C22(0x000, 0x007, 0x000, 0x001), /* Display Control 1: Operate, but do not display */
|
||||
UCG_DLY_MS(100), /* delay 100 ms */ /* ITDB02 none D verion: 50ms */
|
||||
UCG_C22( 0x000, 0x010, 0x010, 0x090), /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
/* 12. Jan 14. Prev value: 0x016, 0x090 */
|
||||
/* ITDB02 none D verion: 0x010, 0x090 */
|
||||
//UCG_C22( 0x000, 0x010, 0x017, 0x0f0), /* Power Control 1: Setting for max quality & power consumption: SAP(Bit 12)=1, BT[3:0]=7 (max), APE (Bit 8)=1, AP=7 (max), disable sleep: SLP=0, STB=0 */
|
||||
UCG_C22( 0x000, 0x011, 0x002, 0x027), /* Power Control 2 VCI ration, step up circuits 1 & 2 */
|
||||
UCG_DLY_MS(50), /* delay 50 ms */
|
||||
|
||||
UCG_C22( 0x000, 0x012, 0x000, 0x01f), /* Power Control 3: VCI: External, VCI*1.80 */
|
||||
/* 12. Jan 14. Prev value: 0x000, 0x00d */
|
||||
UCG_DLY_MS(50), /* delay 50 ms */
|
||||
UCG_C22( 0x000, 0x013, 0x015, 0x000), /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
/* 12. Jan 14. Prev value: 0x012, 0x009 */
|
||||
UCG_C22( 0x000, 0x029, 0x000, 0x027), /* Power Control 7 */
|
||||
/* 12. Jan 14. Prev value: 0x000, 0x00a */
|
||||
UCG_C22( 0x000, 0x02b, 0x000, 0x00d), /* Frame Rate: 93 */
|
||||
//UCG_C22( 0x000, 0x02b, 0x000, 0x00b), /* Frame Rate: 70, too less, some flicker visible */
|
||||
UCG_DLY_MS(50), /* delay 50 ms */
|
||||
|
||||
/* Gamma Control, values from iteadstudio.com reference software on google code */
|
||||
/*
|
||||
UCG_C22(0x00,0x30,0x00,0x00),
|
||||
UCG_C22(0x00,0x31,0x07,0x07),
|
||||
UCG_C22(0x00,0x32,0x03,0x07),
|
||||
UCG_C22(0x00,0x35,0x02,0x00),
|
||||
UCG_C22(0x00,0x36,0x00,0x08),
|
||||
UCG_C22(0x00,0x37,0x00,0x04),
|
||||
UCG_C22(0x00,0x38,0x00,0x00),
|
||||
UCG_C22(0x00,0x39,0x07,0x07),
|
||||
UCG_C22(0x00,0x3C,0x00,0x02),
|
||||
UCG_C22(0x00,0x3D,0x1D,0x04),
|
||||
*/
|
||||
|
||||
UCG_C22( 0x000, 0x020, 0x000, 0x000), /* Horizontal GRAM Address Set */
|
||||
UCG_C22( 0x000, 0x021, 0x000, 0x000), /* Vertical GRAM Address Set */
|
||||
|
||||
UCG_C22( 0x000, 0x050, 0x000, 0x000), /* Horizontal GRAM Start Address */
|
||||
UCG_C22( 0x000, 0x051, 0x000, 0x0EF), /* Horizontal GRAM End Address: 239 */
|
||||
UCG_C22( 0x000, 0x052, 0x000, 0x000), /* Vertical GRAM Start Address */
|
||||
UCG_C22( 0x000, 0x053, 0x001, 0x03F), /* Vertical GRAM End Address: 319 */
|
||||
|
||||
UCG_C22( 0x000, 0x060, 0x0a7, 0x000), /* Driver Output Control 2, NL = 0x027 = 320 lines, GS (bit 15) = 1 */
|
||||
UCG_C22( 0x000, 0x061, 0x000, 0x001), /* Base Image Display Control: NDL,VLE = 0 (Disbale Vertical Scroll), REV */
|
||||
//UCG_C22( 0x000, 0x06a, 0x000, 0x000), /* Vertical Scroll Control */
|
||||
//UCG_C22( 0x000, 0x080, 0x000, 0x000), /* Partial Image 1 Display Position */
|
||||
//UCG_C22( 0x000, 0x081, 0x000, 0x000), /* Partial Image 1 RAM Start Address */
|
||||
//UCG_C22( 0x000, 0x082, 0x000, 0x000), /* Partial Image 1 RAM End Address */
|
||||
//UCG_C22( 0x000, 0x083, 0x000, 0x000), /* Partial Image 2 Display Position */
|
||||
//UCG_C22( 0x000, 0x084, 0x000, 0x000), /* Partial Image 2 RAM Start Address */
|
||||
//UCG_C22( 0x000, 0x085, 0x000, 0x000), /* Partial Image 2 RAM End Address */
|
||||
UCG_C22( 0x000, 0x090, 0x000, 0x010), /* Panel Interface Control 1 */
|
||||
UCG_C22( 0x000, 0x092, 0x000, 0x000), /* Panel Interface Control 2 */
|
||||
/* 0x006, 0x000 */
|
||||
UCG_C22( 0x000, 0x007, 0x001, 0x033), /* Display Control 1: Operate, display ON, Partial image off */
|
||||
UCG_DLY_MS(10), /* delay 10 ms */
|
||||
/* write test pattern */
|
||||
//UCG_C22( 0x000, 0x020, 0x000, 0x000), /* Horizontal GRAM Address Set */
|
||||
//UCG_C22( 0x000, 0x021, 0x000, 0x011), /* Vertical GRAM Address Set */
|
||||
UCG_C20( 0x000, 0x022), /* Write Data to GRAM */
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_ili9325_18x240x320_itdb02(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_ili9325_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_tft_240x320_ili9325_init_seq);
|
||||
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the conroller procedures */
|
||||
return ucg_dev_ic_ili9325_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 240;
|
||||
((ucg_wh_t *)data)->h = 320;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_ili9325_18(ucg, msg, data);
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_dev_tft_240x320_ssd1289.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
#ifdef NOT_YET_IMPLEMENTED
|
||||
|
||||
static const ucg_pgm_uint8_t ucg_tft_240x320_ssd1289_init_seq[] = {
|
||||
UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */
|
||||
UCG_RST(1),
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(0),
|
||||
UCG_DLY_MS(5),
|
||||
UCG_RST(1),
|
||||
UCG_DLY_MS(50),
|
||||
UCG_CS(0), /* enable chip */
|
||||
UCG_C22(0x000, 0x000, 0x000, 0x001), /* enable oscilator */
|
||||
UCG_C22(0x000, 0x003, 0x066, 0x064), /* Power control 1 (POR value) */
|
||||
|
||||
//UCG_C22(0x000, 0x002, 0x007, 0x000), /* LCD Driving Wave Control, bit 9: Set line inversion */
|
||||
//UCG_C22(0x000, 0x003, 0x010, 0x030), /* Entry Mode, GRAM write direction and BGR (Bit 12)=1 (16 bit transfer, 65K Mode)*/
|
||||
//UCG_C22(0x000, 0x004, 0x000, 0x000), /* Resize register, all 0: no resize */
|
||||
UCG_C22(0x000, 0x008, 0x002, 0x007), /* Display Control 2: set the back porch and front porch */
|
||||
//UCG_C22(0x000, 0x009, 0x000, 0x000), /* Display Control 3: normal scan */
|
||||
//UCG_C22(0x000, 0x00a, 0x000, 0x000), /* Display Control 4: set to "no FMARK output" */
|
||||
UCG_C22(0x000, 0x00c, 0x000, 0x000), /* RGB Display Interface Control 1, RIM=10 (3x6 Bit), 12 Jan 14: RIM=00 */
|
||||
//UCG_C22(0x000, 0x00d, 0x000, 0x000), /* Frame Maker Position */
|
||||
//UCG_C22(0x000, 0x00f, 0x000, 0x000), /* RGB Display Interface Control 2 */
|
||||
UCG_C22(0x000, 0x010, 0x000, 0x000), /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB, actual setting is done below */
|
||||
UCG_C22(0x000, 0x011, 0x000, 0x007), /* Power Control 2: DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
UCG_C22(0x000, 0x012, 0x000, 0x000), /* Power Control 3: VREG1OUT voltage */
|
||||
UCG_C22(0x000, 0x013, 0x000, 0x000), /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
UCG_C22(0x000, 0x007, 0x000, 0x001), /* Display Control 1: Operate, but do not display */
|
||||
UCG_DLY_MS(100), /* delay 100 ms */ /* ITDB02 none D verion: 50ms */
|
||||
UCG_C22( 0x000, 0x010, 0x010, 0x090), /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
/* 12. Jan 14. Prev value: 0x016, 0x090 */
|
||||
/* ITDB02 none D verion: 0x010, 0x090 */
|
||||
//UCG_C22( 0x000, 0x010, 0x017, 0x0f0), /* Power Control 1: Setting for max quality & power consumption: SAP(Bit 12)=1, BT[3:0]=7 (max), APE (Bit 8)=1, AP=7 (max), disable sleep: SLP=0, STB=0 */
|
||||
UCG_C22( 0x000, 0x011, 0x002, 0x027), /* Power Control 2 VCI ration, step up circuits 1 & 2 */
|
||||
UCG_DLY_MS(50), /* delay 50 ms */
|
||||
|
||||
UCG_C22( 0x000, 0x012, 0x000, 0x01f), /* Power Control 3: VCI: External, VCI*1.80 */
|
||||
/* 12. Jan 14. Prev value: 0x000, 0x00d */
|
||||
UCG_DLY_MS(50), /* delay 50 ms */
|
||||
UCG_C22( 0x000, 0x013, 0x015, 0x000), /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
/* 12. Jan 14. Prev value: 0x012, 0x009 */
|
||||
UCG_C22( 0x000, 0x029, 0x000, 0x027), /* Power Control 7 */
|
||||
/* 12. Jan 14. Prev value: 0x000, 0x00a */
|
||||
UCG_C22( 0x000, 0x02b, 0x000, 0x00d), /* Frame Rate: 93 */
|
||||
//UCG_C22( 0x000, 0x02b, 0x000, 0x00b), /* Frame Rate: 70, too less, some flicker visible */
|
||||
UCG_DLY_MS(50), /* delay 50 ms */
|
||||
|
||||
/* Gamma Control, values from iteadstudio.com reference software on google code */
|
||||
/*
|
||||
UCG_C22(0x00,0x30,0x00,0x00),
|
||||
UCG_C22(0x00,0x31,0x07,0x07),
|
||||
UCG_C22(0x00,0x32,0x03,0x07),
|
||||
UCG_C22(0x00,0x35,0x02,0x00),
|
||||
UCG_C22(0x00,0x36,0x00,0x08),
|
||||
UCG_C22(0x00,0x37,0x00,0x04),
|
||||
UCG_C22(0x00,0x38,0x00,0x00),
|
||||
UCG_C22(0x00,0x39,0x07,0x07),
|
||||
UCG_C22(0x00,0x3C,0x00,0x02),
|
||||
UCG_C22(0x00,0x3D,0x1D,0x04),
|
||||
*/
|
||||
|
||||
UCG_C22( 0x000, 0x020, 0x000, 0x000), /* Horizontal GRAM Address Set */
|
||||
UCG_C22( 0x000, 0x021, 0x000, 0x000), /* Vertical GRAM Address Set */
|
||||
|
||||
UCG_C22( 0x000, 0x050, 0x000, 0x000), /* Horizontal GRAM Start Address */
|
||||
UCG_C22( 0x000, 0x051, 0x000, 0x0EF), /* Horizontal GRAM End Address: 239 */
|
||||
UCG_C22( 0x000, 0x052, 0x000, 0x000), /* Vertical GRAM Start Address */
|
||||
UCG_C22( 0x000, 0x053, 0x001, 0x03F), /* Vertical GRAM End Address: 319 */
|
||||
|
||||
UCG_C22( 0x000, 0x060, 0x0a7, 0x000), /* Driver Output Control 2, NL = 0x027 = 320 lines, GS (bit 15) = 1 */
|
||||
UCG_C22( 0x000, 0x061, 0x000, 0x001), /* Base Image Display Control: NDL,VLE = 0 (Disbale Vertical Scroll), REV */
|
||||
//UCG_C22( 0x000, 0x06a, 0x000, 0x000), /* Vertical Scroll Control */
|
||||
//UCG_C22( 0x000, 0x080, 0x000, 0x000), /* Partial Image 1 Display Position */
|
||||
//UCG_C22( 0x000, 0x081, 0x000, 0x000), /* Partial Image 1 RAM Start Address */
|
||||
//UCG_C22( 0x000, 0x082, 0x000, 0x000), /* Partial Image 1 RAM End Address */
|
||||
//UCG_C22( 0x000, 0x083, 0x000, 0x000), /* Partial Image 2 Display Position */
|
||||
//UCG_C22( 0x000, 0x084, 0x000, 0x000), /* Partial Image 2 RAM Start Address */
|
||||
//UCG_C22( 0x000, 0x085, 0x000, 0x000), /* Partial Image 2 RAM End Address */
|
||||
UCG_C22( 0x000, 0x090, 0x000, 0x010), /* Panel Interface Control 1 */
|
||||
UCG_C22( 0x000, 0x092, 0x000, 0x000), /* Panel Interface Control 2 */
|
||||
/* 0x006, 0x000 */
|
||||
UCG_C22( 0x000, 0x007, 0x001, 0x033), /* Display Control 1: Operate, display ON, Partial image off */
|
||||
UCG_DLY_MS(10), /* delay 10 ms */
|
||||
/* write test pattern */
|
||||
//UCG_C22( 0x000, 0x020, 0x000, 0x000), /* Horizontal GRAM Address Set */
|
||||
//UCG_C22( 0x000, 0x021, 0x000, 0x011), /* Vertical GRAM Address Set */
|
||||
UCG_C20( 0x000, 0x022), /* Write Data to GRAM */
|
||||
|
||||
UCG_CS(1), /* disable chip */
|
||||
UCG_END(), /* end of sequence */
|
||||
};
|
||||
|
||||
ucg_int_t ucg_dev_ssd1289_18x240x320_itdb02(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_DEV_POWER_UP:
|
||||
/* 1. Call to the controller procedures to setup the com interface */
|
||||
if ( ucg_dev_ic_ssd1289_18(ucg, msg, data) == 0 )
|
||||
return 0;
|
||||
|
||||
/* 2. Send specific init sequence for this display module */
|
||||
ucg_com_SendCmdSeq(ucg, ucg_tft_240x320_ssd1289_init_seq);
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_DEV_POWER_DOWN:
|
||||
/* let do power down by the conroller procedures */
|
||||
return ucg_dev_ic_ssd1289_18(ucg, msg, data);
|
||||
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
((ucg_wh_t *)data)->w = 240;
|
||||
((ucg_wh_t *)data)->h = 320;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* all other messages are handled by the controller procedures */
|
||||
return ucg_dev_ic_ssd1289_18(ucg, msg, data);
|
||||
}
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,78 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_init.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
#include <string.h> /* memset */
|
||||
|
||||
#ifdef __AVR__
|
||||
uint8_t global_SREG_backup; // used by the atomic macros
|
||||
#endif
|
||||
|
||||
|
||||
void ucg_init_struct(ucg_t *ucg)
|
||||
{
|
||||
//memset(ucg, 0, sizeof(ucg_t));
|
||||
ucg->is_power_up = 0;
|
||||
ucg->rotate_chain_device_cb = 0;
|
||||
ucg->arg.scale = 1;
|
||||
//ucg->display_offset.x = 0;
|
||||
//ucg->display_offset.y = 0;
|
||||
ucg->font = 0;
|
||||
//ucg->font_mode = UCG_FONT_MODE_NONE; Old font procedures
|
||||
ucg->font_decode.is_transparent = 1; // new font procedures
|
||||
|
||||
ucg->com_initial_change_sent = 0;
|
||||
ucg->com_status = 0;
|
||||
ucg->com_cfg_cd = 0;
|
||||
}
|
||||
|
||||
|
||||
ucg_int_t ucg_Init(ucg_t *ucg, ucg_dev_fnptr device_cb, ucg_dev_fnptr ext_cb, ucg_com_fnptr com_cb)
|
||||
{
|
||||
ucg_int_t r;
|
||||
ucg_init_struct(ucg);
|
||||
if ( ext_cb == (ucg_dev_fnptr)0 )
|
||||
ucg->ext_cb = ucg_ext_none;
|
||||
else
|
||||
ucg->ext_cb = ext_cb;
|
||||
ucg->device_cb = device_cb;
|
||||
ucg->com_cb = com_cb;
|
||||
ucg_SetFontPosBaseline(ucg);
|
||||
r = ucg_PowerUp(ucg);
|
||||
ucg_GetDimension(ucg);
|
||||
return r;
|
||||
}
|
||||
|
@ -1,131 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_line.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
void ucg_Draw90Line(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t len, ucg_int_t dir, ucg_int_t col_idx)
|
||||
{
|
||||
ucg->arg.pixel.rgb.color[0] = ucg->arg.rgb[col_idx].color[0];
|
||||
ucg->arg.pixel.rgb.color[1] = ucg->arg.rgb[col_idx].color[1];
|
||||
ucg->arg.pixel.rgb.color[2] = ucg->arg.rgb[col_idx].color[2];
|
||||
ucg->arg.pixel.pos.x = x;
|
||||
ucg->arg.pixel.pos.y = y;
|
||||
ucg->arg.len = len;
|
||||
ucg->arg.dir = dir;
|
||||
ucg_DrawL90FXWithArg(ucg);
|
||||
}
|
||||
|
||||
void ucg_DrawHLine(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t len)
|
||||
{
|
||||
ucg_Draw90Line(ucg, x, y, len, 0, 0);
|
||||
}
|
||||
|
||||
void ucg_DrawVLine(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t len)
|
||||
{
|
||||
ucg_Draw90Line(ucg, x, y, len, 1, 0);
|
||||
}
|
||||
|
||||
void ucg_DrawHRLine(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t len)
|
||||
{
|
||||
ucg_Draw90Line(ucg, x, y, len, 2, 0);
|
||||
}
|
||||
|
||||
void ucg_DrawGradientLine(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t len, ucg_int_t dir)
|
||||
{
|
||||
/* color goes from ucg->arg.rgb[0] to ucg->arg.rgb[1] */
|
||||
ucg->arg.pixel.pos.x = x;
|
||||
ucg->arg.pixel.pos.y = y;
|
||||
ucg->arg.len = len;
|
||||
ucg->arg.dir = dir;
|
||||
ucg_DrawL90SEWithArg(ucg);
|
||||
}
|
||||
|
||||
void ucg_DrawLine(ucg_t *ucg, ucg_int_t x1, ucg_int_t y1, ucg_int_t x2, ucg_int_t y2)
|
||||
{
|
||||
ucg_int_t tmp;
|
||||
ucg_int_t x,y;
|
||||
ucg_int_t dx, dy;
|
||||
ucg_int_t err;
|
||||
ucg_int_t ystep;
|
||||
|
||||
uint8_t swapxy = 0;
|
||||
|
||||
/* no BBX intersection check at the moment... */
|
||||
|
||||
ucg->arg.pixel.rgb.color[0] = ucg->arg.rgb[0].color[0];
|
||||
ucg->arg.pixel.rgb.color[1] = ucg->arg.rgb[0].color[1];
|
||||
ucg->arg.pixel.rgb.color[2] = ucg->arg.rgb[0].color[2];
|
||||
|
||||
if ( x1 > x2 ) dx = x1-x2; else dx = x2-x1;
|
||||
if ( y1 > y2 ) dy = y1-y2; else dy = y2-y1;
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
swapxy = 1;
|
||||
tmp = dx; dx =dy; dy = tmp;
|
||||
tmp = x1; x1 =y1; y1 = tmp;
|
||||
tmp = x2; x2 =y2; y2 = tmp;
|
||||
}
|
||||
if ( x1 > x2 )
|
||||
{
|
||||
tmp = x1; x1 =x2; x2 = tmp;
|
||||
tmp = y1; y1 =y2; y2 = tmp;
|
||||
}
|
||||
err = dx >> 1;
|
||||
if ( y2 > y1 ) ystep = 1; else ystep = -1;
|
||||
y = y1;
|
||||
for( x = x1; x <= x2; x++ )
|
||||
{
|
||||
if ( swapxy == 0 )
|
||||
{
|
||||
ucg->arg.pixel.pos.x = x;
|
||||
ucg->arg.pixel.pos.y = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ucg->arg.pixel.pos.x = y;
|
||||
ucg->arg.pixel.pos.y = x;
|
||||
}
|
||||
ucg_DrawPixelWithArg(ucg);
|
||||
err -= (uint8_t)dy;
|
||||
if ( err < 0 )
|
||||
{
|
||||
y += ystep;
|
||||
err += dx;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_pixel.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
void ucg_SetColor(ucg_t *ucg, uint8_t idx, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
//ucg->arg.pixel.rgb.color[0] = r;
|
||||
//ucg->arg.pixel.rgb.color[1] = g;
|
||||
//ucg->arg.pixel.rgb.color[2] = b;
|
||||
ucg->arg.rgb[idx].color[0] = r;
|
||||
ucg->arg.rgb[idx].color[1] = g;
|
||||
ucg->arg.rgb[idx].color[2] = b;
|
||||
}
|
||||
|
||||
|
||||
void ucg_DrawPixel(ucg_t *ucg, ucg_int_t x, ucg_int_t y)
|
||||
{
|
||||
ucg->arg.pixel.rgb.color[0] = ucg->arg.rgb[0].color[0];
|
||||
ucg->arg.pixel.rgb.color[1] = ucg->arg.rgb[0].color[1];
|
||||
ucg->arg.pixel.rgb.color[2] = ucg->arg.rgb[0].color[2];
|
||||
|
||||
ucg->arg.pixel.pos.x = x;
|
||||
ucg->arg.pixel.pos.y = y;
|
||||
ucg_DrawPixelWithArg(ucg);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,328 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_polygon.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
|
||||
/*===========================================*/
|
||||
/* procedures, which should not be inlined (save as much flash ROM as possible) */
|
||||
|
||||
static uint8_t pge_Next(struct pg_edge_struct *pge) PG_NOINLINE;
|
||||
static uint8_t pg_inc(pg_struct *pg, uint8_t i) PG_NOINLINE;
|
||||
static uint8_t pg_dec(pg_struct *pg, uint8_t i) PG_NOINLINE;
|
||||
static void pg_expand_min_y(pg_struct *pg, pg_word_t min_y, uint8_t pge_idx) PG_NOINLINE;
|
||||
static void pg_line_init(pg_struct * const pg, uint8_t pge_index) PG_NOINLINE;
|
||||
|
||||
/*===========================================*/
|
||||
/* line draw algorithm */
|
||||
|
||||
static uint8_t pge_Next(struct pg_edge_struct *pge)
|
||||
{
|
||||
if ( pge->current_y >= pge->max_y )
|
||||
return 0;
|
||||
|
||||
pge->current_x += pge->current_x_offset;
|
||||
pge->error += pge->error_offset;
|
||||
if ( pge->error > 0 )
|
||||
{
|
||||
pge->current_x += pge->x_direction;
|
||||
pge->error -= pge->height;
|
||||
}
|
||||
|
||||
pge->current_y++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* assumes y2 > y1 */
|
||||
static void pge_Init(struct pg_edge_struct *pge, pg_word_t x1, pg_word_t y1, pg_word_t x2, pg_word_t y2)
|
||||
{
|
||||
pg_word_t dx = x2 - x1;
|
||||
pg_word_t width;
|
||||
|
||||
pge->height = y2 - y1;
|
||||
pge->max_y = y2;
|
||||
pge->current_y = y1;
|
||||
pge->current_x = x1;
|
||||
|
||||
if ( dx >= 0 )
|
||||
{
|
||||
pge->x_direction = 1;
|
||||
width = dx;
|
||||
pge->error = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pge->x_direction = -1;
|
||||
width = -dx;
|
||||
pge->error = 1 - pge->height;
|
||||
}
|
||||
|
||||
pge->current_x_offset = dx / pge->height;
|
||||
pge->error_offset = width % pge->height;
|
||||
}
|
||||
|
||||
/*===========================================*/
|
||||
/* convex polygon algorithm */
|
||||
|
||||
static uint8_t pg_inc(pg_struct *pg, uint8_t i)
|
||||
{
|
||||
i++;
|
||||
if ( i >= pg->cnt )
|
||||
i = 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
static uint8_t pg_dec(pg_struct *pg, uint8_t i)
|
||||
{
|
||||
i--;
|
||||
if ( i >= pg->cnt )
|
||||
i = pg->cnt-1;
|
||||
return i;
|
||||
}
|
||||
|
||||
static void pg_expand_min_y(pg_struct *pg, pg_word_t min_y, uint8_t pge_idx)
|
||||
{
|
||||
uint8_t i = pg->pge[pge_idx].curr_idx;
|
||||
for(;;)
|
||||
{
|
||||
i = pg->pge[pge_idx].next_idx_fn(pg, i);
|
||||
if ( pg->list[i].y != min_y )
|
||||
break;
|
||||
pg->pge[pge_idx].curr_idx = i;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t pg_prepare(pg_struct *pg)
|
||||
{
|
||||
pg_word_t max_y;
|
||||
pg_word_t min_y;
|
||||
uint8_t i;
|
||||
|
||||
/* setup the next index procedures */
|
||||
pg->pge[PG_RIGHT].next_idx_fn = pg_inc;
|
||||
pg->pge[PG_LEFT].next_idx_fn = pg_dec;
|
||||
|
||||
/* search for highest and lowest point */
|
||||
max_y = pg->list[0].y;
|
||||
min_y = pg->list[0].y;
|
||||
pg->pge[PG_LEFT].curr_idx = 0;
|
||||
for( i = 1; i < pg->cnt; i++ )
|
||||
{
|
||||
if ( max_y < pg->list[i].y )
|
||||
{
|
||||
max_y = pg->list[i].y;
|
||||
}
|
||||
if ( min_y > pg->list[i].y )
|
||||
{
|
||||
pg->pge[PG_LEFT].curr_idx = i;
|
||||
min_y = pg->list[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
/* calculate total number of scan lines */
|
||||
pg->total_scan_line_cnt = max_y;
|
||||
pg->total_scan_line_cnt -= min_y;
|
||||
|
||||
/* exit if polygon height is zero */
|
||||
if ( pg->total_scan_line_cnt == 0 )
|
||||
return 0;
|
||||
|
||||
/* if the minimum y side is flat, try to find the lowest and highest x points */
|
||||
pg->pge[PG_RIGHT].curr_idx = pg->pge[PG_LEFT].curr_idx;
|
||||
pg_expand_min_y(pg, min_y, PG_RIGHT);
|
||||
pg_expand_min_y(pg, min_y, PG_LEFT);
|
||||
|
||||
/* check if the min side is really flat (depends on the x values) */
|
||||
pg->is_min_y_not_flat = 1;
|
||||
if ( pg->list[pg->pge[PG_LEFT].curr_idx].x != pg->list[pg->pge[PG_RIGHT].curr_idx].x )
|
||||
{
|
||||
pg->is_min_y_not_flat = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pg->total_scan_line_cnt--;
|
||||
if ( pg->total_scan_line_cnt == 0 )
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void pg_hline(pg_struct *pg, ucg_t *ucg)
|
||||
{
|
||||
pg_word_t x1, x2, y;
|
||||
x1 = pg->pge[PG_LEFT].current_x;
|
||||
x2 = pg->pge[PG_RIGHT].current_x;
|
||||
y = pg->pge[PG_RIGHT].current_y;
|
||||
|
||||
if ( y < 0 )
|
||||
return;
|
||||
if ( y >= ucg_GetHeight(ucg) )
|
||||
return;
|
||||
if ( x1 < x2 )
|
||||
{
|
||||
if ( x2 < 0 )
|
||||
return;
|
||||
if ( x1 >= ucg_GetWidth(ucg) )
|
||||
return;
|
||||
if ( x1 < 0 )
|
||||
x1 = 0;
|
||||
if ( x2 >= ucg_GetWidth(ucg) )
|
||||
x2 = ucg_GetWidth(ucg);
|
||||
ucg_DrawHLine(ucg, x1, y, x2 - x1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( x1 < 0 )
|
||||
return;
|
||||
if ( x2 >= ucg_GetWidth(ucg) )
|
||||
return;
|
||||
if ( x2 < 0 )
|
||||
x1 = 0;
|
||||
if ( x1 >= ucg_GetWidth(ucg) )
|
||||
x1 = ucg_GetWidth(ucg);
|
||||
ucg_DrawHLine(ucg, x2, y, x1 - x2);
|
||||
}
|
||||
}
|
||||
|
||||
static void pg_line_init(pg_struct * pg, uint8_t pge_index)
|
||||
{
|
||||
struct pg_edge_struct *pge = pg->pge+pge_index;
|
||||
uint8_t idx;
|
||||
pg_word_t x1;
|
||||
pg_word_t y1;
|
||||
pg_word_t x2;
|
||||
pg_word_t y2;
|
||||
|
||||
idx = pge->curr_idx;
|
||||
y1 = pg->list[idx].y;
|
||||
x1 = pg->list[idx].x;
|
||||
idx = pge->next_idx_fn(pg, idx);
|
||||
y2 = pg->list[idx].y;
|
||||
x2 = pg->list[idx].x;
|
||||
pge->curr_idx = idx;
|
||||
|
||||
pge_Init(pge, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
static void pg_exec(pg_struct *pg, ucg_t *ucg)
|
||||
{
|
||||
pg_word_t i = pg->total_scan_line_cnt;
|
||||
|
||||
/* first line is skipped if the min y line is not flat */
|
||||
pg_line_init(pg, PG_LEFT);
|
||||
pg_line_init(pg, PG_RIGHT);
|
||||
|
||||
if ( pg->is_min_y_not_flat != 0 )
|
||||
{
|
||||
pge_Next(&(pg->pge[PG_LEFT]));
|
||||
pge_Next(&(pg->pge[PG_RIGHT]));
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
pg_hline(pg, ucg);
|
||||
while ( pge_Next(&(pg->pge[PG_LEFT])) == 0 )
|
||||
{
|
||||
pg_line_init(pg, PG_LEFT);
|
||||
}
|
||||
while ( pge_Next(&(pg->pge[PG_RIGHT])) == 0 )
|
||||
{
|
||||
pg_line_init(pg, PG_RIGHT);
|
||||
}
|
||||
i--;
|
||||
} while( i > 0 );
|
||||
}
|
||||
|
||||
/*===========================================*/
|
||||
/* API procedures */
|
||||
|
||||
void ucg_pg_ClearPolygonXY(pg_struct *pg)
|
||||
{
|
||||
pg->cnt = 0;
|
||||
}
|
||||
|
||||
void ucg_pg_AddPolygonXY(pg_struct *pg, ucg_t *ucg, int16_t x, int16_t y)
|
||||
{
|
||||
if ( pg->cnt < PG_MAX_POINTS )
|
||||
{
|
||||
pg->list[pg->cnt].x = x;
|
||||
pg->list[pg->cnt].y = y;
|
||||
pg->cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
void ucg_pg_DrawPolygon(pg_struct *pg, ucg_t *ucg)
|
||||
{
|
||||
if ( pg_prepare(pg) == 0 )
|
||||
return;
|
||||
pg_exec(pg, ucg);
|
||||
}
|
||||
|
||||
pg_struct ucg_pg;
|
||||
|
||||
void ucg_ClearPolygonXY(void)
|
||||
{
|
||||
ucg_pg_ClearPolygonXY(&ucg_pg);
|
||||
}
|
||||
|
||||
void ucg_AddPolygonXY(ucg_t *ucg, int16_t x, int16_t y)
|
||||
{
|
||||
ucg_pg_AddPolygonXY(&ucg_pg, ucg, x, y);
|
||||
}
|
||||
|
||||
void ucg_DrawPolygon(ucg_t *ucg)
|
||||
{
|
||||
ucg_pg_DrawPolygon(&ucg_pg, ucg);
|
||||
}
|
||||
|
||||
void ucg_DrawTriangle(ucg_t *ucg, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2)
|
||||
{
|
||||
ucg_ClearPolygonXY();
|
||||
ucg_AddPolygonXY(ucg, x0, y0);
|
||||
ucg_AddPolygonXY(ucg, x1, y1);
|
||||
ucg_AddPolygonXY(ucg, x2, y2);
|
||||
ucg_DrawPolygon(ucg);
|
||||
}
|
||||
|
||||
void ucg_DrawTetragon(ucg_t *ucg, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3)
|
||||
{
|
||||
ucg_ClearPolygonXY();
|
||||
ucg_AddPolygonXY(ucg, x0, y0);
|
||||
ucg_AddPolygonXY(ucg, x1, y1);
|
||||
ucg_AddPolygonXY(ucg, x2, y2);
|
||||
ucg_AddPolygonXY(ucg, x3, y3);
|
||||
ucg_DrawPolygon(ucg);
|
||||
}
|
@ -1,256 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_rotate.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "ucg.h"
|
||||
#include <assert.h>
|
||||
|
||||
/* Side-Effects: Update dimension and reset clip range to max */
|
||||
void ucg_UndoRotate(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg->rotate_chain_device_cb != NULL )
|
||||
{
|
||||
ucg->device_cb = ucg->rotate_chain_device_cb;
|
||||
ucg->rotate_chain_device_cb = NULL;
|
||||
}
|
||||
ucg_GetDimension(ucg);
|
||||
ucg_SetMaxClipRange(ucg);
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* 90 degree */
|
||||
|
||||
static void ucg_rotate_90_xy(ucg_xy_t *xy, ucg_int_t display_width)
|
||||
{
|
||||
ucg_int_t x, y;
|
||||
y = xy->x;
|
||||
x = display_width;
|
||||
x -= xy->y;
|
||||
x--;
|
||||
xy->x = x;
|
||||
xy->y = y;
|
||||
|
||||
}
|
||||
|
||||
ucg_int_t ucg_dev_rotate90(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
ucg->rotate_chain_device_cb(ucg, msg, &(ucg->rotate_dimension));
|
||||
((ucg_wh_t *)data)->h = ucg->rotate_dimension.w;
|
||||
((ucg_wh_t *)data)->w = ucg->rotate_dimension.h;
|
||||
|
||||
//printf("rw=%d rh=%d\n", ucg->rotate_dimension.w, ucg->rotate_dimension.h);
|
||||
//printf("aw=%d ah=%d\n", ((ucg_wh_t volatile * volatile )data)->w, ((ucg_wh_t volatile * volatile )data)->h);
|
||||
//printf("dw=%d dh=%d\n", ucg->dimension.w, ucg->dimension.h);
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_SET_CLIP_BOX:
|
||||
/* to rotate the box, the lower left corner will become the new xy value pair */
|
||||
/* so the unrotated lower left is put into "ul" */
|
||||
//printf("pre clipbox x=%d y=%d\n", ((ucg_box_t * )data)->ul.x, ((ucg_box_t * )data)->ul.y);
|
||||
((ucg_box_t * )data)->ul.y += ((ucg_box_t * )data)->size.h-1;
|
||||
//printf("pre clipbox lower left x=%d y=%d\n", ((ucg_box_t * )data)->ul.x, ((ucg_box_t * )data)->ul.y);
|
||||
/* then apply rotation */
|
||||
ucg_rotate_90_xy(&(((ucg_box_t * )data)->ul), ucg->rotate_dimension.w);
|
||||
/* finally, swap dimensions */
|
||||
{
|
||||
ucg_int_t tmp;
|
||||
tmp = ((ucg_box_t *)data)->size.w;
|
||||
((ucg_box_t * )data)->size.w = ((ucg_box_t *)data)->size.h;
|
||||
((ucg_box_t * )data)->size.h = tmp;
|
||||
}
|
||||
//printf("post clipbox x=%d y=%d\n", ((ucg_box_t * )data)->ul.x, ((ucg_box_t * )data)->ul.y);
|
||||
break;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//case UCG_MSG_DRAW_L90RL:
|
||||
ucg->arg.dir+=1;
|
||||
ucg->arg.dir&=3;
|
||||
//ucg_rotate_90_xy(&(ucg->arg.pixel.pos), ucg->rotate_dimension.w);
|
||||
//printf("dw=%d dh=%d\n", ucg->dimension.w, ucg->dimension.h);
|
||||
//printf("pre x=%d y=%d\n", ucg->arg.pixel.pos.x, ucg->arg.pixel.pos.y);
|
||||
ucg_rotate_90_xy(&(ucg->arg.pixel.pos), ucg->rotate_dimension.w);
|
||||
//printf("post x=%d y=%d\n", ucg->arg.pixel.pos.x, ucg->arg.pixel.pos.y);
|
||||
break;
|
||||
}
|
||||
return ucg->rotate_chain_device_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
/* Side-Effects: Update dimension and reset clip range to max */
|
||||
void ucg_SetRotate90(ucg_t *ucg)
|
||||
{
|
||||
ucg_UndoRotate(ucg);
|
||||
ucg->rotate_chain_device_cb = ucg->device_cb;
|
||||
ucg->device_cb = ucg_dev_rotate90;
|
||||
ucg_GetDimension(ucg);
|
||||
ucg_SetMaxClipRange(ucg);
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* 180 degree */
|
||||
|
||||
static void ucg_rotate_180_xy(ucg_t *ucg, ucg_xy_t *xy)
|
||||
{
|
||||
ucg_int_t x, y;
|
||||
y = ucg->rotate_dimension.h;
|
||||
y -= xy->y;
|
||||
y--;
|
||||
xy->y = y;
|
||||
|
||||
x = ucg->rotate_dimension.w;
|
||||
x -= xy->x;
|
||||
x--;
|
||||
xy->x = x;
|
||||
|
||||
}
|
||||
|
||||
ucg_int_t ucg_dev_rotate180(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
ucg->rotate_chain_device_cb(ucg, msg, &(ucg->rotate_dimension));
|
||||
*((ucg_wh_t *)data) = (ucg->rotate_dimension);
|
||||
return 1;
|
||||
case UCG_MSG_SET_CLIP_BOX:
|
||||
/* calculate and rotate lower right point of the clip box */
|
||||
((ucg_box_t * )data)->ul.y += ((ucg_box_t * )data)->size.h-1;
|
||||
((ucg_box_t * )data)->ul.x += ((ucg_box_t * )data)->size.w-1;
|
||||
ucg_rotate_180_xy(ucg, &(((ucg_box_t * )data)->ul));
|
||||
/* box dimensions are the same */
|
||||
break;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
//case UCG_MSG_DRAW_L90RL:
|
||||
ucg->arg.dir+=2;
|
||||
ucg->arg.dir&=3;
|
||||
ucg_rotate_180_xy(ucg, &(ucg->arg.pixel.pos));
|
||||
break;
|
||||
}
|
||||
return ucg->rotate_chain_device_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
/* Side-Effects: Update dimension and reset clip range to max */
|
||||
void ucg_SetRotate180(ucg_t *ucg)
|
||||
{
|
||||
ucg_UndoRotate(ucg);
|
||||
ucg->rotate_chain_device_cb = ucg->device_cb;
|
||||
ucg->device_cb = ucg_dev_rotate180;
|
||||
ucg_GetDimension(ucg);
|
||||
ucg_SetMaxClipRange(ucg);
|
||||
}
|
||||
|
||||
/*================================================*/
|
||||
/* 270 degree */
|
||||
|
||||
static void ucg_rotate_270_xy(ucg_t *ucg, ucg_xy_t *xy)
|
||||
{
|
||||
ucg_int_t x, y;
|
||||
x = xy->y;
|
||||
|
||||
y = ucg->rotate_dimension.h;
|
||||
y -= xy->x;
|
||||
y--;
|
||||
|
||||
xy->y = y;
|
||||
xy->x = x;
|
||||
}
|
||||
|
||||
ucg_int_t ucg_dev_rotate270(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
ucg->rotate_chain_device_cb(ucg, msg, &(ucg->rotate_dimension));
|
||||
((ucg_wh_t *)data)->h = ucg->rotate_dimension.w;
|
||||
((ucg_wh_t *)data)->w = ucg->rotate_dimension.h;
|
||||
return 1;
|
||||
case UCG_MSG_SET_CLIP_BOX:
|
||||
/* calculate and rotate upper right point of the clip box */
|
||||
((ucg_box_t * )data)->ul.x += ((ucg_box_t * )data)->size.w-1;
|
||||
ucg_rotate_270_xy(ucg, &(((ucg_box_t * )data)->ul));
|
||||
/* finally, swap dimensions */
|
||||
{
|
||||
ucg_int_t tmp;
|
||||
tmp = ((ucg_box_t *)data)->size.w;
|
||||
((ucg_box_t * )data)->size.w = ((ucg_box_t *)data)->size.h;
|
||||
((ucg_box_t * )data)->size.h = tmp;
|
||||
}
|
||||
break;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
// case UCG_MSG_DRAW_L90RL:
|
||||
ucg->arg.dir+=3;
|
||||
ucg->arg.dir&=3;
|
||||
ucg_rotate_270_xy(ucg, &(ucg->arg.pixel.pos));
|
||||
break;
|
||||
}
|
||||
return ucg->rotate_chain_device_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
/* Side-Effects: Update dimension and reset clip range to max */
|
||||
void ucg_SetRotate270(ucg_t *ucg)
|
||||
{
|
||||
ucg_UndoRotate(ucg);
|
||||
ucg->rotate_chain_device_cb = ucg->device_cb;
|
||||
ucg->device_cb = ucg_dev_rotate270;
|
||||
ucg_GetDimension(ucg);
|
||||
ucg_SetMaxClipRange(ucg);
|
||||
}
|
||||
|
@ -1,226 +0,0 @@
|
||||
/*
|
||||
|
||||
ucg_scale.c
|
||||
|
||||
Universal uC Color Graphics Library
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "ucg.h"
|
||||
|
||||
void ucg_UndoScale(ucg_t *ucg)
|
||||
{
|
||||
if ( ucg->scale_chain_device_cb != NULL )
|
||||
{
|
||||
ucg->device_cb = ucg->scale_chain_device_cb;
|
||||
ucg->scale_chain_device_cb = NULL;
|
||||
}
|
||||
ucg_GetDimension(ucg);
|
||||
ucg_SetMaxClipRange(ucg);
|
||||
}
|
||||
|
||||
const ucg_fntpgm_uint8_t ucg_scale_2x2[16] UCG_FONT_SECTION("ucg_scale_2x2") =
|
||||
{ 0x00, 0x03, 0x0c, 0x0f, 0x30, 0x33, 0x3c, 0x3f, 0xc0, 0xc3, 0xcc, 0xcf, 0xf0, 0xf3, 0xfc, 0xff };
|
||||
|
||||
static void ucg_scale_2x2_send_next_half_byte(ucg_t *ucg, ucg_xy_t *xy, ucg_int_t msg, ucg_int_t len, ucg_int_t dir, uint8_t b)
|
||||
{
|
||||
b &= 15;
|
||||
len *=2;
|
||||
|
||||
|
||||
|
||||
ucg->arg.pixel.pos = *xy;
|
||||
switch(dir)
|
||||
{
|
||||
case 0: break;
|
||||
case 1: break;
|
||||
case 2: ucg->arg.pixel.pos.x++; break;
|
||||
default: case 3: ucg->arg.pixel.pos.y++; break;
|
||||
}
|
||||
|
||||
ucg->arg.bitmap = ucg_scale_2x2+b;
|
||||
ucg->arg.len = len;
|
||||
ucg->arg.dir = dir;
|
||||
ucg->scale_chain_device_cb(ucg, msg, &(ucg->arg));
|
||||
|
||||
ucg->arg.pixel.pos = *xy;
|
||||
switch(dir)
|
||||
{
|
||||
case 0: ucg->arg.pixel.pos.y++; break;
|
||||
case 1: ucg->arg.pixel.pos.x++; break;
|
||||
case 2: ucg->arg.pixel.pos.y++; ucg->arg.pixel.pos.x++; break;
|
||||
default: case 3: ucg->arg.pixel.pos.x++; ucg->arg.pixel.pos.y++; break;
|
||||
}
|
||||
ucg->arg.bitmap = ucg_scale_2x2+b;
|
||||
ucg->arg.len = len;
|
||||
ucg->arg.dir = dir;
|
||||
ucg->scale_chain_device_cb(ucg, msg, &(ucg->arg));
|
||||
|
||||
switch(dir)
|
||||
{
|
||||
case 0: xy->x+=len; break;
|
||||
case 1: xy->y+=len; break;
|
||||
case 2: xy->x-=len; break;
|
||||
default: case 3: xy->y-=len; break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ucg_int_t ucg_dev_scale2x2(ucg_t *ucg, ucg_int_t msg, void *data)
|
||||
{
|
||||
ucg_xy_t xy;
|
||||
ucg_int_t len;
|
||||
ucg_int_t dir;
|
||||
switch(msg)
|
||||
{
|
||||
case UCG_MSG_GET_DIMENSION:
|
||||
ucg->scale_chain_device_cb(ucg, msg, data);
|
||||
((ucg_wh_t *)data)->h /= 2;
|
||||
((ucg_wh_t *)data)->w /= 2;
|
||||
|
||||
//printf("rw=%d rh=%d\n", ucg->rotate_dimension.w, ucg->rotate_dimension.h);
|
||||
//printf("aw=%d ah=%d\n", ((ucg_wh_t volatile * volatile )data)->w, ((ucg_wh_t volatile * volatile )data)->h);
|
||||
//printf("dw=%d dh=%d\n", ucg->dimension.w, ucg->dimension.h);
|
||||
return 1;
|
||||
|
||||
case UCG_MSG_SET_CLIP_BOX:
|
||||
((ucg_box_t * )data)->ul.y *= 2;
|
||||
((ucg_box_t * )data)->ul.x *= 2;
|
||||
((ucg_box_t * )data)->size.h *= 2;
|
||||
((ucg_box_t * )data)->size.w *= 2;
|
||||
|
||||
//printf("post clipbox x=%d y=%d\n", ((ucg_box_t * )data)->ul.x, ((ucg_box_t * )data)->ul.y);
|
||||
break;
|
||||
case UCG_MSG_DRAW_PIXEL:
|
||||
xy = ucg->arg.pixel.pos;
|
||||
ucg->arg.pixel.pos.x *= 2;
|
||||
ucg->arg.pixel.pos.y *= 2;
|
||||
ucg->scale_chain_device_cb(ucg, msg, data);
|
||||
ucg->arg.pixel.pos.x++;
|
||||
ucg->scale_chain_device_cb(ucg, msg, data);
|
||||
ucg->arg.pixel.pos.y++;
|
||||
ucg->scale_chain_device_cb(ucg, msg, data);
|
||||
ucg->arg.pixel.pos.x--;
|
||||
ucg->scale_chain_device_cb(ucg, msg, data);
|
||||
ucg->arg.pixel.pos = xy;
|
||||
return 1;
|
||||
case UCG_MSG_DRAW_L90SE:
|
||||
case UCG_MSG_DRAW_L90FX:
|
||||
xy = ucg->arg.pixel.pos;
|
||||
len = ucg->arg.len;
|
||||
dir = ucg->arg.dir;
|
||||
|
||||
|
||||
ucg->arg.pixel.pos.x *= 2;
|
||||
ucg->arg.pixel.pos.y *= 2;
|
||||
|
||||
switch(dir)
|
||||
{
|
||||
case 0: break;
|
||||
case 1: break;
|
||||
case 2: ucg->arg.pixel.pos.x++; break;
|
||||
default: case 3: ucg->arg.pixel.pos.y++; break;
|
||||
}
|
||||
|
||||
ucg->arg.len *= 2;
|
||||
ucg->scale_chain_device_cb(ucg, msg, data);
|
||||
|
||||
ucg->arg.pixel.pos = xy;
|
||||
ucg->arg.pixel.pos.x *= 2;
|
||||
ucg->arg.pixel.pos.y *= 2;
|
||||
ucg->arg.len = len*2;
|
||||
ucg->arg.dir = dir;
|
||||
switch(dir)
|
||||
{
|
||||
case 0: ucg->arg.pixel.pos.y++; break;
|
||||
case 1: ucg->arg.pixel.pos.x++; break;
|
||||
case 2: ucg->arg.pixel.pos.y++; ucg->arg.pixel.pos.x++; break;
|
||||
default: case 3: ucg->arg.pixel.pos.x++; ucg->arg.pixel.pos.y++; break;
|
||||
}
|
||||
ucg->scale_chain_device_cb(ucg, msg, data);
|
||||
|
||||
ucg->arg.pixel.pos = xy;
|
||||
ucg->arg.len = len;
|
||||
ucg->arg.dir = dir;
|
||||
return 1;
|
||||
#ifdef UCG_MSG_DRAW_L90TC
|
||||
case UCG_MSG_DRAW_L90TC:
|
||||
#endif /* UCG_MSG_DRAW_L90TC */
|
||||
#ifdef UCG_MSG_DRAW_L90BF
|
||||
case UCG_MSG_DRAW_L90BF:
|
||||
#endif /* UCG_MSG_DRAW_L90BF */
|
||||
|
||||
#if defined(UCG_MSG_DRAW_L90TC) || defined(UCG_MSG_DRAW_L90BF)
|
||||
xy = ucg->arg.pixel.pos;
|
||||
len = ucg->arg.len;
|
||||
dir = ucg->arg.dir;
|
||||
|
||||
ucg->arg.pixel.pos.x *= 2;
|
||||
ucg->arg.pixel.pos.y *= 2;
|
||||
|
||||
{
|
||||
const unsigned char *b = ucg->arg.bitmap;
|
||||
ucg_xy_t my_xy = ucg->arg.pixel.pos;
|
||||
ucg_int_t i;
|
||||
for( i = 8; i < len; i+=8 )
|
||||
{
|
||||
ucg_scale_2x2_send_next_half_byte(ucg, &my_xy, msg, 4, dir, ucg_pgm_read(b)>>4);
|
||||
ucg_scale_2x2_send_next_half_byte(ucg, &my_xy, msg, 4, dir, ucg_pgm_read(b));
|
||||
b+=1;
|
||||
}
|
||||
i = len+8-i;
|
||||
if ( i > 4 )
|
||||
{
|
||||
ucg_scale_2x2_send_next_half_byte(ucg, &my_xy, msg, 4, dir, ucg_pgm_read(b)>>4);
|
||||
ucg_scale_2x2_send_next_half_byte(ucg, &my_xy, msg, i-4, dir, ucg_pgm_read(b));
|
||||
}
|
||||
else
|
||||
{
|
||||
ucg_scale_2x2_send_next_half_byte(ucg, &my_xy, msg, i, dir, ucg_pgm_read(b)>>4);
|
||||
}
|
||||
}
|
||||
ucg->arg.pixel.pos = xy;
|
||||
ucg->arg.len = len;
|
||||
ucg->arg.dir = dir;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
return ucg->scale_chain_device_cb(ucg, msg, data);
|
||||
}
|
||||
|
||||
/* Side-Effects: Update dimension and reset clip range to max */
|
||||
void ucg_SetScale2x2(ucg_t *ucg)
|
||||
{
|
||||
ucg_UndoScale(ucg);
|
||||
ucg->scale_chain_device_cb = ucg->device_cb;
|
||||
ucg->device_cb = ucg_dev_scale2x2;
|
||||
ucg_GetDimension(ucg);
|
||||
ucg_SetMaxClipRange(ucg);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -3,17 +3,52 @@
|
||||
| :----- | :-------------------- | :---------- | :------ |
|
||||
| 2015-08-05 | [Oli Kraus](https://github.com/olikraus/ucglib), [Arnim Läuger](https://github.com/devsaurus) | [Arnim Läuger](https://github.com/devsaurus) | [ucglib](../../../app/ucglib/)|
|
||||
|
||||
Ucglib is a graphics library developed at [olikraus/ucglib](https://github.com/olikraus/ucglib) with support for color TFT displays. The NodeMCU firmware supports a subset of these:
|
||||
Ucglib is a graphics library developed at [olikraus/ucglib](https://github.com/olikraus/ucglib) with support for color TFT displays.
|
||||
|
||||
!!! note "BSD License for Ucglib Code"
|
||||
Universal 8bit Graphics Library (http://code.google.com/p/u8glib/)
|
||||
|
||||
Copyright (c) 2014, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The NodeMCU firmware supports a subset of these:
|
||||
|
||||
- HX8352C
|
||||
- ILI9163
|
||||
- ILI9341
|
||||
- ILI9486
|
||||
- PCF8833
|
||||
- SEPS225
|
||||
- SSD1331
|
||||
- SSD1351
|
||||
- ST7735
|
||||
|
||||
This integration is based on [v1.3.3](https://github.com/olikraus/Ucglib_Arduino/releases/tag/v1.3.3).
|
||||
This integration is based on [v1.5.2](https://github.com/olikraus/Ucglib_Arduino/releases/tag/v1.5.2).
|
||||
|
||||
## Overview
|
||||
|
||||
@ -50,16 +85,31 @@ disp = ucg.ili9341_18x240x320_hw_spi(cs, dc, res)
|
||||
This object provides all of ucglib's methods to control the display.
|
||||
Again, refer to [GraphicsTest.lua](https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/ucglib/GraphicsTest.lua) to get an impression how this is achieved with Lua code. Visit the [ucglib homepage](https://github.com/olikraus/ucglib) for technical details.
|
||||
|
||||
### Displays
|
||||
To get access to the display constructors, add the desired entries to the display table in [app/include/ucg_config.h](https://github.com/nodemcu/nodemcu-firmware/blob/master/app/include/ucg_config.h):
|
||||
### Display selection
|
||||
HW SPI based displays with support in u8g2 can be enabled.
|
||||
|
||||
The procedure is different for ESP8266 and ESP32 platforms.
|
||||
|
||||
#### ESP8266
|
||||
|
||||
Add the desired entries to the display table in [app/include/ucg_config.h](../../../app/include/ucg_config.h):
|
||||
```c
|
||||
#define UCG_DISPLAY_TABLE \
|
||||
UCG_DISPLAY_TABLE_ENTRY(ili9341_18x240x320_hw_spi, ucg_dev_ili9341_18x240x320, ucg_ext_ili9341_18) \
|
||||
UCG_DISPLAY_TABLE_ENTRY(st7735_18x128x160_hw_spi, ucg_dev_st7735_18x128x160, ucg_ext_st7735_18) \
|
||||
```
|
||||
|
||||
#### ESP32
|
||||
Enable the desired entries for SPI displays in ucg's sub-menu (run `make menuconfig`).
|
||||
|
||||
### Fonts
|
||||
ucglib comes with a wide range of fonts for small displays. Since they need to be compiled into the firmware image, you'd need to include them in [app/include/ucg_config.h](https://github.com/nodemcu/nodemcu-firmware/blob/master/app/include/ucg_config.h) and recompile. Simply add the desired fonts to the font table:
|
||||
ucglib comes with a wide range of fonts for small displays. Since they need to be compiled into the firmware image.
|
||||
|
||||
The procedure is different for ESP8266 and ESP32 platforms.
|
||||
|
||||
#### ESP8266
|
||||
|
||||
Add the desired fonts to the font table in [app/include/ucg_config.h](../../../app/include/ucg_config.h):
|
||||
```c
|
||||
#define UCG_FONT_TABLE \
|
||||
UCG_FONT_TABLE_ENTRY(font_7x13B_tr) \
|
||||
@ -68,14 +118,19 @@ ucglib comes with a wide range of fonts for small displays. Since they need to b
|
||||
UCG_FONT_TABLE_ENTRY(font_ncenR12_tr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_ncenR14_hr)
|
||||
```
|
||||
They'll be available as `ucg.<font_name>` in Lua.
|
||||
They will be available as `ucg.<font_name>` in Lua.
|
||||
|
||||
#### ESP32
|
||||
Add the desired fonts to the font selection sub-entry via `make menuconfig`.
|
||||
|
||||
## Display Drivers
|
||||
|
||||
Initialize a display via Hardware SPI.
|
||||
|
||||
- `hx8352c_18x240x400_hw_spi()`
|
||||
- `ili9163_18x128x128_hw_spi()`
|
||||
- `ili9341_18x240x320_hw_spi()`
|
||||
- `ili9486_18x320x480_hw_spi()`
|
||||
- `pcf8833_16x132x132_hw_spi()`
|
||||
- `seps225_16x128x128_uvis_hw_spi()`
|
||||
- `ssd1351_18x128x128_hw_spi()`
|
||||
@ -84,24 +139,43 @@ Initialize a display via Hardware SPI.
|
||||
- `st7735_18x128x160_hw_spi()`
|
||||
|
||||
#### Syntax
|
||||
`ucg.st7735_18x128x160_hw_spi(cs, dc[, res])`
|
||||
`ucg.st7735_18x128x160_hw_spi(bus, cs, dc[, res])`
|
||||
|
||||
#### Parameters
|
||||
- `bus` SPI master bus
|
||||
- `cs` GPIO pin for /CS
|
||||
- `dc` GPIO pin for DC
|
||||
- `res` GPIO pin for /RES (optional)
|
||||
- `res` GPIO pin for /RES, none if omitted
|
||||
|
||||
#### Returns
|
||||
ucg display object
|
||||
|
||||
#### Example
|
||||
#### Example for ESP8266
|
||||
```lua
|
||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||
|
||||
-- Hardware SPI CLK = GPIO14
|
||||
-- Hardware SPI MOSI = GPIO13
|
||||
-- Hardware SPI MISO = GPIO12 (not used)
|
||||
-- Hardware SPI /CS = GPIO15 (not used)
|
||||
cs = 8 -- GPIO15, pull-down 10k to GND
|
||||
dc = 4 -- GPIO2
|
||||
res = 0 -- GPIO16, RES is optional YMMV
|
||||
disp = ucg.st7735_18x128x160_hw_spi(cs, dc, res)
|
||||
bus = 1
|
||||
spi.setup(bus, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||
-- we won't be using the HSPI /CS line, so disable it again
|
||||
gpio.mode(8, gpio.INPUT, gpio.PULLUP)
|
||||
|
||||
disp = ucg.st7735_18x128x160_hw_spi(bus, cs, dc, res)
|
||||
```
|
||||
|
||||
#### Example for ESP32
|
||||
```lua
|
||||
sclk = 19
|
||||
mosi = 23
|
||||
cs = 22
|
||||
dc = 16
|
||||
res = 17
|
||||
bus = spi.master(spi.HSPI, {sclk=sclk, mosi=mosi})
|
||||
disp = ucg.st7735_18x128x160_hw_spi(bus, cs, dc, res)
|
||||
```
|
||||
|
||||
## Constants
|
||||
@ -196,16 +270,7 @@ See [ucglib setClipRange()](https://github.com/olikraus/ucglib/wiki/reference#se
|
||||
See [ucglib setColor()](https://github.com/olikraus/ucglib/wiki/reference#setcolor).
|
||||
|
||||
## ucg.disp:setFont()
|
||||
ucglib comes with a wide range of fonts for small displays. Since they need to be compiled into the firmware image, you'd need to include them in [app/include/ucg_config.h](https://github.com/nodemcu/nodemcu-firmware/blob/master/app/include/ucg_config.h) and recompile. Simply add the desired fonts to the font table:
|
||||
```c
|
||||
#define UCG_FONT_TABLE \
|
||||
UCG_FONT_TABLE_ENTRY(font_7x13B_tr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_helvB12_hr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_helvB18_hr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_ncenR12_tr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_ncenR14_hr)
|
||||
```
|
||||
They'll be available as `ucg.<font_name>` in Lua.
|
||||
Define a ucg font for the glyph and string drawing functions. They are available as `ucg.<font_name>` in Lua.
|
||||
|
||||
#### Syntax
|
||||
`disp:setFont(font)`
|
||||
|
@ -8,15 +8,16 @@ function init_spi_display()
|
||||
local cs = 8 -- GPIO15, pull-down 10k to GND
|
||||
local dc = 4 -- GPIO2
|
||||
local res = 0 -- GPIO16
|
||||
local bus = 1
|
||||
|
||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8)
|
||||
spi.setup(bus, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8)
|
||||
-- we won't be using the HSPI /CS line, so disable it again
|
||||
gpio.mode(8, gpio.INPUT, gpio.PULLUP)
|
||||
|
||||
-- initialize the matching driver for your display
|
||||
-- see app/include/ucg_config.h
|
||||
--disp = ucg.ili9341_18x240x320_hw_spi(cs, dc, res)
|
||||
disp = ucg.st7735_18x128x160_hw_spi(cs, dc, res)
|
||||
--disp = ucg.ili9341_18x240x320_hw_spi(bus, cs, dc, res)
|
||||
disp = ucg.st7735_18x128x160_hw_spi(bus, cs, dc, res)
|
||||
end
|
||||
|
||||
|
||||
|
@ -8,15 +8,16 @@ function init_spi_display()
|
||||
local cs = 8 -- GPIO15, pull-down 10k to GND
|
||||
local dc = 4 -- GPIO2
|
||||
local res = 0 -- GPIO16
|
||||
local bus = 1
|
||||
|
||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8)
|
||||
spi.setup(bus, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8)
|
||||
-- we won't be using the HSPI /CS line, so disable it again
|
||||
gpio.mode(8, gpio.INPUT, gpio.PULLUP)
|
||||
|
||||
-- initialize the matching driver for your display
|
||||
-- see app/include/ucg_config.h
|
||||
--disp = ucg.ili9341_18x240x320_hw_spi(cs, dc, res)
|
||||
disp = ucg.st7735_18x128x160_hw_spi(cs, dc, res)
|
||||
--disp = ucg.ili9341_18x240x320_hw_spi(bus, cs, dc, res)
|
||||
disp = ucg.st7735_18x128x160_hw_spi(bus, cs, dc, res)
|
||||
end
|
||||
|
||||
|
||||
|
@ -8,15 +8,16 @@ function init_spi_display()
|
||||
local cs = 8 -- GPIO15, pull-down 10k to GND
|
||||
local dc = 4 -- GPIO2
|
||||
local res = 0 -- GPIO16
|
||||
local bus = 1
|
||||
|
||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8)
|
||||
spi.setup(bus, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8)
|
||||
-- we won't be using the HSPI /CS line, so disable it again
|
||||
gpio.mode(8, gpio.INPUT, gpio.PULLUP)
|
||||
|
||||
-- initialize the matching driver for your display
|
||||
-- see app/include/ucg_config.h
|
||||
--disp = ucg.ili9341_18x240x320_hw_spi(cs, dc, res)
|
||||
disp = ucg.st7735_18x128x160_hw_spi(cs, dc, res)
|
||||
--disp = ucg.ili9341_18x240x320_hw_spi(bus, cs, dc, res)
|
||||
disp = ucg.st7735_18x128x160_hw_spi(bus, cs, dc, res)
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user