Project 14 - Post-It-Note Like Scribble Message Pad

<< Click to Display Table of Contents >>

Navigation:  Projects >

Project 14 - Post-It-Note Like Scribble Message Pad

This project creates a message pad with clear/save functionality.

 

 

Code

 

The loop() routine starts with drawing a "SKETCH PAD" title. It then draws the rectangle area using the RectangleExt() command for message pad and uses the BitmapColor() command to select the color of the sketch line. Both rectangle and sketch area are using the same (left, top) and (right, bottom) coordinates. It then proceeds to draw the CLEAR and SAVE buttons using the touch tag 1 and 2.

 

The screen frame is drawn using the Show() command. The loop() routine waits for any touch and if it is for the SAVE or CLEAR button, then it comes out of this waiting loop. If tag 2 is found (save button is touched), then it takes the screen shot of the sketch area. For tag 1, no action is required as the display will be redrawn for the next frame.

 

The following code snippet from loop routine shows the above steps:

 

void loop() {

 /* Start building a screen frame */

 CleO.Start();

 

 /* Title */

 CleO.StringExt(FONT_MEDIUM, 160, 0, LIGHT_GREEN, TM, 0, 0, "SKETCH PAD");

 

 /* Draw a rectangle area for sketch */

 CleO.RectangleExt(0, 50, 320, 350, LIGHTYELLOW1, TL, 0, 0);

 CleO.BitmapColor(BLUE);

 CleO.Sketch(0, 50, 320, 350);

 

 CleO.LineWidth(30);

 

 /* Draw CLEAR button */

 CleO.Tag(1);

 CleO.LineColor(WHITE);

 CleO.Line(50 + 1, 440 + 1, 125 + 1, 440 + 1);

 CleO.LineColor(RED);

 CleO.Line(50, 440, 125, 440);

 CleO.StringExt(FONT_MEDIUM, 88, 440, WHITE, MM, 0, 0, "CLEAR");

 

/* Draw SAVE button */

 CleO.Tag(2);

 CleO.LineColor(WHITE);

 CleO.Line(200 + 1, 440 + 1, 275 + 1, 440 + 1);

 CleO.LineColor(RED);

 CleO.Line(200, 440, 275, 440);

 CleO.StringExt(FONT_MEDIUM, 238, 440, WHITE, MM, 0, 0, "SAVE");

 

 /* Display completed screen frame */

 CleO.Show();

 

 /* Wait until clear or save button is pressed */

 int16_t x, y, dur, tag, newval;

 do {

   CleO.TouchCoordinates(x, y, dur, tag);

   if (tag == 1 || tag == 2)

     break;

 } while (true);

 

  /* Do not perform any action as new frame will erase the message pad */

 if (tag == 1) { }

 

 /* Capture the message pad screen area */

 if (tag == 2)

   CleO.CaptureScreen("@Pictures/sketch.png", 0, 50, 320, 350);

}

 

 

Output

 

 

Project 14-ScribbleMessagePad