Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • batt-capacity
  • battery-symbol
  • ch3/api-speed-eval2
  • ch3/dual-core
  • ch3/genapi-refactor
  • ch3/leds-api
  • ch3/splashscreen
  • charge_voltage
  • clock-fix
  • color-definitions
  • dualcore
  • framebuffer-overlay
  • freertos-btle
  • genofire/ble-rewrite
  • ios-workarounds
  • koalo/bhi160
  • koalo/bhi160-works-but-dirty
  • koalo/factory-reset
  • koalo/wip/i2c-for-python
  • master
  • menu-disp
  • msgctl/faultscreen
  • msgctl/gfx_rle
  • msgctl/textbuffer_api
  • personal-state-colors
  • power
  • pybattery
  • rahix/bhi
  • rahix/bma
  • rahix/simple_menu
  • renze/hatchery_apps
  • renze/safe_mode
  • schleicher-test
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • schneider/fundamental-test
  • schneider/mp-for-old-bl
  • schneider/schleicher-test
  • bootloader-v1
  • release-1
  • v0.0
  • v1.0
  • v1.1
  • v1.2
45 results

Target

Select target project
  • card10/firmware
  • annejan/firmware
  • astro/firmware
  • fpletz/firmware
  • gerd/firmware
  • fleur/firmware
  • swym/firmware
  • l/firmware
  • uberardy/firmware
  • wink/firmware
  • madonius/firmware
  • mot/firmware
  • filid/firmware
  • q3k/firmware
  • hauke/firmware
  • Woazboat/firmware
  • pink/firmware
  • mossmann/firmware
  • omniskop/firmware
  • zenox/firmware
  • trilader/firmware
  • Danukeru/firmware
  • shoragan/firmware
  • zlatko/firmware
  • sistason/firmware
  • datenwolf/firmware
  • bene/firmware
  • amedee/firmware
  • martinling/firmware
  • griffon/firmware
  • chris007/firmware
  • adisbladis/firmware
  • dbrgn/firmware
  • jelly/firmware
  • rnestler/firmware
  • mh/firmware
  • ln/firmware
  • penguineer/firmware
  • monkeydom/firmware
  • jens/firmware
  • jnaulty/firmware
  • jeffmakes/firmware
  • marekventur/firmware
  • pete/firmware
  • h2obrain/firmware
  • DooMMasteR/firmware
  • jackie/firmware
  • prof_r/firmware
  • Draradech/firmware
  • Kartoffel/firmware
  • hinerk/firmware
  • abbradar/firmware
  • JustTB/firmware
  • LuKaRo/firmware
  • iggy/firmware
  • ente/firmware
  • flgr/firmware
  • Lorphos/firmware
  • matejo/firmware
  • ceddral7/firmware
  • danb/firmware
  • joshi/firmware
  • melle/firmware
  • fitch/firmware
  • deurknop/firmware
  • sargon/firmware
  • markus/firmware
  • kloenk/firmware
  • lucaswerkmeister/firmware
  • derf/firmware
  • meh/firmware
  • dx/card10-firmware
  • torben/firmware
  • yuvadm/firmware
  • AndyBS/firmware
  • klausdieter1/firmware
  • katzenparadoxon/firmware
  • xiretza/firmware
  • ole/firmware
  • techy/firmware
  • thor77/firmware
  • TilCreator/firmware
  • fuchsi/firmware
  • dos/firmware
  • yrlf/firmware
  • PetePriority/firmware
  • SuperVirus/firmware
  • sur5r/firmware
  • tazz/firmware
  • Alienmaster/firmware
  • flo_h/firmware
  • baldo/firmware
  • mmu_man/firmware
  • Foaly/firmware
  • sodoku/firmware
  • Guinness/firmware
  • ssp/firmware
  • led02/firmware
  • Stormwind/firmware
  • arist/firmware
  • coon/firmware
  • mdik/firmware
  • pippin/firmware
  • royrobotiks/firmware
  • zigot83/firmware
  • mo_k/firmware
106 results
Select Git revision
  • add_menu_vibration
  • blinkisync-as-preload
  • ch3/api-speed-eval2
  • ch3/dual-core
  • ch3/genapi-refactor
  • ch3/leds-api
  • ch3/splashscreen
  • dualcore
  • dx/flatten-config-module
  • dx/meh-bdf-to-stm
  • freertos-btle
  • genofire/ble-follow-py
  • koalo/bhi160-works-but-dirty
  • koalo/factory-reset
  • koalo/wip/i2c-for-python
  • master
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • plaetzchen/ios-workaround
  • rahix/bhi
  • rahix/bluetooth-app-favorite
  • rahix/bma
  • rahix/user-space-ctx
  • renze/hatchery_apps
  • renze/safe_mode
  • schleicher-test
  • schneider/212-reset-hardware-when-entering-repl
  • schneider/ancs
  • schneider/ble-buffers
  • schneider/ble-central
  • schneider/ble-ecg-stream-visu
  • schneider/ble-fixes-2020-3
  • schneider/ble-mini-demo
  • schneider/ble-stability
  • schneider/ble-stability-new-phy
  • schneider/bonding
  • schneider/bonding-fail-if-full
  • schneider/bootloader-update-9a0d158
  • schneider/deepsleep
  • schneider/deepsleep2
  • schneider/deepsleep4
  • schneider/default-main
  • schneider/freertos-list-debug
  • schneider/fundamental-test
  • schneider/iaq-python
  • schneider/ir
  • schneider/max30001
  • schneider/max30001-epicaridum
  • schneider/max30001-pycardium
  • schneider/maxim-sdk-update
  • schneider/mp-exception-print
  • schneider/mp-for-old-bl
  • schneider/png
  • schneider/schleicher-test
  • schneider/sdk-0.2.1-11
  • schneider/sdk-0.2.1-7
  • schneider/sleep-display
  • schneider/spo2-playground
  • schneider/stream-locks
  • schneider/v1.17-changelog
  • bootloader-v1
  • release-1
  • v0.0
  • v1.0
  • v1.1
  • v1.10
  • v1.11
  • v1.12
  • v1.13
  • v1.14
  • v1.15
  • v1.16
  • v1.17
  • v1.18
  • v1.2
  • v1.3
  • v1.4
  • v1.5
  • v1.6
  • v1.7
  • v1.8
  • v1.9
82 results
Show changes
Commits on Source (6)
......@@ -55,6 +55,9 @@ typedef _Bool bool;
#define API_DISP_FRAMEBUFFER 0x29
#define API_DISP_BACKLIGHT 0x2a
#define API_DISP_PRINT_ADV 0x2b
#define API_DISP_OVERLAY 0x2c
#define API_DISP_SET_FULLSCREEN 0x2d
#define API_DISP_IS_FULLSCREEN 0x2e
/* API_BATTERY_VOLTAGE 0x30 */
#define API_BATTERY_CURRENT 0x31
......@@ -1306,6 +1309,36 @@ union disp_framebuffer {
*/
API(API_DISP_OPEN, int epic_disp_open());
/**
* Enable/disable fullscreen mode.
*
* Fullscreen will disable the overlay display.
*
* :param enable: ``true`` to enable fullscreen mode
* :return: ``0`` on success or a negative value in case of an error:
*
* - ``-EBUSY``: Display was already locked from another task.
*/
API(API_DISP_SET_FULLSCREEN, int epic_disp_set_fullscreen(bool enable));
/**
* Return fullscreen status. No lock is required.
*
* Fullscreen will disable the overlay display.
*
* :return: ``true`` if fullscreen is enabled
*/
API(API_DISP_IS_FULLSCREEN, bool epic_disp_is_fullscreen());
/**
* Switch framebuffer to overlay.
*
* :return: ``0`` on success or a negative value in case of an error:
*
* - ``-EBUSY``: Display was already locked from another task.
*/
API(API_DISP_OVERLAY, int epic_disp_overlay());
/**
* Unlocks the display again.
*
......
......@@ -3,6 +3,7 @@
#include "FreeRTOS.h"
#include "LCD_Driver.h"
#include "epicardium.h"
#include "framebuffer.h"
#include "gfx.h"
#include "gpio.h"
#include "task.h"
......@@ -11,6 +12,9 @@
static TaskHandle_t lock = NULL;
static struct gfx_region *current_fb = &application_screen;
static bool fullscreen = false;
static int check_lock()
{
TaskHandle_t task = xTaskGetCurrentTaskHandle();
......@@ -71,7 +75,7 @@ int epic_disp_clear(uint16_t color)
if (cl < 0) {
return cl;
} else {
gfx_clear_to_color(&display_screen, color);
gfx_clear_to_color(current_fb, color);
return 0;
}
}
......@@ -82,7 +86,7 @@ int epic_disp_pixel(int16_t x, int16_t y, uint16_t color)
if (cl < 0) {
return cl;
} else {
gfx_setpixel(&display_screen, x, y, color);
gfx_setpixel(current_fb, x, y, color);
return 0;
}
}
......@@ -102,7 +106,7 @@ int epic_disp_line(
} else {
/* TODO add linestyle support to gfx code */
gfx_line(
&display_screen,
current_fb,
xstart,
ystart,
xend,
......@@ -130,7 +134,7 @@ int epic_disp_rect(
switch (fillstyle) {
case FILLSTYLE_EMPTY:
gfx_rectangle(
&display_screen,
current_fb,
xstart,
ystart,
xend - xstart,
......@@ -141,7 +145,7 @@ int epic_disp_rect(
break;
case FILLSTYLE_FILLED:
gfx_rectangle_fill(
&display_screen,
current_fb,
xstart,
ystart,
xend - xstart,
......@@ -167,16 +171,47 @@ int epic_disp_circ(
switch (fillstyle) {
case FILLSTYLE_EMPTY:
gfx_circle(&display_screen, x, y, rad, pixelsize, color);
gfx_circle(current_fb, x, y, rad, pixelsize, color);
break;
case FILLSTYLE_FILLED:
gfx_circle_fill(&display_screen, x, y, rad, color);
gfx_circle_fill(current_fb, x, y, rad, color);
break;
}
return 0;
}
void compositor()
{
/* Check that BPP is 2 for everything */
const size_t bpp_app = fb_bytes_per_pixel(application_screen.fb);
const size_t bpp_ovl = fb_bytes_per_pixel(overlay_screen.fb);
const size_t bpp_disp = fb_bytes_per_pixel(overlay_screen.fb);
if ((bpp_app != 2) || (bpp_ovl != 2) || (bpp_disp != 2))
return;
/* Compose overlay on application */
for (int y = 0; y < display_screen.height; y++) {
for (int x = 0; x < display_screen.width; x++) {
uint8_t *overlay_pixel =
fb_pixel(overlay_screen.fb, x, y);
uint8_t *target = fb_pixel(display_screen.fb, x, y);
if ((overlay_pixel[0] == 0) &&
(overlay_pixel[1] == 0)) {
uint8_t *app_pixel =
fb_pixel(application_screen.fb, x, y);
target[0] = app_pixel[0];
target[1] = app_pixel[1];
} else {
target[0] = overlay_pixel[0];
target[1] = overlay_pixel[1];
}
}
}
}
int epic_disp_update()
{
int cl = check_lock();
......@@ -184,6 +219,10 @@ int epic_disp_update()
return cl;
}
if (!fullscreen) {
compositor();
}
gfx_update(&display_screen);
return 0;
}
......@@ -210,15 +249,48 @@ int epic_disp_open()
{
TaskHandle_t task = xTaskGetCurrentTaskHandle();
if (lock == task) {
current_fb = fullscreen ? &display_screen : &application_screen;
return 0;
} else if (lock == NULL) {
lock = task;
current_fb = fullscreen ? &display_screen : &application_screen;
return 0;
} else {
return -EBUSY;
}
}
int epic_disp_set_fullscreen(bool enable)
{
int cl = check_lock();
if (cl < 0) {
return cl;
}
fullscreen = enable;
current_fb = fullscreen ? &display_screen : &application_screen;
return 0;
}
bool epic_disp_is_fullscreen()
{
return fullscreen;
}
int epic_disp_overlay()
{
int cl = check_lock();
if (cl < 0) {
return cl;
}
current_fb = &overlay_screen;
return 0;
}
int epic_disp_close()
{
if (check_lock() < 0 && lock != NULL) {
......
......@@ -16,6 +16,31 @@ const gpio_cfg_t DEV_DC_PIN = { PORT_1, PIN_6, GPIO_FUNC_OUT, GPIO_PAD_NONE };
struct gfx_region display_screen;
struct txt_buffer display_textb;
/***** Virtual framebuffers *****/
static uint8_t app_buffer[LCD_HEIGHT][LCD_WIDTH][2];
static struct framebuffer app_framebuffer = { .data = app_buffer,
.width = LCD_WIDTH,
.height = LCD_HEIGHT,
.stride = LCD_WIDTH * LCD_HEIGHT *
2,
.orientation = FB_O_180,
.update = NULL };
struct gfx_region application_screen;
static uint8_t ovl_buffer[LCD_HEIGHT][LCD_WIDTH][2];
static struct framebuffer ovl_framebuffer = { .data = ovl_buffer,
.width = LCD_WIDTH,
.height = LCD_HEIGHT,
.stride = LCD_WIDTH * LCD_HEIGHT *
2,
.orientation = FB_O_180,
.update = NULL };
struct gfx_region overlay_screen;
/***** Functions *****/
void display_set_reset_pin(uint8_t state)
{
......@@ -43,6 +68,14 @@ void display_init(void)
display_screen = gfx_screen(LCD_framebuffer());
txt_init(&display_textb, &display_screen, &Font12);
gfx_clear(&display_screen);
app_framebuffer.encode_color_rgb = display_screen.fb->encode_color_rgb;
application_screen = gfx_screen(&app_framebuffer);
gfx_clear(&application_screen);
ovl_framebuffer.encode_color_rgb = display_screen.fb->encode_color_rgb;
overlay_screen = gfx_screen(&ovl_framebuffer);
gfx_clear(&overlay_screen);
}
void display_init_slim(void)
......@@ -58,4 +91,12 @@ void display_init_slim(void)
display_screen = gfx_screen(LCD_framebuffer());
txt_init(&display_textb, &display_screen, &Font12);
app_framebuffer.encode_color_rgb = display_screen.fb->encode_color_rgb;
application_screen = gfx_screen(&app_framebuffer);
gfx_clear(&application_screen);
ovl_framebuffer.encode_color_rgb = display_screen.fb->encode_color_rgb;
overlay_screen = gfx_screen(&ovl_framebuffer);
gfx_clear(&overlay_screen);
}
......@@ -5,6 +5,9 @@
extern struct gfx_region display_screen;
extern struct txt_buffer display_textb;
extern struct gfx_region application_screen;
extern struct gfx_region overlay_screen;
void display_init(void);
void display_init_slim(void);
......
......@@ -42,6 +42,19 @@ class Display:
"""
return cls()
def set_fullscreen(self, enable):
"""
Enable/disable fullscreen, so that overlays are not shown.
Will fail the display can't be locked
"""
sys_display.set_fullscreen(enable)
def is_fullscreen(self):
"""
Check if application is in fullscreen.
"""
return sys_display.is_fullscreen()
@staticmethod
def close():
"""
......
......@@ -93,6 +93,8 @@ Q(read_thermistor_voltage)
/* display */
Q(sys_display)
Q(set_fullscreen)
Q(is_fullscreen)
Q(display)
Q(print)
Q(print_adv)
......
......@@ -242,6 +242,29 @@ static mp_obj_t mp_display_open()
}
static MP_DEFINE_CONST_FUN_OBJ_0(display_open_obj, mp_display_open);
static mp_obj_t mp_display_set_fullscreen(mp_obj_t enable_obj)
{
int res = epic_disp_set_fullscreen(mp_obj_is_true(enable_obj));
if (res < 0) {
mp_raise_OSError(-res);
}
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_1(
display_set_fullscreen_obj, mp_display_set_fullscreen
);
static mp_obj_t mp_display_is_fullscreen()
{
bool res = epic_disp_is_fullscreen();
return mp_obj_new_bool(res);
}
static MP_DEFINE_CONST_FUN_OBJ_0(
display_is_fullscreen_obj, mp_display_is_fullscreen
);
/* Overlay mode is not exposed to Python apps*/
static mp_obj_t mp_display_close()
{
int res = epic_disp_close();
......@@ -256,6 +279,10 @@ static MP_DEFINE_CONST_FUN_OBJ_0(display_close_obj, mp_display_close);
static const mp_rom_map_elem_t display_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys_display) },
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&display_open_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_fullscreen),
MP_ROM_PTR(&display_set_fullscreen_obj) },
{ MP_ROM_QSTR(MP_QSTR_is_fullscreen),
MP_ROM_PTR(&display_is_fullscreen_obj) },
{ MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&display_close_obj) },
{ MP_ROM_QSTR(MP_QSTR_print), MP_ROM_PTR(&display_print_obj) },
{ MP_ROM_QSTR(MP_QSTR_print_adv), MP_ROM_PTR(&display_print_adv_obj) },
......