Reference (PiFace CAD)¶
pifacecad.core¶
- class pifacecad.core.PiFaceCAD(hardware_addr=0, bus=0, chip_select=1, init_board=True)¶
A PiFace Control and Display board.
Attribute: switch_port – See pifacecommon.mcp23s17.MCP23S17RegisterNeg. Attribute: switches – list containing pifacecommon.mcp23s17.MCP23S17RegisterBitNeg. Attribute: lcd – See pifacecad.lcd.PiFaceLCD. Example:
>>> cad = pifacecad.PiFaceCAD() >>> hex(cad.switch_port.value) 0x02 >>> cad.switches[1].value 1 >>> cad.lcd.write("Hello, PiFaceLCD!") >>> cad.lcd.backlight_on()
- class pifacecad.core.SwitchEventListener(chip=None)¶
Listens for events on the switches and calls the mapped callback functions.
>>> def print_flag(event): ... print(event.interrupt_flag) ... >>> listener = pifacecad.SwitchEventListener() >>> listener.register(0, pifacecad.IODIR_ON, print_flag) >>> listener.activate()
pifacecad.ir¶
- class pifacecad.ir.IREvent(ir_code)¶
An IR event.
- class pifacecad.ir.IREventListener(prog, lircrc=None)¶
Listens for IR events and calls the registered functions. prog specifies
>>> def print_ir_code(event): ... print(event.ir_code) ... >>> listener = pifacecad.IREventListener(prog="myprogram") >>> listener.register('one', print_ir_code) >>> listener.activate()
- activate()¶
When activated the IREventListener will run callbacks associated with IR codes.
- deactivate()¶
When deactivated the IREventListener will not run anything.
- class pifacecad.ir.IRFunctionMap(ir_code, callback)¶
Maps an IR code to callback function.
- pifacecad.ir.watch_ir_events(event_queue)¶
Waits for IR code events and places them on the event queue.
Parameters: event_queue (multiprocessing.Queue) – A queue to put events on.
pifacecad.lcd¶
- class pifacecad.lcd.HD44780ControlPort(chip)¶
Control Port for an HD44780 LCD display. Must have the following properties:
- backlight_pin
- read_write_pin
- register_select_pin
- enable_pin
- class pifacecad.lcd.HD44780DataPort(chip)¶
Data Port for an HD44780 LCD display. Must have the following properties:
- value
- class pifacecad.lcd.HD44780LCD(control_port, data_port, init_lcd=True)¶
Component part of an HD4780, must be combined with a 4 or 8 bit mixin.
- backlight_off()¶
Turn on the backlight.
- backlight_on()¶
Turn on the backlight.
- blink_off()¶
Turns off the blinking cursor.
- blink_on()¶
Turns on the blinking cursor.
- char_bank_in_range_or_error(char_bank)¶
Raises an exception if char_bank is out of bounds. Returns True otherwise.
Parameters: char_bank (int) – The address to check.
- clear()¶
Clears the display.
- colrow2address(col, row)¶
Returns address of column and row.
Parameters: - col – The column.
- col – int
- row – The row.
- row – int
Returns: The address of the column and row.
- cursor_off()¶
Turns the underline cursor off.
- cursor_on()¶
Turns the underline cursor on.
- display_off()¶
Turns the display off (quickly).
- display_on()¶
Turns the display on (quickly).
- get_cursor()¶
Returns the current column and row of the cursor. Also fixes internal value.
Returns: (int, int) – A tuple containing the column and row.
- home()¶
Moves the cursor to the home position.
- left_justify()¶
Left justifies text from the cursor.
- left_to_right()¶
Sets the text to flow from left to right.
- move_left()¶
Scrolls the display without changing the RAM.
- move_right()¶
Scrolls the display without changing the RAM.
- pulse_clock()¶
Pulse the LCD clock for reading data.
- right_justify()¶
Right justifies text from the cursor.
- right_to_left()¶
Sets the text to flow from right to left.
- see_cursor(col=None)¶
Moves the viewport so that the cursor is visible.
- send_command(command)¶
Send command byte to LCD.
Parameters: command (int) – The command byte to be sent.
- set_cgram_address(address=0)¶
Start using CGRAM at the given address.
Parameters: address (int) – The address to start at (default: 0)
- set_cursor(col, row)¶
Places the cursor at the specified column and row.
Parameters:
- set_ddram_address(address=None)¶
Start using DDRAM at the given address.
Parameters: address (int) – The address to start at (default: current)
- store_custom_bitmap(char_bank, bitmap)¶
Stores a custom bitmap bitmap at char_bank.
Parameters:
- update_display_control()¶
Update the display control to reflect the displaycontrol.
- update_entry_mode()¶
Update entrymodeset to reflect the displaymode.
- update_function_set()¶
Updates the function set to reflect the current displayfunction.
- viewport_corner¶
The top left corner of the current viewport.
- class pifacecad.lcd.LCDBitmap(lines=[])¶
A custom bitmap for the LCD screen.
- class pifacecad.lcd.PiFaceLCD(control_port, data_port, init_lcd=True)¶
An HD44780 LCD in 4-bit mode.