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

Show loading progress #768

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions selfdrive/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def unblock_stdout():
if is_neos:
version = int(open("/VERSION").read()) if os.path.isfile("/VERSION") else 0
revision = int(open("/REVISION").read()) if version >= 10 else 0 # Revision only present in NEOS 10 and up
neos_update_required = version < 10 or (version == 10 and revision != 3)
neos_update_required = version < 10 or (version == 10 and revision != 4)

if neos_update_required:
# update continue.sh before updating NEOS
Expand Down Expand Up @@ -504,8 +504,24 @@ def manager_prepare():

# build all processes
os.chdir(os.path.dirname(os.path.abspath(__file__)))
for p in managed_processes:

params = Params()
process_cnt = len(managed_processes)
loader_proc = subprocess.Popen(["./spinner"], stdin = subprocess.PIPE,
cwd=os.path.join(BASEDIR, "selfdrive", "ui", "spinner"),
close_fds=True)
spinner_text = "chffrplus" if params.get("Passive")=="1" else "openpilot"

for n,p in enumerate(managed_processes):
if os.getenv("PREPAREONLY") is None:
loader_text = "loading {0}: {1}/{2} {3}".format(spinner_text, n+1, process_cnt, p)
loader_proc.stdin.write(loader_text + "\n")
prepare_managed_process(p)

loader_proc.stdin.close()
loader_proc.terminate()
# end subprocesses here to stop screen flickering
#[loader_proc[pc].terminate() for pc in range(process_cnt) if loader_proc]

def uninstall():
cloudlog.warning("uninstalling")
Expand All @@ -518,6 +534,9 @@ def main():
# the flippening!
os.system('LD_LIBRARY_PATH="" content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1')

# disable bluetooth
os.system('service call bluetooth_manager 8')

if os.getenv("NOLOG") is not None:
del managed_processes['loggerd']
del managed_processes['tombstoned']
Expand Down Expand Up @@ -585,9 +604,11 @@ def main():
spinner_proc = None
else:
spinner_text = "chffrplus" if params.get("Passive")=="1" else "openpilot"
spinner_proc = subprocess.Popen(["./spinner", "loading %s"%spinner_text],
init_text = "initializing {0}".format(spinner_text)
spinner_proc = subprocess.Popen(["./spinner"], stdin = subprocess.PIPE,
cwd=os.path.join(BASEDIR, "selfdrive", "ui", "spinner"),
close_fds=True)
spinner_proc.stdin.write(init_text + "\n")
try:
manager_update()
manager_init()
Expand Down
Binary file modified selfdrive/ui/spinner/spinner
Binary file not shown.
28 changes: 16 additions & 12 deletions selfdrive/ui/spinner/spinner.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

#include "common/framebuffer.h"

int main(int argc, char** argv) {
int main() {
int err;

const char* spintext = NULL;
if (argc >= 2) {
spintext = argv[1];
}
fd_set readfds;
FD_ZERO(&readfds);
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
char spintext[50];

// spinner
int fb_w, fb_h;
Expand All @@ -35,7 +36,7 @@ int main(int argc, char** argv) {
NVGcontext *vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
assert(vg);

int font = nvgCreateFont(vg, "Bold", "../../assets/OpenSans-SemiBold.ttf");
int font = nvgCreateFont(vg, "Bold", "../../assets/fonts/opensans_semibold.ttf");
assert(font >= 0);

int spinner_img = nvgCreateImage(vg, "../../assets/img_spinner_track.png", 0);
Expand All @@ -49,6 +50,11 @@ int main(int argc, char** argv) {
assert(spinner_comma_img >= 0);

for (int cnt = 0; ; cnt++) {
FD_SET(STDIN_FILENO, &readfds);
if (select(1, &readfds, NULL, NULL, &timeout)) {
fgets(spintext, sizeof spintext, stdin);
spintext[strcspn(spintext, "\n")] = 0;
}
glClearColor(0.1, 0.1, 0.1, 1.0);
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glEnable(GL_BLEND);
Expand Down Expand Up @@ -85,11 +91,9 @@ int main(int argc, char** argv) {
nvgFill(vg);

// message
if (spintext) {
nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP);
nvgFontSize(vg, 96.0f);
nvgText(vg, fb_w/2, (fb_h*2/3)+24, spintext, NULL);
}
nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP);
nvgFontSize(vg, 96.0f);
nvgText(vg, fb_w/2, (fb_h*2/3)+24, spintext, NULL);

nvgEndFrame(vg);
eglSwapBuffers(display, surface);
Expand Down