Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init() needlessly calls begin() #69

Open
iflyhigh opened this issue Apr 2, 2023 · 1 comment
Open

init() needlessly calls begin() #69

iflyhigh opened this issue Apr 2, 2023 · 1 comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@iflyhigh
Copy link

iflyhigh commented Apr 2, 2023

init() function for some reason calls begin(16, 1) without any good reason for doing so. init() is normally called from LiquidCrystal constructor and begin() needs to be called from user program before any other code. Current code actually performs double LCD initialization which appears to be harmless but unneeded/time consuming.

if (fourbitmode)
_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
else
_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
begin(16, 1);
}

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Apr 2, 2023
@6v6gt-duino
Copy link

This is also raised in issue #11 and issue #41 (currently both open)
It is not harmless because it causes a failure on some platforms.
It is generally incorrect to include, in the constructor, functions which depend on the Arduino run time system being ready, since the object instantiation happens long before that. The unwanted call of begin( 16, 1) has the effect of calling delayMicroseconds() from the constructor and the impact of that depends on the platform. On AVR, delayMicroseconds() falls through immediately if timer0 is not (yet) running so it may appear to work although useless because the timings for the initialisation sequence as specified in the HD44780 data sheet are ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants