Added more high-level bindings
This commit is contained in:
parent
bda4affe9b
commit
5d0c458056
49
README.md
49
README.md
|
@ -73,18 +73,22 @@ void sendCommand(LCDScreen* screen, uint8_t command);
|
|||
```
|
||||
Sends a command to the LCD screen. If a command takes parameters, you can supply them by bitwise ORing them with the command name:
|
||||
|
||||
* `SCREEN_CLEAR` clears the display. Use `clearScreen()` instead (WIP).
|
||||
* `SCREEN_CLEAR` clears the display. Use `clearScreen()` instead.
|
||||
|
||||
* `CURSOR_RETURN` sets the cursor to (0, 0). Use `cursorReturn()` instead (WIP).
|
||||
* `CURSOR_RETURN` sets the cursor to (0, 0). Use `cursorReturn()` instead.
|
||||
|
||||
* `INPUT_SET` sets the writing direction. Use `setWritingDirection()` instead (WIP).
|
||||
* `INPUT_SET` sets the writing direction. Use `setWritingDirection()` instead.
|
||||
* Either `LEFT_TO_RIGHT` or `RIGHT_TO_LEFT`
|
||||
|
||||
* `DISPLAY_SWITCH` can turn the display on/off and change the cursor style
|
||||
* `DISPLAY_SWITCH` can turn the display on/off and change the cursor style. Use `setDisplaySettings()` instead.
|
||||
* `DISPLAY_ON` / `DISPLAY_OFF`
|
||||
* `CURSOR_ON` / `CURSOR_OFF`
|
||||
* `CURSOR_BLINK` / `CURSOR_STATIC`
|
||||
|
||||
* `SHIFT` shifts either the cursor or the entire display. Use `shiftCursor()` or `shiftScreen()` instead.
|
||||
* `DISPLAY_SHIFT` / `CURSOR_SHIFT`
|
||||
* `RIGHT_SHIFT` / `LEFT_SHIFT`
|
||||
|
||||
* `FUNCTION_SET` if you're using this you're using this library wrong
|
||||
|
||||
***
|
||||
|
@ -111,6 +115,41 @@ This function sends a variable number of characters to the screen. Use `sendText
|
|||
***
|
||||
|
||||
```c
|
||||
void setCursor(LCDScreen* screen, uint8_t x, uint8_t y);
|
||||
void clearScreen(LCDScreen* screen);
|
||||
```
|
||||
This function clears the screen
|
||||
|
||||
***
|
||||
|
||||
```c
|
||||
void returnCursor(LCDScreen* screen);
|
||||
```
|
||||
This function sets the cursor position to (0, 0)
|
||||
|
||||
***
|
||||
|
||||
```c
|
||||
void setWritingDirection(LCDScreen* screen, direction);
|
||||
```
|
||||
This function sets the writing direction of the display. Can either be `LEFT_TO_RIGHT` or `RIGHT_TO_LEFT`.
|
||||
|
||||
***
|
||||
|
||||
```c
|
||||
void shiftCursor(LCDScreen* screen, direction);
|
||||
```
|
||||
This function shifts the cursor in the specified direction. `RIGHT_SHIFT` or `LEFT_SHIFT`.
|
||||
|
||||
***
|
||||
|
||||
```c
|
||||
void shiftScreen(LCDScreen* screen, direction);
|
||||
```
|
||||
This function shifts the entire screen in the specified direction. `RIGHT_SHIFT` or `LEFT_SHIFT`.
|
||||
|
||||
***
|
||||
|
||||
```c
|
||||
void setCursor(LCDScreen* screen, x, y);
|
||||
```
|
||||
This function sets the cursor position on the display.
|
||||
|
|
|
@ -9,6 +9,10 @@ int main(void)
|
|||
sendText(&screen, "スウェーデン");
|
||||
setCursor(&screen, 0, 1);
|
||||
sendText(&screen, "オーストラリア");
|
||||
shiftScreen(&screen, RIGHT_SHIFT);
|
||||
shiftScreen(&screen, RIGHT_SHIFT);
|
||||
shiftScreen(&screen, RIGHT_SHIFT);
|
||||
setDisplaySettings(&screen, DISPLAY_ON, CURSOR_OFF, CURSOR_STATIC);
|
||||
resetPins(&screen);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -244,8 +244,3 @@ void sendChars(LCDScreen* screen, size_t len, ...)
|
|||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void setCursor(LCDScreen* screen, uint8_t x, uint8_t y)
|
||||
{
|
||||
sendCommand(screen, DDRAM_AD_SET | (y << 6) | x);
|
||||
}
|
|
@ -151,6 +151,12 @@ extern void sendData(LCDScreen* screen, uint8_t data);
|
|||
extern void sendText(LCDScreen* screen, const char* text);
|
||||
extern void sendChars(LCDScreen* screen, unsigned int len, ...);
|
||||
|
||||
extern void setCursor(LCDScreen* screen, uint8_t x, uint8_t y);
|
||||
#define clearScreen(screen) sendCommand(screen, SCREEN_CLEAR)
|
||||
#define returnCursor(screen) sendCommand(screen, CURSOR_RETURN)
|
||||
#define setWritingDirection(screen, direction) sendCommand(screen, INPUT_SET | direction)
|
||||
#define setDisplaySettings(screen, display, cursor_shown, cursor_behaviour) sendCommand(screen, DISPLAY_SWITCH | display | cursor_shown | cursor_behaviour)
|
||||
#define shiftCursor(screen, direction) sendCommand(screen, SHIFT | CURSOR_SHIFT | direction)
|
||||
#define shiftScreen(screen, direction) sendCommand(screen, SHIFT | DISPLAY_SHIFT | direction)
|
||||
#define setCursor(screen, x, y) sendCommand(screen, DDRAM_AD_SET | (y << 6) | x)
|
||||
|
||||
#endif // RASPBERRY_LCD_H
|
Loading…
Reference in a new issue