Class: Phidgets::TextLCD::TextLCDScreens

Inherits:
Object
  • Object
show all
Defined in:
lib/phidgets-ffi/text_lcd.rb

Overview

This class represents a screen a PhidgetTextLCD. All the properties of a screen are stored and modified in this class.

Defined Under Namespace

Classes: TextLCDScreensRows

Constant Summary collapse

Klass =
Phidgets::FFI::CPhidgetTextLCD

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rowsTextLCDScreensRows (readonly)

Collection of rows of text display in a PhidgetTextLCD

Returns:



44
45
46
# File 'lib/phidgets-ffi/text_lcd.rb', line 44

def rows
  @rows
end

Instance Method Details

#back_lightBoolean

Returns the back light state of a screen, or raises an error.

Returns:

  • (Boolean)

    returns the back light state of a screen, or raises an error.



52
53
54
55
56
57
# File 'lib/phidgets-ffi/text_lcd.rb', line 52

def back_light
  try_set_screen
    ptr = ::FFI::MemoryPointer.new(:int)
    Klass.getBacklight(@handle, ptr)
  (ptr.get_int(0) == 0) ? false : true
end

#back_light=(new_state) ⇒ Boolean

Sets the back light state of a screen, or raises an error.

Parameters:

  • new_state (Boolean)

    new state

Returns:

  • (Boolean)

    returns the back light state of a screen, or raises an error.



62
63
64
65
66
67
# File 'lib/phidgets-ffi/text_lcd.rb', line 62

def back_light=(new_state)
    try_set_screen
    tmp = new_state ? 1 : 0
    Klass.setBacklight(@handle, tmp)
  new_state
end

#brightnessInteger

Returns the brightness value of a screen, or raises an error. Not all PhidgetTextLCDs support brightness.

Returns:

  • (Integer)

    returns the brightness value of a screen, or raises an error. Not all PhidgetTextLCDs support brightness.



70
71
72
73
74
75
# File 'lib/phidgets-ffi/text_lcd.rb', line 70

def brightness
  try_set_screen
    ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getBrightness(@handle, ptr)
  ptr.get_int(0)
end

#brightness=(new_brightness) ⇒ Integer

Sets the brightness value of a screen, or raises an error. Not all PhidgetTextLCDs support brightness.

Parameters:

  • new_brightness (Integer)

    new brightness(0-255)

Returns:

  • (Integer)

    returns the brightness value of a screen, or raises an error.



80
81
82
83
84
# File 'lib/phidgets-ffi/text_lcd.rb', line 80

def brightness=(new_brightness)
  try_set_screen
    Klass.setBrightness(@handle, new_brightness.to_i)
  new_brightness.to_i
end

#contrastInteger

Returns the contrast of a screen, or raises an error.

Returns:

  • (Integer)

    returns the contrast of a screen, or raises an error.



87
88
89
90
91
92
# File 'lib/phidgets-ffi/text_lcd.rb', line 87

def contrast
  try_set_screen
    ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getContrast(@handle, ptr)
  ptr.get_int(0)
end

#contrast=(new_contrast) ⇒ Integer

Sets the contrast value of a screen, or raises an error.

Parameters:

  • new_contrast (Integer)

    new contrast(0-255)

Returns:

  • (Integer)

    returns the contrast value of a screen, or raises an error.



97
98
99
100
101
# File 'lib/phidgets-ffi/text_lcd.rb', line 97

def contrast=(new_contrast)
  try_set_screen
    Klass.setContrast(@handle, new_contrast.to_i)
  new_contrast.to_i
end

#cursorBoolean

Returns the cursor state of a screen, or raises an error.

Returns:

  • (Boolean)

    returns the cursor state of a screen, or raises an error.



105
106
107
108
109
110
# File 'lib/phidgets-ffi/text_lcd.rb', line 105

def cursor
  try_set_screen
    ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getCursonOn(@handle, ptr)
  (ptr.get_int(0) == 0) ? false : true
end

#cursor=(new_state) ⇒ Boolean

Sets the cursor state of a screen, or raises an error.

Parameters:

  • new_state (Boolean)

    new state

Returns:

  • (Boolean)

    returns the cursor state of a screen, or raises an error.



115
116
117
118
119
120
# File 'lib/phidgets-ffi/text_lcd.rb', line 115

def cursor=(new_state)
    try_set_screen
    tmp = new_state ? 1 : 0
  Klass.setCursorOn(@handle, tmp)
  new_state
end

The cursor blink is a flashing box which appears directly to the right of the last entered character on the display, in the same apot as the cursor if it is enabled.

Returns:

  • (Boolean)

    returns the cursor blink state of a screen, or raises an error.



124
125
126
127
128
129
# File 'lib/phidgets-ffi/text_lcd.rb', line 124

def cursor_blink
  try_set_screen
    ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getCursonBlink(@handle, ptr)
  (ptr.get_int(0) == 0) ? false : true
end

#cursor_blink=(new_state) ⇒ Boolean

Sets the cursor blink state of a screen, or raises an error.

Parameters:

  • new_state (Boolean)

    new state

Returns:

  • (Boolean)

    returns the cursor blink state of a screen, or raises an error.



134
135
136
137
138
139
# File 'lib/phidgets-ffi/text_lcd.rb', line 134

def cursor_blink=(new_state)
  try_set_screen
    tmp = new_state ? 1 : 0
  Klass.setCursorBlink(@handle, tmp)
    new_state
end

#indexInteger

Returns index of the screen, or raises an error.

Returns:

  • (Integer)

    returns index of the screen, or raises an error.



47
48
49
# File 'lib/phidgets-ffi/text_lcd.rb', line 47

def index 
  @index
end

#initialize_screenBoolean

Initializes a screen, or raises an error. Not all PhidgetTextLCDs support initialize

Returns:

  • (Boolean)

    returns true if the screen was successfully initialize, or raises an error.



162
163
164
165
166
# File 'lib/phidgets-ffi/text_lcd.rb', line 162

def initialize_screen
  try_set_screen
    Klass.initialize(@handle)
    true
end

#inspectObject

Displays data for the servo motor.



38
39
40
# File 'lib/phidgets-ffi/text_lcd.rb', line 38

def inspect
     "#<#{self.class} @index=#{index}>"
end

#screen_sizePhidgets::FFI::TextLCDScreenSizes

Returns the screen size of a screen, or raises an error. Not all PhidgetTextLCDs support screen_size.

Returns:



142
143
144
145
146
147
# File 'lib/phidgets-ffi/text_lcd.rb', line 142

def screen_size
  try_set_screen
    ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getScreenSize(@handle, ptr)
  Phidgets::FFI::TextLCDScreenSizes[ptr.get_int(0)]
end

#screen_size=(new_screen_size) ⇒ Phidgets::FFI::TextLCDScreenSizes

Sets the screen size of a screen, or raises an error. Not all PhidgetTextLCDs support screen_size.

Parameters:

Returns:



152
153
154
155
156
157
158
# File 'lib/phidgets-ffi/text_lcd.rb', line 152

def screen_size=(new_screen_size)
    try_set_screen
  Klass.setScreenSize(@handle, Phidgets::FFI::TextLCDScreenSizes[new_screen_size])
    
    load_rows(@index)  #readjust screen rows
  new_screen_size
end