summaryrefslogtreecommitdiff
path: root/supervisor/shared
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2020-11-25 17:52:06 -0500
committerDan Halbert <halbert@halwitz.org>2020-11-25 17:52:06 -0500
commitef0830bfe241b544b05bd3081f5bba03af57fe0d (patch)
tree28b6c45fdd03288bbf43b77f42025d1773622f13 /supervisor/shared
parent9dbea36eac9a78cf324bba8d32a5cb2c9940d411 (diff)
parente778fc1f876116fd8f07b95f9eb8439745988fba (diff)
merge from upstream + wip
Diffstat (limited to 'supervisor/shared')
-rw-r--r--supervisor/shared/display.c14
-rw-r--r--supervisor/shared/workflow.c29
-rw-r--r--supervisor/shared/workflow.h7
3 files changed, 17 insertions, 33 deletions
diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c
index afb3f3a9a..a9ae25884 100644
--- a/supervisor/shared/display.c
+++ b/supervisor/shared/display.c
@@ -60,18 +60,21 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
#if CIRCUITPY_TERMINALIO
displayio_tilegrid_t* grid = &supervisor_terminal_text_grid;
- uint16_t width_in_tiles = (width_px - blinka_bitmap.width) / grid->tile_width;
+ bool tall = height_px > width_px;
+ uint16_t terminal_width_px = tall ? width_px : width_px - blinka_bitmap.width;
+ uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px ;
+ uint16_t width_in_tiles = terminal_width_px / grid->tile_width;
// determine scale based on h
if (width_in_tiles < 80) {
scale = 1;
}
- width_in_tiles = (width_px - blinka_bitmap.width * scale) / (grid->tile_width * scale);
+ width_in_tiles = terminal_width_px / (grid->tile_width * scale);
if (width_in_tiles < 1) {
width_in_tiles = 1;
}
- uint16_t height_in_tiles = height_px / (grid->tile_height * scale);
- uint16_t remaining_pixels = height_px % (grid->tile_height * scale);
+ uint16_t height_in_tiles = terminal_height_px / (grid->tile_height * scale);
+ uint16_t remaining_pixels = tall ? 0 : terminal_height_px % (grid->tile_height * scale);
if (height_in_tiles < 1 || remaining_pixels > 0) {
height_in_tiles += 1;
}
@@ -91,7 +94,8 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
if (tiles == NULL) {
return;
}
- grid->y = 0;
+ grid->y = tall ? blinka_bitmap.height : 0;
+ grid->x = tall ? 0 : blinka_bitmap.width;
grid->top_left_y = 0;
if (remaining_pixels > 0) {
grid->y -= (grid->tile_height - remaining_pixels);
diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c
index 67d191172..8e4ec16c0 100644
--- a/supervisor/shared/workflow.c
+++ b/supervisor/shared/workflow.c
@@ -28,33 +28,18 @@
#include "py/mpconfig.h"
#include "tusb.h"
-STATIC bool _allow_deep_sleep_when_connected;
-STATIC bool _allow_deep_sleep_on_error;
-
-
void supervisor_workflow_reset(void) {
- _allow_deep_sleep_when_connected = false;
- _allow_deep_sleep_on_error = false;
}
+// Return true as soon as USB communication with host has started,
+// even before enumeration is done.
+bool supervisor_workflow_connecting(void) {
+ return tud_connected();
+}
+
+// Return true if host has completed connection to us (such as USB enumeration).
bool supervisor_workflow_active(void) {
// Eventually there might be other non-USB workflows, such as BLE.
// tud_ready() checks for usb mounted and not suspended.
return tud_ready();
}
-
-bool supervisor_workflow_get_allow_deep_sleep_when_connected(void) {
- return _allow_deep_sleep_when_connected;
-}
-
-void supervisor_workflow_set_allow_deep_sleep_when_connected(bool allow) {
- _allow_deep_sleep_when_connected = allow;
-}
-
-bool supervisor_workflow_get_allow_deep_sleep_on_error(void) {
- return _allow_deep_sleep_on_error;
-}
-
-void supervisor_workflow_set_allow_deep_sleep_on_error(bool allow) {
- _allow_deep_sleep_on_error = allow;
-}
diff --git a/supervisor/shared/workflow.h b/supervisor/shared/workflow.h
index 97584a1f4..22a9fa468 100644
--- a/supervisor/shared/workflow.h
+++ b/supervisor/shared/workflow.h
@@ -28,10 +28,5 @@
extern void supervisor_workflow_reset(void);
+extern bool supervisor_workflow_connecting(void);
extern bool supervisor_workflow_active(void);
-
-extern bool supervisor_workflow_get_allow_deep_sleep_when_connected(void);
-extern void supervisor_workflow_set_allow_deep_sleep_when_connected(bool allow);
-
-extern bool supervisor_workflow_get_allow_deep_sleep_on_error(void);
-extern void supervisor_workflow_set_allow_deep_sleep_on_error(bool allow);