The class LCDNumber (gb.qt4.ext) implements a component that displays the digits (digits) to be displayed like an LCD screen. In a 7-segment display element, each segment can be switched on or off. Each digit is displayed in a separate 7-segment display element. The digits 0 to 9 and a dot as well as the letters A, b, C, d, E and F are displayed in hexadecimal display mode.
The LCDNumber component is considered obsolete since Gambas 3.4. It is recommended to use the LCDLabel component → Chapter 17.16 LCDLabel instead of the LCDNumber component. The author does not share this opinion, because at least the following reasons speak for the use of the LCDNumber component - in view of the possibilities of the LCDLabel component:
Figure 17.10.1: Binary display of integers with LCDNumber
The following table describes selected properties of the LCDNumber component:
LCDNumber | Data type | Default | Description |
---|---|---|---|
.Digits | Integer | 1 | This property is used to set or read the number of digits to be displayed. |
.Mode | Integer | 1 | Specifies the display mode (hexadecimal (0), decimal (1), binary (3)) or reads the mode. |
.Overflow | Boolean | - | Indicates whether the number is too large to be displayed exactly (read-only) |
.SmallDecimalPoint | Boolean | False | Determines or sets how the decimal point is displayed. If this property is TRUE, the decimal point is inserted between two digits. |
.Style | Integer | Outline | Sets or returns the style. Constants: LCDNumber.Outline (0), LCDNumber.Filled (1) and LCDNumber.Flat (2) |
.Value | Float | 0 | Sets or returns the value to be displayed in the LCDNumber component. |
Table 17.10.1.1: Selected Properties
3 constants are provided for the display mode:
In the project, the number (LCDNumber1.Value) is generated from the range [0,10] by a rotary knob (Dial component) and displayed in a component LCDNumber in decimal display mode. The same applies to the project extension where the display element LCDNumber was exchanged for an LCDLabel:
Figure 17.10.2.1: Decimal display with LCDNumber
Figure 17.10.2.2: Decimal display with LCDLabel
' Gambas class file Private $iRatio As Integer = 10 Public Sub Form_Open() FMain.Center Dial1.MinValue = 0 Dial1.MaxValue = 100 Dial1.PageStep = 10 Dial1.Step = 1 Dial1.Value = 25 Dial1.Wrap = False LCDNumber1.Digits = 3 LCDNumber1.SmallDecimalPoint = False LCDNumber1.Mode = LCDNumber1.Decimal Form2.Show End '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Public Sub Dial1_Change() GetOverflow() LCDNumber1.Value = Dial1.Value / $iRatio If LCDNumber1.Value >= 9 Then LCDNumber1.Background = &HFFBFBF Else LCDNumber1.Background = &HF5FFE6 Endif End Private Sub GetOverflow() If LCDNumber1.Overflow = True Then Message.Error("Die Zahl ist zu groß, um exakt angezeigt zu werden.") Inc LCDNumber1.Digits Return Endif End
The procedure GetOverflow() takes effect depending on the preset number of digits and the mode used. In the event handler Dial1.Change(), the background colour of the display element LCDNumber is changed from light green to light red when the value to be displayed reaches or exceeds the limit value 9:
Figure 17.10.2.3: Display in the limit range with LCDNumber