Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add power devices menu #75

Merged
merged 11 commits into from
May 24, 2024
Merged

add power devices menu #75

merged 11 commits into from
May 24, 2024

Conversation

kevdliu
Copy link
Contributor

@kevdliu kevdliu commented Apr 14, 2024

This PR adds a power devices sub-menu to the printer tuning menu that allows users to turn on/off power devices exposed via moonraker. Examples of power devices include smart plugs that the printer is connected to or external fans etc.

I'm pretty new to LGVL so appreciate any feedback you have. The only thing missing is the icon for the menu button as I'm unsure how to generate an icon for the button. I'm using the graph icon as a placeholder for now.

Capture
2Capture

@kevdliu
Copy link
Contributor Author

kevdliu commented Apr 14, 2024

I'm trying to cross compile the binary for my Creality Ender V3 KE (which has the same chipset as K1) but keep running into this error:

/home/kevdliu/mips-gcc720-glibc229/bin/../lib/gcc/mips-linux-gnu/7.2.0/../../../../mips-linux-gnu/bin/ld: skipping incompatible spdlog/build/libspdlog.a when searching for -l:libspdlog.a
/home/kevdliu/mips-gcc720-glibc229/bin/../lib/gcc/mips-linux-gnu/7.2.0/../../../../mips-linux-gnu/bin/ld: skipping incompatible spdlog/build/libspdlog.a when searching for -l:libspdlog.a
/home/kevdliu/mips-gcc720-glibc229/bin/../lib/gcc/mips-linux-gnu/7.2.0/../../../../mips-linux-gnu/bin/ld: cannot find -l:libspdlog.a
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:132: default] Error 1
make[1]: Leaving directory '/home/kevdliu/Downloads/guppyscreen'
make: *** [Makefile:162: build] Error 2

I've downloaded the mips sdk and included it in my path. Building natively for x86 works fine but when I set export CROSS_COMPILE=mips-linux-gnu- it throws the above error

@ballaswag
Copy link
Owner

Thanks for the PR! See https://github.com/ballaswag/guppyscreen/pull/62/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52R105 to get around that spdlog issue.

For icons, I use the lvgl image convert tool to convert svg into c arrays (https://github.com/lvgl/lv_img_conv):
./lv_img_conv.js logo_lvgl.png -f -c CF_TRUE_COLOR_ALPHA

The icon set I'm using are from https://pictogrammers.com/library/mdi/ (I'm out of the zbolt icons since that set is custom). There are also 2 sizes because I didn't bother trying to figure out how to dynamically scale them in lvgl.

The default set is 64x64, and the small screen ones are 46x46.

@kevdliu
Copy link
Contributor Author

kevdliu commented Apr 15, 2024

Thanks for the PR! See https://github.com/ballaswag/guppyscreen/pull/62/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52R105 to get around that spdlog issue.

For icons, I use the lvgl image convert tool to convert svg into c arrays (https://github.com/lvgl/lv_img_conv): ./lv_img_conv.js logo_lvgl.png -f -c CF_TRUE_COLOR_ALPHA

The icon set I'm using are from https://pictogrammers.com/library/mdi/ (I'm out of the zbolt icons since that set is custom). There are also 2 sizes because I didn't bother trying to figure out how to dynamically scale them in lvgl.

The default set is 64x64, and the small screen ones are 46x46.

Thanks for the spdlog suggestion! It's working now. I've updated the PR with a new icon for the power devices menu. Unsure what to do about ZBolt though.

@kevdliu
Copy link
Contributor Author

kevdliu commented Apr 16, 2024

New icon:
Screenshot from 2024-04-15 21-57-22

void PowerPanel::create_devices(json &j) {
std::lock_guard<std::mutex> lock(lv_lock);

if (j.contains("result")) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need to clear the devices map here for when the printer re-initializes, so if any devices removed physically will also get removed from in the UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Do you know how I can remove existing UI widgets in LVGL? Simply clearing the map still leaves the UI widget on screen and causes duplicate entries.

#ifndef ZBOLT
, power_devices_btn(cont, &power_devices_img, "Power Devices", &PrinterTunePanel::_handle_callback, this)
#else
, power_devices_btn(cont, &print, "Power Devices", &PrinterTunePanel::_handle_callback, this)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just start using material icons for zbolt too when there's no zbolt equivalent.

@ballaswag
Copy link
Owner

Thanks for the feature! Will merge and let it bake in nightly. Some minor comments, if you don't a chance to fix, I'll see to them when I get some time.

Another thing is I'll probably move this icon into a different section and leave the tuning panel for tuning stuff. For now it's good enough.

@ballaswag ballaswag merged commit 7cec1a2 into ballaswag:main May 24, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants