Commit e5661f12 authored by Rahix's avatar Rahix
Browse files

chore(panic): Use ctx instead of gfx

Use ctx to display the panic message.  The implementation contains a few
safeguards to hopefully deal with any breakage that happended before the
panic.
parent 69770d87
......@@ -12,16 +12,17 @@
#include "os/core.h"
#include "modules/modules.h"
#include "drivers/drivers.h"
#include "drivers/display/epic_ctx.h"
#include "drivers/display/lcd.h"
#include "card10.h"
#include "card10-version.h"
#include "gfx.h"
#include "display.h"
#include "LCD_Driver.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
static void faultsplash(const char *msg);
......@@ -121,34 +122,37 @@ static void faultsplash(const char *msg)
{
LCD_SetBacklight(100);
gfx_copy_region_rle_mono(
&display_screen,
0,
0,
160,
80,
sizeof(faultsplash_rle),
faultsplash_rle
);
size_t idx = 0;
for (size_t i = 0; i < sizeof(faultsplash_rle); i++) {
uint8_t color = (faultsplash_rle[i] & 0x80) ? 0xff : 0x00;
uint8_t length = faultsplash_rle[i] & 0x7f;
gfx_puts(&Font20, &display_screen, 80, 5, "Panic", 0xf800, 0xf800);
memset(&epicardium_ctx_fb[idx], color, length * 2);
idx += length * 2;
}
lcd_write_fb(epicardium_ctx_fb);
/* make sure we get a clean graphics ctx */
disp_ctx_reinit();
ctx_text_baseline(epicardium_ctx, CTX_TEXT_BASELINE_TOP);
ctx_font_size(epicardium_ctx, 20.0f);
ctx_move_to(epicardium_ctx, 80.0f, 8.0f);
ctx_rgba8(epicardium_ctx, 0xff, 0x00, 0x00, 0xff);
ctx_text(epicardium_ctx, "Panic");
ctx_font_size(epicardium_ctx, 12.0f);
ctx_rgba8(epicardium_ctx, 197, 197, 197, 0xff);
size_t len = strlen(msg);
char buf[15] = { 0 };
int offset = 34;
float offset = 34.0f;
for (size_t i = 0; i < len; i += 14) {
strncpy(buf, &msg[i], 14);
gfx_puts(
&Font12,
&display_screen,
52,
offset,
buf,
0xc618,
0xc618
);
offset += 12;
ctx_move_to(epicardium_ctx, 52.0f, offset);
ctx_text(epicardium_ctx, buf);
offset += 12.0f;
}
gfx_update(&display_screen);
lcd_write_fb(epicardium_ctx_fb);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment