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@1:e2337e2653e1, 2016-09-08 (annotated)
- Committer:
- CaptainR
- Date:
- Thu Sep 08 13:40:36 2016 +0000
- Revision:
- 1:e2337e2653e1
- Parent:
- 0:a5ef6bc3c2e8
- Child:
- 2:81eaaa491a02
a little cleanup;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CaptainR | 1:e2337e2653e1 | 1 | // |
CaptainR | 1:e2337e2653e1 | 2 | // TFT_4DGL is a class to drive 4D Systems TFT touch screens with Picaso processor |
CaptainR | 1:e2337e2653e1 | 3 | // |
CaptainR | 1:e2337e2653e1 | 4 | // Copyright (C) <2016> Rihards Balass |
CaptainR | 1:e2337e2653e1 | 5 | // |
CaptainR | 0:a5ef6bc3c2e8 | 6 | |
CaptainR | 0:a5ef6bc3c2e8 | 7 | #include "mbed.h" |
CaptainR | 0:a5ef6bc3c2e8 | 8 | #include "Picaso_4DGL-32PTU.h" |
CaptainR | 0:a5ef6bc3c2e8 | 9 | |
CaptainR | 0:a5ef6bc3c2e8 | 10 | //************************************************************************** |
CaptainR | 0:a5ef6bc3c2e8 | 11 | // The Clear Screen command clears the screen using the current background colour. |
CaptainR | 0:a5ef6bc3c2e8 | 12 | // This command brings some of the settings back to default; such as, |
CaptainR | 0:a5ef6bc3c2e8 | 13 | // Transparency turned OFF |
CaptainR | 0:a5ef6bc3c2e8 | 14 | // Outline colour set to BLACK |
CaptainR | 0:a5ef6bc3c2e8 | 15 | // Opacity set to OPAQUE |
CaptainR | 0:a5ef6bc3c2e8 | 16 | // Pen set to OUTLINE |
CaptainR | 0:a5ef6bc3c2e8 | 17 | // Line patterns set to OFF |
CaptainR | 0:a5ef6bc3c2e8 | 18 | // Right text margin set to full width |
CaptainR | 0:a5ef6bc3c2e8 | 19 | // Text magnifications set to 1 |
CaptainR | 0:a5ef6bc3c2e8 | 20 | // All origins set to 0:0 |
CaptainR | 0:a5ef6bc3c2e8 | 21 | // The alternative to maintain settings and clear screen is |
CaptainR | 0:a5ef6bc3c2e8 | 22 | // to draw a filled rectangle with the required background colour. |
CaptainR | 0:a5ef6bc3c2e8 | 23 | //************************************************************************** |
CaptainR | 0:a5ef6bc3c2e8 | 24 | void TFT_4DGL :: cls() { // clear screen |
CaptainR | 0:a5ef6bc3c2e8 | 25 | |
CaptainR | 0:a5ef6bc3c2e8 | 26 | char command[2] = ""; |
CaptainR | 0:a5ef6bc3c2e8 | 27 | |
CaptainR | 0:a5ef6bc3c2e8 | 28 | command[0] = CLS_MSB; |
CaptainR | 0:a5ef6bc3c2e8 | 29 | command[1] = CLS_LSB; |
CaptainR | 0:a5ef6bc3c2e8 | 30 | |
CaptainR | 0:a5ef6bc3c2e8 | 31 | writeCOMMAND(command, 2); |
CaptainR | 0:a5ef6bc3c2e8 | 32 | } |
CaptainR | 0:a5ef6bc3c2e8 | 33 | |
CaptainR | 0:a5ef6bc3c2e8 | 34 | //************************************************************************** |
CaptainR | 0:a5ef6bc3c2e8 | 35 | // The Change Colour command changes all oldColour pixels to newColour |
CaptainR | 0:a5ef6bc3c2e8 | 36 | // within the clipping window area. |
CaptainR | 0:a5ef6bc3c2e8 | 37 | //************************************************************************** |
CaptainR | 0:a5ef6bc3c2e8 | 38 | void TFT_4DGL :: changeColor(char oldM, char oldL, char newM, char newL) { |
CaptainR | 0:a5ef6bc3c2e8 | 39 | |
CaptainR | 0:a5ef6bc3c2e8 | 40 | char command[6] = ""; |
CaptainR | 0:a5ef6bc3c2e8 | 41 | |
CaptainR | 0:a5ef6bc3c2e8 | 42 | command[0] = CHANGE_COLOR_MSB; |
CaptainR | 0:a5ef6bc3c2e8 | 43 | command[1] = CHANGE_COLOR_LSB; |
CaptainR | 0:a5ef6bc3c2e8 | 44 | command[2] = oldM; |
CaptainR | 0:a5ef6bc3c2e8 | 45 | command[3] = oldL; |
CaptainR | 0:a5ef6bc3c2e8 | 46 | command[4] = newM; |
CaptainR | 0:a5ef6bc3c2e8 | 47 | command[5] = newL; |
CaptainR | 0:a5ef6bc3c2e8 | 48 | |
CaptainR | 0:a5ef6bc3c2e8 | 49 | writeCOMMAND(command, 6); |
CaptainR | 0:a5ef6bc3c2e8 | 50 | } |
CaptainR | 0:a5ef6bc3c2e8 | 51 | |
CaptainR | 0:a5ef6bc3c2e8 | 52 | //************************************************************************** |
CaptainR | 0:a5ef6bc3c2e8 | 53 | // The Draw Circle command draws a circle with centre point x, y |
CaptainR | 0:a5ef6bc3c2e8 | 54 | // with radius r using the specified colour. |
CaptainR | 0:a5ef6bc3c2e8 | 55 | //************************************************************************** |
CaptainR | 0:a5ef6bc3c2e8 | 56 | void TFT_4DGL :: drawCircle(short x, short y, short r, char colorM, char colorL) { |
CaptainR | 0:a5ef6bc3c2e8 | 57 | |
CaptainR | 0:a5ef6bc3c2e8 | 58 | char command[10] = ""; |
CaptainR | 0:a5ef6bc3c2e8 | 59 | |
CaptainR | 0:a5ef6bc3c2e8 | 60 | command[0] = DRAW_CIRCLE_MSB; |
CaptainR | 0:a5ef6bc3c2e8 | 61 | command[1] = DRAW_CIRCLE_LSB; |
CaptainR | 0:a5ef6bc3c2e8 | 62 | command[2] = (x >> (8*1)) & 0xff; |
CaptainR | 0:a5ef6bc3c2e8 | 63 | command[3] = (x >> (8*0)) & 0xff; |
CaptainR | 0:a5ef6bc3c2e8 | 64 | command[4] = (y >> (8*1)) & 0xff; |
CaptainR | 0:a5ef6bc3c2e8 | 65 | command[5] = (y >> (8*0)) & 0xff; |
CaptainR | 0:a5ef6bc3c2e8 | 66 | command[6] = (r >> (8*1)) & 0xff; |
CaptainR | 0:a5ef6bc3c2e8 | 67 | command[7] = (r >> (8*0)) & 0xff; |
CaptainR | 0:a5ef6bc3c2e8 | 68 | command[8] = colorM; |
CaptainR | 0:a5ef6bc3c2e8 | 69 | command[9] = colorL; |
CaptainR | 0:a5ef6bc3c2e8 | 70 | |
CaptainR | 0:a5ef6bc3c2e8 | 71 | writeCOMMAND(command, 10); |
CaptainR | 0:a5ef6bc3c2e8 | 72 | } |
CaptainR | 0:a5ef6bc3c2e8 | 73 | |
CaptainR | 0:a5ef6bc3c2e8 | 74 | |
CaptainR | 0:a5ef6bc3c2e8 | 75 | |
CaptainR | 0:a5ef6bc3c2e8 | 76 | |
CaptainR | 0:a5ef6bc3c2e8 | 77 | |
CaptainR | 0:a5ef6bc3c2e8 | 78 | |
CaptainR | 0:a5ef6bc3c2e8 | 79 | |
CaptainR | 0:a5ef6bc3c2e8 | 80 | |
CaptainR | 0:a5ef6bc3c2e8 | 81 | |
CaptainR | 0:a5ef6bc3c2e8 | 82 | |
CaptainR | 0:a5ef6bc3c2e8 | 83 | |
CaptainR | 0:a5ef6bc3c2e8 | 84 | |
CaptainR | 0:a5ef6bc3c2e8 | 85 | |
CaptainR | 0:a5ef6bc3c2e8 | 86 | |
CaptainR | 0:a5ef6bc3c2e8 | 87 | |
CaptainR | 0:a5ef6bc3c2e8 | 88 | |
CaptainR | 0:a5ef6bc3c2e8 | 89 |