Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Picaso_4DGL-32PTU_graphics.cpp@2:81eaaa491a02, 2016-09-09 (annotated)
- Committer:
- CaptainR
- Date:
- Fri Sep 09 06:17:05 2016 +0000
- Revision:
- 2:81eaaa491a02
- Parent:
- 1:e2337e2653e1
- Child:
- 3:dcfbceb81fef
Cleaned up all files, redefined constants to be more easier to use...; Added info about copyright :)
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| CaptainR | 1:e2337e2653e1 | 1 | // |
| CaptainR | 2:81eaaa491a02 | 2 | // Picaso_4DGL-32PTU is a class to drive 4D Systems TFT touch screens with PICASO processor |
| CaptainR | 2:81eaaa491a02 | 3 | // Tested with NUCLEO L152RE development board |
| CaptainR | 2:81eaaa491a02 | 4 | // Copyright (C) <2016> Rihards Balass <rihards.balass@gmail.com> |
| CaptainR | 1:e2337e2653e1 | 5 | // |
| CaptainR | 2:81eaaa491a02 | 6 | // Picaso_4DGL-32PTU is free software: you can redistribute it and/or modify |
| CaptainR | 2:81eaaa491a02 | 7 | // it under the terms of the GNU General Public License as published by |
| CaptainR | 2:81eaaa491a02 | 8 | // the Free Software Foundation, either version 3 of the License, or |
| CaptainR | 2:81eaaa491a02 | 9 | // (at your option) any later version. |
| CaptainR | 2:81eaaa491a02 | 10 | // |
| CaptainR | 2:81eaaa491a02 | 11 | // Picaso_4DGL-32PTU is distributed in the hope that it will be useful, |
| CaptainR | 2:81eaaa491a02 | 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| CaptainR | 2:81eaaa491a02 | 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| CaptainR | 2:81eaaa491a02 | 14 | // GNU General Public License for more details. |
| CaptainR | 2:81eaaa491a02 | 15 | // |
| CaptainR | 2:81eaaa491a02 | 16 | // You can see GNU General Public License at <http://www.gnu.org/licenses/>. |
| CaptainR | 1:e2337e2653e1 | 17 | // |
| CaptainR | 0:a5ef6bc3c2e8 | 18 | |
| CaptainR | 0:a5ef6bc3c2e8 | 19 | #include "mbed.h" |
| CaptainR | 0:a5ef6bc3c2e8 | 20 | #include "Picaso_4DGL-32PTU.h" |
| CaptainR | 0:a5ef6bc3c2e8 | 21 | |
| CaptainR | 0:a5ef6bc3c2e8 | 22 | //************************************************************************** |
| CaptainR | 0:a5ef6bc3c2e8 | 23 | // The Clear Screen command clears the screen using the current background colour. |
| CaptainR | 0:a5ef6bc3c2e8 | 24 | // This command brings some of the settings back to default; such as, |
| CaptainR | 0:a5ef6bc3c2e8 | 25 | // Transparency turned OFF |
| CaptainR | 0:a5ef6bc3c2e8 | 26 | // Outline colour set to BLACK |
| CaptainR | 0:a5ef6bc3c2e8 | 27 | // Opacity set to OPAQUE |
| CaptainR | 0:a5ef6bc3c2e8 | 28 | // Pen set to OUTLINE |
| CaptainR | 0:a5ef6bc3c2e8 | 29 | // Line patterns set to OFF |
| CaptainR | 0:a5ef6bc3c2e8 | 30 | // Right text margin set to full width |
| CaptainR | 0:a5ef6bc3c2e8 | 31 | // Text magnifications set to 1 |
| CaptainR | 0:a5ef6bc3c2e8 | 32 | // All origins set to 0:0 |
| CaptainR | 0:a5ef6bc3c2e8 | 33 | // The alternative to maintain settings and clear screen is |
| CaptainR | 0:a5ef6bc3c2e8 | 34 | // to draw a filled rectangle with the required background colour. |
| CaptainR | 0:a5ef6bc3c2e8 | 35 | //************************************************************************** |
| CaptainR | 0:a5ef6bc3c2e8 | 36 | void TFT_4DGL :: cls() { // clear screen |
| CaptainR | 0:a5ef6bc3c2e8 | 37 | |
| CaptainR | 0:a5ef6bc3c2e8 | 38 | char command[2] = ""; |
| CaptainR | 0:a5ef6bc3c2e8 | 39 | |
| CaptainR | 2:81eaaa491a02 | 40 | command[0] = (CLS >> (8*1)) & 0xff; |
| CaptainR | 2:81eaaa491a02 | 41 | command[1] = (CLS >> (8*0)) & 0xff; |
| CaptainR | 0:a5ef6bc3c2e8 | 42 | |
| CaptainR | 0:a5ef6bc3c2e8 | 43 | writeCOMMAND(command, 2); |
| CaptainR | 0:a5ef6bc3c2e8 | 44 | } |
| CaptainR | 0:a5ef6bc3c2e8 | 45 | |
| CaptainR | 0:a5ef6bc3c2e8 | 46 | //************************************************************************** |
| CaptainR | 0:a5ef6bc3c2e8 | 47 | // The Change Colour command changes all oldColour pixels to newColour |
| CaptainR | 0:a5ef6bc3c2e8 | 48 | // within the clipping window area. |
| CaptainR | 0:a5ef6bc3c2e8 | 49 | //************************************************************************** |
| CaptainR | 2:81eaaa491a02 | 50 | void TFT_4DGL :: changeColor(short oldColor, short newColor) { |
| CaptainR | 0:a5ef6bc3c2e8 | 51 | |
| CaptainR | 0:a5ef6bc3c2e8 | 52 | char command[6] = ""; |
| CaptainR | 0:a5ef6bc3c2e8 | 53 | |
| CaptainR | 2:81eaaa491a02 | 54 | command[0] = (CHANGE_COLOR >> (8*1)) & 0xff; |
| CaptainR | 2:81eaaa491a02 | 55 | command[1] = (CHANGE_COLOR >> (8*0)) & 0xff; |
| CaptainR | 2:81eaaa491a02 | 56 | command[2] = (oldColor >> (8*1)) & 0xff; |
| CaptainR | 2:81eaaa491a02 | 57 | command[3] = (oldColor >> (8*0)) & 0xff; |
| CaptainR | 2:81eaaa491a02 | 58 | command[4] = (newColor >> (8*1)) & 0xff; |
| CaptainR | 2:81eaaa491a02 | 59 | command[5] = (newColor >> (8*0)) & 0xff; |
| CaptainR | 0:a5ef6bc3c2e8 | 60 | |
| CaptainR | 0:a5ef6bc3c2e8 | 61 | writeCOMMAND(command, 6); |
| CaptainR | 0:a5ef6bc3c2e8 | 62 | } |
| CaptainR | 0:a5ef6bc3c2e8 | 63 | |
| CaptainR | 0:a5ef6bc3c2e8 | 64 | //************************************************************************** |
| CaptainR | 0:a5ef6bc3c2e8 | 65 | // The Draw Circle command draws a circle with centre point x, y |
| CaptainR | 0:a5ef6bc3c2e8 | 66 | // with radius r using the specified colour. |
| CaptainR | 0:a5ef6bc3c2e8 | 67 | //************************************************************************** |
| CaptainR | 2:81eaaa491a02 | 68 | void TFT_4DGL :: drawCircle(short x, short y, short r, short color) { |
| CaptainR | 0:a5ef6bc3c2e8 | 69 | |
| CaptainR | 0:a5ef6bc3c2e8 | 70 | char command[10] = ""; |
| CaptainR | 0:a5ef6bc3c2e8 | 71 | |
| CaptainR | 2:81eaaa491a02 | 72 | command[0] = (DRAW_CIRCLE >> (8*1)) & 0xff; |
| CaptainR | 2:81eaaa491a02 | 73 | command[1] = (DRAW_CIRCLE >> (8*0)) & 0xff; |
| CaptainR | 0:a5ef6bc3c2e8 | 74 | command[2] = (x >> (8*1)) & 0xff; |
| CaptainR | 0:a5ef6bc3c2e8 | 75 | command[3] = (x >> (8*0)) & 0xff; |
| CaptainR | 0:a5ef6bc3c2e8 | 76 | command[4] = (y >> (8*1)) & 0xff; |
| CaptainR | 0:a5ef6bc3c2e8 | 77 | command[5] = (y >> (8*0)) & 0xff; |
| CaptainR | 0:a5ef6bc3c2e8 | 78 | command[6] = (r >> (8*1)) & 0xff; |
| CaptainR | 0:a5ef6bc3c2e8 | 79 | command[7] = (r >> (8*0)) & 0xff; |
| CaptainR | 2:81eaaa491a02 | 80 | command[8] = (color >> (8*1)) & 0xff; |
| CaptainR | 2:81eaaa491a02 | 81 | command[9] = (color >> (8*0)) & 0xff; |
| CaptainR | 0:a5ef6bc3c2e8 | 82 | |
| CaptainR | 0:a5ef6bc3c2e8 | 83 | writeCOMMAND(command, 10); |
| CaptainR | 0:a5ef6bc3c2e8 | 84 | } |
| CaptainR | 0:a5ef6bc3c2e8 | 85 | |
| CaptainR | 0:a5ef6bc3c2e8 | 86 | |
| CaptainR | 0:a5ef6bc3c2e8 | 87 | |
| CaptainR | 0:a5ef6bc3c2e8 | 88 | |
| CaptainR | 0:a5ef6bc3c2e8 | 89 | |
| CaptainR | 0:a5ef6bc3c2e8 | 90 | |
| CaptainR | 0:a5ef6bc3c2e8 | 91 | |
| CaptainR | 0:a5ef6bc3c2e8 | 92 | |
| CaptainR | 0:a5ef6bc3c2e8 | 93 | |
| CaptainR | 0:a5ef6bc3c2e8 | 94 | |
| CaptainR | 0:a5ef6bc3c2e8 | 95 | |
| CaptainR | 0:a5ef6bc3c2e8 | 96 | |
| CaptainR | 0:a5ef6bc3c2e8 | 97 | |
| CaptainR | 0:a5ef6bc3c2e8 | 98 | |
| CaptainR | 0:a5ef6bc3c2e8 | 99 | |
| CaptainR | 0:a5ef6bc3c2e8 | 100 | |
| CaptainR | 0:a5ef6bc3c2e8 | 101 |