Skip to content

Commit

Permalink
Undeath guppy (respawns when it gets terminated). Bigger numpad keys.…
Browse files Browse the repository at this point in the history
… Properly empty thumbnails where applicable. Fixed progress bar reset. More scaling for different resolutions.
  • Loading branch information
ballaswag committed Jan 22, 2024
1 parent a20edd7 commit 4a0b68d
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 32 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.19
0.0.20
5 changes: 5 additions & 0 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fi

#### let's see if guppyscreen starts before doing anything more
printf "${green} Test starting Guppy Screen ${white}\n"
[ -f /etc/init.d/S99guppyscreen ] && /etc/init.d/S99guppyscreen stop &> /dev/null
killall -q guppyscreen
$K1_GUPPY_DIR/guppyscreen &> /dev/null &

Expand Down Expand Up @@ -176,6 +177,10 @@ else
cp $K1_GUPPY_DIR/k1_mods/ft2font.cpython-38-mipsel-linux-gnu.so $FT2FONT_PATH
fi

ln -sf $K1_GUPPY_DIR/k1_mods/respawn/libeinfo.so.1 /lib/libeinfo.so.1
ln -sf $K1_GUPPY_DIR/k1_mods/respawn/librc.so.1 /lib/librc.so.1


sync

if [ ! -f $K1_GUPPY_DIR/guppyscreen ]; then
Expand Down
21 changes: 17 additions & 4 deletions k1/k1_mods/S99guppyscreen
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
#!/bin/sh

GUPPYSCREEN_PATH=/usr/data/guppyscreen/guppyscreen
GUPPY_DIR=/usr/data/guppyscreen
GUPPYSCREEN=$GUPPY_DIR/guppyscreen
LIBEINFO=$GUPPY_DIR/k1_mods/respawn/libeinfo.so.1
LIBRC=$GUPPY_DIR/k1_mods/respawn/librc.so.1
GUPPYSCREEN_LOG=/usr/data/printer_data/logs/guppyscreen.log
PID_FILE=/var/run/guppyscreen.pid
RC_DIR=/run/openrc
SUPERVISE_DAEMON=/usr/data/guppyscreen/k1_mods/respawn/supervise-daemon
SVC_NAME=guppyscreen

start_server(){

export HOME=/root
sync && echo 3 > /proc/sys/vm/drop_caches
[ -x "$GUPPYSCREEN_PATH" ] && $GUPPYSCREEN_PATH &
mkdir -p $RC_DIR

# need to check for now if installers skips the symlink
[ ! -f $LIBEINFO ] && ln -sf $LIBEINFO /lib/libeinfo.so.1
[ ! -f $LIBRC ] && ln -sf $LIBRC /lib/librc.so.1

RC_SVCNAME=$SVC_NAME $SUPERVISE_DAEMON $SVC_NAME --start --stderr $GUPPYSCREEN_LOG --pidfile $PID_FILE $GUPPYSCREEN
}

stop_server(){
killall guppyscreen
RC_SVCNAME=$SVC_NAME $SUPERVISE_DAEMON $SVC_NAME --stop --pidfile $PID_FILE
}


Expand Down
Binary file added k1/k1_mods/respawn/libeinfo.so.1
Binary file not shown.
Binary file added k1/k1_mods/respawn/librc.so.1
Binary file not shown.
Binary file added k1/k1_mods/respawn/supervise-daemon
Binary file not shown.
5 changes: 3 additions & 2 deletions src/button_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ void ButtonContainer::handle_prompt() {

lv_obj_t *mbox1 = lv_msgbox_create(NULL, NULL, prompt_text.c_str(), btns, false);
lv_obj_t *msg = ((lv_msgbox_t*)mbox1)->text;
lv_obj_set_width(msg, LV_SIZE_CONTENT);
lv_obj_set_style_text_align(msg, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_width(msg, LV_PCT(100));
lv_obj_center(msg);

lv_obj_t *btnm = lv_msgbox_get_btns(mbox1);
Expand All @@ -119,7 +120,7 @@ void ButtonContainer::handle_prompt() {
auto hscale = (double)lv_disp_get_physical_ver_res(NULL) / 480.0;

lv_obj_set_size(btnm, LV_PCT(90), 50 *hscale);
lv_obj_set_size(mbox1, LV_PCT(50), LV_PCT(30));
lv_obj_set_size(mbox1, LV_PCT(50), LV_PCT(35));

lv_obj_add_event_cb(mbox1, [](lv_event_t *e) {
lv_obj_t *obj = lv_obj_get_parent(lv_event_get_target(e));
Expand Down
5 changes: 5 additions & 0 deletions src/file_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ void FilePanel::refresh_view(json &j, const std::string &gcode_path) {
uint32_t normalized_thumb_scale = ((0.29 * (double)screen_width) / (double)thumb_detail.second) * 256;
lv_img_set_src(thumbnail, ("A:" + fullpath).c_str());
lv_img_set_zoom(thumbnail, normalized_thumb_scale);
} else {
// free src
lv_img_set_src(thumbnail, NULL);
// hack to color in empty space.
((lv_img_t*)thumbnail)->src_type = LV_IMG_SRC_SYMBOL;
}
}

Expand Down
12 changes: 9 additions & 3 deletions src/inputshaper_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,12 @@ void InputShaperPanel::handle_callback(lv_event_t *event) {
if (x_requested) {
// ws.gcode_script(fmt::format("TEST_RESONANCES AXIS=X NAME=x FREQ_START={} FREQ_END={}\nM400", 5, 10));
ws.gcode_script(fmt::format("TEST_RESONANCES AXIS=X NAME=x\nM400"));


// free src
lv_img_set_src(xgraph, NULL);
lv_obj_invalidate(xgraph);
// hack to color in empty space.
((lv_img_t*)xgraph)->src_type = LV_IMG_SRC_SYMBOL;

lv_label_set_text(xoutput, "");
lv_obj_add_flag(xgraph_cont, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(xspinner, LV_OBJ_FLAG_HIDDEN);
Expand All @@ -315,8 +318,11 @@ void InputShaperPanel::handle_callback(lv_event_t *event) {
// ws.gcode_script(fmt::format("TEST_RESONANCES AXIS=Y NAME=y FREQ_START={} FREQ_END={}\nM400", 5, 10));
ws.gcode_script(fmt::format("TEST_RESONANCES AXIS=Y NAME=y\nM400"));

// free src
lv_img_set_src(ygraph, NULL);
lv_obj_invalidate(ygraph);
// hack to color in empty space.
((lv_img_t*)ygraph)->src_type = LV_IMG_SRC_SYMBOL;

lv_label_set_text(youtput, "");
lv_obj_add_flag(ygraph_cont, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(yspinner, LV_OBJ_FLAG_HIDDEN);
Expand Down
6 changes: 6 additions & 0 deletions src/mini_print_status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ void MiniPrintStatus::update_img(const std::string &img_path, size_t twidth) {

void MiniPrintStatus::reset() {
lv_arc_set_value(progress_bar, 0);

// free src
lv_img_set_src(thumb, NULL);
// hack to color in empty space.
((lv_img_t*)thumb)->src_type = LV_IMG_SRC_SYMBOL;

eta = "...";
status = "n/a";
}
Expand Down
8 changes: 6 additions & 2 deletions src/numpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Numpad::Numpad(lv_obj_t *parent)
lv_obj_clear_flag(edit_cont, LV_OBJ_FLAG_SCROLLABLE);

lv_obj_move_background(edit_cont);
lv_obj_set_size(edit_cont, LV_PCT(48), LV_PCT(90));
lv_obj_set_size(edit_cont, LV_PCT(48), LV_PCT(100));

lv_obj_set_flex_align(edit_cont, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_align(edit_cont, LV_ALIGN_RIGHT_MID, 0, 0);
Expand All @@ -27,7 +27,11 @@ Numpad::Numpad(lv_obj_t *parent)
lv_obj_set_size(input, LV_PCT(100), LV_SIZE_CONTENT);
lv_textarea_set_one_line(input, true);

lv_obj_set_size(kb, LV_PCT(100), LV_PCT(70));
lv_obj_set_size(kb, LV_PCT(100), LV_PCT(85));
static const char * kb_map[] = {"1", "2", "3", "\n", "4", "5", "6", "\n", "7", "8", "9", "\n", LV_SYMBOL_BACKSPACE, "0", LV_SYMBOL_OK, NULL };
static const lv_btnmatrix_ctrl_t kb_ctrl[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
lv_keyboard_set_map(kb, LV_KEYBOARD_MODE_NUMBER, kb_map, kb_ctrl);

lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUMBER);
lv_keyboard_set_textarea(kb, input);

Expand Down
1 change: 0 additions & 1 deletion src/print_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ void PrintPanel::handle_print_callback(lv_event_t *event) {

json fname_input = {{"filename", cur_file->full_path }};
ws.send_jsonrpc("printer.print.start", fname_input);
print_status.reset();
print_status.foreground();

} else {
Expand Down
36 changes: 17 additions & 19 deletions src/print_status_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ PrintStatusPanel::PrintStatusPanel(KWebSocketClient &websocket_client,
lv_obj_set_flex_align(buttons_cont, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);

lv_obj_set_style_pad_all(pbar_cont, 0, 0);
lv_obj_set_style_pad_top(pbar_cont, 10, 0);
lv_obj_set_size(pbar_cont, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
// lv_obj_set_style_border_width(pbar_cont, 2, 0);
// lv_obj_set_style_border_width(thumbnail_cont, 2, 0);
Expand All @@ -133,10 +132,10 @@ PrintStatusPanel::PrintStatusPanel(KWebSocketClient &websocket_client,
lv_obj_center(progress_label);

lv_obj_set_flex_flow(thumbnail_cont, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(thumbnail_cont, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_set_flex_align(thumbnail_cont, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START);
lv_obj_set_size(thumbnail_cont, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_pad_all(thumbnail_cont, 0, 0);
lv_obj_set_style_pad_row(thumbnail_cont, 0, 0);
lv_obj_set_style_pad_row(thumbnail_cont, 20, 0);

// row 1
lv_obj_set_grid_cell(thumbnail_cont, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
Expand All @@ -158,7 +157,7 @@ PrintStatusPanel::~PrintStatusPanel() {
}

void PrintStatusPanel::foreground() {
populate();
// populate();
lv_obj_move_foreground(status_cont);
}

Expand All @@ -184,6 +183,11 @@ void PrintStatusPanel::reset() {
extruder_target = -1;
heater_bed_target = -1;

// free src
lv_img_set_src(thumbnail, NULL);
// hack to color in empty space.
((lv_img_t*)thumbnail)->src_type = LV_IMG_SRC_SYMBOL;

mini_print_status.reset();
}

Expand Down Expand Up @@ -212,6 +216,7 @@ void PrintStatusPanel::init(json &fans) {

fan0.update_label(fmt::format("{}", fmt::join(values, ", ")).c_str());

reset();
populate();
json &pstat_state = State::get_instance()
->get_data("/printer_state/print_stats/state"_json_pointer);
Expand All @@ -230,7 +235,6 @@ void PrintStatusPanel::init(json &fans) {
void PrintStatusPanel::populate() {
State* s = State::get_instance();
json& printfile = s->get_data("/printer_state/print_stats/filename"_json_pointer);

if (!printfile.is_null()) {
const std::string fname = printfile.template get<std::string>();
if (fname.length() > 0) {
Expand All @@ -254,13 +258,10 @@ void PrintStatusPanel::populate() {
// progress percentage
auto v = s->get_data("/printer_state/virtual_sdcard/progress"_json_pointer);
if (!v.is_null()) {
int cur_value = (int)lv_bar_get_value(progress_bar);
int new_value = static_cast<int>(v.template get<double>() * 100);
if (new_value >= cur_value + 1) {
lv_bar_set_value(progress_bar, new_value, LV_ANIM_ON);
lv_label_set_text(progress_label, fmt::format("{}%", new_value).c_str());
mini_print_status.update_progress(new_value);
}
lv_bar_set_value(progress_bar, new_value, LV_ANIM_ON);
lv_label_set_text(progress_label, fmt::format("{}%", new_value).c_str());
mini_print_status.update_progress(new_value);
}
}

Expand Down Expand Up @@ -303,8 +304,8 @@ void PrintStatusPanel::consume(json &j) {
auto printfile = j["/params/0/print_stats/filename"_json_pointer];
if (!printfile.is_null()) {
// filename change indicates a start of a print
// populate();
reset();
populate();
foreground(); // auto move to front when print is detected
}

Expand Down Expand Up @@ -397,13 +398,10 @@ void PrintStatusPanel::consume(json &j) {
// progress percentage
v = j["/params/0/virtual_sdcard/progress"_json_pointer];
if (!v.is_null()) {
int cur_value = (int)lv_bar_get_value(progress_bar);
int new_value = static_cast<int>(v.template get<double>() * 100);
if (new_value >= cur_value + 1) {
lv_bar_set_value(progress_bar, new_value, LV_ANIM_ON);
lv_label_set_text(progress_label, fmt::format("{}%", new_value).c_str());
mini_print_status.update_progress(new_value);
}
lv_bar_set_value(progress_bar, new_value, LV_ANIM_ON);
lv_label_set_text(progress_label, fmt::format("{}%", new_value).c_str());
mini_print_status.update_progress(new_value);
}

// flow
Expand Down Expand Up @@ -518,7 +516,7 @@ void PrintStatusPanel::update_flow_rate(double filament_used) {
flow = filament_xsection * filament_delta / delta;

spdlog::trace("caculated flow {}", flow);
flow_rate.update_label(fmt::format("{:.4} mm3/s", flow).c_str());
flow_rate.update_label(fmt::format("{:.3f} mm3/s", flow).c_str());
}

last_filament_used = filament_used;
Expand Down

0 comments on commit 4a0b68d

Please sign in to comment.