Browse Source

GD.alert(msg): show message and halt

jamesbowman 9 years ago
parent
commit
15c0bb98eb
2 changed files with 23 additions and 8 deletions
  1. 22 8
      GD2.cpp
  2. 1 0
      GD2.h

+ 22 - 8
GD2.cpp

@@ -925,22 +925,36 @@ byte GDClass::load(const char *filename, void (*progress)(long, long))
 }
 
 // Generated by mk_bsod.py. Blue screen with 'ERROR' text
-static const PROGMEM uint8_t __bsod[31] = {
-0, 255, 255, 255, 255, 0, 0, 2, 7, 0, 0, 38, 12, 255, 255, 255, 240,
-0, 120, 0, 28, 0, 0, 6, 69, 82, 82, 79, 82, 33, 0
+static const PROGMEM uint8_t __bsod[32] = {
+0, 255, 255, 255, 96, 0, 0, 2, 7, 0, 0, 38, 12, 255, 255, 255, 240, 0,
+90, 0, 31, 0, 0, 6, 69, 82, 82, 79, 82, 0, 0, 0
 };
-// "Cannot open file" text
-static const PROGMEM uint8_t __bsod_badfile[31] = {
-12, 255, 255, 255, 240, 0, 148, 0, 28, 0, 0, 6, 67, 97, 110, 110, 111,
-116, 32, 111, 112, 101, 110, 32, 102, 105, 108, 101, 0, 0, 0
+static const PROGMEM uint8_t __bsod_badfile[32] = {
+12, 255, 255, 255, 240, 0, 148, 0, 29, 0, 0, 6, 67, 97, 110, 110, 111,
+116, 32, 111, 112, 101, 110, 32, 102, 105, 108, 101, 58, 0, 0, 0
 };
 
+// Fatal error alert.
+// Show a blue screen with message.
+// This method never returns.
+
+void GDClass::alert(const char *message)
+{
+  begin(0);
+  copy(__bsod, sizeof(__bsod));
+  cmd_text(240, 176, 29, OPT_CENTER, message);
+  swap();
+  GD.finish();
+  for (;;)
+    ;
+}
+
 void GDClass::safeload(const char *filename)
 {
   if (!load(filename)) {
     copy(__bsod, sizeof(__bsod));
     copy(__bsod_badfile, sizeof(__bsod_badfile));
-    cmd_text(240, 176, 28, OPT_CENTER, filename);
+    cmd_text(240, 190, 29, OPT_CENTER, filename);
     swap();
     for (;;)
       ;

+ 1 - 0
GD2.h

@@ -463,6 +463,7 @@ public:
   void dumpscreen(void);
   byte load(const char *filename, void (*progress)(long, long) = NULL);
   void safeload(const char *filename);
+  void alert(const char *message);
 
   sdcard SD;