-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
printerdemo_mcu PrinterQueueItem uses a status string
Use a string instead of the JobStatus enum. This makes the PrinterQueue code compatible with the printerdemo code, allowing us to switch between mcu and non-mcu versions of this demo, depending on what will fit on a device. A string is used, rather than porting the non-mcu demo to an enum, because the non-mcu demo needs to work with the cpp_interpreted demo.
- Loading branch information
Showing
3 changed files
with
12 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ extern "C" void app_main(void) | |
char time_buf[100] = { 0 }; | ||
std::strftime(time_buf, sizeof(time_buf), "%H:%M:%S %d/%m/%Y", std::localtime(&now)); | ||
PrinterQueueItem item; | ||
item.status = JobStatus::Waiting; | ||
item.status = "waiting"; | ||
item.progress = 0; | ||
item.title = std::move(name); | ||
item.owner = "[email protected]"; | ||
|
@@ -94,7 +94,7 @@ extern "C" void app_main(void) | |
if (top_item.progress > 100) { | ||
printer_queue->erase(0); | ||
} else { | ||
top_item.status = JobStatus::Printing; | ||
top_item.status = "printing"; | ||
printer_queue->set_row_data(0, top_item); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,8 @@ | |
|
||
import { DemoPalette, PushButton } from "./common.slint"; | ||
|
||
enum JobStatus { | ||
Waiting, | ||
Printing | ||
} | ||
|
||
export struct PrinterQueueItem { | ||
status: JobStatus, | ||
status: string, | ||
progress: int, | ||
title: string, | ||
owner: string, | ||
|
@@ -20,19 +15,19 @@ export struct PrinterQueueItem { | |
|
||
export global PrinterQueue { | ||
in property <[PrinterQueueItem]> printer-queue: [ | ||
{ status: JobStatus.Printing, progress: 63, title: "Slint-Demo.jpeg", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" }, | ||
{ status: JobStatus.Waiting, title: "Adressliste.docx", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" }, | ||
{ status: JobStatus.Waiting, title: "210106-FinalPresentation.pdf", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" }, | ||
{ status: "printing", progress: 63, title: "Slint-Demo.jpeg", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" }, | ||
{ status: "waiting", title: "Adressliste.docx", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" }, | ||
{ status: "waiting", title: "210106-FinalPresentation.pdf", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" }, | ||
]; | ||
|
||
callback start-job(string); | ||
callback cancel-job(int); | ||
callback pause-job(int); | ||
|
||
public pure function statusString(status: JobStatus) -> string { | ||
if (status == JobStatus.Printing) { | ||
public pure function statusString(status: string) -> string { | ||
if (status == "printing") { | ||
"PRINTING" | ||
} else if (status == JobStatus.Waiting) { | ||
} else if (status == "waiting") { | ||
"WAITING..." | ||
} else { | ||
"Unknown job status" | ||
|
@@ -186,7 +181,7 @@ component NarrowPrintQueueElement inherits Rectangle { | |
Text { | ||
// TODO: text-transform: uppercase | ||
text: { | ||
if (root.queue-item.status == JobStatus.Printing) { | ||
if (root.queue-item.status == "printing") { | ||
"\{root.queue-item.progress}% - \{PrinterQueue.statusString(root.queue-item.status)}" | ||
} else { | ||
PrinterQueue.statusString(root.queue-item.status) | ||
|