Skip to content

Commit

Permalink
2.24.3
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed Oct 28, 2018
1 parent 7a9c4fc commit e749fc3
Show file tree
Hide file tree
Showing 20 changed files with 687 additions and 229 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Description: https://github.com/olikraus/u8g2/wiki

Issue Tracker: https://github.com/olikraus/u8g2/issues

Download (2.24.2): https://github.com/olikraus/U8g2_Arduino/archive/master.zip
Download (2.24.3): https://github.com/olikraus/U8g2_Arduino/archive/master.zip

282 changes: 282 additions & 0 deletions examples/page_buffer/ClipWindow/ClipWindow.ino

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions examples/page_buffer/FPS/FPS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@
U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI Uno Clip=2.7 Box=2.9 @=1.8 Pix=2.2 issue 586, before optimization
U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI Uno Clip=23.4 Box=40.8 @=4.4 Pix=8.1 issue 586, after optimization
28 Oct 2018, Arduino 1.8.4, 8 Bit Mode
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI Uno Clip=34.0 Box=88.4 @=4.5 Pix=8.2 issue 364, clip window
U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C Uno Clip=28.4 Box=39.2 @=10.0 Pix=14.9 I2C default
U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C Uno Clip=32.9 Box=48.3 @=10.5 Pix=16.1 I2C default, u8g2.setBusClock(600000UL)
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI Uno Clip=33.9 Box=88.2 @=4.5 Pix=8.2 SPI default speed
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI Uno Clip=32.8 Box=80.6 @=4.5 Pix=8.2 SPI default speed u8g2.setBusClock(6000000UL);
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI Uno Clip=33.9 Box=88.2 @=4.5 Pix=8.2 SPI default speed u8g2.setBusClock(9000000UL);
*/


Expand Down
22 changes: 20 additions & 2 deletions examples/page_buffer/HelloWorld/HelloWorld.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,25 @@
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.
27 Oct 2018:
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2
make -f Makefile.184.uno
text
8732 default, all active
8500 -232 -2.65% no U8G2_WITH_CLIP_WINDOW_SUPPORT
8316 -416 -4.76% no U8G2_WITH_FONT_ROTATION
8606 -126 -1.44% no U8G2_WITH_UNICODE
8692 -40 -0.45% no U8G2_WITH_INTERSECTION
8328 -404 -4.62% no U8G2_WITH_INTERSECTION no U8G2_WITH_CLIP_WINDOW_SUPPORT
8718 -14 -4.86% no U8G2_WITH_HVLINE_SPEED_OPTIMIZATION
8026 -706 -8.08% no U8G2_WITH_FONT_ROTATION no U8G2_WITH_INTERSECTION no U8G2_WITH_CLIP_WINDOW_SUPPORT
Some flags depend on each other: `U8G2_WITH_INTERSECTION` is required for `U8G2_WITH_CLIP_WINDOW_SUPPORT`, so `U8G2_WITH_INTERSECTION` is partly active as long
as `U8G2_WITH_CLIP_WINDOW_SUPPORT` is requested.
*/

#include <Arduino.h>
Expand Down Expand Up @@ -60,7 +78,7 @@
//U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing
//U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition)
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
//U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the "every 2nd line skipped" problem
Expand Down
4 changes: 2 additions & 2 deletions examples/page_buffer/Shennong/Shennong.ino
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
// To read the short story with all glyphs you need at least a font with _gb2312b postfix
// However, a font with _gb2312b postfix is very large and will not always fit on
// the target controller. For testing you can use _chinese1 extenstion, but then
// many gylphs are skipped.
// many gylphs are skipped and not visible.
//
// wqy fonts are available in different sizes, here are only wqy12, wqy14 and wqy16 listed

Expand Down Expand Up @@ -392,7 +392,7 @@ void setup(void) {

/* select a font */

u8g2.setFont(u8g2_font_wqy12_t_chinese1); // two unknown glyphs
// u8g2.setFont(u8g2_font_wqy12_t_chinese1); // two unknown glyphs
//u8g2.setFont(u8g2_font_wqy12_t_chinese3); // two unknown glyphs

//u8g2.setFont(u8g2_font_wqy12_t_gb2312a); // ";" is missing
Expand Down
7 changes: 6 additions & 1 deletion extras/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ https://github.com/olikraus/u8g2 ChangeLog
* Added contributed 7-segment font, https://github.com/olikraus/u8g2/wiki/fntgrpu8g#7segments_26x42 (issue 634)
* Added several fonts from fontstruct.com, https://github.com/olikraus/u8g2/wiki/fntgrpfontstruct (issue 687)#
This also includes several outline fonts.

2018-10-28 v2.24.3 [email protected]
* Added clip window support (issue 364)
* Added setBusClock() proc to change the I2C/SPI bus clock speed (Arduino only, issue 705)
* Added sleep mode for ST7920 (issue 245)
* Added support for SSD0323 (issue 720)



2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=U8g2
version=2.24.2
version=2.24.3
author=oliver <[email protected]>
maintainer=oliver <[email protected]>
sentence=Monochrome LCD, OLED and eInk Library. Display controller: SSD1305, SSD1306, SSD1309, SSD1322, SSD1325, SSD1327, SSD1329, SSD1606, SSD1607, SH1106, SH1107, SH1108, SH1122, T6963, RA8835, LC7981, PCD8544, PCF8812, HX1230, UC1601, UC1604, UC1608, UC1610, UC1611, UC1701, ST7565, ST7567, ST7588, ST75256, NT7534, IST3020, ST7920, LD7032, KS0108, SED1520, SBN1661, IL3820, MAX7219. Interfaces: I2C, SPI, Parallel.
Expand Down
9 changes: 9 additions & 0 deletions src/U8g2lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class U8G2 : public Print
u8x8_t *getU8x8(void) { return u8g2_GetU8x8(&u8g2); }
u8g2_t *getU8g2(void) { return &u8g2; }

uint32_t getBusClock(void) { return u8g2_GetU8x8(&u8g2)->bus_clock; }
void setBusClock(uint32_t clock_speed) { u8g2_GetU8x8(&u8g2)->bus_clock = clock_speed; }

void setI2CAddress(uint8_t adr) { u8g2_SetI2CAddress(&u8g2, adr); }


Expand Down Expand Up @@ -144,6 +147,12 @@ class U8G2 : public Print

/* u8g2 */

#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
void setMaxClipWindow(void) { u8g2_SetMaxClipWindow(&u8g2); }
void setClipWindow(u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1) {
u8g2_SetClipWindow(&u8g2, clip_x0, clip_y0, clip_x1, clip_y1 ); }
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */


u8g2_uint_t getDisplayHeight(void) { return u8g2_GetDisplayHeight(&u8g2); }
u8g2_uint_t getDisplayWidth(void) { return u8g2_GetDisplayWidth(&u8g2); }
Expand Down
18 changes: 8 additions & 10 deletions src/U8x8lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t a

break;
case U8X8_MSG_BYTE_INIT:
u8x8->bus_clock = u8x8->display_info->sck_clock_hz;
/* disable chipselect */
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);

Expand Down Expand Up @@ -608,7 +609,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t a
}

#if ARDUINO >= 10600
SPI.beginTransaction(SPISettings(u8x8->display_info->sck_clock_hz, MSBFIRST, internal_spi_mode));
SPI.beginTransaction(SPISettings(u8x8->bus_clock, MSBFIRST, internal_spi_mode));
#else
SPI.begin();

Expand Down Expand Up @@ -674,6 +675,7 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_spi(U8X8_UNUSED u8x8_t *u8x8, U8X8_U

break;
case U8X8_MSG_BYTE_INIT:
u8x8->bus_clock = u8x8->display_info->sck_clock_hz;
/* disable chipselect */
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
/* no wait required here */
Expand Down Expand Up @@ -704,7 +706,7 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_spi(U8X8_UNUSED u8x8_t *u8x8, U8X8_U
}

#if ARDUINO >= 10600
SPI1.beginTransaction(SPISettings(u8x8->display_info->sck_clock_hz, MSBFIRST, internal_spi_mode));
SPI1.beginTransaction(SPISettings(u8x8->bus_clock, MSBFIRST, internal_spi_mode));
#else
SPI1.begin();

Expand Down Expand Up @@ -975,6 +977,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSE
Wire.write((uint8_t *)arg_ptr, (int)arg_int);
break;
case U8X8_MSG_BYTE_INIT:
u8x8->bus_clock = u8x8->display_info->i2c_bus_clock_100kHz * 100000UL;
#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP8266) || defined(ESP_PLATFORM) || defined(ARDUINO_ARCH_ESP32)
/* for ESP8266/ESP32, Wire.begin has two more arguments: clock and data */
if ( u8x8->pins[U8X8_PIN_I2C_CLOCK] != U8X8_PIN_NONE && u8x8->pins[U8X8_PIN_I2C_DATA] != U8X8_PIN_NONE )
Expand All @@ -996,10 +999,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSE
#if ARDUINO >= 10600
/* not sure when the setClock function was introduced, but it is there since 1.6.0 */
/* if there is any error with Wire.setClock() just remove this function call */
if ( u8x8->display_info->i2c_bus_clock_100kHz >= 4 )
{
Wire.setClock(400000L);
}
Wire.setClock(u8x8->bus_clock);
#endif
Wire.beginTransmission(u8x8_GetI2CAddress(u8x8)>>1);
break;
Expand All @@ -1022,6 +1022,7 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_U
Wire1.write((uint8_t *)arg_ptr, (int)arg_int);
break;
case U8X8_MSG_BYTE_INIT:
u8x8->bus_clock = u8x8->display_info->i2c_bus_clock_100kHz * 100000UL;
Wire1.begin();
break;
case U8X8_MSG_BYTE_SET_DC:
Expand All @@ -1030,10 +1031,7 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_U
#if ARDUINO >= 10600
/* not sure when the setClock function was introduced, but it is there since 1.6.0 */
/* if there is any error with Wire.setClock() just remove this function call */
if ( u8x8->display_info->i2c_bus_clock_100kHz >= 4 )
{
Wire1.setClock(400000L);
}
Wire1.setClock(u8x8->bus_clock);
#endif
Wire1.beginTransmission(u8x8_GetI2CAddress(u8x8)>>1);
break;
Expand Down
5 changes: 4 additions & 1 deletion src/U8x8lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@ class U8X8 : public Print
public:
uint8_t tx, ty;

U8X8(void) { home(); }
U8X8(void) { home(); }
u8x8_t *getU8x8(void) { return &u8x8; }

uint32_t getBusClock(void) { return u8x8.bus_clock; }
void setBusClock(uint32_t clock_speed) { u8x8.bus_clock = clock_speed; }

void setI2CAddress(uint8_t adr) { u8x8_SetI2CAddress(&u8x8, adr); }

uint8_t getCols(void) { return u8x8_GetCols(&u8x8); }
Expand Down
88 changes: 41 additions & 47 deletions src/clib/u8g2.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,14 @@
//#define U8G2_16BIT


/*
The following macro enables a special check and optimization
in the HVLine procedure for lines with one pixel length.
It enabled, it will consume about 60 bytes in flash memory of the AVR and
there will be a speed improvement of about 20% for any single pixel draw.
*/
#define U8G2_WITH_ONE_PIXEL_OPTIMIZATION

/* U8g2 feature selection, see also https://github.com/olikraus/u8g2/wiki/u8g2optimization */

/*
The following macro enables the HVLine speed optimization.
It will consume about 40 bytes more in flash memory of the AVR.
HVLine procedures are also used by the text drawing functions.
*/
#define U8G2_HVLINE_SPEED_OPTIMIZATION

/*
The following macro enables all four drawing directions for glyphs and strings.
If this macro is not defined, than a string can be drawn only in horizontal direction.
*/
#define U8G2_WITH_FONT_ROTATION
#define U8G2_WITH_HVLINE_SPEED_OPTIMIZATION

/*
The following macro activates the early intersection check with the current visible area.
Expand All @@ -103,6 +90,22 @@
*/
#define U8G2_WITH_INTERSECTION


/*
Enable clip window support:
void u8g2_SetMaxClipWindow(u8g2_t *u8g2)
void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1 )
Setting a clip window will restrict all drawing to this window.
Clip window support requires about 200 bytes flash memory on AVR systems
*/
#define U8G2_WITH_CLIP_WINDOW_SUPPORT

/*
The following macro enables all four drawing directions for glyphs and strings.
If this macro is not defined, than a string can be drawn only in horizontal direction.
*/
#define U8G2_WITH_FONT_ROTATION

/*
U8glib V2 contains support for unicode plane 0 (Basic Multilingual Plane, BMP).
The following macro activates this support. Deactivation would save some ROM.
Expand Down Expand Up @@ -130,24 +133,6 @@
#define U8G2_WITH_UNICODE


/*
Internal performance test for the effect of enabling U8G2_WITH_INTERSECTION
Should not be defined for production code
*/
//#define U8G2_WITH_HVLINE_COUNT

/*
Defining the following variable adds the clipping and check procedures agains the display boundaries.
Clipping procedures are mandatory for the picture loop (u8g2_FirstPage/NextPage).
Clipping procedures will also allow strings to exceed the display boundaries.
On the other side, without clipping, all the setting of pixels must happen within the display boundaries.
WARNING: Adding a comment in front of the following macro or removing the following line
may lead to memory faults if you write any pixel outside the display boundary.
*/
#define U8G2_WITH_CLIPPING




/*==========================================*/
Expand Down Expand Up @@ -194,6 +179,7 @@ typedef struct u8g2_struct u8g2_t;
typedef struct u8g2_cb_struct u8g2_cb_t;

typedef void (*u8g2_update_dimension_cb)(u8g2_t *u8g2);
typedef void (*u8g2_update_page_win_cb)(u8g2_t *u8g2);
typedef void (*u8g2_draw_l90_cb)(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);
typedef void (*u8g2_draw_ll_hvline_cb)(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);

Expand Down Expand Up @@ -276,7 +262,8 @@ typedef struct _u8g2_kerning_t u8g2_kerning_t;

struct u8g2_cb_struct
{
u8g2_update_dimension_cb update;
u8g2_update_dimension_cb update_dimension;
u8g2_update_page_win_cb update_page_win;
u8g2_draw_l90_cb draw_l90;
};

Expand All @@ -300,24 +287,33 @@ struct u8g2_struct
u8g2_uint_t pixel_curr_row; /* u8g2.tile_curr_row*8 */

/* the following variables are set by the update dimension callback */
/* this is clipbox after rotation for the hvline procedures */
/* this is the clipbox after rotation for the hvline procedures */
//u8g2_uint_t buf_x0; /* left corner of the buffer */
//u8g2_uint_t buf_x1; /* right corner of the buffer (excluded) */
u8g2_uint_t buf_y0;
u8g2_uint_t buf_y1;

/* display dimensions in pixel for the user, calculated in u8g2_update_dimension_common(), used in u8g2_draw_hv_line_2dir() */
/* display dimensions in pixel for the user, calculated in u8g2_update_dimension_common() */
u8g2_uint_t width;
u8g2_uint_t height;

/* ths is the clip box for the user to check if a specific box has an intersection */
/* use u8g2_IsIntersection from u8g2_intersection.c to test against this intersection */
/* boundary values are part of the box so that they can be used with u8g2_IsIntersection */
/* actually, this window describes the positon of the current page */
u8g2_uint_t user_x0; /* left corner of the buffer */
u8g2_uint_t user_x1; /* right corner of the buffer (excluded) */
u8g2_uint_t user_y0; /* upper edge of the buffer */
u8g2_uint_t user_y1; /* lower edge of the buffer (excluded) */

#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
/* clip window */
u8g2_uint_t clip_x0; /* left corner of the clip window */
u8g2_uint_t clip_x1; /* right corner of the clip window (excluded) */
u8g2_uint_t clip_y0; /* upper edge of the clip window */
u8g2_uint_t clip_y1; /* lower edge of the clip window (excluded) */
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */


/* information about the current font */
const uint8_t *font; /* current font for all text procedures */
// removed: const u8g2_kerning_t *kerning; /* can be NULL */
Expand All @@ -327,6 +323,11 @@ struct u8g2_struct
u8g2_font_decode_t font_decode; /* new font decode structure */
u8g2_font_info_t font_info; /* new font info structure */

#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
/* 1 of there is an intersection between user_?? and clip_?? box */
uint8_t is_page_clip_window_intersection;
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */

uint8_t font_height_mode;
int8_t font_ref_ascent;
int8_t font_ref_descent;
Expand All @@ -341,16 +342,6 @@ struct u8g2_struct
// the following variable should be renamed to is_buffer_auto_clear
uint8_t is_auto_page_clear; /* set to 0 to disable automatic clear of the buffer in firstPage() and nextPage() */

#ifdef U8G2_WITH_HVLINE_COUNT
unsigned long hv_cnt;
#endif /* U8G2_WITH_HVLINE_COUNT */

// removed, there is now the new index table
//#ifdef __unix__
// uint16_t last_unicode;
// const uint8_t *last_font_data;
//#endif

};

#define u8g2_GetU8x8(u8g2) ((u8x8_t *)(u8g2))
Expand Down Expand Up @@ -419,6 +410,9 @@ extern const u8g2_cb_t u8g2_cb_mirror;
*/

void u8g2_SetMaxClipWindow(u8g2_t *u8g2);
void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1 );

void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_draw_ll_hvline_cb ll_hvline_cb, const u8g2_cb_t *u8g2_cb);
void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);

Expand Down
3 changes: 2 additions & 1 deletion src/clib/u8g2_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ void u8g2_SendBuffer(u8g2_t *u8g2)
void u8g2_SetBufferCurrTileRow(u8g2_t *u8g2, uint8_t row)
{
u8g2->tile_curr_row = row;
u8g2->cb->update(u8g2);
u8g2->cb->update_dimension(u8g2);
u8g2->cb->update_page_win(u8g2);
}

void u8g2_FirstPage(u8g2_t *u8g2)
Expand Down
Loading

0 comments on commit e749fc3

Please sign in to comment.