Go Down

Topic: device gets unresponsive after using Serial1 (Read 2378 times) previous topic - next topic

lavd

Device gets unresponsive after using Serial1. Code appears to be halted.
Device disappears from Com port list.
Only double-tap on reset and flushing empty sketch returns it back.
Code works on other Arduino fine.
IDE 1.8.12


Code: [Select]
#define DisplaySerial Serial1

#include "Diablo_Serial_4DLib.h"
#include "Diablo_Const4D.h"


Diablo_Serial_4DLib Display(&DisplaySerial);


void text_Tests(void)
{
  Display.gfx_Cls() ;
  Display.putstr("Text Tests") ;
 
  Display.txt_Attributes(BOLD + INVERSE + ITALIC + UNDERLINED) ;
  Display.txt_Xgap(3) ;
  Display.txt_Ygap(3) ;
  Display.txt_BGcolour(YELLOW) ;
  Display.txt_FGcolour(WHITE) ;
  Display.txt_FontID(FONT3) ;
  Display.txt_MoveCursor(5, 0) ;
  Display.putstr("Hello There") ;
 
  Display.txt_MoveCursor(6, 2) ;
  Display.txt_Height(2) ;
  Display.txt_Width(2) ;
  Display.txt_Inverse(OFF) ;
  Display.txt_Italic(OFF) ;
  Display.txt_Opacity(TRANSPARENT) ;
  Display.txt_Set(TEXT_COLOUR, LIME) ;
  Display.txt_Underline(ON) ;
  Display.txt_Bold(OFF) ;
  Display.txt_Wrap(88) ;
  Display.putstr("Hello There") ;
  Display.txt_Height(1) ;
  Display.txt_Width(1) ;
  Display.txt_Wrap(0) ;              // reset
  Display.putCH('z') ;
  Display.txt_BGcolour(BLACK) ;
  Display.txt_FGcolour(LIME) ;
  Display.txt_FontID(FONT3) ;
  Display.txt_MoveCursor(0,0) ;      // reset
}


void Touch_Tests(void)
{
  int firstx ;
  int firsty ;
  int x ;
  int y ;
  int state ;
  Display.gfx_Cls() ;
  Display.putstr("Touch Tests\n") ;
  Display.putstr("Please ensure Touch is only\ndetected in the Blue area") ;
  Display.touch_Set(TOUCH_ENABLE) ;
  Display.touch_DetectRegion(100,100, 200, 200) ;
  Display.gfx_RectangleFilled(100,100, 200, 200, BLUE) ;
  do {} while (Display.touch_Get(TOUCH_STATUS) != TOUCH_PRESSED);
  Display.touch_Set(TOUCH_REGIONDEFAULT) ;
  Display.gfx_Cls() ;
  Display.putstr("Draw.. Drawing stops\nwhen touch released\n") ;
 
  while(Display.touch_Get(TOUCH_STATUS) != TOUCH_PRESSED)
  {      // we"ll wait for a touch
  }
  firstx = Display.touch_Get(TOUCH_GETX);                          // so we can get the first point
  firsty = Display.touch_Get(TOUCH_GETY);
  while(state != TOUCH_RELEASED)
  {
    state = Display.touch_Get(TOUCH_STATUS);                       // look for any touch activity
    x = Display.touch_Get(TOUCH_GETX);                             // grab the x
    y = Display.touch_Get(TOUCH_GETY);                             // and the y coordinates of the touch
    if (state == TOUCH_PRESSED)                               // if there"s a press
    {
      firstx = x;
      firsty = y;
    }
    if (state == TOUCH_MOVING)                                // if there"s movement
    {
      Display.gfx_Line(firstx, firsty, x, y, BLUE);                 // but lines are much better
      firstx = x;
      firsty = y;
    }
  }
  Display.putstr("Done!") ;
  Display.touch_Set(TOUCH_DISABLE) ;
}


void setup()
{
 
  DisplaySerial.begin(9600);
  //HWLOGGING.begin(9600);
  delay(4000);
  //Display.Callback4D = mycallback ;
}

void loop()
{
  text_Tests() ; // text tests
  delay(5000) ;

  Touch_Tests() ;
  delay(5000) ;
}

Go Up