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.
Diff: Picaso_4DGL-32PTU_graphics.cpp
- Revision:
- 10:b959bb206e6b
- Parent:
- 9:32eb75c01e9d
- Child:
- 11:3ebd2263f3e9
--- a/Picaso_4DGL-32PTU_graphics.cpp Mon Sep 12 12:48:47 2016 +0000
+++ b/Picaso_4DGL-32PTU_graphics.cpp Tue Sep 13 05:53:39 2016 +0000
@@ -517,3 +517,230 @@
getResponse(1);
}
+//**************************************************************************
+// The Draw Ellipse command plots a colored Ellipse on the screen at centre
+// x, y with x-radius = xrad and y-radius = yrad.
+//**************************************************************************
+void PICASO_4DGL :: drawElipse(short x, short y, short xRad, short yRad, short color) {
+
+ char command[12] = "";
+
+ command[0] = (DRAW_ELIPSE >> (8*1)) & 0xff;
+ command[1] = (DRAW_ELIPSE >> (8*0)) & 0xff;
+ command[2] = (x >> (8*1)) & 0xff;
+ command[3] = (x >> (8*0)) & 0xff;
+ command[4] = (y >> (8*1)) & 0xff;
+ command[5] = (y >> (8*0)) & 0xff;
+ command[6] = (xRad >> (8*1)) & 0xff;
+ command[7] = (xRad >> (8*0)) & 0xff;
+ command[8] = (yRad >> (8*1)) & 0xff;
+ command[9] = (yRad >> (8*0)) & 0xff;
+ command[10] = (color >> (8*1)) & 0xff;
+ command[11] = (color >> (8*0)) & 0xff;
+
+ writeCOMMAND(command, 12);
+ getResponse(1);
+}
+
+//**************************************************************************
+// The Draw Filled Ellipse command plots a solid colored Ellipse on the screen at centre
+// x, y with x-radius = xrad and y-radius = yrad.
+//**************************************************************************
+void PICASO_4DGL :: drawFilledElipse(short x, short y, short xRad, short yRad, short color) {
+
+ char command[12] = "";
+
+ command[0] = (ELIPSE_FILLED >> (8*1)) & 0xff;
+ command[1] = (ELIPSE_FILLED >> (8*0)) & 0xff;
+ command[2] = (x >> (8*1)) & 0xff;
+ command[3] = (x >> (8*0)) & 0xff;
+ command[4] = (y >> (8*1)) & 0xff;
+ command[5] = (y >> (8*0)) & 0xff;
+ command[6] = (xRad >> (8*1)) & 0xff;
+ command[7] = (xRad >> (8*0)) & 0xff;
+ command[8] = (yRad >> (8*1)) & 0xff;
+ command[9] = (yRad >> (8*0)) & 0xff;
+ command[10] = (color >> (8*1)) & 0xff;
+ command[11] = (color >> (8*0)) & 0xff;
+
+ writeCOMMAND(command, 12);
+ getResponse(1);
+}
+
+//**************************************************************************
+// The Draw Button command draws a 3 dimensional Text Button at screen location
+// defined by x, y parameters (top left corner). The size of the button depends
+// on the font, width, height and length of the text. The button can contain
+// multiple lines of text by having the \n character embedded in the string
+// for the end of line marker. In this case, the widest text in the string sets
+// the overall width, and the height of the button is set by the number of
+// text lines. In the case of multiple lines, each line is left justified.
+// If you wish to centre or right justify the text, you will need to prepare
+// the text string according to your requirements.
+//
+// state - Appearance of button, 0 = Button depressed; 1 = Button raised.
+// x, y - Specifies the top left corner position of the button on the screen.
+//**************************************************************************
+void PICASO_4DGL :: drawButton(short state, short x, short y, short btnColor, short txtColor, short font, short txtW, short txtH, char *txt) {
+
+ int size = 19 + (strlen(txt));
+ int i, j = 18;
+ char command[size];
+ for(i = 0; i < size; i++) command[i] = 0;
+
+ command[0] = (DRAW_BUTTON >> (8*1)) & 0xff;
+ command[1] = (DRAW_BUTTON >> (8*0)) & 0xff;
+ command[2] = (state >> (8*1)) & 0xff;
+ command[3] = (state >> (8*0)) & 0xff;
+ command[4] = (x >> (8*1)) & 0xff;
+ command[5] = (x >> (8*0)) & 0xff;
+ command[6] = (y >> (8*1)) & 0xff;
+ command[7] = (y >> (8*0)) & 0xff;
+ command[8] = (btnColor >> (8*1)) & 0xff;
+ command[9] = (btnColor >> (8*0)) & 0xff;
+ command[10] = (txtColor >> (8*1)) & 0xff;
+ command[11] = (txtColor >> (8*0)) & 0xff;
+ command[12] = (font >> (8*1)) & 0xff;
+ command[13] = (font >> (8*0)) & 0xff;
+ command[14] = (txtW >> (8*1)) & 0xff;
+ command[15] = (txtW >> (8*0)) & 0xff;
+ command[16] = (txtH >> (8*1)) & 0xff;
+ command[17] = (txtH >> (8*0)) & 0xff;
+ for (i = 0; i < strlen(txt); i++) {
+ command[j] = txt[i];
+ j++;
+ }
+ command[j] = 0;
+
+ writeCOMMAND(command, size);
+ getResponse(1);
+}
+
+//**************************************************************************
+// The Draw Panel command draws a 3 dimensional rectangular panel at a screen
+// location defined by x, y parameters (top left corner). The size of the panel
+// is set with the width and height parameters. The colour is defined by colour.
+// The state parameter determines the appearance of the panel, 0 = recessed, 1 = raised.
+//**************************************************************************
+void PICASO_4DGL :: drawPanel(short state, short x, short y, short width, short height, short color) {
+
+ char command[14] = "";
+
+ command[0] = (DRAW_PANEL >> (8*1)) & 0xff;
+ command[1] = (DRAW_PANEL >> (8*0)) & 0xff;
+ command[2] = (state >> (8*1)) & 0xff;
+ command[3] = (state >> (8*0)) & 0xff;
+ command[4] = (x >> (8*1)) & 0xff;
+ command[5] = (x >> (8*0)) & 0xff;
+ command[6] = (y >> (8*1)) & 0xff;
+ command[7] = (y >> (8*0)) & 0xff;
+ command[8] = (width >> (8*1)) & 0xff;
+ command[9] = (width >> (8*0)) & 0xff;
+ command[10] = (height >> (8*1)) & 0xff;
+ command[11] = (height >> (8*0)) & 0xff;
+ command[12] = (color >> (8*1)) & 0xff;
+ command[13] = (color >> (8*0)) & 0xff;
+
+ writeCOMMAND(command, 14);
+ getResponse(1);
+}
+
+//**************************************************************************
+// The Draw Slider command draws a vertical or horizontal slider bar on the screen.
+// The Draw Slider command has several different modes of operation.
+// In order to minimise the amount of graphics functions we need, all modes of operation
+// are selected naturally depending on the parameter values.
+// Selection rules:
+// 1a) if x2-x1 > y2-y1 slider is assumed to be horizontal
+// (ie: if width > height, slider is horizontal)
+// 1b) if x2-x1 <= y2-y1 slider is assumed to be vertical
+// (ie: if height <= width, slider is horizontal)
+// 2a) If value is positive, thumb is set to the position that is the proportion
+// of value to the scale parameter.(used to set the control to the actual value of a variable)
+// 2b) If value is negative, thumb is driven to the graphics position set by the
+// ABSolute of value. (used to set thumb to its actual graphical position (usually by touch screen)
+// 3) The thumb colour is determine by the “Set Graphics Parameters” –
+// “Object Colour” command, however, if the current object colour is BLACK,
+// a darkened shade of the colour parameter is used for the thumb .
+//
+// mode - mode = 0 : Slider Indented, mode = 1 : Slider Raised, mode 2, Slider Hidden (background colour).
+// Scale - scale = n : sets the full scale range of the slider for the thumb from 0 to n.
+// Value - If value positive, sets the relative position of the thumb on the slider bar, else set thumb to ABS position of the negative number.
+//**************************************************************************
+void PICASO_4DGL :: drawSlider(short state, short x1, short y1, short x2, short y2, short color, short scale, short value) {
+
+ char command[18] = "";
+
+ command[0] = (DRAW_SLIDER >> (8*1)) & 0xff;
+ command[1] = (DRAW_SLIDER >> (8*0)) & 0xff;
+ command[2] = (state >> (8*1)) & 0xff;
+ command[3] = (state >> (8*0)) & 0xff;
+ command[4] = (x1 >> (8*1)) & 0xff;
+ command[5] = (x1 >> (8*0)) & 0xff;
+ command[6] = (y1 >> (8*1)) & 0xff;
+ command[7] = (y1 >> (8*0)) & 0xff;
+ command[8] = (x2 >> (8*1)) & 0xff;
+ command[9] = (x2 >> (8*0)) & 0xff;
+ command[10] = (y2 >> (8*1)) & 0xff;
+ command[11] = (y2 >> (8*0)) & 0xff;
+ command[12] = (color >> (8*1)) & 0xff;
+ command[13] = (color >> (8*0)) & 0xff;
+ command[14] = (scale >> (8*1)) & 0xff;
+ command[15] = (scale >> (8*0)) & 0xff;
+ command[16] = (value >> (8*1)) & 0xff;
+ command[17] = (value >> (8*0)) & 0xff;
+
+ writeCOMMAND(command, 18);
+ getResponse(1);
+}
+
+//**************************************************************************
+// The Screen Copy Paste command copies an area of a screen from xs, ys of size given
+// by width and height parameters and pastes it to another location determined by xd, yd.
+//**************************************************************************
+void PICASO_4DGL :: screenCopyPaste(short xs, short ys, short xd, short yd, short width, short height) {
+
+ char command[14] = "";
+
+ command[0] = (SCREEN_CP >> (8*1)) & 0xff;
+ command[1] = (SCREEN_CP >> (8*0)) & 0xff;
+ command[2] = (xs >> (8*1)) & 0xff;
+ command[3] = (xs >> (8*0)) & 0xff;
+ command[4] = (ys >> (8*1)) & 0xff;
+ command[5] = (ys >> (8*0)) & 0xff;
+ command[6] = (xd >> (8*1)) & 0xff;
+ command[7] = (xd >> (8*0)) & 0xff;
+ command[8] = (yd >> (8*1)) & 0xff;
+ command[9] = (yd >> (8*0)) & 0xff;
+ command[10] = (width >> (8*1)) & 0xff;
+ command[11] = (width >> (8*0)) & 0xff;
+ command[12] = (height >> (8*1)) & 0xff;
+ command[13] = (height >> (8*0)) & 0xff;
+
+ writeCOMMAND(command, 14);
+ getResponse(1);
+}
+
+//**************************************************************************
+// The Bevel Shadow command changes the graphics “Draw Button” commands bevel shadow depth
+// value - 0 = No Bevel Shadow 1-4 = Number of Pixels Deep (Default = 3)
+//**************************************************************************
+void PICASO_4DGL :: bevelShadow(short value) {
+
+ char command[4] = "";
+
+ command[0] = (BEVEL_SHADOW >> (8*1)) & 0xff;
+ command[1] = (BEVEL_SHADOW >> (8*0)) & 0xff;
+ command[2] = (value >> (8*1)) & 0xff;
+ command[3] = (value >> (8*0)) & 0xff;
+
+ writeCOMMAND(command, 4);
+ getResponse(3);
+}
+
+
+
+
+
+
+
\ No newline at end of file