@@ -5,19 +5,67 @@ Derived from the Arduino LiquidCrystal library v1.8.0.
55
66
77
8+ ## API
9+
10+ This library is a singleton library, it is not possible to use more than one
11+ instance per sketch.
12+
13+ The API syntax is very similar to the original C++ syntax, thanks to some
14+ [ c preprocessor macro magic] ( macro.html ) .
15+
16+ Apart from the usual name mangeling for polymorph functions (mostly the
17+ different variants of the Print::print method) moving the opening bracket at
18+ the class declarator line and replacing the dots in the method names for
19+ underscores is all it needs.
20+
21+
22+ Arduino syntax |sduino syntax
23+ -------------------- |---------------------
24+ ` LiquidCrystal lcd(rs,en,d0,d1,d2,d3) ` |` LiquidCrystal (lcd,rs,en,d0,d1,d2,d3) `
25+ ` LiquidCrystal lcd(rs,rw,en,d0,d1,d2,d3) ` |` LiquidCrystal (lcd,rs,rw,en,d0,d1,d2,d3) `
26+ ` LiquidCrystal lcd(rs,en,d0,d1,d2,d3,d4,d5,d6,d7) ` |` LiquidCrystal (lcd,rs,en,d0,d1,d2,d3,d4,d5,d6,d7) `
27+ ` LiquidCrystal lcd(rs,rw,en,d0,d1,d2,d3,d4,d5,d6,d7) ` |` LiquidCrystal (lcd,rs,rw,en,d0,d1,d2,d3,d4,d5,d6,d7) `
28+ ` lcd.init(rs,rw,en,d0,d1,d2,d3,d4,d5,d6,d7) ` |` lcd_init(mode,rs,rw,en,d0,d1,d2,d3,d4,d5,d6,d7) `
29+ ` lcd.begin(cols,lines) ` |` lcd_begin(cols,lines) `
30+ ` lcd.begin(cols,lines,charsize) ` |` lcd_begin_charsize(cols,lines,charsize) `
31+ ` lcd.clear() ` |` lcd_clear() `
32+ ` lcd.home() ` |` lcd_home() `
33+ ` lcd.noDisplay() ` |` lcd_noDisplay() `
34+ ` lcd.display() ` |` lcd_display() `
35+ ` lcd.noBlink() ` |` lcd_noBlink() `
36+ ` lcd.blink() ` |` lcd_blink() `
37+ ` lcd.noCursor() ` |` lcd_noCursor() `
38+ ` lcd.cursor() ` |` lcd_cursor() `
39+ ` lcd.scrollDisplayLeft() ` |` lcd_scrollDisplayLeft() `
40+ ` lcd.scrollDisplayRight() ` |` lcd_scrollDisplayRight() `
41+ ` lcd.leftToRight() ` |` lcd_leftToRight() `
42+ ` lcd.rightToLeft() ` |` lcd_rightToLeft() `
43+ ` lcd.noAutoscroll() ` |` lcd_noAutoscroll() `
44+ ` lcd.autoscroll() ` |` lcd_autoscroll() `
45+ ` lcd.setRowOffsets(row0,row1,row2,row3) ` |` lcd_setRowOffsets(row0,row1,row2,row3) `
46+ ` lcd.createChar(number, data[]) ` |` lcd_createChar(number, data[]) `
47+ ` lcd.setCursor(col,row) ` |` lcd_setCursor(col,row) `
48+ ` result = lcd.write(value) ` |` result = lcd_write(value) `
49+ ` lcd.command(value) ` |` lcd_command(value) `
50+
51+ The LCD interface mode can be changed at run time by calling the
52+ ` lcd_init(...) ` function.
53+
54+
55+
856## Example
957
1058Output some Text and count the time since the last reset. Mind the
1159slightly different position of the opening parenthesis at the "class
12- constructor" function LiquidCrystal_4bit_r compared to the C++ instatiation.
60+ constructor" function LiquidCrystal compared to the C++ instatiation.
1361
1462``` c
1563#include < Arduino.h>
1664#include < LiquidCrystal.h>
1765
1866// initialize the library with the numbers of the interface pins
19- // The instance name "lcd" is _within_ the brackets
20- LiquidCrystal_4bit_r (lcd,PA1,PA2, PA3,PD2,PD3,PD4);
67+ // The instance name "lcd" is *within* the brackets
68+ LiquidCrystal (lcd,PA1,PA2, PA3,PD2,PD3,PD4);
2169
2270void setup() {
2371 lcd_begin(16, 2);
@@ -32,12 +80,12 @@ void loop() {
3280```
3381
3482
35- Original Arduino C++-Sytax:
83+ Compare it to the original Arduino C++-Sytax:
3684```c
3785#include <LiquidCrystal.h>
3886
3987// initialize the library with the numbers of the interface pins
40- // The instance name "lcd" is _before_ the brackets
88+ // The instance name "lcd" is *before* the brackets
4189LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
4290
4391void setup() {
@@ -53,56 +101,10 @@ void loop() {
53101
54102
55103
56- ## API
57-
58- This library is a singleton library, it is not possible to use more than one
59- instance per sketch.
60-
61- The API syntax is very similar to the original C++ syntax, thanks to some
62- [ c preprocessor macro magic] ( macro.html ) .
63- Apart from the usual name mangeling for polymorph functions replacing the
64- dots in the method names for underscores and a small modification of the
65- initializer code should be enough.
66-
67- The polymorph instantiation method is split into for different macros. Only
68- one can be used per sketch. The choice for one of them has to be made at
69- compile time. Changing the LCD mode at run time can be done by calling the
70- ` lcd_init(...) ` function.
71-
72-
73- Arduino syntax |sduino syntax
74- -------------------- |---------------------
75- ` LiquidCrystal lcd(rs,en,d0,d1,d2,d3) ` |` LiquidCrystal_4bit_r (lcd,rs,en,d0,d1,d2,d3) `
76- ` LiquidCrystal lcd(rs,rw,en,d0,d1,d2,d3) ` |` LiquidCrystal_4bit_rw (lcd,rs,rw,en,d0,d1,d2,d3) `
77- ` LiquidCrystal lcd(rs,en,d0,d1,d2,d3,d4,d5,d6,d7) ` |` LiquidCrystal_8bit_r (lcd,rs,en,d0,d1,d2,d3,d4,d5,d6,d7) `
78- ` LiquidCrystal lcd(rs,rw,en,d0,d1,d2,d3,d4,d5,d6,d7) ` |` LiquidCrystal_8bit_rw (lcd,rs,rw,en,d0,d1,d2,d3,d4,d5,d6,d7) `
79- ` lcd.init(rs,rw,en,d0,d1,d2,d3,d4,d5,d6,d7) ` |` lcd_init(mode,rs,rw,en,d0,d1,d2,d3,d4,d5,d6,d7) `
80- ` lcd.begin(cols,lines) ` |` lcd_begin(cols,lines) `
81- ` lcd.begin(cols,lines,charsize) ` |` lcd_begin_charsize(cols,lines,charsize) `
82- ` lcd.clear() ` |` lcd_clear() `
83- ` lcd.home() ` |` lcd_home() `
84- ` lcd.noDisplay() ` |` lcd_noDisplay() `
85- ` lcd.display() ` |` lcd_display() `
86- ` lcd.noBlink() ` |` lcd_noBlink() `
87- ` lcd.blink() ` |` lcd_blink() `
88- ` lcd.noCursor() ` |` lcd_noCursor() `
89- ` lcd.cursor() ` |` lcd_cursor() `
90- ` lcd.scrollDisplayLeft() ` |` lcd_scrollDisplayLeft() `
91- ` lcd.scrollDisplayRight() ` |` lcd_scrollDisplayRight() `
92- ` lcd.leftToRight() ` |` lcd_leftToRight() `
93- ` lcd.rightToLeft() ` |` lcd_rightToLeft() `
94- ` lcd.noAutoscroll() ` |` lcd_noAutoscroll() `
95- ` lcd.autoscroll() ` |` lcd_autoscroll() `
96- ` lcd.setRowOffsets(row0,row1,row2,row3) ` |` lcd_setRowOffsets(row0,row1,row2,row3) `
97- ` lcd.createChar(number, data[]) ` |` lcd_createChar(number, data[]) `
98- ` lcd.setCursor(col,row) ` |` lcd_setCursor(col,row) `
99- ` result = lcd.write(value) ` |` result = lcd_write(value) `
100- ` lcd.command(value) ` |` lcd_command(value) `
101-
102-
103-
104104## Possible improvements
105105
106+ This is not a to-do-list, just a collection of random thoughts.
107+
106108### Direct port access
107109As long as the pin numberings are known at compile time it would be possible
108110use direct port register access and the access pattern could be optimized if
0 commit comments