libpifacecad
v0.1.0
A simple static C library for controlling PiFace Control and Display.
|
A simple static library for controlling PiFace Control and Display. More...
#include <stdint.h>
Go to the source code of this file.
A simple static library for controlling PiFace Control and Display.
Copyright (C) 2013 Thomas Preston thoma s.pr eston @ope nlx.o rg.u k
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
uint8_t address2col | ( | uint8_t | address | ) |
Returns a column calculated from an address.
Example:
uint8_t col = address2col(42); // col=2
uint8_t address2row | ( | uint8_t | address | ) |
Returns a row calculated from an address.
Example:
uint8_t row = address2col(42); // row=1
uint8_t colrow2address | ( | uint8_t | col, |
uint8_t | row | ||
) |
Returns an address calculated from a column and a row.
Example:
uint8_t address = colrow2address(5, 1);
void pifacecad_close | ( | void | ) |
Closes a PiFace Control and Display (turns off interrupts, closes file descriptor).
Example:
pifacecad_close();
void pifacecad_lcd_autoscroll_off | ( | void | ) |
The screen will not follow text if it moves out of view.
Example:
pifacecad_lcd_autoscroll_off();
void pifacecad_lcd_autoscroll_on | ( | void | ) |
The screen will follow text if it moves out of view.
Example:
pifacecad_lcd_autoscroll_on();
void pifacecad_lcd_backlight_off | ( | void | ) |
Turns the backlight off.
Example:
pifacecad_lcd_display_off();
void pifacecad_lcd_backlight_on | ( | void | ) |
Turns the backlight on.
Example:
pifacecad_lcd_display_on();
void pifacecad_lcd_blink_off | ( | void | ) |
Turns the blink off.
Example:
pifacecad_lcd_display_off();
void pifacecad_lcd_blink_on | ( | void | ) |
Turns the blink on.
Example:
pifacecad_lcd_display_on();
void pifacecad_lcd_clear | ( | void | ) |
Clears the screen and returns the cursor to home (0, 0).
Example:
pifacecad_lcd_clear();
void pifacecad_lcd_cursor_off | ( | void | ) |
Turns the cursor off.
Example:
pifacecad_lcd_display_off();
void pifacecad_lcd_cursor_on | ( | void | ) |
Turns the cursor on.
Example:
pifacecad_lcd_display_on();
void pifacecad_lcd_display_off | ( | void | ) |
Turns the display off.
Example:
pifacecad_lcd_display_off();
void pifacecad_lcd_display_on | ( | void | ) |
Turns the display on.
Example:
pifacecad_lcd_display_on();
uint8_t pifacecad_lcd_get_cursor_address | ( | void | ) |
Returns the cursor position (address).
Example:
uint8_t cursor_addr = pifacecad_lcd_get_cursor_address();
void pifacecad_lcd_home | ( | void | ) |
Returns the cursor to home (0, 0).
Example:
pifacecad_lcd_home();
void pifacecad_lcd_init | ( | void | ) |
Initialised the LCD. You will not need to call this if you have called pifacecad_open.
Example:
pifacecad_lcd_init();
void pifacecad_lcd_left_to_right | ( | void | ) |
The cursor will move to the right after printing causing text to read left to right.
Example:
pifacecad_lcd_left_to_right();
void pifacecad_lcd_move_left | ( | void | ) |
Moves the display left.
Example:
pifacecad_lcd_move_left();
void pifacecad_lcd_move_right | ( | void | ) |
Moves the display right.
Example:
pifacecad_lcd_move_right();
void pifacecad_lcd_pulse_enable | ( | void | ) |
Pulse the enable pin on the HD44780.
Example:
pifacecad_lcd_set_backlight(1);
void pifacecad_lcd_right_to_left | ( | void | ) |
The cursor will move to the left after printing causing text to read right to left.
Example:
pifacecad_lcd_right_to_left();
void pifacecad_lcd_send_byte | ( | uint8_t | byte | ) |
Send a byte to the HD44780.
Example:
pifacecad_lcd_send_byte(0xaa);
void pifacecad_lcd_send_command | ( | uint8_t | command | ) |
Send a command to the HD44780.
Example:
pifacecad_lcd_send_command(LCD_CLEARDISPLAY);
void pifacecad_lcd_send_data | ( | uint8_t | data | ) |
Send data to the HD44780.
Example:
pifacecad_lcd_send_data('a');
void pifacecad_lcd_set_backlight | ( | uint8_t | state | ) |
Set the backlight pin on the HD44780.
Example:
pifacecad_lcd_set_backlight(1);
uint8_t pifacecad_lcd_set_cursor | ( | uint8_t | col, |
uint8_t | row | ||
) |
Sets the cursor position on the screen (col , row).
Example:
pifacecad_lcd_set_cursor(5, 1);
void pifacecad_lcd_set_cursor_address | ( | uint8_t | address | ) |
Sets the cursor position on the screen (address = col + row*40).
Example:
pifacecad_lcd_set_cursor(41); // col=1, row=40
void pifacecad_lcd_set_enable | ( | uint8_t | state | ) |
Set the enable pin on the HD44780.
Example:
pifacecad_lcd_set_enable(1);
void pifacecad_lcd_set_rs | ( | uint8_t | state | ) |
Set the RS pin on the HD44780.
Example:
pifacecad_lcd_set_rs(1);
void pifacecad_lcd_set_rw | ( | uint8_t | state | ) |
Set the RW pin on the HD44780.
Example:
pifacecad_lcd_set_rw(1);
void pifacecad_lcd_store_custom_bitmap | ( | uint8_t | location, |
uint8_t | bitmap[] | ||
) |
Stores a custom bitmap to the location specified (up to 8: 0-7).
Example:
uint8_t bitmap[] = {0x15, 0xa, 0x15, 0xa, 0x15, 0xa, 0x15, 0xa}; pifacecad_lcd_store_custom_bitmap(0, bitmap); // store pifacecad_lcd_write_custom_bitmap(0); // write
uint8_t pifacecad_lcd_write | ( | const char * | message | ) |
Writes a message to the LCD screen starting from the current cursor position. Accepts '\n'. Returns the current cursor address.
Example:
pifacecad_lcd_write("Hello, World!"); pifacecad_lcd_write("Moving to a\nnew line is easy"); uint8_t address = pifacecad_lcd_write("Cursor moves after\nwriting");
void pifacecad_lcd_write_custom_bitmap | ( | uint8_t | location | ) |
Writes the custom bitmap stored at the specified bank location to the display.
Example:
pifacecad_lcd_write_custom_bitmap(0);
int pifacecad_open | ( | void | ) |
Opens and initialises a PiFace Control and Display. Returns a file descriptor for making raw SPI transactions to the MCP23S17 (for advanced users only).
Example:
pifacecad_open(); int pifacedigital_fd = pifacecad_open(); // advanced
int pifacecad_open_noinit | ( | void | ) |
Opens a PiFace Control and Display without initialising it. Returns a file descriptor for making raw SPI transactions to the MCP23S17 (for advanced users only).
Example:
pifacecad_open_noinit(); int pifacedigital_fd = pifacecad_open_noinit(); // advanced
uint8_t pifacecad_read_switch | ( | uint8_t | switch_num | ) |
Reads a single switch.
Example (read switch 3):
uint8_t switch_value = pifacecad_read_switch(3);
uint8_t pifacecad_read_switches | ( | void | ) |
Reads the entire switch port.
Example:
uint8_t switch_bits = pifacecad_read_switches();