Merge pull request #572 from devsaurus/dev
Upgrade u8g module and add display bindings
This commit is contained in:
commit
00e1e6bcbe
30
README.md
30
README.md
|
@ -359,14 +359,14 @@ cu:send("hello")
|
|||
package.loaded["ds18b20"]=nil
|
||||
```
|
||||
|
||||
####Operate a display via I2c with u8glib
|
||||
####Operate a display with u8glib
|
||||
u8glib is a graphics library with support for many different displays.
|
||||
The integration in nodemcu is developed for SSD1306 based display attached via the I2C port. Further display types and SPI connectivity will be added in the future.
|
||||
|
||||
U8glib v1.17
|
||||
U8glib v1.18.1
|
||||
|
||||
#####I2C connection
|
||||
Hook up SDA and SCL to any free GPIOs. Eg. `lua_examples/u8glib/graphics_test.lua` expects SDA=5 (GPIO14) and SCL=6 (GPIO12). They are used to set up nodemcu's I2C driver before accessing the display:
|
||||
Hook up SDA and SCL to any free GPIOs. Eg. [u8g_graphics_test.lua](lua_examples/u8glib/u8g_graphics_test.lua) expects SDA=5 (GPIO14) and SCL=6 (GPIO12). They are used to set up nodemcu's I2C driver before accessing the display:
|
||||
```lua
|
||||
sda = 5
|
||||
scl = 6
|
||||
|
@ -384,7 +384,7 @@ All other pins can be assigned to any available GPIO:
|
|||
* D/C
|
||||
* RES (optional for some displays)
|
||||
|
||||
Also refer to the initialization sequence eg in `lua_examples/u8glib/graphics_test.lua`:
|
||||
Also refer to the initialization sequence eg in [u8g_graphics_test.lua](lua_examples/u8glib/u8g_graphics_test.lua):
|
||||
```lua
|
||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||
```
|
||||
|
@ -403,14 +403,28 @@ SSD1306 via SPI:
|
|||
cs = 8 -- GPIO15, pull-down 10k to GND
|
||||
dc = 4 -- GPIO2
|
||||
res = 0 -- GPIO16, RES is optional YMMV
|
||||
disp = u8g.ssd1306_128x64_spi(cs, dc, res)
|
||||
disp = u8g.ssd1306_128x64_hw_spi(cs, dc, res)
|
||||
```
|
||||
|
||||
This object provides all of u8glib's methods to control the display.
|
||||
Again, refer to `lua_examples/u8glib/graphics_test.lua` to get an impression how this is achieved with Lua code. Visit the [u8glib homepage](https://code.google.com/p/u8glib/) for technical details.
|
||||
Again, refer to [u8g_graphics_test.lua](lua_examples/u8glib/u8g_graphics_test.lua) to get an impression how this is achieved with Lua code. Visit the [u8glib homepage](https://github.com/olikraus/u8glib) for technical details.
|
||||
|
||||
#####Displays
|
||||
I2C and HW SPI based displays with support in u8glib can be enabled. To get access to the respective constructors, add the desired entries to the I2C or SPI display tables in [app/include/u8g_config.h](app/include/u8g_config.h):
|
||||
```c
|
||||
#define U8G_DISPLAY_TABLE_I2C \
|
||||
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c) \
|
||||
|
||||
#define U8G_DISPLAY_TABLE_SPI \
|
||||
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi) \
|
||||
U8G_DISPLAY_TABLE_ENTRY(pcd8544_84x48_hw_spi) \
|
||||
U8G_DISPLAY_TABLE_ENTRY(pcf8812_96x65_hw_spi) \
|
||||
```
|
||||
An exhaustive list of available displays can be found in the [u8g module wiki entry](https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#u8g-module).
|
||||
|
||||
|
||||
#####Fonts
|
||||
u8glib 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/u8g_config.h` and recompile. Simply add the desired fonts to the font table:
|
||||
u8glib 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/u8g_config.h](app/include/u8g_config.h) and recompile. Simply add the desired fonts to the font table:
|
||||
```c
|
||||
#define U8G_FONT_TABLE \
|
||||
U8G_FONT_TABLE_ENTRY(font_6x10) \
|
||||
|
@ -419,7 +433,7 @@ u8glib comes with a wide range of fonts for small displays. Since they need to b
|
|||
They'll be available as `u8g.<font_name>` in Lua.
|
||||
|
||||
#####Bitmaps
|
||||
Bitmaps and XBMs are supplied as strings to `drawBitmap()` and `drawXBM()`. This off-loads all data handling from the u8g module to generic methods for binary files. See `lua_examples/u8glib/u8g_bitmaps.lua`.
|
||||
Bitmaps and XBMs are supplied as strings to `drawBitmap()` and `drawXBM()`. This off-loads all data handling from the u8g module to generic methods for binary files. See [u8g_bitmaps.lua](lua_examples/u8glib/u8g_bitmaps.lua).
|
||||
In contrast to the source code based inclusion of XBMs into u8glib, it's required to provide precompiled binary files. This can be performed online with [Online-Utility's Image Converter](http://www.online-utility.org/image_converter.jsp): Convert from XBM to MONO format and upload the binary result with [nodemcu-uploader.py](https://github.com/kmpm/nodemcu-uploader).
|
||||
|
||||
#####Unimplemented functions
|
||||
|
|
|
@ -2,20 +2,81 @@
|
|||
#define __U8G_CONFIG_H__
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// Configure U8glib fonts
|
||||
// add a U8G_FONT_TABLE_ENTRY for each font you want to compile into the image
|
||||
//
|
||||
// Add a U8G_FONT_TABLE_ENTRY for each font you want to compile into the image
|
||||
#define U8G_FONT_TABLE_ENTRY(font)
|
||||
#define U8G_FONT_TABLE \
|
||||
U8G_FONT_TABLE_ENTRY(font_6x10) \
|
||||
#define U8G_FONT_TABLE \
|
||||
U8G_FONT_TABLE_ENTRY(font_6x10) \
|
||||
U8G_FONT_TABLE_ENTRY(font_chikita)
|
||||
#undef U8G_FONT_TABLE_ENTRY
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// Enable display drivers
|
||||
#define U8G_SSD1306_128x64_I2C
|
||||
#define U8G_SSD1306_128x64_SPI
|
||||
// untested
|
||||
#undef U8G_PCD8544_84x48
|
||||
//
|
||||
// Uncomment the U8G_DISPLAY_TABLE_ENTRY for the device(s) you want to
|
||||
// compile into the firmware.
|
||||
// Stick to the assignments to *_I2C and *_SPI tables.
|
||||
//
|
||||
// I2C based displays go into here:
|
||||
// U8G_DISPLAY_TABLE_ENTRY(sh1106_128x64_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_64x48_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1309_128x64_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1327_96x96_gr_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1611_dogm240_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1611_dogxl240_i2c) \
|
||||
|
||||
#define U8G_DISPLAY_TABLE_ENTRY(device)
|
||||
#define U8G_DISPLAY_TABLE_I2C \
|
||||
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c) \
|
||||
|
||||
// SPI based displays go into here:
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ld7032_60x32_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(pcd8544_84x48_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(pcf8812_96x65_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(sh1106_128x64_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_64x48_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1309_128x64_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1322_nhd31oled_bw_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1322_nhd31oled_gr_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1325_nhd27oled_bw_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1325_nhd27oled_gr_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1327_96x96_gr_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1351_128x128_332_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1351_128x128gh_332_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1351_128x128_hicolor_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1351_128x128gh_hicolor_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1353_160x128_332_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1353_160x128_hicolor_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_64128n_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_dogm128_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_dogm132_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_lm6059_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_lm6063_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_nhd_c12832_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_nhd_c12864_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1601_c128032_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1608_240x128_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1608_240x64_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1610_dogxl160_bw_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1610_dogxl160_gr_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1611_dogm240_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1611_dogxl240_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1701_dogs102_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1701_mini12864_hw_spi) \
|
||||
|
||||
#define U8G_DISPLAY_TABLE_SPI \
|
||||
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi) \
|
||||
|
||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
#endif /* __U8G_CONFIG_H__ */
|
||||
|
|
|
@ -980,148 +980,66 @@ static int lu8g_close_display( lua_State *L )
|
|||
}
|
||||
|
||||
|
||||
// device constructors
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
// Lua: object = u8g.ssd1306_128x64_i2c( i2c_addr )
|
||||
static int lu8g_ssd1306_128x64_i2c( lua_State *L )
|
||||
{
|
||||
unsigned addr = luaL_checkinteger( L, 1 );
|
||||
|
||||
if (addr == 0)
|
||||
return luaL_error( L, "i2c address required" );
|
||||
|
||||
lu8g_userdata_t *lud = (lu8g_userdata_t *) lua_newuserdata( L, sizeof( lu8g_userdata_t ) );
|
||||
|
||||
lud->u8g.i2c_addr = (uint8_t)addr;
|
||||
|
||||
// Don't use the pre-defined device structure for u8g_dev_ssd1306_128x64_i2c here
|
||||
// Reason: linking the pre-defined structures allocates RAM for the device/comm structure
|
||||
// *before* the display is constructed (especially the page buffers)
|
||||
// this consumes heap even when the device is not used at all
|
||||
#if 1
|
||||
// build device entry
|
||||
lud->dev = (u8g_dev_t){ u8g_dev_ssd1306_128x64_fn, &(lud->pb), U8G_COM_SSD_I2C };
|
||||
|
||||
// populate and allocate page buffer
|
||||
// constants taken from u8g_dev_ssd1306_128x64.c:
|
||||
// PAGE_HEIGHT
|
||||
// | Height
|
||||
// | | WIDTH
|
||||
// | | |
|
||||
lud->pb = (u8g_pb_t){ { 8, 64, 0, 0, 0 }, 128, NULL };
|
||||
//
|
||||
if ((lud->pb.buf = (void *)c_zalloc(lud->pb.width)) == NULL)
|
||||
return luaL_error( L, "out of memory" );
|
||||
|
||||
// and finally init device using specific interface init function
|
||||
u8g_InitI2C( LU8G, &(lud->dev), U8G_I2C_OPT_NONE);
|
||||
#else
|
||||
u8g_InitI2C( LU8G, &u8g_dev_ssd1306_128x64_i2c, U8G_I2C_OPT_NONE);
|
||||
#endif
|
||||
|
||||
|
||||
// set its metatable
|
||||
luaL_getmetatable(L, "u8g.display");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Lua: object = u8g.ssd1306_128x64_spi( cs, dc, [res] )
|
||||
static int lu8g_ssd1306_128x64_spi( lua_State *L )
|
||||
{
|
||||
unsigned cs = luaL_checkinteger( L, 1 );
|
||||
if (cs == 0)
|
||||
return luaL_error( L, "CS pin required" );
|
||||
unsigned dc = luaL_checkinteger( L, 2 );
|
||||
if (dc == 0)
|
||||
return luaL_error( L, "D/C pin required" );
|
||||
unsigned res = luaL_optinteger( L, 3, U8G_PIN_NONE );
|
||||
|
||||
lu8g_userdata_t *lud = (lu8g_userdata_t *) lua_newuserdata( L, sizeof( lu8g_userdata_t ) );
|
||||
|
||||
// Don't use the pre-defined device structure for u8g_dev_ssd1306_128x64_spi here
|
||||
// Reason: linking the pre-defined structures allocates RAM for the device/comm structure
|
||||
// *before* the display is constructed (especially the page buffers)
|
||||
// this consumes heap even when the device is not used at all
|
||||
#if 1
|
||||
// build device entry
|
||||
lud->dev = (u8g_dev_t){ u8g_dev_ssd1306_128x64_fn, &(lud->pb), U8G_COM_HW_SPI };
|
||||
|
||||
// populate and allocate page buffer
|
||||
// constants taken from u8g_dev_ssd1306_128x64.c:
|
||||
// PAGE_HEIGHT
|
||||
// | Height
|
||||
// | | WIDTH
|
||||
// | | |
|
||||
lud->pb = (u8g_pb_t){ { 8, 64, 0, 0, 0 }, 128, NULL };
|
||||
//
|
||||
if ((lud->pb.buf = (void *)c_zalloc(lud->pb.width)) == NULL)
|
||||
return luaL_error( L, "out of memory" );
|
||||
|
||||
// and finally init device using specific interface init function
|
||||
u8g_InitHWSPI( LU8G, &(lud->dev), cs, dc, res );
|
||||
#else
|
||||
u8g_InitHWSPI( LU8G, &u8g_dev_ssd1306_128x64_spi, cs, dc, res );
|
||||
#endif
|
||||
|
||||
|
||||
// set its metatable
|
||||
luaL_getmetatable(L, "u8g.display");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_pcd8544_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
// Lua: object = u8g.pcd8544_84x48( sce, dc, res )
|
||||
static int lu8g_pcd8544_84x48( lua_State *L )
|
||||
{
|
||||
unsigned sce = luaL_checkinteger( L, 1 );
|
||||
if (sce == 0)
|
||||
return luaL_error( L, "SCE pin required" );
|
||||
unsigned dc = luaL_checkinteger( L, 2 );
|
||||
if (dc == 0)
|
||||
return luaL_error( L, "D/C pin required" );
|
||||
unsigned res = luaL_checkinteger( L, 3 );
|
||||
if (res == 0)
|
||||
return luaL_error( L, "RES pin required" );
|
||||
|
||||
lu8g_userdata_t *lud = (lu8g_userdata_t *) lua_newuserdata( L, sizeof( lu8g_userdata_t ) );
|
||||
|
||||
// Don't use the pre-defined device structure for u8g_dev_pcd8544_84x48_hw_spi here
|
||||
// Reason: linking the pre-defined structures allocates RAM for the device/comm structure
|
||||
// *before* the display is constructed (especially the page buffers)
|
||||
// this consumes heap even when the device is not used at all
|
||||
#if 1
|
||||
// build device entry
|
||||
lud->dev = (u8g_dev_t){ u8g_dev_pcd8544_fn, &(lud->pb), U8G_COM_HW_SPI };
|
||||
|
||||
// populate and allocate page buffer
|
||||
// constants taken from u8g_dev_pcd8544_84x48.c:
|
||||
// PAGE_HEIGHT
|
||||
// | Height
|
||||
// | | WIDTH
|
||||
// | | |
|
||||
lud->pb = (u8g_pb_t){ { 8, 48, 0, 0, 0 }, 84, NULL };
|
||||
//
|
||||
if ((lud->pb.buf = (void *)c_zalloc(lud->pb.width)) == NULL)
|
||||
return luaL_error( L, "out of memory" );
|
||||
|
||||
// and finally init device using specific interface init function
|
||||
u8g_InitHWSPI( LU8G, &(lud->dev), sce, dc, res );
|
||||
#else
|
||||
u8g_InitHWSPI( LU8G, &u8g_dev_pcd8544_84x48_hw_spi, sce, dc, res );
|
||||
#endif
|
||||
|
||||
|
||||
// set its metatable
|
||||
luaL_getmetatable(L, "u8g.display");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
// ***************************************************************************
|
||||
// Device constructors
|
||||
//
|
||||
//
|
||||
// I2C based devices will use this function template to implement the Lua binding.
|
||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||
#define U8G_DISPLAY_TABLE_ENTRY(device) \
|
||||
static int lu8g_ ## device( lua_State *L ) \
|
||||
{ \
|
||||
unsigned addr = luaL_checkinteger( L, 1 ); \
|
||||
\
|
||||
if (addr == 0) \
|
||||
return luaL_error( L, "i2c address required" ); \
|
||||
\
|
||||
lu8g_userdata_t *lud = (lu8g_userdata_t *) lua_newuserdata( L, sizeof( lu8g_userdata_t ) ); \
|
||||
\
|
||||
lud->u8g.i2c_addr = (uint8_t)addr; \
|
||||
\
|
||||
u8g_InitI2C( LU8G, &u8g_dev_ ## device, U8G_I2C_OPT_NONE); \
|
||||
\
|
||||
/* set its metatable */ \
|
||||
luaL_getmetatable(L, "u8g.display"); \
|
||||
lua_setmetatable(L, -2); \
|
||||
\
|
||||
return 1; \
|
||||
}
|
||||
//
|
||||
// Unroll the display table and insert binding functions for I2C based displays.
|
||||
U8G_DISPLAY_TABLE_I2C
|
||||
//
|
||||
//
|
||||
//
|
||||
// SPI based devices will use this function template to implement the Lua binding.
|
||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||
#define U8G_DISPLAY_TABLE_ENTRY(device) \
|
||||
static int lu8g_ ## device( lua_State *L ) \
|
||||
{ \
|
||||
unsigned cs = luaL_checkinteger( L, 1 ); \
|
||||
if (cs == 0) \
|
||||
return luaL_error( L, "CS pin required" ); \
|
||||
unsigned dc = luaL_checkinteger( L, 2 ); \
|
||||
if (dc == 0) \
|
||||
return luaL_error( L, "D/C pin required" ); \
|
||||
unsigned res = luaL_optinteger( L, 3, U8G_PIN_NONE ); \
|
||||
\
|
||||
lu8g_userdata_t *lud = (lu8g_userdata_t *) lua_newuserdata( L, sizeof( lu8g_userdata_t ) ); \
|
||||
\
|
||||
u8g_InitHWSPI( LU8G, &u8g_dev_ ## device, cs, dc, res ); \
|
||||
\
|
||||
/* set its metatable */ \
|
||||
luaL_getmetatable(L, "u8g.display"); \
|
||||
lua_setmetatable(L, -2); \
|
||||
\
|
||||
return 1; \
|
||||
}
|
||||
//
|
||||
// Unroll the display table and insert binding functions for SPI based displays.
|
||||
U8G_DISPLAY_TABLE_SPI
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
// Module function map
|
||||
|
@ -1189,15 +1107,10 @@ static const LUA_REG_TYPE lu8g_display_map[] =
|
|||
|
||||
const LUA_REG_TYPE lu8g_map[] =
|
||||
{
|
||||
#ifdef U8G_SSD1306_128x64_I2C
|
||||
{ LSTRKEY( "ssd1306_128x64_i2c" ), LFUNCVAL ( lu8g_ssd1306_128x64_i2c ) },
|
||||
#endif
|
||||
#ifdef U8G_SSD1306_128x64_I2C
|
||||
{ LSTRKEY( "ssd1306_128x64_spi" ), LFUNCVAL ( lu8g_ssd1306_128x64_spi ) },
|
||||
#endif
|
||||
#ifdef U8G_PCD8544_84x48
|
||||
{ LSTRKEY( "pcd8544_84x48" ), LFUNCVAL ( lu8g_pcd8544_84x48 ) },
|
||||
#endif
|
||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||
#define U8G_DISPLAY_TABLE_ENTRY(device) { LSTRKEY( #device ), LFUNCVAL ( lu8g_ ##device ) },
|
||||
U8G_DISPLAY_TABLE_I2C
|
||||
U8G_DISPLAY_TABLE_SPI
|
||||
|
||||
#if LUA_OPTIMIZE_MEMORY > 0
|
||||
|
||||
|
@ -1206,7 +1119,7 @@ const LUA_REG_TYPE lu8g_map[] =
|
|||
#define U8G_FONT_TABLE_ENTRY(font) { LSTRKEY( #font ), LUDATA( (void *)(u8g_ ## font) ) },
|
||||
U8G_FONT_TABLE
|
||||
|
||||
// Options for circle/ ellipse drwing
|
||||
// Options for circle/ ellipse drawing
|
||||
{ LSTRKEY( "DRAW_UPPER_RIGHT" ), LNUMVAL( U8G_DRAW_UPPER_RIGHT ) },
|
||||
{ LSTRKEY( "DRAW_UPPER_LEFT" ), LNUMVAL( U8G_DRAW_UPPER_LEFT ) },
|
||||
{ LSTRKEY( "DRAW_LOWER_RIGHT" ), LNUMVAL( U8G_DRAW_LOWER_RIGHT ) },
|
||||
|
|
154
app/u8glib/u8g.h
154
app/u8glib/u8g.h
|
@ -53,7 +53,7 @@ typedef signed short int16_t;
|
|||
#elif defined(__XTENSA__)
|
||||
# include <c_types.h>
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
@ -63,7 +63,7 @@ typedef signed short int16_t;
|
|||
/*
|
||||
use the com interface directly on any systems which are not AVR or ARDUINO
|
||||
*/
|
||||
#if defined(__AVR__) || defined(ARDUINO)
|
||||
#if defined(__AVR__) || defined(ARDUINO) || defined(__MSP430__)
|
||||
#define U8G_WITH_PINLIST
|
||||
#endif
|
||||
#define U8G_WITH_PINLIST
|
||||
|
@ -98,6 +98,19 @@ extern "C" {
|
|||
# define U8G_FONT_SECTION(name)
|
||||
#endif
|
||||
|
||||
#ifdef __MSP430__
|
||||
/*
|
||||
Specifying a section will cause the MSP-GCC to put even const data to RAM
|
||||
at least for the fonts. But as the fonts are consts we don't need to specify
|
||||
it manually - the MSP-GCC seems to be smart enough to put it into the
|
||||
flash memory.
|
||||
*/
|
||||
# undef U8G_SECTION
|
||||
# define U8G_SECTION(name)
|
||||
#endif
|
||||
|
||||
/*===============================================================*/
|
||||
|
||||
#ifndef U8G_FONT_SECTION
|
||||
# define U8G_FONT_SECTION(name)
|
||||
#endif
|
||||
|
@ -267,11 +280,13 @@ extern u8g_dev_t u8g_dev_st7565_dogm128_2x_parallel;
|
|||
extern u8g_dev_t u8g_dev_uc1611_dogm240_i2c;
|
||||
extern u8g_dev_t u8g_dev_uc1611_dogm240_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1611_dogm240_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1611_dogm240_8bit;
|
||||
|
||||
/* EA DOGXL 240 */
|
||||
extern u8g_dev_t u8g_dev_uc1611_dogxl240_i2c;
|
||||
extern u8g_dev_t u8g_dev_uc1611_dogxl240_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1611_dogxl240_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1611_dogxl240_8bit;
|
||||
|
||||
/* Display: Topway LM6059 128x64 (Adafruit) */
|
||||
extern u8g_dev_t u8g_dev_st7565_lm6059_sw_spi;
|
||||
|
@ -464,6 +479,15 @@ extern u8g_dev_t u8g_dev_ssd1306_128x32_2x_sw_spi;
|
|||
extern u8g_dev_t u8g_dev_ssd1306_128x32_2x_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1306_128x32_2x_i2c;
|
||||
|
||||
/* OLED 64x48 Display with SSD1306 Controller */
|
||||
extern u8g_dev_t u8g_dev_ssd1306_64x48_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1306_64x48_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1306_64x48_i2c;
|
||||
|
||||
extern u8g_dev_t u8g_dev_ssd1306_64x48_2x_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1306_64x48_2x_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1306_64x48_2x_i2c;
|
||||
|
||||
/* OLED 60x32 Display with LD7032 Controller */
|
||||
extern u8g_dev_t u8g_dev_ld7032_60x32_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ld7032_60x32_hw_spi;
|
||||
|
@ -506,6 +530,11 @@ extern u8g_dev_t u8g_dev_ssd1351_128x128gh_hicolor_hw_spi;
|
|||
extern u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_hw_spi;
|
||||
|
||||
|
||||
/* SSD1353 OLED Palmtronics */
|
||||
extern u8g_dev_t u8g_dev_ssd1353_160x128_332_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1353_160x128_hicolor_hw_spi;
|
||||
|
||||
/* HT1632 */
|
||||
extern u8g_dev_t u8g_dev_ht1632_24x16;
|
||||
|
||||
|
@ -639,7 +668,12 @@ struct _u8g_dev_arg_irgb_t
|
|||
|
||||
|
||||
/* com driver */
|
||||
|
||||
uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_null.c */
|
||||
|
||||
uint8_t u8g_com_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* requires U8G_WITH_PINLIST */
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_std_sw_spi.c */
|
||||
uint8_t u8g_com_arduino_hw_usart_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_hw_usart_spi.c */
|
||||
uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_sw_spi.c */
|
||||
|
@ -665,6 +699,8 @@ uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val
|
|||
uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
|
||||
uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_parallel.c */
|
||||
|
||||
uint8_t u8g_com_msp430_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_msp430_hw_spi.c */
|
||||
|
||||
uint8_t u8g_com_raspberrypi_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_rasperrypi_hw_spi.c */
|
||||
uint8_t u8g_com_raspberrypi_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_raspberrypi_ssd_i2c.c */
|
||||
|
||||
|
@ -684,6 +720,12 @@ defined(__18CXX) || defined(__PIC32MX)
|
|||
|
||||
*/
|
||||
|
||||
/* ==== HW SPI, msp430 ====*/
|
||||
#if defined(__MSP430__)
|
||||
#define U8G_COM_HW_SPI u8g_com_msp430_hw_spi_fn
|
||||
#define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
|
||||
#endif
|
||||
|
||||
/* ==== HW SPI, Raspberry PI ====*/
|
||||
#if defined(U8G_RASPBERRY_PI)
|
||||
#define U8G_COM_HW_SPI u8g_com_raspberrypi_hw_spi_fn
|
||||
|
@ -758,6 +800,13 @@ defined(__18CXX) || defined(__PIC32MX)
|
|||
|
||||
#ifndef U8G_COM_SW_SPI
|
||||
/* ==== SW SPI, not Arduino ====*/
|
||||
|
||||
/* ==== SW SPI, msp430 ====*/
|
||||
#if defined(__MSP430__)
|
||||
#define U8G_COM_SW_SPI u8g_com_std_sw_spi_fn
|
||||
#define U8G_COM_ST7920_SW_SPI u8g_com_null_fn
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define U8G_COM_SW_SPI u8g_com_atmega_sw_spi_fn
|
||||
#define U8G_COM_ST7920_SW_SPI u8g_com_atmega_st7920_sw_spi_fn
|
||||
|
@ -1073,6 +1122,49 @@ typedef void (*u8g_state_cb)(uint8_t msg);
|
|||
#define U8G_FONT_HEIGHT_MODE_XTEXT 1
|
||||
#define U8G_FONT_HEIGHT_MODE_ALL 2
|
||||
|
||||
struct _u8g_t
|
||||
{
|
||||
u8g_uint_t width;
|
||||
u8g_uint_t height;
|
||||
|
||||
|
||||
u8g_dev_t *dev; /* first device in the device chain */
|
||||
const u8g_pgm_uint8_t *font; /* regular font for all text procedures */
|
||||
const u8g_pgm_uint8_t *cursor_font; /* special font for cursor procedures */
|
||||
uint8_t cursor_fg_color, cursor_bg_color;
|
||||
uint8_t cursor_encoding;
|
||||
uint8_t mode; /* display mode, one of U8G_MODE_xxx */
|
||||
u8g_uint_t cursor_x;
|
||||
u8g_uint_t cursor_y;
|
||||
u8g_draw_cursor_fn cursor_fn;
|
||||
|
||||
int8_t glyph_dx;
|
||||
int8_t glyph_x;
|
||||
int8_t glyph_y;
|
||||
uint8_t glyph_width;
|
||||
uint8_t glyph_height;
|
||||
|
||||
u8g_font_calc_vref_fnptr font_calc_vref;
|
||||
uint8_t font_height_mode;
|
||||
int8_t font_ref_ascent;
|
||||
int8_t font_ref_descent;
|
||||
uint8_t font_line_spacing_factor; /* line_spacing = factor * (ascent - descent) / 64 */
|
||||
uint8_t line_spacing;
|
||||
|
||||
u8g_dev_arg_pixel_t arg_pixel;
|
||||
/* uint8_t color_index; */
|
||||
|
||||
#ifdef U8G_WITH_PINLIST
|
||||
uint8_t pin_list[U8G_PIN_LIST_LEN];
|
||||
#endif
|
||||
|
||||
u8g_state_cb state_cb;
|
||||
|
||||
u8g_box_t current_page; /* current box of the visible page */
|
||||
|
||||
uint8_t i2c_addr;
|
||||
};
|
||||
|
||||
#define u8g_GetFontAscent(u8g) ((u8g)->font_ref_ascent)
|
||||
#define u8g_GetFontDescent(u8g) ((u8g)->font_ref_descent)
|
||||
#define u8g_GetFontLineSpacing(u8g) ((u8g)->line_spacing)
|
||||
|
@ -1094,6 +1186,8 @@ void u8g_UpdateDimension(u8g_t *u8g);
|
|||
uint8_t u8g_Begin(u8g_t *u8g); /* reset device, put it into default state and call u8g_UpdateDimension() */
|
||||
uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev); /* only usefull if the device only as hardcoded ports */
|
||||
uint8_t u8g_InitComFn(u8g_t *u8g, u8g_dev_t *dev, u8g_com_fnptr com_fn); /* Init procedure for anything which is not Arduino or AVR (e.g. ARM, but not Due, which is Arduino) */
|
||||
|
||||
#if defined(U8G_WITH_PINLIST)
|
||||
uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset);
|
||||
uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset);
|
||||
uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options); /* use U8G_I2C_OPT_NONE as options */
|
||||
|
@ -1102,6 +1196,8 @@ uint8_t u8g_Init8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t
|
|||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset);
|
||||
uint8_t u8g_InitRW8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset);
|
||||
#endif
|
||||
|
||||
void u8g_FirstPage(u8g_t *u8g);
|
||||
uint8_t u8g_NextPage(u8g_t *u8g);
|
||||
uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast);
|
||||
|
@ -1110,6 +1206,7 @@ void u8g_SleepOff(u8g_t *u8g);
|
|||
void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y);
|
||||
void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
|
||||
void u8g_Draw4TPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
|
||||
void u8g_Draw8ColorPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t colpixel);
|
||||
|
||||
uint8_t u8g_Stop(u8g_t *u8g);
|
||||
void u8g_SetColorEntry(u8g_t *u8g, uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
|
||||
|
@ -1371,7 +1468,7 @@ struct _pg_struct
|
|||
void pg_ClearPolygonXY(pg_struct *pg);
|
||||
void pg_AddPolygonXY(pg_struct *pg, u8g_t *u8g, int16_t x, int16_t y);
|
||||
void pg_DrawPolygon(pg_struct *pg, u8g_t *u8g);
|
||||
void u8g_ClearPolygonXY(u8g_t *u8g);
|
||||
void u8g_ClearPolygonXY(void);
|
||||
void u8g_AddPolygonXY(u8g_t *u8g, int16_t x, int16_t y);
|
||||
void u8g_DrawPolygon(u8g_t *u8g);
|
||||
void u8g_DrawTriangle(u8g_t *u8g, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
|
||||
|
@ -1446,57 +1543,6 @@ void chess_Init(u8g_t *u8g, uint8_t empty_body_color);
|
|||
void chess_Draw(void);
|
||||
void chess_Step(uint8_t keycode);
|
||||
|
||||
|
||||
|
||||
struct _u8g_t
|
||||
{
|
||||
u8g_uint_t width;
|
||||
u8g_uint_t height;
|
||||
|
||||
|
||||
u8g_dev_t *dev; /* first device in the device chain */
|
||||
const u8g_pgm_uint8_t *font; /* regular font for all text procedures */
|
||||
const u8g_pgm_uint8_t *cursor_font; /* special font for cursor procedures */
|
||||
uint8_t cursor_fg_color, cursor_bg_color;
|
||||
uint8_t cursor_encoding;
|
||||
uint8_t mode; /* display mode, one of U8G_MODE_xxx */
|
||||
u8g_uint_t cursor_x;
|
||||
u8g_uint_t cursor_y;
|
||||
u8g_draw_cursor_fn cursor_fn;
|
||||
|
||||
int8_t glyph_dx;
|
||||
int8_t glyph_x;
|
||||
int8_t glyph_y;
|
||||
uint8_t glyph_width;
|
||||
uint8_t glyph_height;
|
||||
|
||||
u8g_font_calc_vref_fnptr font_calc_vref;
|
||||
uint8_t font_height_mode;
|
||||
int8_t font_ref_ascent;
|
||||
int8_t font_ref_descent;
|
||||
uint8_t font_line_spacing_factor; /* line_spacing = factor * (ascent - descent) / 64 */
|
||||
uint8_t line_spacing;
|
||||
|
||||
u8g_dev_arg_pixel_t arg_pixel;
|
||||
/* uint8_t color_index; */
|
||||
|
||||
#ifdef U8G_WITH_PINLIST
|
||||
uint8_t pin_list[U8G_PIN_LIST_LEN];
|
||||
#endif
|
||||
|
||||
u8g_state_cb state_cb;
|
||||
|
||||
u8g_box_t current_page; /* current box of the visible page */
|
||||
|
||||
uint8_t i2c_addr;
|
||||
|
||||
/* global variables from u8g_polygon.c */
|
||||
pg_struct pg;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* font definitions */
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_m2icon_5[] U8G_FONT_SECTION("u8g_font_m2icon_5");
|
||||
|
|
|
@ -66,6 +66,10 @@ uint8_t u8g_i2c_get_err_pos(void)
|
|||
return u8g_i2c_err_pos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
static void u8g_i2c_set_error(uint8_t code, uint8_t pos)
|
||||
{
|
||||
if ( u8g_i2c_err_code > 0 )
|
||||
|
@ -74,9 +78,6 @@ static void u8g_i2c_set_error(uint8_t code, uint8_t pos)
|
|||
u8g_i2c_err_pos = pos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define U8G_ATMEGA_HW_TWI
|
||||
|
||||
/* remove the definition for attiny */
|
||||
|
|
|
@ -191,6 +191,107 @@ uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#elif defined (__MSP430__)
|
||||
#include <msp430.h>
|
||||
|
||||
typedef volatile uint8_t * IO_PTR;
|
||||
|
||||
// MSP430 F5XXX / F6XXX series.
|
||||
const IO_PTR u8g_msp_ddr_P[] PROGMEM = {
|
||||
&P1DIR
|
||||
,&P2DIR
|
||||
,&P3DIR
|
||||
,&P4DIR
|
||||
,&P5DIR
|
||||
,&P6DIR
|
||||
,&P7DIR
|
||||
,&P8DIR
|
||||
#if defined (__MSP430_HAS_PORT9_R__)
|
||||
,&P9DIR
|
||||
#if defined (__MSP430_HAS_PORT10_R__)
|
||||
,&P10DIR
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const IO_PTR u8g_msp_port_P[] PROGMEM = {
|
||||
&P1OUT
|
||||
,&P2OUT
|
||||
,&P3OUT
|
||||
,&P4OUT
|
||||
,&P5OUT
|
||||
,&P6OUT
|
||||
,&P7OUT
|
||||
,&P8OUT
|
||||
#if defined (__MSP430_HAS_PORT9_R__)
|
||||
,&P9OUT
|
||||
#if defined (__MSP430_HAS_PORT10_R__)
|
||||
,&P10OUT
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const IO_PTR u8g_msp_pin_P[] PROGMEM = {
|
||||
&P1IN
|
||||
,&P2IN
|
||||
,&P3IN
|
||||
,&P4IN
|
||||
,&P5IN
|
||||
,&P6IN
|
||||
,&P7IN
|
||||
,&P8IN
|
||||
#if defined (__MSP430_HAS_PORT9_R__)
|
||||
,&P9IN
|
||||
#if defined (__MSP430_HAS_PORT10_R__)
|
||||
,&P10IN
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos)
|
||||
{
|
||||
port <<= 3;
|
||||
port += bitpos;
|
||||
return port;
|
||||
}
|
||||
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number)
|
||||
{
|
||||
uint8_t port = (internal_pin_number >> 3)-1;
|
||||
uint8_t output = 1 << (internal_pin_number & 0x07);
|
||||
*u8g_msp_ddr_P[port] |= output;
|
||||
}
|
||||
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number)
|
||||
{
|
||||
uint8_t port = (internal_pin_number >> 3)-1;
|
||||
*u8g_msp_ddr_P[port] &= ~(1 << (internal_pin_number & 0x07));
|
||||
}
|
||||
|
||||
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
|
||||
{
|
||||
uint8_t port = (internal_pin_number >> 3)-1;
|
||||
if (level == 0)
|
||||
{
|
||||
*u8g_msp_port_P[port] &= ~(1 << (internal_pin_number & 0x07));
|
||||
}
|
||||
else
|
||||
{
|
||||
*u8g_msp_port_P[port]|= (1 << (internal_pin_number & 0x07));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
|
||||
{
|
||||
uint8_t port = (internal_pin_number >> 3)-1;
|
||||
uint8_t tmp = *u8g_msp_pin_P[port];
|
||||
if (tmp & (1 << (internal_pin_number & 0x07)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(U8G_RASPBERRY_PI)
|
||||
|
||||
#include <wiringPi.h>
|
||||
|
|
|
@ -61,6 +61,10 @@
|
|||
# else
|
||||
# define USE_ARDUINO_DELAY
|
||||
# endif
|
||||
#elif defined(_GNU_SOURCE)
|
||||
# define USE_LINUX_DELAY
|
||||
#elif defined(__MSP430__)
|
||||
# define USE_MSP430_DELAY
|
||||
#elif defined(U8G_RASPBERRY_PI)
|
||||
# define USE_RASPBERRYPI_DELAY
|
||||
#elif defined(__AVR__)
|
||||
|
@ -103,6 +107,22 @@ void u8g_10MicroDelay(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_LINUX_DELAY)
|
||||
void u8g_Delay(uint16_t val) {
|
||||
//delay(val);
|
||||
usleep((uint32_t)val*(uint32_t)1000);
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
usleep(1);
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
usleep(10);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*== AVR Delay ==*/
|
||||
|
||||
|
@ -247,6 +267,34 @@ void u8g_10MicroDelay(void)
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(USE_MSP430_DELAY)
|
||||
#include <msp430.h>
|
||||
|
||||
#ifndef F_CPU
|
||||
#define F_CPU 1000000UL
|
||||
#endif
|
||||
|
||||
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
int t;
|
||||
for (t=0; t < val; t++)
|
||||
{
|
||||
__delay_cycles(F_CPU/1000UL);
|
||||
}
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
__delay_cycles(F_CPU/1000000UL);
|
||||
}
|
||||
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
__delay_cycles(F_CPU/100000UL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*== Any other systems: Dummy Delay ==*/
|
||||
#if defined(USE_DUMMY_DELAY)
|
||||
void u8g_Delay(uint16_t val)
|
||||
|
|
|
@ -409,3 +409,4 @@ u8g_pb_t u8g_dev_sh1106_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_
|
|||
u8g_dev_t u8g_dev_sh1106_128x64_2x_sw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_sh1106_128x64_2x_hw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SSD_I2C };
|
||||
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
|
||||
u8g_dev_ssd1306_64x48.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 64
|
||||
#define HEIGHT 48
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
|
||||
/* init sequence buydisplay.com 0.66" 64x48 OLED */
|
||||
/* http://www.buydisplay.com/download/manual/ER-OLED0.66-1_Series_Datasheet.pdf */
|
||||
static const uint8_t u8g_dev_ssd1306_64x48_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x02f, /* Multiplex Ration, Jul 12, 2015: From 0.66" OLED datasheet */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
//0x020, 0x002, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), Feb 23, 2013: 64x48 OLED: 0x002, 64x48 OLED 0x012 */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), Jul 12, 2015: From 0.66" OLED datasheet */
|
||||
0x081, 0x0cf, /* set contrast control */
|
||||
0x0d9, 0x022, /* pre-charge period 0x022/f1, from 0.66" OLED datasheet */
|
||||
0x0db, 0x000, /* vcomh deselect level, from 0.66" OLED datasheet */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1306_64x48_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010+2, /* set upper 4 bit of the col adr. to 0, 0.66" OLED starts with offset 32 */
|
||||
0x000, /* set lower 4 bit of the col adr. to 4 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1306_64x48_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1306_64x48_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2+1)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_64x48_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_64x48_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_64x48_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_64x48_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_64x48_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_64x48_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
uint8_t u8g_dev_ssd1306_64x48_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1306_64x48_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_64x48_2x_buf};
|
||||
u8g_dev_t u8g_dev_ssd1306_64x48_2x_sw_spi = { u8g_dev_ssd1306_64x48_2x_fn, &u8g_dev_ssd1306_64x48_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1306_64x48_2x_hw_spi = { u8g_dev_ssd1306_64x48_2x_fn, &u8g_dev_ssd1306_64x48_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1306_64x48_2x_i2c = { u8g_dev_ssd1306_64x48_2x_fn, &u8g_dev_ssd1306_64x48_2x_pb, U8G_COM_SSD_I2C };
|
|
@ -124,7 +124,7 @@ uint8_t u8g_dev_ssd1309_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void
|
|||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* 11 Jul 2015: fixed contrast calculation */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
|
@ -140,5 +140,3 @@ uint8_t u8g_dev_ssd1309_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void
|
|||
U8G_PB_DEV(u8g_dev_ssd1309_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1309_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1309_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
|
|
@ -0,0 +1,425 @@
|
|||
/*
|
||||
u8g_dev_ssd1353_160x128.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2015, hugodan3@googlemail.com
|
||||
Copyright (c) 2013, jamjardavies@gmail.com
|
||||
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.
|
||||
|
||||
History:
|
||||
Initial version 8 Mar 2015 hugodan3@googlemail.com. This version has
|
||||
been derived from the ssd1351 driver by jamjarda. It has
|
||||
been improved by in-lining time critical functions.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 160
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
#define USE_GREY_TABLE 0
|
||||
|
||||
static const uint8_t u8g_dev_ssd1353_160x128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0xFD, /* Command unlock */
|
||||
U8G_ESC_ADR(1),
|
||||
0x12,
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xAE, /* Set Display Off */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA8,
|
||||
U8G_ESC_ADR(1),
|
||||
0x7F, /* Set Multiplex Ratio */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA0,
|
||||
U8G_ESC_ADR(1),
|
||||
0xB4, /* Set remapping */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA1,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, /* Set Display Start Line */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA2,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, /* Set Display Offset */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xB1,
|
||||
U8G_ESC_ADR(1),
|
||||
0x32, /* Set Phase Length */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xB4,
|
||||
U8G_ESC_ADR(1),
|
||||
0x04, /* Set Second Precharge Period */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA4, /* Set Display Mode ON */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xB3,
|
||||
U8G_ESC_ADR(1), /* frame rate */
|
||||
0x40,
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xBB,
|
||||
U8G_ESC_ADR(1), /* pre-charge level */
|
||||
0x08,
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xBE,
|
||||
U8G_ESC_ADR(1), /* vcomh */
|
||||
0x3C,
|
||||
|
||||
/* color adjustments */
|
||||
#if USE_GREY_TABLE != 1
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x81,
|
||||
U8G_ESC_ADR(1),
|
||||
0xC8, /* Set Contrast Color 1*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x82,
|
||||
U8G_ESC_ADR(1),
|
||||
0x80, /* Set Contrast Color 2*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x83,
|
||||
U8G_ESC_ADR(1),
|
||||
0xF8, /* Set Contrast Color 3*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x87,
|
||||
U8G_ESC_ADR(1),
|
||||
0x09, /* Set Master Contrast MAX */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xB9, /* Set CMD Grayscale Linear */
|
||||
#else
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x81,
|
||||
U8G_ESC_ADR(1),
|
||||
0xC8, /* Set Contrast Color 1*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x82,
|
||||
U8G_ESC_ADR(1),
|
||||
0xA0, /* Set Contrast Color 2*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x83,
|
||||
U8G_ESC_ADR(1),
|
||||
0xB0, /* Set Contrast Color 3*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x87,
|
||||
U8G_ESC_ADR(1),
|
||||
0x0F, /* Set Master Contrast MAX */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xB8, /* Set CMD Grayscale Lookup */
|
||||
U8G_ESC_ADR(1),
|
||||
0x05, 0x06, 0x07, 0x08,
|
||||
0x09, 0x0a, 0x0b, 0x0c,
|
||||
0x0D, 0x0E, 0x0F, 0x10,
|
||||
0x11, 0x12, 0x13, 0x14,
|
||||
0x15, 0x16, 0x18, 0x1a,
|
||||
0x1b, 0x1C, 0x1D, 0x1F,
|
||||
0x21, 0x23, 0x25, 0x27,
|
||||
0x2A, 0x2D, 0x30, 0x33,
|
||||
0x36, 0x39, 0x3C, 0x3F,
|
||||
0x42, 0x45, 0x48, 0x4C,
|
||||
0x50, 0x54, 0x58, 0x5C,
|
||||
0x60, 0x64, 0x68, 0x6C,
|
||||
0x70, 0x74, 0x78, 0x7D,
|
||||
0x82, 0x87, 0x8C, 0x91,
|
||||
0x96, 0x9B, 0xA0, 0xA5,
|
||||
0xAA, 0xAF, 0xB4,
|
||||
#endif
|
||||
U8G_ESC_ADR(0),
|
||||
0xAF, /* Set Display On */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1),
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1353_160x128_column_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(1),
|
||||
U8G_ESC_ADR(0), 0x15,
|
||||
U8G_ESC_ADR(1), 0x00, 0x9f,
|
||||
U8G_ESC_ADR(0), 0x75,
|
||||
U8G_ESC_ADR(1), 0x00, 0x7f,
|
||||
U8G_ESC_ADR(0), 0x5c,
|
||||
U8G_ESC_ADR(1),
|
||||
U8G_ESC_CS(0),
|
||||
U8G_ESC_END
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1353_160x128_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_CS(1),
|
||||
U8G_ESC_ADR(0), 0xAE,
|
||||
U8G_ESC_CS(0),
|
||||
U8G_ESC_END
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1353_160x128_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_CS(1),
|
||||
U8G_ESC_ADR(0), 0xAF,
|
||||
U8G_ESC_CS(0),
|
||||
U8G_ESC_END
|
||||
};
|
||||
|
||||
|
||||
#define RGB332_STREAM_BYTES 8
|
||||
static uint8_t u8g_ssd1353_stream_bytes[RGB332_STREAM_BYTES*3];
|
||||
|
||||
uint8_t u8g_dev_ssd1353_160x128_332_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_init_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_column_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_uint_t x;
|
||||
uint8_t page_height;
|
||||
uint8_t i;
|
||||
uint8_t cnt;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( i = 0; i < page_height; i++ )
|
||||
{
|
||||
|
||||
for (x = 0; x < pb->width; x+=RGB332_STREAM_BYTES)
|
||||
{
|
||||
/* inline operation for better perf */
|
||||
uint8_t *dest = u8g_ssd1353_stream_bytes;
|
||||
for( cnt = 0; cnt < RGB332_STREAM_BYTES; cnt++ )
|
||||
{
|
||||
uint8_t val = *ptr++;
|
||||
*dest++ = ((val & 0xe0) >> 2);
|
||||
*dest++ = ((val & 0x1c) << 1);
|
||||
*dest++ = ((val & 0x03) << 4);
|
||||
}
|
||||
u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1353_stream_bytes);
|
||||
}
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_sleep_on);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_sleep_off);
|
||||
break;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* not tested and not released, just taken from ssd1351
|
||||
*/
|
||||
static uint8_t u8g_dev_ssd1353_160x128_r[256];
|
||||
static uint8_t u8g_dev_ssd1353_160x128_g[256];
|
||||
static uint8_t u8g_dev_ssd1353_160x128_b[256];
|
||||
|
||||
uint8_t u8g_dev_ssd1353_160x128_idx_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
// u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_init_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
u8g_dev_ssd1353_160x128_r[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->r;
|
||||
u8g_dev_ssd1353_160x128_g[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->g;
|
||||
u8g_dev_ssd1353_160x128_b[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->b;
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_column_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
int x;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
for (x = 0; x < pb->width; x++)
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ssd1353_160x128_r[(*ptr)>>2]);
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ssd1353_160x128_g[(*ptr)>>2]);
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ssd1353_160x128_b[(*ptr)>>2]);
|
||||
|
||||
ptr++;
|
||||
}
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_INDEX;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1353_160x128_hicolor_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_column_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t i, j;
|
||||
uint8_t page_height;
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( j = 0; j < page_height; j++ )
|
||||
{
|
||||
for (i = 0; i < pb->width; i+=RGB332_STREAM_BYTES)
|
||||
{
|
||||
register uint8_t cnt, low, high, r, g, b;
|
||||
uint8_t *dest = u8g_ssd1353_stream_bytes;
|
||||
for( cnt = 0; cnt < RGB332_STREAM_BYTES; cnt++ )
|
||||
{
|
||||
low = *ptr++;
|
||||
high = *ptr++;
|
||||
|
||||
r = high & ~7;
|
||||
r >>= 2;
|
||||
b = low & 31;
|
||||
b <<= 1;
|
||||
g = high & 7;
|
||||
g <<= 3;
|
||||
g |= (low>>5)&7;
|
||||
|
||||
*dest++ = r;
|
||||
*dest++ = g;
|
||||
*dest++ = b;
|
||||
}
|
||||
u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1353_stream_bytes);
|
||||
}
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break; /* continue to base fn */
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_sleep_on);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_sleep_off);
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pbxh16_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1353_160x128_byte_buf[WIDTH*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
|
||||
u8g_pb_t u8g_dev_ssd1353_160x128_byte_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1353_160x128_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_332_sw_spi = { u8g_dev_ssd1353_160x128_332_fn, &u8g_dev_ssd1353_160x128_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_332_hw_spi = { u8g_dev_ssd1353_160x128_332_fn, &u8g_dev_ssd1353_160x128_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
//u8g_dev_t u8g_dev_ssd1353_160x128_idx_sw_spi = { u8g_dev_ssd1353_160x128_idx_fn, &u8g_dev_ssd1353_160x128_byte_pb, U8G_COM_SW_SPI };
|
||||
//u8g_dev_t u8g_dev_ssd1353_160x128_idx_hw_spi = { u8g_dev_ssd1353_160x128_idx_fn, &u8g_dev_ssd1353_160x128_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
|
||||
/* only half of the height, because two bytes are needed for one pixel */
|
||||
u8g_pb_t u8g_dev_ssd1353_160x128_hicolor_byte_pb = { {PAGE_HEIGHT/2, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1353_160x128_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_hicolor_sw_spi = { u8g_dev_ssd1353_160x128_hicolor_fn, &u8g_dev_ssd1353_160x128_hicolor_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_hicolor_hw_spi = { u8g_dev_ssd1353_160x128_hicolor_fn, &u8g_dev_ssd1353_160x128_hicolor_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
|
||||
/* the 4x buffer is removed since it does not fit the RAM space of very small MCUs */
|
||||
#if 0
|
||||
uint8_t u8g_dev_ssd1353_160x128_4x_byte_buf[WIDTH*PAGE_HEIGHT*4] U8G_NOCOMMON ;
|
||||
|
||||
u8g_pb_t u8g_dev_ssd1353_160x128_4x_332_byte_pb = { {PAGE_HEIGHT*4, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1353_160x128_4x_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_4x_332_sw_spi = { u8g_dev_ssd1353_160x128_332_fn, &u8g_dev_ssd1353_160x128_4x_332_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_4x_332_hw_spi = { u8g_dev_ssd1353_160x128_332_fn, &u8g_dev_ssd1353_160x128_4x_332_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
u8g_pb_t u8g_dev_ssd1353_160x128_4x_hicolor_byte_pb = { {PAGE_HEIGHT/2*4, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1353_160x128_4x_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_4x_hicolor_sw_spi = { u8g_dev_ssd1353_160x128_hicolor_fn, &u8g_dev_ssd1353_160x128_4x_hicolor_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_4x_hicolor_hw_spi = { u8g_dev_ssd1353_160x128_hicolor_fn, &u8g_dev_ssd1353_160x128_4x_hicolor_byte_pb, U8G_COM_HW_SPI };
|
||||
#endif
|
|
@ -66,7 +66,7 @@ static const uint8_t u8g_dev_uc1611_dogm240_init_seq[] PROGMEM = {
|
|||
|
||||
static void setPage(u8g_t *u8g, u8g_dev_t *dev, unsigned char page)
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x70);
|
||||
u8g_WriteByte(u8g, dev, 0x70 + (page>>4));
|
||||
u8g_WriteByte(u8g, dev, 0x60 + (page&0x0F));
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,8 @@ uint8_t u8g_dev_uc1611_dogm240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void
|
|||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x81);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2); /* set contrast from, keep gain at 0 */
|
||||
/* 11 Jul 2015: bugfix, github issue 339 */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* set contrast from, keep gain at 0 */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
return 1;
|
||||
}
|
||||
|
@ -113,4 +114,5 @@ uint8_t u8g_dev_uc1611_dogm240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void
|
|||
U8G_PB_DEV(u8g_dev_uc1611_dogm240_i2c , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogm240_fn, U8G_COM_UC_I2C);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogm240_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogm240_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogm240_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogm240_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogm240_8bit , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogm240_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
|
|
@ -103,7 +103,8 @@ static uint8_t u8g_dev_uc1611_dogxl240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t ms
|
|||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x81);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2); /* set contrast from, keep gain at 0 */
|
||||
/* 11 Jul 2015: bugfix, github issue 339 */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* set contrast from, keep gain at 0 */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
return 1;
|
||||
}
|
||||
|
@ -113,4 +114,5 @@ static uint8_t u8g_dev_uc1611_dogxl240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t ms
|
|||
U8G_PB_DEV(u8g_dev_uc1611_dogxl240_i2c , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogxl240_fn, U8G_COM_UC_I2C);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogxl240_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogxl240_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogxl240_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogxl240_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogxl240_8bit , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogxl240_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
|
|
@ -902,12 +902,16 @@ u8g_uint_t u8g_DrawStr90P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_
|
|||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
uint8_t c;
|
||||
|
||||
x -= u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
for(;;)
|
||||
{
|
||||
d = u8g_DrawGlyph90(u8g, x, y, u8g_pgm_read(s));
|
||||
c = u8g_pgm_read(s);
|
||||
if ( c == '\0' )
|
||||
break;
|
||||
d = u8g_DrawGlyph90(u8g, x, y, c);
|
||||
y += d;
|
||||
t += d;
|
||||
s++;
|
||||
|
@ -919,12 +923,16 @@ u8g_uint_t u8g_DrawStr180P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm
|
|||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
uint8_t c;
|
||||
|
||||
y -= u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
for(;;)
|
||||
{
|
||||
d = u8g_DrawGlyph180(u8g, x, y, u8g_pgm_read(s));
|
||||
c = u8g_pgm_read(s);
|
||||
if ( c == '\0' )
|
||||
break;
|
||||
d = u8g_DrawGlyph180(u8g, x, y, c);
|
||||
x -= d;
|
||||
t += d;
|
||||
s++;
|
||||
|
@ -936,12 +944,16 @@ u8g_uint_t u8g_DrawStr270P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm
|
|||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
uint8_t c;
|
||||
|
||||
x += u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
for(;;)
|
||||
{
|
||||
d = u8g_DrawGlyph270(u8g, x, y, u8g_pgm_read(s));
|
||||
c = u8g_pgm_read(s);
|
||||
if ( c == '\0' )
|
||||
break;
|
||||
d = u8g_DrawGlyph270(u8g, x, y, c);
|
||||
y -= d;
|
||||
t += d;
|
||||
s++;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
|
||||
u8g_line.h
|
||||
u8g_line.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
|
@ -65,6 +65,15 @@ void u8g_DrawLine(u8g_t *u8g, u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_u
|
|||
err = dx >> 1;
|
||||
if ( y2 > y1 ) ystep = 1; else ystep = -1;
|
||||
y = y1;
|
||||
|
||||
#ifndef U8G_16BIT
|
||||
if ( x2 == 255 )
|
||||
x2--;
|
||||
#else
|
||||
if ( x2 == 0xffff )
|
||||
x2--;
|
||||
#endif
|
||||
|
||||
for( x = x1; x <= x2; x++ )
|
||||
{
|
||||
if ( swapxy == 0 )
|
||||
|
|
|
@ -425,6 +425,16 @@ void u8g_Draw4TPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_
|
|||
u8g_Draw4TPixelLL(u8g, u8g->dev, x, y, dir, pixel);
|
||||
}
|
||||
|
||||
void u8g_Draw8ColorPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t colpixel)
|
||||
{
|
||||
u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
|
||||
arg->x = x;
|
||||
arg->y = y;
|
||||
arg->dir = 0;
|
||||
arg->pixel = 0x80;
|
||||
arg->color = colpixel;
|
||||
u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SET_8PIXEL, arg);
|
||||
}
|
||||
|
||||
/* u8g_IsBBXIntersection() has been moved to u8g_clip.c */
|
||||
#ifdef OBSOLETE_CODE
|
||||
|
@ -522,9 +532,8 @@ uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g)
|
|||
return 255; /* white */
|
||||
else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
|
||||
return 3; /* max intensity */
|
||||
else /* if ( u8g.getMode() == U8G_MODE_BW ) */
|
||||
return 1; /* pixel on */
|
||||
return 1;
|
||||
/* if ( u8g.getMode() == U8G_MODE_BW ) */
|
||||
return 1; /* pixel on */
|
||||
}
|
||||
|
||||
void u8g_SetDefaultForegroundColor(u8g_t *u8g)
|
||||
|
@ -556,11 +565,10 @@ uint8_t u8g_GetDefaultMidColor(u8g_t *u8g)
|
|||
mode = u8g_GetMode(u8g);
|
||||
if ( mode == U8G_MODE_R3G3B2 )
|
||||
return 0x06d; /* gray: 01101101 */
|
||||
else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
|
||||
else if ( mode == U8G_MODE_GRAY2BIT )
|
||||
return 1; /* low mid intensity */
|
||||
else /* if ( u8g.getMode() == U8G_MODE_BW ) */
|
||||
return 1; /* pixel on */
|
||||
return 1; /* default */
|
||||
/* if ( u8g.getMode() == U8G_MODE_BW ) */
|
||||
return 1; /* pixel on */
|
||||
}
|
||||
|
||||
void u8g_SetDefaultMidColor(u8g_t *u8g)
|
||||
|
|
|
@ -306,26 +306,26 @@ void pg_DrawPolygon(pg_struct *pg, u8g_t *u8g)
|
|||
pg_exec(pg, u8g);
|
||||
}
|
||||
|
||||
//pg_struct u8g_pg;
|
||||
pg_struct u8g_pg;
|
||||
|
||||
void u8g_ClearPolygonXY(u8g_t *u8g)
|
||||
void u8g_ClearPolygonXY(void)
|
||||
{
|
||||
pg_ClearPolygonXY(&(u8g->pg));
|
||||
pg_ClearPolygonXY(&u8g_pg);
|
||||
}
|
||||
|
||||
void u8g_AddPolygonXY(u8g_t *u8g, int16_t x, int16_t y)
|
||||
{
|
||||
pg_AddPolygonXY(&(u8g->pg), u8g, x, y);
|
||||
pg_AddPolygonXY(&u8g_pg, u8g, x, y);
|
||||
}
|
||||
|
||||
void u8g_DrawPolygon(u8g_t *u8g)
|
||||
{
|
||||
pg_DrawPolygon(&(u8g->pg), u8g);
|
||||
pg_DrawPolygon(&u8g_pg, u8g);
|
||||
}
|
||||
|
||||
void u8g_DrawTriangle(u8g_t *u8g, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2)
|
||||
{
|
||||
u8g_ClearPolygonXY(u8g);
|
||||
u8g_ClearPolygonXY();
|
||||
u8g_AddPolygonXY(u8g, x0, y0);
|
||||
u8g_AddPolygonXY(u8g, x1, y1);
|
||||
u8g_AddPolygonXY(u8g, x2, y2);
|
||||
|
|
|
@ -81,7 +81,6 @@ uint8_t u8g_dev_vs_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
|||
return 0;
|
||||
return u8g_call_dev_fn(u8g_vs_list[u8g_vs_current].u8g, u8g_vs_list[u8g_vs_current].u8g->dev, U8G_DEV_MSG_PAGE_FIRST, arg);
|
||||
}
|
||||
return 0;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = u8g_vs_width;
|
||||
break;
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
-- ***************************************************************************
|
||||
-- Bitmaps Test
|
||||
--
|
||||
-- This script executes the bitmap features of u8glib to test their Lua
|
||||
-- integration.
|
||||
--
|
||||
-- Note: It is prepared for SSD1306-based displays. Select your connectivity
|
||||
-- type by calling either init_i2c_display() or init_spi_display() at
|
||||
-- the bottom of this file.
|
||||
--
|
||||
-- ***************************************************************************
|
||||
|
||||
-- setup I2c and connect display
|
||||
function init_i2c_display()
|
||||
|
@ -20,7 +31,7 @@ function init_spi_display()
|
|||
local res = 0 -- GPIO16
|
||||
|
||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||
disp = u8g.ssd1306_128x64_spi(cs, dc, res)
|
||||
disp = u8g.ssd1306_128x64_hw_spi(cs, dc, res)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
-- ***************************************************************************
|
||||
-- Graphics Test
|
||||
--
|
||||
-- This script executes several features of u8glib to test their Lua bindings.
|
||||
--
|
||||
-- Note: It is prepared for SSD1306-based displays. Select your connectivity
|
||||
-- type by calling either init_i2c_display() or init_spi_display() at
|
||||
-- the bottom of this file.
|
||||
--
|
||||
-- ***************************************************************************
|
||||
|
||||
-- setup I2c and connect display
|
||||
function init_i2c_display()
|
||||
|
@ -20,7 +30,7 @@ function init_spi_display()
|
|||
local res = 0 -- GPIO16
|
||||
|
||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||
disp = u8g.ssd1306_128x64_spi(cs, dc, res)
|
||||
disp = u8g.ssd1306_128x64_hw_spi(cs, dc, res)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
-- ***************************************************************************
|
||||
-- Rotation Test
|
||||
--
|
||||
-- This script executes the rotation features of u8glib to test their Lua
|
||||
-- integration.
|
||||
--
|
||||
-- Note: It is prepared for SSD1306-based displays. Select your connectivity
|
||||
-- type by calling either init_i2c_display() or init_spi_display() at
|
||||
-- the bottom of this file.
|
||||
--
|
||||
-- ***************************************************************************
|
||||
|
||||
-- setup I2c and connect display
|
||||
function init_i2c_display()
|
||||
|
@ -20,7 +31,7 @@ function init_spi_display()
|
|||
local res = 0 -- GPIO16
|
||||
|
||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||
disp = u8g.ssd1306_128x64_spi(cs, dc, res)
|
||||
disp = u8g.ssd1306_128x64_hw_spi(cs, dc, res)
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue