Simplify a bit the rst logic and make a bit more robust draft

Thu, 09 Sep 2021 21:59:53 +0200

author
David Douard <david.douard@sdfa3.org>
date
Thu, 09 Sep 2021 21:59:53 +0200
changeset 63
f71f6c0af3cd
parent 62
55e3b4441b11
child 64
897330ee6e9d

Simplify a bit the rst logic and make a bit more robust

src/main.cpp file | annotate | diff | comparison | revisions
--- a/src/main.cpp	Thu Sep 09 21:49:16 2021 +0200
+++ b/src/main.cpp	Thu Sep 09 21:59:53 2021 +0200
@@ -29,7 +29,7 @@
 HPSerial *hp;
 Thread tdsp(osPriorityNormal, OS_STACK_SIZE, nullptr, "DSP");
 Ticker dsp_refresh;
-Timeout rst_delay;
+//Timeout rst_delay;
 Timeout splashscreen_timer;
 Timeout byescreen_timer;
 InterruptIn rst(HP_RST);
@@ -235,21 +235,22 @@
 
 void end_splashscreen(void)
 {
-  // print is forbidden here because we are in an ISR context here
-  //printf("End of splash screen CB\r\n");
   splashscreen = false;
-  dsp->cls();
-  dsp->power_off();
+  // wait for the reset irq from the CPU board
+  must_shutdown = true;
 }
 
+/*
 void reset_irq_tmr(void)
 {
 	must_reset = true;
 }
+*/
 
 void reset_irq(void)
 {
-	rst_delay.attach(callback(&reset_irq_tmr), 50ms);
+	must_reset = true;
+	//rst_delay.attach(callback(&reset_irq_tmr), 50ms);
 }
 
 void reset(void)
@@ -258,13 +259,13 @@
   printf("Reset connection to the main unit\n");
   if (DigitalIn(HP_RST).read() == 0) {
 	  byescreen_timer.detach(); // cancel a "poweroff", if any
+	  splashscreen_timer.detach(); // same for splashscreen
 	  splashscreen = false; // in case it still on
 
     if (hp == NULL) {
       printf("setup HP communication handler\r\n");
       hp = new HPSerial(HP_TX, HP_RX);
-    }
-	else {
+    } else {
 		printf("Connection already initialized\n");
 	}
 
@@ -274,10 +275,12 @@
 	dsp->power_on();
 	dsp->cls();
     printf("Initiate startup sequence\n");
-	if (last_key.keyevent == KEY_PRESSED)
+	if (last_key.keyevent == KEY_PRESSED) {
+		printf("  with key pressed\n");
 		hp->send_startup_seq(kp_mapping[last_key.row][last_key.col]);
-	else
+	} else {
 		hp->send_startup_seq();
+	}
   }
   else
   {
@@ -310,10 +313,13 @@
   while(1) {
 	if (must_reset) {
 	  must_reset = false;
+	  must_shutdown = false;  // just in case...
 	  reset();
 	}
+
 	if (must_shutdown) {
 		must_shutdown = false;
+		dsp->cls();
 		dsp->power_off();
 	}
 

mercurial