Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:49 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 : Button colour

Author Message
Alastair
Senior Member

Joined: 03/04/2017
Location: Australia
Posts: 161
Posted: 10:09am 02 Oct 2017
Copy link to clipboard 
Print this post

Is it possible to change the button colour during execution? I find the split button for ON|OFF say not obvious which is down. I would like to have an ON button in green when it is enabled and the OFF button bright red when enabled.

Have I missed something? I have currently used gui led above the buttons to simulate the above but it just adds 'noise' and additional controls.

Cheers, Alastair
 
Alastair
Senior Member

Joined: 03/04/2017
Location: Australia
Posts: 161
Posted: 01:01pm 02 Oct 2017
Copy link to clipboard 
Print this post

Ok - so I can't read the manual.

Looks like gui FColour is what I want.

Cheers, Alastair
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9749
Posted: 03:54pm 02 Oct 2017
Copy link to clipboard 
Print this post


Smoke makes things work. When the smoke gets out, it stops!
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1116
Posted: 02:28pm 03 Oct 2017
Copy link to clipboard 
Print this post

Alastair,

I think the forground/background colours on the GUI switch command relate to the switch colour and the text colour.

The ON/OFF indication is half intensity.

The following kluge simulates a switch that toggles on and off with each touch and shows as red for off and green for on.


' Demo of a toggle switch type function

GUI displaybox #1,120,120,120,120,RGB(green),RGB(black)
GUI displaybox #2,120,120,120,120,RGB(red),RGB(black)
GUI area #3,120,120,120,120 'define touch area
GUI interrupt flip_sw
GUI hide #1
GUI show #2 ' default to off
Dim tst_sw As integer
tst_sw = 0 ' set switch to off

Do
' nothing to see here .... except main program
Loop

Sub flip_sw ' subroutine called by touch interrupt
If tst_sw = 0 Then
GUI hide #2
GUI show #1
Else
GUI hide #1
GUI show #2
EndIf
tst_sw = Not tst_sw ' invert switch ready for next touch
End Sub


Hope this helps.
panky
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1116
Posted: 06:48pm 03 Oct 2017
Copy link to clipboard 
Print this post

.... slight mod to show button more clearly


' Demo of a toggle switch type function

GUI displaybox #4,119,119,122,122,RGB(white),RGB(black)
GUI displaybox #1,120,120,60,120,RGB(black),RGB(green)
GUI displaybox #2,180,120,60,120,RGB(black),RGB(red)

GUI area #3,120,120,120,120 'define touch area
GUI interrupt flip_sw
GUI hide #1
GUI show #2 ' default to off
Dim tst_sw As integer
tst_sw = 0 ' set switch to off

Do
' nothing to see here .... except main program
Loop

Sub flip_sw ' subroutine called by touch interrupt
If tst_sw = 0 Then
GUI hide #2
GUI show #1
Else
GUI hide #1
GUI show #2
EndIf
tst_sw = Not tst_sw ' invert switch ready for next touch
End Sub

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
Alastair
Senior Member

Joined: 03/04/2017
Location: Australia
Posts: 161
Posted: 11:38am 04 Oct 2017
Copy link to clipboard 
Print this post

Panky,
thanks. I will play with your idea when I have a moment.

Whilst I think the MM is a great, the gui button , especially when split, is a little disappointing. My skills are too rusty to consider modifying the basic code. Also I realise any enhancements come at a cost in terms of overhead and kernel size.

In most cases everything works well but there are times, especially when doing things for use by non-computer oriented people, i would like to have an option that is more intuitive. I will look again at the Nextion type displays which should work well with the MM and allow a step up in gui design.

https://www.itead.cc/display/nextion.html

Cheers, Alastair
 
Alastair
Senior Member

Joined: 03/04/2017
Location: Australia
Posts: 161
Posted: 10:45am 06 Oct 2017
Copy link to clipboard 
Print this post

Panky,
following your post I decided to play with your idea which looked good. I also decided that to start thinking of moving to the Nextion displays was silly if my only real concern was cosmetic and the split button which I found was often misunderstood.

I found that because the gui button does not respond to a touch when it is hidden, then it is quite ok to put 2 buttons on top of each other. This gives a user only 1 appropriate option. EG

'test of overlaid buttons

cls
backlight=50

gui button 2,"ON", 100,100,100,100,rgb(white), rgb(green)
gui button 3,"OFF", 100,100,100,100,rgb(white), rgb(red)
gui hide 3
gui show 2

gui interrupt btn_dn,btn_up

do

loop
end

sub btn_up
btn=touch(lastref)
if btn=2 then
gui hide 2
gui show 3
elseif btn=3 then
gui hide 3
gui show 2
endif
end sub

sub btn_dn
end sub

Edited by Alastair 2017-10-07
Cheers, Alastair
 
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