Class: HumbleRPiPluginMTP
- Inherits:
-
SerialPortMTP
- Object
- SerialPortMTP
- HumbleRPiPluginMTP
- Defined in:
- lib/humble_rpi-plugin-mtp.rb
Instance Method Summary collapse
-
#initialize(settings: {}, variables: {}) ⇒ HumbleRPiPluginMTP
constructor
A new instance of HumbleRPiPluginMTP.
- #on_printer_message(raw_message) ⇒ Object
- #start ⇒ Object (also: #on_start)
Constructor Details
#initialize(settings: {}, variables: {}) ⇒ HumbleRPiPluginMTP
Returns a new instance of HumbleRPiPluginMTP.
39 40 41 42 43 44 45 46 47 |
# File 'lib/humble_rpi-plugin-mtp.rb', line 39 def initialize(settings: {}, variables: {}) h = {port: "/dev/ttyAMA0", baud_rate: 19200}.merge settings @username, @password = settings[:username], settings[:password] device_id = variables[:device_id] || 'pi' super(port: h[:port], baud_rate: h[:baud_rate]) end |
Instance Method Details
#on_printer_message(raw_message) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/humble_rpi-plugin-mtp.rb', line 49 def () = [/^https?:\/\//] ? fetch() : return if .strip.empty? wake inverse_on bold_on println Time.now.to_s bold_off inverse_off feed if =~ /^</ then scanprint Html.new().to_a else wordwrap().lines {|x| self.print x} end feed 4 sleep_after 10 # seconds end |
#start ⇒ Object Also known as: on_start
74 75 76 77 78 79 |
# File 'lib/humble_rpi-plugin-mtp.rb', line 74 def start() super sleep_after 1 # second end |