Class: OdroidLCD::LCD

Inherits:
Object
  • Object
show all
Defined in:
lib/odroid_lcd/lcd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mocks: {}) ⇒ LCD

Returns a new instance of LCD.



8
9
10
11
12
13
# File 'lib/odroid_lcd/lcd.rb', line 8

def initialize(mocks: {})
  @hw = mocks[:odroidlcd_hw] || OdroidLCD::HW.new
  @max_column = @hw.max_column
  @max_row = @hw.max_row
  freeze()
end

Instance Attribute Details

#max_columnObject (readonly)

Returns the value of attribute max_column.



5
6
7
# File 'lib/odroid_lcd/lcd.rb', line 5

def max_column
  @max_column
end

#max_rowObject (readonly)

Returns the value of attribute max_row.



6
7
8
# File 'lib/odroid_lcd/lcd.rb', line 6

def max_row
  @max_row
end

Instance Method Details

#clearObject



15
16
17
# File 'lib/odroid_lcd/lcd.rb', line 15

def clear
  @hw.clear
end

#set_character(row:, column:, character:) ⇒ Object



19
20
21
# File 'lib/odroid_lcd/lcd.rb', line 19

def set_character(row:, column:, character:)
  @hw.set_character(row, column, character)
end

#set_string(row: 0, string:) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/odroid_lcd/lcd.rb', line 23

def set_string(row: 0, string:)
  column = 0
  string[0, @max_column].ljust(@max_column - 1).chars do |chr|
    set_character(row: row, column: column, character: chr)
    column += 1
  end
end