Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:20 10 Nov 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 : Pump Control program for ILI9341

Author Message
G.B.P.

Newbie

Joined: 13/08/2014
Location: Australia
Posts: 16
Posted: 08:21pm 29 Sep 2017
Copy link to clipboard 
Print this post

While testing all GUI commends on the MM Plus, I have found very useful the possibility to modify Geoff's program 'Pump Control" to fit into the ILI9341 smaller 320x240 LCD. (Thanks Geoff )



I hope it can assist many others. ..:


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Demonstration program for the Micromite+
' It does not do anything useful except demo the various controls
'
' Geoff Graham, October 2015
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Dim ledsY
Colour RGB(white), RGB(black)
pwm 2, 1000, 50
' 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
' now draw the "Pump Control" display
CLS
GUI Interrupt TouchDown, TouchUp
' display the heading
Font 1,2 : GUI Caption c_head, "Pump Control", 5, 0
Font 1 : GUI Caption c_pmp, "Pump", 10, 35, , RGB(brown)
' now, define and display the controls, first display the switch
Font 1
GUI Switch sw_pmp, "ON|OFF", 10, 50, 75, 25, RGB(white),RGB(brown)
CtrlVal(sw_pmp) = 1
' the flow rate display box
Font 1 : GUI Caption c_flow, "Flow Rate", 10, 85,, RGB(brown),0
Font 1 : GUI Displaybox tb_flow, 10, 100, 75, 27
CtrlVal(tb_flow) = "20.1"
' the radio buttons and their frame
Font 1 : GUI Frame frm_pump, "Power", 10, 145, 85, 81,RGB(200,20,255)
GUI Radio r_econ, "Econ.", 25, 161, 8, RGB(230, 230, 255)
GUI Radio r_norm, "Norm.", 25, 184
GUI Radio r_hi, "High", 25, 206
CtrlVal(r_norm) = 1 ' start with the "normal" button selected
' the alarm frame with two number boxes and a push button switch
Font 1 : GUI Frame frm_alarm, "Alarm", 110, 110, 100, 120,RGB(green)
GUI Caption c_hi, "High:", 116, 130, LT, RGB(yellow)
GUI Numberbox nbr_hi, 159,MM.VPos-3,45,MM.FontHeight+6,RGB(yellow),RGB(64,64,64)
GUI Caption c_lo, "Low:", 116, 162, LT, RGB(yellow),0
GUI Numberbox nbr_lo, 154,MM.VPos-3,45,MM.FontHeight+6,RGB(yellow),RGB(64,64,64)
GUI Button pb_test, "TEST", 128, 191, 65, 20,RGB(yellow), RGB(red)
CtrlVal(nbr_lo) = 15.7 : CtrlVal(nbr_hi) = 35.5
' draw the two LEDs
Const ledsX = 120, coff = 25 ' define their position
ledsY = 45 : GUI LED led_run, "Running", ledsX, ledsY, 12, RGB(green)
ledsY = ledsY+29 : GUI LED led_alarm, "Alarm", ledsX, ledsY, 12, 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
Colour RGB(cyan), 0
GUI Frame frm_log, "Log File", 222, 10, 100, 177, RGB(green),0
GUI Checkbox cb_enabled, "Log.Enab", 225, 25, 15, RGB(cyan)
GUI Caption c_fname, "File Name", 235, 45
GUI Textbox tb_fname, 228 ,67, 80, 20, RGB(cyan), RGB(64,64,64)
GUI Caption c_log, "Record:", 235, 102, , RGB(cyan), 0
GUI Checkbox cb_flow, "Flow Rate", 225, 122, 12
GUI Checkbox cb_alarm, "Alarms", 225, 142, 12
GUI Checkbox cb_warn, "Warnings", 225, 167, 12
CtrlVal(cb_enabled) = 1
CtrlVal(tb_fname) = "LOG.TXT"
' define and display the spinbox for controlling the backlight
GUI Caption c_bright, "Backlight", 221, 191,,RGB(200,200,255),0
GUI Spinbox sb_bright, MM.HPos -80, 210, 100, 25,,,10, 10, 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
pwm 2, 1000, CtrlVal(sb_bright)
Case sw_pmp ' the pump on/off switch
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
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

 
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