LVGL Switch widget color

Hi all, I am developing an LVGL interface for a Waveshare screen to the Bambu Home assistant integration for my Bambu P1S 3D printer. The supplied Bambu control screen isn’t very good but the home assistant integration provides lots of access. I am trying to keep to a theme and would like to change the blue color of an activated LVGL switch from the default blue to something else but whatever I do it stays stubbornly blue as shown below.

The documentation seems to suggest this should be able to set under the indicator section of the switch but doesn’t appear to work, I have tried a few different combinations or bg_color, arc_color and text_color but nothing seems to work. Here is the relevant bit.

	- switch:
		x: 0
		y: 320
		id: SwitchControl1FanAux
		bg_color: ${BambuGreyText}
		align: TOP_MID
		indicator:
		  bg_color: ${BambuGreen}
		on_click:
		  then:
			- homeassistant.action:
				action: fan.toggle
				data:
				  entity_id: ${PrinterFanAuxControl} 

I am doing most of the development in SDL2 with occasional verifying it on the waveshare screen. It isn’t the most critical of things but just wondering if something I’m doing wrong or a bug?

2 Likes

Nice looking dashboard!

You didn’t specify the state you want to change the colour for.

        - switch:
            id: lv_switch
            indicator:
              checked:
                bg_color: 0xFF0000

Thanks Clyde, that fixed it, struggled to find that nugget of information in the documentation.

And thanks for the comments, trying to keep the panel similar to their other printer which has a much better display, having to go off pictures on the Internet though. One thing I have learnt about LVGL is that - obj are your friends!

Another poor photo picture from the Waveshare itself as online images don’t work in SDL2 and I use this to download an image of the object being printed. Still a lot of work to do, next on the list combine data from a HA fan speed sensor modify it and then change the value via an HA homeassitant.action.

Andy

1 Like

online_image does work on host, what doesn’t is the http_request it depends on, but you can use this PR for now.

Thanks, I knew there was something that didn’t, not a big deal it is only used for one image used once. I have 3 yaml files, 1 specific to the Waveshare, 1 specific to the host and then a common one that has the majority of sensors, lvgl, scripts etc, makes the development a bit easier. I’ll give it a go though will test your PR out.

Really appreciate the help and support and the work you have put into lvgl.

Andy

Edit - Tried your PR there was a warning during compile but works, have raised a comment with details on Github though the formatting of my comment has gone a bit strange.

Hi @EBME2

Would you mind share your code for this project?

It would a perfect usage for my Waveshare 4.3" that have been collecting dust for the past year…

Hi

It is still work in progress and I haven’t done a lot in recent months due to life etc. It is currently about 3000 lines of code, and I use the bigger 7” screen but I started out on the smaller 4…3”, few parameters to change from memory still in the code and commented out. I’ll try putting on GitHub later this week, instructions/documentation will be severely lacking.

I’ll post back when done.

Andy

3 Likes

I’ll be waiting :slight_smile:

@EBME2 Care to share the code? It doesn’t matter to me if it’s incomplete or lacking. Just wondering how you are doing things :smiley: .

Perhaps you can create a gist?

Hi @alex3305 @TheStigh

Life got in the way, plus issues with later versions of ESPHome, here it is without warranty and minimal instructions. It will need fairly recent version of ESPHome

https://github.com/EBME2/BambuPanel

1 Like

Hey @EBME2

Nothing in that URL…

@TheStigh try again, GitHub is fairly new to me.

Great! It is there :slight_smile:
Shot question - what is bambuhost.yaml used for ?

It is in the very brief instructions it is for use in SDL2, saves quite a lot of time compiling for minor changes. I do most of the initial development in this environment then once close start using the Waveshare.

Details about SDL2 below.

No worries. Thanks for sharing!

Thanks for sharing @EBME2! Already started the setup in ESPHome :slight_smile: