Class: Evepi::LCD_Screen

Inherits:
Object
  • Object
show all
Includes:
Evepi_Init_Mixin
Defined in:
lib/evepi.rb

Constant Summary collapse

@@CURSOR_SET =
1
@@CURSOR_APPEND =
0
@@CURSOR_CLEAR =
2

Instance Attribute Summary

Attributes included from Evepi_Init_Mixin

#json_obj

Instance Method Summary collapse

Methods included from Evepi_Init_Mixin

#initialize

Instance Method Details

#_write(input_json, name) ⇒ Object



48
49
50
51
52
53
# File 'lib/evepi.rb', line 48

def _write(input_json, name)
    socket = TCPSocket.open(@hostname, @port)
    socket.send input_json, 0
    line = socket.recv(1024)
    socket.close
end

#clear(name = @name) ⇒ Object



99
100
101
# File 'lib/evepi.rb', line 99

def clear(name=@name)
    return write(@@CURSOR_CLEAR, 0, 0, nil, name)
end

#set_cursor(x, y, name = @name) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/evepi.rb', line 67

def set_cursor(x, y, name=@name)
    input_dict = {
        :cursor_whether => @@CURSOR_SET,
        :cursor_i => x,
        :cursor_j => y,
    }
    input_json = JSON.dump(input_dict)
    return _write(input_json, name)
end

#write(type, x, y, content, name = @name) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/evepi.rb', line 55

def write(type, x, y, content, name=@name)
    input_dict = {
        :cursor_whether => type,
        :cursor_i => x,
        :cursor_j => y,
        :input_string => content
    }
    input_json = JSON.dump(input_dict)
    return _write(input_json, name)
end

#write_after(content, name = @name) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/evepi.rb', line 89

def write_after(content, name=@name)
    input_dict = {
        :cursor_whether => @@CURSOR_APPEND,
        :input_string => content
    }
    input_json = JSON.dump(input_dict)
    return _write(input_json, name)
end

#write_at(x, y, content, name = @name) ⇒ Object



77
78
79
80
81
82
83
84
85
86
# File 'lib/evepi.rb', line 77

def write_at(x, y, content, name=@name)
    input_dict = {
        :cursor_whether => @@CURSOR_SET,
        :cursor_i => x,
        :cursor_j => y,
        :input_string => content
    }
    input_json = JSON.dump(input_dict)
    return _write(input_json, name)
end