Class: OdroidLCD::HWMock

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHWMock

Returns a new instance of HWMock.



7
8
9
10
11
12
13
14
15
16
# File 'lib/odroid_lcd/hw_mock.rb', line 7

def initialize
  @max_column = 16
  @max_row = 2

  @display = [
    [],
    []
  ]

end

Instance Attribute Details

#max_columnObject (readonly)

Returns the value of attribute max_column.



4
5
6
# File 'lib/odroid_lcd/hw_mock.rb', line 4

def max_column
  @max_column
end

#max_rowObject (readonly)

Returns the value of attribute max_row.



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

def max_row
  @max_row
end

Instance Method Details

#clearObject



18
19
20
21
22
23
# File 'lib/odroid_lcd/hw_mock.rb', line 18

def clear
  @display = [
    [],
    []
  ]
end

#get(row: 0) ⇒ Object

Extra methods for use as a mock



41
42
43
# File 'lib/odroid_lcd/hw_mock.rb', line 41

def get(row: 0)
  @display[row]
end

#set_character(row, column, character) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/odroid_lcd/hw_mock.rb', line 27

def set_character(row, column, character)
  chr = case character
        when "\u005c" then "\u00a5"
        when "\u007e" then "\u2192"
        when "\u007f" then "\u2190"
        else character
        end

  @display[row][column] = chr
end