@horace my friend, this got me out of the woods to an extent! Thank you for this.
My next issue is not I am trying to use these interrupts to push an image onto my E Paper Display. I can see it enters my function call successfully by using serial outs just to see where it gets stuck, and it's getting stuck on line 126 which is being used to clear the display...
I know @ZinggJM is a Guru with these displays, maybe you could bestow some of your wisdom onto us Please refer to my other post to see my setup for this including the display and lib I used.
Thanks in advance guys!
I have posted my code below for reference
/* Includes ------------------------------------------------------------------*/
#include "DEV_Config.h"
#include "EPD.h"
#include "GUI_Paint.h"
#include "imagedata.h"
#include <stdlib.h>
#define Threshold 15
int touchPad;
bool touchDetected = false;
int flag = 0;
int i = 0;
UBYTE *BlackImage;
UWORD Imagesize = ((EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1)) * EPD_4IN2_V2_HEIGHT;
void setup() {
Serial.begin(115200);
delay(1000); // give me time to bring up serial monitor
Serial.println("Booting");
// printf("Beginning Display Setup----------------\r\n");
Serial.println("Beginning Display Setup");
DEV_Module_Init(); //Needs to be present
EPD_4IN2_V2_Init(); //Needs to be present
EPD_4IN2_V2_Clear(); //Needs to be present - Clears display on boot
// DEV_Delay_ms(500); //Needs to be present - Waits some time to let display chill
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
printf("Failed to apply for black memory...\r\n");
// while (1);
}
// printf("Goto Sleep...\r\n");
EPD_4IN2_V2_Sleep();
free(BlackImage);
BlackImage = NULL;
Serial.println("Completed Display Setup");
// printf("Completed Display Setup----------------\r\n");
// printf("Beginning Touch Setup------------------\r\n");
Serial.println("Beginning Touch Setup");
touchAttachInterrupt(T0, gotTouch0, Threshold);
touchAttachInterrupt(T3, gotTouch3, Threshold);
touchAttachInterrupt(T4, gotTouch4, Threshold);
touchAttachInterrupt(T5, gotTouch5, Threshold);
touchAttachInterrupt(T6, gotTouch6, Threshold);
touchAttachInterrupt(T7, gotTouch7, Threshold);
touchAttachInterrupt(T8, gotTouch8, Threshold);
touchAttachInterrupt(T9, gotTouch9, Threshold);
// printf("Completed Touch Setup------------------\r\n");
Serial.println("Completed Touch Setup");
}
void loop(){
if(touchDetected){ //Check continuously if any touch is detected
touchDetected = false;
switch(touchPad){
case 0 : Serial.println("Case 0 Selected"); prepareDisplay(); Paint_DrawBitMap(gImage_4in2_4Gray); sleepDisplay(); break;
case 3 : Serial.println("Case 3 Selected"); prepareDisplay(); Paint_DrawBitMap(gImage_4in2_4Gray1); sleepDisplay(); break;
case 4 : Serial.println("Case 4 Selected"); prepareDisplay(); Paint_DrawBitMap(gImage_Uchihas); sleepDisplay(); break;
case 5 : Serial.println("Case 5 Selected"); prepareDisplay(); Paint_DrawBitMap(gImage_barb); sleepDisplay(); break;
case 6 : Serial.println("Case 6 Selected"); prepareDisplay(); Paint_DrawBitMap(gImage_4in2_4Gray); sleepDisplay(); break;
case 7 : Serial.println("Case 7 Selected"); prepareDisplay(); Paint_DrawBitMap(gImage_4in2_4Gray); sleepDisplay(); break;
case 8 : Serial.println("Case 8 Selected"); prepareDisplay(); Paint_DrawBitMap(gImage_4in2_4Gray); sleepDisplay(); break;
case 9 : Serial.println("Case 9 Selected"); prepareDisplay(); Paint_DrawBitMap(gImage_4in2_4Gray); sleepDisplay(); break;
default : break;
}
}
// DEV_Delay_ms(2000);
touchDetected = false;
delay(1000);
}
void gotTouch0(){
touchDetected = true;
touchPad = 0;
}
void gotTouch3(){
touchDetected = true;
touchPad = 3;
}
void gotTouch4(){
touchDetected = true;
touchPad = 4;
}
void gotTouch5(){
touchDetected = true;
touchPad = 5;
}
void gotTouch6(){
touchDetected = true;
touchPad = 6;
}
void gotTouch7(){
touchDetected = true;
touchPad = 7;
}
void gotTouch8(){
touchDetected = true;
touchPad = 8;
}
void gotTouch9(){
touchDetected = true;
touchPad = 9;
}
void prepareDisplay(){
EPD_4IN2_V2_Init_4Gray();
free(BlackImage);
Paint_NewImage(BlackImage, EPD_4IN2_V2_WIDTH, EPD_4IN2_V2_HEIGHT, 0, WHITE);
Paint_SetScale(4);
Paint_Clear(WHITE);
EPD_4IN2_V2_Display_4Gray(BlackImage);
// DEV_Delay_ms(2000);
Paint_Clear(WHITE);
// Paint_DrawBitMap(gImage_barb);
}
void sleepDisplay() {
EPD_4IN2_V2_Display_4Gray(BlackImage);
// DEV_Delay_ms(2000);
EPD_4IN2_V2_Sleep();
free(BlackImage);
BlackImage = NULL;
}
Also for reference, please see the crash report
Booting
e-Paper busy
e-Paper busy release
e-Paper busy
e-Paper busy release
e-Paper busy
e-Paper busy release
e-Paper busy
e-Paper busy release
Completed Display Setup
Beginning Touch Setup
Completed Touch Setup
Case 9 Selected
Preparing Image-----------------------
e-Paper busy
e-Paper busy release
Free Image-----------------------
Set Image Width -----------------------
Set Image Scale -----------------------
Set Image Colour ----------------------- (This is line 126)
Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d19b8 PS : 0x00060a30 A0 : 0x800d16f7 A1 : 0x3ffb2230
A2 : 0x000000ff A3 : 0x00000000 A4 : 0x0000012c A5 : 0x00000000
A6 : 0x000000ff A7 : 0x00000000 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00000001 A11 : 0x3ffc1c74 A12 : 0x00000000 A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x0000001b EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x400864a1 LEND : 0x400864b1 LCOUNT : 0xfffffff5
Backtrace: 0x400d19b5:0x3ffb2230 0x400d16f4:0x3ffb2250 0x400d17a2:0x3ffb2270 0x400d34e1:0x3ffb2290
ELF file SHA256: 2c57bb49822248f3
Rebooting...