Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:11 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : LCD Panel in PORTRAIT Mode

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 05:04pm 22 Apr 2017
Copy link to clipboard 
Print this post

Greetings,

In preparation for a project, I'm experimenting with an ILI9341 LCD Panel connected to Micromite+ Explore 64.

My plan is to use the LCD in portrait mode.

So first off was to alter the pump control demo program to suit the vertical screen orientation, as follows:

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Demonstration program for the Micromite+
' It does not do anything useful except demo the various controls
'
' Geoff Graham, October 2015
' GUI layout altered to fit 320x240 (ILI9341) LCD panel
' used in PORTRAIT mode by Vegipete, April 2017
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Autorun On
Option Explicit

Dim ledsX, ledsY
Colour RGB(white), RGB(black)

' reference numbers for the controls are defined as constants
Const c_head = 1, c_pmp = 2, sw_pmp = 3, c_flow = 4, tb_flow = 5
Const led_run = 6, led_alarm = 7
Const frm_alarm = 20, nbr_hi = 21, nbr_lo = 22, pb_test =23
Const c_hi = 24, c_lo = 25
Const frm_pump = 30, r_econ = 31, r_norm = 32, r_hi = 33
Const frm_log = 40, cb_enabled = 41, c_fname = 42, tb_fname = 43
Const c_log = 44, cb_flow = 45, cb_pwr = 46, cb_warn = 47
Const cb_alarm = 48, c_bright = 49, sb_bright = 50
CLS
GUI Interrupt TouchDown, TouchUp

' now draw the "Pump Control" display
' display the heading
Font 2 : GUI Caption c_head, "Pump Control", 45, 0

' now, define and display the controls
' first display the switch
Font 2 : GUI Caption c_pmp, "Pump", 30, 19, , RGB(brown)
GUI Switch sw_pmp, "OFF|ON ", 10, 40, 100, 30, RGB(white),RGB(brown)
CtrlVal(sw_pmp) = 1

' the flow rate display box
Font 2 : GUI Caption c_flow, "Flow Rate", 5, 70,, RGB(brown),0
Font 2 : GUI Displaybox tb_flow, 5, 90, 105, 25
CtrlVal(tb_flow) = "20.1"

' the radio buttons and their frame
ledsX = 125 : ledsY = 30 ' define the position
Font 2 : GUI Frame frm_pump, "Power", ledsX, ledsY, 105, 90,RGB(200,20,255)
Font 1
ledsX = 145 : ledsY = 52 ' define their position
GUI Radio r_econ, "Economy", ledsX, ledsY, 12, RGB(230, 230, 255)
GUI Radio r_norm, "Normal", ledsX, MM.VPos+32
GUI Radio r_hi, "High", ledsX, MM.VPos+32
CtrlVal(r_norm) = 1 ' start with the "normal" button selected

' the alarm frame with two number boxes and a push button switch
Font 2 : GUI Frame frm_alarm, "Alarm", 10, 175, 90, 95,RGB(green)
Font 1
GUI Caption c_hi, "Hi:", 15, 195, LT, RGB(yellow)
GUI Numberbox nbr_hi, 45,MM.VPos-6,40,MM.FontHeight+6,RGB(yellow),RGB(64,64,64)
GUI Caption c_lo, "Lo:", 15, 215, LT, RGB(yellow),0
GUI Numberbox nbr_lo, 45,MM.VPos-6,40,MM.FontHeight+6,RGB(yellow),RGB(64,64,64)
GUI Button pb_test, "TEST", 20, 235, 70, 25,RGB(yellow), RGB(red)
CtrlVal(nbr_lo) = 15.7 : CtrlVal(nbr_hi) = 35.5

' draw the two LEDs
ledsX = 20 : ledsY = 130 ' define their position
GUI LED led_run, "Running", ledsX, ledsY, 10, RGB(green)
ledsY = ledsY+25
GUI LED led_alarm, "Alarm", ledsX, ledsY, 10, RGB(red)
CtrlVal(led_run) = 1 ' the switch defaults to on so set the LED on

' the logging frame with check boxes and a text box
ledsX = 120 : ledsY = 140 ' define their position
Colour RGB(cyan), 0
Font 2
GUI Frame frm_log, "Log File", ledsX, ledsY, 115, 160, RGB(green),0
Font 1
GUI Checkbox cb_enabled, "Log On", ledsX+10, ledsY+15, 20, RGB(cyan)
GUI Caption c_fname, "File Name", ledsX+5, ledsY+40
GUI Textbox tb_fname, ledsX+5, ledsY+55, 100, 20, RGB(cyan), RGB(64,64,64)
GUI Caption c_log, "Record:", ledsX+5, ledsY+80, , RGB(cyan), 0
GUI Checkbox cb_flow, "Flow", ledsX+10, ledsY+95, 20
GUI Checkbox cb_alarm, "Alarms", ledsX+10, ledsY+115, 20
GUI Checkbox cb_warn, "Warnings", ledsX+10, ledsY+135, 20
CtrlVal(cb_enabled) = 1
CtrlVal(tb_fname) = "LOGFILE.TXT"

' define and display the spinbox for controlling the backlight
GUI Caption c_bright, "Back Light", 16, 275,,RGB(200,200,255),0
GUI Spinbox sb_bright, 0, 290, 110, 25,,,5, 0, 100
CtrlVal(sb_bright) = 100

' All the controls have been defined and displayed. At this point
' the program could do some real work but because this is just a
' demo there is nothing to do. So it just sits in a loop.
Do : Loop
' the interrupt routine for touch down
' using a select case command it has a different process for each
' control

Sub TouchDown
Select Case Touch(REF) ' find out the control touched
Case cb_enabled ' the enable check box
If CtrlVal(cb_enabled) Then
GUI Restore c_fname, tb_fname, c_log, cb_flow, cb_alarm, cb_warn
Else
GUI Disable c_fname, tb_fname, c_log, cb_flow, cb_alarm, cb_warn
EndIf
Case sb_bright ' the brightness spin box
'BackLight CtrlVal(sb_bright)
Case sw_pmp ' the pump on/off switch
Print CtrlVal(sw_pmp)
CtrlVal(led_run) = CtrlVal(sw_pmp)
CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 20.1)
CtrlVal(r_norm) = 1
Case pb_test ' the alarm test button
'Open "Test.txt" For Append As #1
'Print "File Opened"
'Print #1, "Hello World", Time$
'Print "Hello World", Time$
'Close #1
'Print "File Closed"
CtrlVal(led_alarm) = 1
'GUI beep 250
Case r_econ ' the economy radio button
CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 18.3)
Case r_norm ' the normal radio button
CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 20.1)
Case r_hi ' the high radio button
CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 23.7)
End Select
End Sub

' interrupt routine when the touch is removed
Sub TouchUp
Select Case Touch(LASTREF) ' use the last reference
Case pb_test ' was it the test button
CtrlVal(led_alarm) = 0 ' turn off the LED
End Select
End Sub

This works very nicely. Hats off to Geoff (and community) for such a marvelous and easy to use system to rapidly create such a GUI! Fantastic job!

My question pertains to the GUI NUMBERBOX and GUI TEXTBOX controls. I am not completely satisfied with the onscreen results. Note I haven't tried this in landscape mode to compare.

The NUMBERBOX fills the entire screen with the 12 position keypad with odd overwriting effects of the display value as you type digits. Is this to be expected? The biggest difficulty is that the original value is not visible. Perhaps the keypad could be shrunk vertically a bit and a number field positioned in the new space above showing either the original value or the ghost text hint?

The TEXTBOX works well enough except the keyboard is somewhat small because it has to be squashed into the narrow width of portrait mode. An evil non-qwerty keyboard with strange proportions is not desirable so I guess there's nothing much that can be done about that.

I notice that the keyboard reverts to capital letters when returning from the number/symbol keyboard, even if lower case was selected. Is that ideal?

Also, the text entry field can appear below the on-screen keyboard, making it difficult to see what you're typing. Would it be difficult or confusing to change this to a dedicated entry line above the keyboard?

Finally, editing the existing text value is not possible. Might this ability get created in the future? Especially if the ability to evaluate strings were added to the number entry field?

Thanks for the amazing work!
Pete
Visit Vegipete's *Mite Library for cool programs.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025