note description: "[ A communication channel for reading and writting data to a parallel port for a HD44780 device. ]" legal : "See notice at end of class." status : "See notice at end of class."; author : "Paul Bates (paul.a.bates@gmail.com)" date : "$Date$" revision: "$Revision$" class HD44780_PARALLEL_COMM_CHANNEL inherit HD44780_COMM_CHANNEL_I [PRT_PARALLEL_CONNECTION] inherit {NONE} SHARED_HD44780_OP_CODES export {NONE} all end create make feature {HD44780_CONTROLLER} -- Status report is_4bit_channel: BOOLEAN = False -- feature {NONE} -- Query register (a_instruction: BOOLEAN): NATURAL_8 -- Retrieves a register given the state of `a_instruction' -- -- `a_instruction': When true an instruction transaction is being processed, otherwise it is a data transaction. do if a_instruction then Result := {HD44780_OP_CODES}.read_write_register_instruction else Result := {HD44780_OP_CODES}.read_write_register_data end end feature {NONE} -- Transaction handlers on_being_transaction (a_instruction: BOOLEAN) -- Called when a transaction is about to start. -- -- `a_instruction': When true an instruction transaction is being processed, otherwise it is a data transaction. do pulse (False, a_instruction) end on_complete_transaction (a_instruction: BOOLEAN) -- Called when a transaction has been completed. -- -- `a_instruction': When true an instruction transaction is being processed, otherwise it is a data transaction. do pulse (True, a_instruction) end feature {HD44780_CONTROLLER} -- Write operations send (a_data: NATURAL_8) -- Attempts to send a 8-bit instruction to a HD44780 controller do connection.data_register.send (a_data) end feature {NONE} -- Write operations pulse (a_strobe: BOOLEAN; a_instruction: BOOLEAN) -- Pulses a signal on the parallel port to indicate flush sent data -- -- `a_strobe': True to strobe and flush data changes; False to reset the strobe. -- `a_instruction': When true an instruction transaction is being processed, otherwise it is a data transaction. local l_strobe: NATURAL_8 do if a_strobe then l_strobe := {HD44780_OP_CODES}.read_write_strobe_on else l_strobe := {HD44780_OP_CODES}.read_write_strobe_off end connection.control_register.send (op_codes.write_to_register_op (register (a_instruction), l_strobe)) end feature {HD44780_CONTROLLER} -- Read operations retrieve: NATURAL_8 -- Attempts to retrieve a 8-bit instruction from a HD44780 controller local l_reg: PRT_PARALLEL_DATA_REGISTER do l_reg := connection.data_register l_reg.read Result := l_reg.data end end