Version 0.2.6. Removed dead code in the tft component.

Fri, 26 Oct 2018 22:19:48 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 26 Oct 2018 22:19:48 +0200
changeset 20
3fd5e0fc075f
parent 19
49e2960d4642
child 21
9e4cce24f6ff

Version 0.2.6. Removed dead code in the tft component.

components/tft/tft.c file | annotate | diff | comparison | revisions
components/tft/tft.h file | annotate | diff | comparison | revisions
main/config.h file | annotate | diff | comparison | revisions
--- a/components/tft/tft.c	Fri Oct 26 21:23:46 2018 +0200
+++ b/components/tft/tft.c	Fri Oct 26 22:19:48 2018 +0200
@@ -123,7 +123,6 @@
 static uint8_t *userfont = NULL;
 static int TFT_OFFSET = 0;
 static propFont	fontChar;
-static float _arcAngleMax = DEFAULT_ARC_ANGLE_MAX;
 
 
 // =========================================================================
@@ -134,17 +133,6 @@
 // =========================================================================
 
 
-// Compare two colors; return 0 if equal
-//============================================
-int TFT_compare_colors(color_t c1, color_t c2)
-{
-	if ((c1.r & 0xFC) != (c2.r & 0xFC)) return 1;
-	if ((c1.g & 0xFC) != (c2.g & 0xFC)) return 1;
-	if ((c1.b & 0xFC) != (c2.b & 0xFC)) return 1;
-
-	return 0;
-}
-
 // draw color pixel on screen
 //------------------------------------------------------------------------
 static void _drawPixel(int16_t x, int16_t y, color_t color, uint8_t sel) {
@@ -447,35 +435,6 @@
 
 
 //-----------------------------------------------------------------------------------------------
-static void _drawLineByAngle(int16_t x, int16_t y, int16_t angle, uint16_t length, color_t color)
-{
-	_drawLine(
-		x,
-		y,
-		x + length * cos((angle + _angleOffset) * DEG_TO_RAD),
-		y + length * sin((angle + _angleOffset) * DEG_TO_RAD), color);
-}
-
-//---------------------------------------------------------------------------------------------------------------
-static void _DrawLineByAngle(int16_t x, int16_t y, int16_t angle, uint16_t start, uint16_t length, color_t color)
-{
-	_drawLine(
-		x + start * cos((angle + _angleOffset) * DEG_TO_RAD),
-		y + start * sin((angle + _angleOffset) * DEG_TO_RAD),
-		x + (start + length) * cos((angle + _angleOffset) * DEG_TO_RAD),
-		y + (start + length) * sin((angle + _angleOffset) * DEG_TO_RAD), color);
-}
-
-//===========================================================================================================
-void TFT_drawLineByAngle(uint16_t x, uint16_t y, uint16_t start, uint16_t len, uint16_t angle, color_t color)
-{
-	x += dispWin.x1;
-	y += dispWin.y1;
-
-	if (start == 0) _drawLineByAngle(x, y, angle, len, color);
-	else _DrawLineByAngle(x, y, angle, start, len, color);
-}
-
 
 // Draw a triangle
 //--------------------------------------------------------------------------------------------------------------------
@@ -486,21 +445,6 @@
 	_drawLine(x2, y2, x0, y0, color);
 }
 
-//================================================================================================================
-void TFT_drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color)
-{
-	x0 += dispWin.x1;
-	y0 += dispWin.y1;
-	x1 += dispWin.x1;
-	y1 += dispWin.y1;
-	x2 += dispWin.x1;
-	y2 += dispWin.y1;
-
-	_drawLine(x0, y0, x1, y1, color);
-	_drawLine(x1, y1, x2, y2, color);
-	_drawLine(x2, y2, x0, y0, color);
-}
-
 // Fill a triangle
 //--------------------------------------------------------------------------------------------------------------------
 static void _fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color)
@@ -579,16 +523,6 @@
   }
 }
 
-//================================================================================================================
-void TFT_fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color)
-{
-	_fillTriangle(
-			x0 + dispWin.x1, y0 + dispWin.y1,
-			x1 + dispWin.x1, y1 + dispWin.y1,
-			x2 + dispWin.x1, y2 + dispWin.y1,
-			color);
-}
-
 //====================================================================
 void TFT_drawCircle(int16_t x, int16_t y, int radius, color_t color) {
 	x += dispWin.x1;
@@ -634,395 +568,6 @@
 	fillCircleHelper(x, y, radius, 3, 0, color);
 }
 
-//----------------------------------------------------------------------------------------------------------------
-static void _draw_ellipse_section(uint16_t x, uint16_t y, uint16_t x0, uint16_t y0, color_t color, uint8_t option)
-{
-	disp_select();
-    // upper right
-    if ( option & TFT_ELLIPSE_UPPER_RIGHT ) _drawPixel(x0 + x, y0 - y, color, 0);
-    // upper left
-    if ( option & TFT_ELLIPSE_UPPER_LEFT ) _drawPixel(x0 - x, y0 - y, color, 0);
-    // lower right
-    if ( option & TFT_ELLIPSE_LOWER_RIGHT ) _drawPixel(x0 + x, y0 + y, color, 0);
-    // lower left
-    if ( option & TFT_ELLIPSE_LOWER_LEFT ) _drawPixel(x0 - x, y0 + y, color, 0);
-	disp_deselect();
-}
-
-//=====================================================================================================
-void TFT_drawEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option)
-{
-	x0 += dispWin.x1;
-	y0 += dispWin.y1;
-
-	uint16_t x, y;
-	int32_t xchg, ychg;
-	int32_t err;
-	int32_t rxrx2;
-	int32_t ryry2;
-	int32_t stopx, stopy;
-
-	rxrx2 = rx;
-	rxrx2 *= rx;
-	rxrx2 *= 2;
-
-	ryry2 = ry;
-	ryry2 *= ry;
-	ryry2 *= 2;
-
-	x = rx;
-	y = 0;
-
-	xchg = 1;
-	xchg -= rx;
-	xchg -= rx;
-	xchg *= ry;
-	xchg *= ry;
-
-	ychg = rx;
-	ychg *= rx;
-
-	err = 0;
-
-	stopx = ryry2;
-	stopx *= rx;
-	stopy = 0;
-
-	while( stopx >= stopy ) {
-		_draw_ellipse_section(x, y, x0, y0, color, option);
-		y++;
-		stopy += rxrx2;
-		err += ychg;
-		ychg += rxrx2;
-		if ( 2*err+xchg > 0 ) {
-			x--;
-			stopx -= ryry2;
-			err += xchg;
-			xchg += ryry2;
-		}
-	}
-
-	x = 0;
-	y = ry;
-
-	xchg = ry;
-	xchg *= ry;
-
-	ychg = 1;
-	ychg -= ry;
-	ychg -= ry;
-	ychg *= rx;
-	ychg *= rx;
-
-	err = 0;
-
-	stopx = 0;
-
-	stopy = rxrx2;
-	stopy *= ry;
-
-	while( stopx <= stopy ) {
-		_draw_ellipse_section(x, y, x0, y0, color, option);
-		x++;
-		stopx += ryry2;
-		err += xchg;
-		xchg += ryry2;
-		if ( 2*err+ychg > 0 ) {
-			y--;
-			stopy -= rxrx2;
-			err += ychg;
-			ychg += rxrx2;
-		}
-	}
-}
-
-//-----------------------------------------------------------------------------------------------------------------------
-static void _draw_filled_ellipse_section(uint16_t x, uint16_t y, uint16_t x0, uint16_t y0, color_t color, uint8_t option)
-{
-    // upper right
-    if ( option & TFT_ELLIPSE_UPPER_RIGHT ) _drawFastVLine(x0+x, y0-y, y+1, color);
-    // upper left
-    if ( option & TFT_ELLIPSE_UPPER_LEFT ) _drawFastVLine(x0-x, y0-y, y+1, color);
-    // lower right
-    if ( option & TFT_ELLIPSE_LOWER_RIGHT ) _drawFastVLine(x0+x, y0, y+1, color);
-    // lower left
-    if ( option & TFT_ELLIPSE_LOWER_LEFT ) _drawFastVLine(x0-x, y0, y+1, color);
-}
-
-//=====================================================================================================
-void TFT_fillEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option)
-{
-	x0 += dispWin.x1;
-	y0 += dispWin.y1;
-
-	uint16_t x, y;
-	int32_t xchg, ychg;
-	int32_t err;
-	int32_t rxrx2;
-	int32_t ryry2;
-	int32_t stopx, stopy;
-
-	rxrx2 = rx;
-	rxrx2 *= rx;
-	rxrx2 *= 2;
-
-	ryry2 = ry;
-	ryry2 *= ry;
-	ryry2 *= 2;
-
-	x = rx;
-	y = 0;
-
-	xchg = 1;
-	xchg -= rx;
-	xchg -= rx;
-	xchg *= ry;
-	xchg *= ry;
-
-	ychg = rx;
-	ychg *= rx;
-
-	err = 0;
-
-	stopx = ryry2;
-	stopx *= rx;
-	stopy = 0;
-
-	while( stopx >= stopy ) {
-		_draw_filled_ellipse_section(x, y, x0, y0, color, option);
-		y++;
-		stopy += rxrx2;
-		err += ychg;
-		ychg += rxrx2;
-		if ( 2*err+xchg > 0 ) {
-			x--;
-			stopx -= ryry2;
-			err += xchg;
-			xchg += ryry2;
-		}
-	}
-
-	x = 0;
-	y = ry;
-
-	xchg = ry;
-	xchg *= ry;
-
-	ychg = 1;
-	ychg -= ry;
-	ychg -= ry;
-	ychg *= rx;
-	ychg *= rx;
-
-	err = 0;
-
-	stopx = 0;
-
-	stopy = rxrx2;
-	stopy *= ry;
-
-	while( stopx <= stopy ) {
-		_draw_filled_ellipse_section(x, y, x0, y0, color, option);
-		x++;
-		stopx += ryry2;
-		err += xchg;
-		xchg += ryry2;
-		if ( 2*err+ychg > 0 ) {
-			y--;
-			stopy -= rxrx2;
-			err += ychg;
-			ychg += rxrx2;
-		}
-	}
-}
-
-
-// ==== ARC DRAWING ===================================================================
-
-//---------------------------------------------------------------------------------------------------------------------------------
-static void _fillArcOffsetted(uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, float start, float end, color_t color)
-{
-	//float sslope = (float)cos_lookup(start) / (float)sin_lookup(start);
-	//float eslope = (float)cos_lookup(end) / (float)sin_lookup(end);
-	float sslope = (cos(start/_arcAngleMax * 2 * PI) * _arcAngleMax) / (sin(start/_arcAngleMax * 2 * PI) * _arcAngleMax) ;
-	float eslope = (cos(end/_arcAngleMax * 2 * PI) * _arcAngleMax) / (sin(end/_arcAngleMax * 2 * PI) * _arcAngleMax);
-
-	if (end == 360) eslope = -1000000;
-
-	int ir2 = (radius - thickness) * (radius - thickness);
-	int or2 = radius * radius;
-
-	disp_select();
-	for (int x = -radius; x <= radius; x++) {
-		for (int y = -radius; y <= radius; y++) {
-			int x2 = x * x;
-			int y2 = y * y;
-
-			if (
-				(x2 + y2 < or2 && x2 + y2 >= ir2) &&
-				(
-				(y > 0 && start < 180 && x <= y * sslope) ||
-				(y < 0 && start > 180 && x >= y * sslope) ||
-				(y < 0 && start <= 180) ||
-				(y == 0 && start <= 180 && x < 0) ||
-				(y == 0 && start == 0 && x > 0)
-				) &&
-				(
-				(y > 0 && end < 180 && x >= y * eslope) ||
-				(y < 0 && end > 180 && x <= y * eslope) ||
-				(y > 0 && end >= 180) ||
-				(y == 0 && end >= 180 && x < 0) ||
-				(y == 0 && start == 0 && x > 0)
-				)
-				)
-				_drawPixel(cx+x, cy+y, color, 0);
-		}
-	}
-	disp_deselect();
-}
-
-
-//===========================================================================================================================
-void TFT_drawArc(uint16_t cx, uint16_t cy, uint16_t r, uint16_t th, float start, float end, color_t color, color_t fillcolor)
-{
-	cx += dispWin.x1;
-	cy += dispWin.y1;
-
-	if (th < 1) th = 1;
-	if (th > r) th = r;
-
-	int f = TFT_compare_colors(fillcolor, color);
-
-	float astart = fmodf(start, _arcAngleMax);
-	float aend = fmodf(end, _arcAngleMax);
-
-	astart += _angleOffset;
-	aend += _angleOffset;
-
-	if (astart < 0) astart += (float)360;
-	if (aend < 0) aend += (float)360;
-
-	if (aend == 0) aend = (float)360;
-
-	if (astart > aend) {
-		_fillArcOffsetted(cx, cy, r, th, astart, _arcAngleMax, fillcolor);
-		_fillArcOffsetted(cx, cy, r, th, 0, aend, fillcolor);
-		if (f) {
-			_fillArcOffsetted(cx, cy, r, 1, astart, _arcAngleMax, color);
-			_fillArcOffsetted(cx, cy, r, 1, 0, aend, color);
-			_fillArcOffsetted(cx, cy, r-th, 1, astart, _arcAngleMax, color);
-			_fillArcOffsetted(cx, cy, r-th, 1, 0, aend, color);
-		}
-	}
-	else {
-		_fillArcOffsetted(cx, cy, r, th, astart, aend, fillcolor);
-		if (f) {
-			_fillArcOffsetted(cx, cy, r, 1, astart, aend, color);
-			_fillArcOffsetted(cx, cy, r-th, 1, astart, aend, color);
-		}
-	}
-	if (f) {
-		_drawLine(cx + (r-th) * cos(astart * DEG_TO_RAD), cy + (r-th) * sin(astart * DEG_TO_RAD),
-			cx + (r-1) * cos(astart * DEG_TO_RAD), cy + (r-1) * sin(astart * DEG_TO_RAD), color);
-		_drawLine(cx + (r-th) * cos(aend * DEG_TO_RAD), cy + (r-th) * sin(aend * DEG_TO_RAD),
-			cx + (r-1) * cos(aend * DEG_TO_RAD), cy + (r-1) * sin(aend * DEG_TO_RAD), color);
-	}
-}
-
-//=============================================================================================================
-void TFT_drawPolygon(int cx, int cy, int sides, int diameter, color_t color, color_t fill, int rot, uint8_t th)
-{
-	cx += dispWin.x1;
-	cy += dispWin.y1;
-
-	int deg = rot - _angleOffset;
-	int f = TFT_compare_colors(fill, color);
-
-	if (sides < MIN_POLIGON_SIDES) sides = MIN_POLIGON_SIDES;	// This ensures the minimum side number
-	if (sides > MAX_POLIGON_SIDES) sides = MAX_POLIGON_SIDES;	// This ensures the maximum side number
-
-	int Xpoints[sides], Ypoints[sides];							// Set the arrays based on the number of sides entered
-	int rads = 360 / sides;										// This equally spaces the points.
-
-	for (int idx = 0; idx < sides; idx++) {
-		Xpoints[idx] = cx + sin((float)(idx*rads + deg) * deg_to_rad) * diameter;
-		Ypoints[idx] = cy + cos((float)(idx*rads + deg) * deg_to_rad) * diameter;
-	}
-
-	// Draw the polygon on the screen.
-	if (f) {
-		for(int idx = 0; idx < sides; idx++) {
-			if((idx+1) < sides) _fillTriangle(cx,cy,Xpoints[idx],Ypoints[idx],Xpoints[idx+1],Ypoints[idx+1], fill);
-			else _fillTriangle(cx,cy,Xpoints[idx],Ypoints[idx],Xpoints[0],Ypoints[0], fill);
-		}
-	}
-
-	if (th) {
-		for (int n=0; n<th; n++) {
-			if (n > 0) {
-				for (int idx = 0; idx < sides; idx++) {
-					Xpoints[idx] = cx + sin((float)(idx*rads + deg) * deg_to_rad) * (diameter-n);
-					Ypoints[idx] = cy + cos((float)(idx*rads + deg) * deg_to_rad) * (diameter-n);
-				}
-			}
-			for(int idx = 0; idx < sides; idx++) {
-				if( (idx+1) < sides)
-					_drawLine(Xpoints[idx],Ypoints[idx],Xpoints[idx+1],Ypoints[idx+1], color); // draw the lines
-				else
-					_drawLine(Xpoints[idx],Ypoints[idx],Xpoints[0],Ypoints[0], color); // finishes the last line to close up the polygon.
-			}
-		}
-	}
-}
-
-/*
-// Similar to the Polygon function.
-//=====================================================================================
-void TFT_drawStar(int cx, int cy, int diameter, color_t color, bool fill, float factor)
-{
-	cx += dispWin.x1;
-	cy += dispWin.y1;
-
-	factor = constrain(factor, 1.0, 4.0);
-	uint8_t sides = 5;
-	uint8_t rads = 360 / sides;
-
-	int Xpoints_O[sides], Ypoints_O[sides], Xpoints_I[sides], Ypoints_I[sides];//Xpoints_T[5], Ypoints_T[5];
-
-	for(int idx = 0; idx < sides; idx++) {
-		// makes the outer points
-		Xpoints_O[idx] = cx + sin((float)(idx*rads + 72) * deg_to_rad) * diameter;
-		Ypoints_O[idx] = cy + cos((float)(idx*rads + 72) * deg_to_rad) * diameter;
-		// makes the inner points
-		Xpoints_I[idx] = cx + sin((float)(idx*rads + 36) * deg_to_rad) * ((float)(diameter)/factor);
-		// 36 is half of 72, and this will allow the inner and outer points to line up like a triangle.
-		Ypoints_I[idx] = cy + cos((float)(idx*rads + 36) * deg_to_rad) * ((float)(diameter)/factor);
-	}
-
-	for(int idx = 0; idx < sides; idx++) {
-		if((idx+1) < sides) {
-			if(fill) {// this part below should be self explanatory. It fills in the star.
-				_fillTriangle(cx,cy,Xpoints_I[idx],Ypoints_I[idx],Xpoints_O[idx],Ypoints_O[idx], color);
-				_fillTriangle(cx,cy,Xpoints_O[idx],Ypoints_O[idx],Xpoints_I[idx+1],Ypoints_I[idx+1], color);
-			}
-			else {
-				_drawLine(Xpoints_O[idx],Ypoints_O[idx],Xpoints_I[idx+1],Ypoints_I[idx+1], color);
-				_drawLine(Xpoints_I[idx],Ypoints_I[idx],Xpoints_O[idx],Ypoints_O[idx], color);
-			}
-		}
-		else {
-			if(fill) {
-				_fillTriangle(cx,cy,Xpoints_I[0],Ypoints_I[0],Xpoints_O[idx],Ypoints_O[idx], color);
-				_fillTriangle(cx,cy,Xpoints_O[idx],Ypoints_O[idx],Xpoints_I[idx],Ypoints_I[idx], color);
-			}
-			else {
-				_drawLine(Xpoints_O[idx],Ypoints_O[idx],Xpoints_I[idx],Ypoints_I[idx], color);
-				_drawLine(Xpoints_I[0],Ypoints_I[0],Xpoints_O[idx],Ypoints_O[idx], color);
-			}
-		}
-	}
-}
-*/
 
 // ================ Font and string functions ==================================
 
@@ -1157,174 +702,6 @@
 	return err;
 }
 
-//------------------------------------------------
-int compile_font_file(char *fontfile, uint8_t dbg)
-{
-	int err = 0;
-	char err_msg[128] = {'\0'};
-	char outfile[128] = {'\0'};
-	size_t len;
-    struct stat sb;
-    FILE *ffd = NULL;
-    FILE *ffd_out = NULL;
-    char *sourcebuf = NULL;
-
-    len = strlen(fontfile);
-
-	// check here that filename end with ".c".
-	if ((len < 3) || (len > 125) || (strcmp(fontfile + len - 2, ".c") != 0)) {
-		sprintf(err_msg, "not a .c file");
-		err = 1;
-		goto exit;
-	}
-
-	sprintf(outfile, "%s", fontfile);
-	sprintf(outfile+strlen(outfile)-1, "fon");
-
-	// Open the source file
-    if (stat(fontfile, &sb) != 0) {
-    	sprintf(err_msg, "Error opening source file '%s'", fontfile);
-    	err = 2;
-		goto exit;
-    }
-    // Open the file
-    ffd = fopen(fontfile, "rb");
-    if (!ffd) {
-    	sprintf(err_msg, "Error opening source file '%s'", fontfile);
-    	err = 3;
-		goto exit;
-    }
-
-	// Open the font file
-    ffd_out= fopen(outfile, "wb");
-	if (!ffd_out) {
-		sprintf(err_msg, "error opening destination file");
-		err = 4;
-		goto exit;
-	}
-
-	// Get file size
-	int fsize = sb.st_size;
-	if (fsize <= 0) {
-		sprintf(err_msg, "source file size error");
-		err = 5;
-		goto exit;
-	}
-
-	sourcebuf = malloc(fsize+4);
-	if (sourcebuf == NULL) {
-		sprintf(err_msg, "memory allocation error");
-		err = 6;
-		goto exit;
-	}
-	char *fbuf = sourcebuf;
-
-	int rdsize = fread(fbuf, 1, fsize, ffd);
-	fclose(ffd);
-	ffd = NULL;
-
-	if (rdsize != fsize) {
-		sprintf(err_msg, "error reading from source file");
-		err = 7;
-		goto exit;
-	}
-
-	*(fbuf+rdsize) = '\0';
-
-	fbuf = strchr(fbuf, '{');			// beginning of font data
-	char *fend = strstr(fbuf, "};");	// end of font data
-
-	if ((fbuf == NULL) || (fend == NULL) || ((fend-fbuf) < 22)) {
-		sprintf(err_msg, "wrong source file format");
-		err = 8;
-		goto exit;
-	}
-
-	fbuf++;
-	*fend = '\0';
-	char hexstr[5] = {'\0'};
-	int lastline = 0;
-
-	fbuf = strstr(fbuf, "0x");
-	int size = 0;
-	char *nextline;
-	char *numptr;
-
-	int bptr = 0;
-
-	while ((fbuf != NULL) && (fbuf < fend) && (lastline == 0)) {
-		nextline = strchr(fbuf, '\n'); // beginning of the next line
-		if (nextline == NULL) {
-			nextline = fend-1;
-			lastline++;
-		}
-		else nextline++;
-
-		while (fbuf < nextline) {
-			numptr = strstr(fbuf, "0x");
-			if ((numptr == NULL) || ((fbuf+4) > nextline)) numptr = strstr(fbuf, "0X");
-			if ((numptr != NULL) && ((numptr+4) <= nextline)) {
-				fbuf = numptr;
-				if (bptr >= 128) {
-					// buffer full, write to file
-                    if (fwrite(outfile, 1, 128, ffd_out) != 128) goto error;
-					bptr = 0;
-					size += 128;
-				}
-				memcpy(hexstr, fbuf, 4);
-				hexstr[4] = 0;
-				outfile[bptr++] = (uint8_t)strtol(hexstr, NULL, 0);
-				fbuf += 4;
-			}
-			else fbuf = nextline;
-		}
-		fbuf = nextline;
-	}
-
-	if (bptr > 0) {
-		size += bptr;
-        if (fwrite(outfile, 1, bptr, ffd_out) != bptr) goto error;
-	}
-
-	// write font ID
-	sprintf(outfile, "RPH_font");
-    if (fwrite(outfile, 1, 8, ffd_out) != 8) goto error;
-
-    fclose(ffd_out);
-    ffd_out = NULL;
-
-	// === Test compiled font ===
-	sprintf(outfile, "%s", fontfile);
-	sprintf(outfile+strlen(outfile)-1, "fon");
-
-	uint8_t *uf = userfont; // save userfont pointer
-	userfont = NULL;
-	if (load_file_font(outfile, 1) != 0) {
-		sprintf(err_msg, "Error compiling file!");
-		err = 10;
-	}
-	else {
-		free(userfont);
-		sprintf(err_msg, "File compiled successfully.");
-	}
-	userfont = uf; // restore userfont
-
-	goto exit;
-
-error:
-	sprintf(err_msg, "error writing to destination file");
-	err = 9;
-
-exit:
-	if (sourcebuf) free(sourcebuf);
-	if (ffd) fclose(ffd);
-	if (ffd_out) fclose(ffd_out);
-
-	if (dbg) printf("%s\r\n", err_msg);
-
-	return err;
-}
-
 
 // -----------------------------------------------------------------------------------------
 // Individual Proportional Font Character Format:
@@ -1344,49 +721,6 @@
 //---------------------------------------------------------------------------------------------
 
 //----------------------------------
-void getFontCharacters(uint8_t *buf)
-{
-    if (cfont.bitmap == 2) {
-    	//For 7 segment font only characters 0,1,2,3,4,5,6,7,8,9, . , - , : , / are available.
-		for (uint8_t n=0; n < 11; n++) {
-			buf[n] = n + 0x30;
-		}
-		buf[11] = '.';
-		buf[12] = '-';
-		buf[13] = '/';
-		buf[14] = '\0';
-    	return;
-    }
-
-    if (cfont.x_size > 0) {
-		for (uint8_t n=0; n < cfont.numchars; n++) {
-			buf[n] = cfont.offset + n;
-		}
-		buf[cfont.numchars] = '\0';
-		return;
-	}
-
-	uint16_t tempPtr = 4; // point at first char data
-	uint8_t cc, cw, ch, n;
-
-	n = 0;
-    cc = cfont.font[tempPtr++];
-    while (cc != 0xFF)  {
-    	cfont.numchars++;
-        tempPtr++;
-        cw = cfont.font[tempPtr++];
-        ch = cfont.font[tempPtr++];
-        tempPtr++;
-        tempPtr++;
-		if (cw != 0) {
-			// packed bits
-			tempPtr += (((cw * ch)-1) / 8) + 1;
-		}
-		buf[n++] = cc;
-	    cc = cfont.font[tempPtr++];
-	}
-	buf[n] = '\0';
-}
 
 // Set max width & height of the proportional font
 //-----------------------------
@@ -1457,40 +791,6 @@
   return 1;
 }
 
-/*
-//-----------------------
-static void _testFont() {
-  if (cfont.x_size) {
-	  printf("FONT TEST: fixed font\r\n");
-	  return;
-  }
-  uint16_t tempPtr = 4; // point at first char data
-  uint8_t c = 0x20;
-  for (c=0x20; c <0xFF; c++) {
-	fontChar.charCode = cfont.font[tempPtr++];
-    if (fontChar.charCode == 0xFF) break;
-    if (fontChar.charCode != c) {
-    	printf("FONT TEST: last sequential char: %d, expected %d\r\n", fontChar.charCode, c);
-    	break;
-    }
-    c = fontChar.charCode;
-    fontChar.adjYOffset = cfont.font[tempPtr++];
-    fontChar.width = cfont.font[tempPtr++];
-    fontChar.height = cfont.font[tempPtr++];
-    fontChar.xOffset = cfont.font[tempPtr++];
-    fontChar.xOffset = fontChar.xOffset < 0x80 ? fontChar.xOffset : -(0xFF - fontChar.xOffset);
-    fontChar.xDelta = cfont.font[tempPtr++];
-
-    if (fontChar.charCode != 0xFF) {
-      if (fontChar.width != 0) {
-        // packed bits
-        tempPtr += (((fontChar.width * fontChar.height)-1) / 8) + 1;
-      }
-    }
-  }
-  printf("FONT TEST: W=%d  H=%d last char: %d [%c]; length: %d\r\n", cfont.max_x_size, cfont.y_size, c, c, tempPtr);
-}
-*/
 
 //===================================================
 void TFT_setFont(uint8_t font, const char *font_file)
@@ -2093,13 +1393,6 @@
 	TFT_fillScreen(_bg);
 }
 
-// Send the command to invert all of the colors.
-// Input: i 0 to disable inversion; non-zero to enable inversion
-//==========================================
-void TFT_invertDisplay(const uint8_t mode) {
-  if ( mode == INVERT_ON ) disp_spi_transfer_cmd(TFT_INVONN);
-  else disp_spi_transfer_cmd(TFT_INVOFF);
-}
 
 // Select gamma curve
 // Input: gamma = 0~3
@@ -2109,74 +1402,7 @@
   disp_spi_transfer_cmd_data(TFT_CMD_GAMMASET, &gamma_curve, 1);
 }
 
-//===========================================================
-color_t HSBtoRGB(float _hue, float _sat, float _brightness) {
- float red = 0.0;
- float green = 0.0;
- float blue = 0.0;
 
- if (_sat == 0.0) {
-   red = _brightness;
-   green = _brightness;
-   blue = _brightness;
- } else {
-   if (_hue == 360.0) {
-     _hue = 0;
-   }
-
-   int slice = (int)(_hue / 60.0);
-   float hue_frac = (_hue / 60.0) - slice;
-
-   float aa = _brightness * (1.0 - _sat);
-   float bb = _brightness * (1.0 - _sat * hue_frac);
-   float cc = _brightness * (1.0 - _sat * (1.0 - hue_frac));
-
-   switch(slice) {
-     case 0:
-         red = _brightness;
-         green = cc;
-         blue = aa;
-         break;
-     case 1:
-         red = bb;
-         green = _brightness;
-         blue = aa;
-         break;
-     case 2:
-         red = aa;
-         green = _brightness;
-         blue = cc;
-         break;
-     case 3:
-         red = aa;
-         green = bb;
-         blue = _brightness;
-         break;
-     case 4:
-         red = cc;
-         green = aa;
-         blue = _brightness;
-         break;
-     case 5:
-         red = _brightness;
-         green = aa;
-         blue = bb;
-         break;
-     default:
-         red = 0.0;
-         green = 0.0;
-         blue = 0.0;
-         break;
-   }
- }
-
- color_t color;
- color.r = ((uint8_t)(red * 255.0)) & 0xFC;
- color.g = ((uint8_t)(green * 255.0)) & 0xFC;
- color.b = ((uint8_t)(blue * 255.0)) & 0xFC;
-
- return color;
-}
 //=====================================================================
 void TFT_setclipwin(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
 {
--- a/components/tft/tft.h	Fri Oct 26 21:23:46 2018 +0200
+++ b/components/tft/tft.h	Fri Oct 26 22:19:48 2018 +0200
@@ -3,6 +3,7 @@
  * @brief High level TFT functions
  * @author LoBo 04/2017
  * @see https://github.com/loboris
+ * @author M. Broek - removed unused code for this app.
  */
 
 #ifndef _TFT_H_
@@ -179,21 +180,6 @@
  */
 void TFT_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, color_t color);
 
-
-/**
- * @brief Draw line on screen from (x,y) point at given angle
- *        Line drawing angle starts at lower right quadrant of the screen and is offseted by
- *        '_angleOffset' global variable (default: -90 degrees)
- *
- * @param x horizontal start position
- * @param y vertical start position
- * @param start start offset from (x,y)
- * @param len length of the line
- * @param angle line angle in degrees
- * @param color line color
- */
-void TFT_drawLineByAngle(uint16_t x, uint16_t y, uint16_t start, uint16_t len, uint16_t angle, color_t color);
-
 /**
  * @brief Fill given rectangular screen region with color
  * 
@@ -255,32 +241,6 @@
 void TFT_fillWindow(color_t color);
 
 /**
- * @brief Draw triangle on screen
- * 
- * @param x0 first triangle point x position
- * @param y0 first triangle point y position
- * @param x0 second triangle point x position
- * @param y0 second triangle point y position
- * @param x0 third triangle point x position
- * @param y0 third triangle point y position
- * @param color triangle color
- */
-void TFT_drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color);
-
-/**
- * @brief Fill triangular screen region with color
- * 
- * @param x0 first triangle point x position
- * @param y0 first triangle point y position
- * @param x0 second triangle point x position
- * @param y0 second triangle point y position
- * @param x0 third triangle point x position
- * @param y0 third triangle point y position
- * @param color fill color
- */
-void TFT_fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color);
-
-/**
  * @brief Draw circle on screen
  * 
  * @param x circle center x position
@@ -301,73 +261,6 @@
 void TFT_fillCircle(int16_t x, int16_t y, int radius, color_t color);
 
 /**
- * @brief Draw ellipse on screen
- * 
- * @param x0 ellipse center x position
- * @param y0 ellipse center x position
- * @param rx ellipse horizontal radius
- * @param ry ellipse vertical radius
- * @param option drawing options, multiple options can be combined
- *
- *               1 (TFT_ELLIPSE_UPPER_RIGHT) draw upper right corner
- *               2 (TFT_ELLIPSE_UPPER_LEFT)  draw upper left corner
- *               4 (TFT_ELLIPSE_LOWER_LEFT)  draw lower left corner
- *               8 (TFT_ELLIPSE_LOWER_RIGHT) draw lower right corner
- *             to draw the whole ellipse use option value 15 (1 | 2 | 4 | 8)
- * @param color: circle color
- */
-void TFT_drawEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option);
-
-/**
- * @brief Fill elliptical region on screen
- * 
- * @param x0 ellipse center x position
- * @param y0 ellipse center x position
- * @param rx ellipse horizontal radius
- * @param ry ellipse vertical radius
- * @param option drawing options, multiple options can be combined
- *
- *              1 (TFT_ELLIPSE_UPPER_RIGHT) fill upper right corner
- *              2 (TFT_ELLIPSE_UPPER_LEFT)  fill upper left corner
- *              4 (TFT_ELLIPSE_LOWER_LEFT)  fill lower left corner
- *              8 (TFT_ELLIPSE_LOWER_RIGHT) fill lower right corner
- *            to fill the whole ellipse use option value 15 (1 | 2 | 4 | 8)
- * @param color fill color
- */
-void TFT_fillEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option);
-
-
-/**
- * @brief Draw circle arc on screen
- *         Arc drawing angle starts at lower right quadrant of the screen and is offseted by
- *         '_angleOffset' global variable (default: -90 degrees)
- *
- * @param cx arc center X position
- * @param cy arc center Y position
- * @param th thickness of the drawn arc
- * @param ry arc vertical radius
- * @param start arc start angle in degrees
- * @param end arc end angle in degrees
- * @param color arc outline color
- * @param fillcolor arc fill color
- */
-void TFT_drawArc(uint16_t cx, uint16_t cy, uint16_t r, uint16_t th, float start, float end, color_t color, color_t fillcolor);
-
-/**
- * @brief Draw polygon on screen
- *
- * @param cx polygon center X position
- * @param cy arc center Y position
- * @param sides number of polygon sides; MAX_POLIGON_SIDES ~ MAX_POLIGON_SIDES (3 ~ 60)
- * @param diameter diameter of the circle inside which the polygon is drawn
- * @param color polygon outline color
- * @param fill polygon fill color; if same as color, polygon is not filled
- * @param deg polygon rotation angle; 0 ~ 360
- * @param th thickness of the polygon outline
- */
-void TFT_drawPolygon(int cx, int cy, int sides, int diameter, color_t color, color_t fill, int deg, uint8_t th);
-
-/**
  * @brief Set the font used for writing the text to display.
  *
  * ------------------------------------------------------------------------------------
@@ -470,27 +363,12 @@
 void TFT_setRotation(uint8_t rot);
 
 /**
- * @brief Set inverted/normal colors
- *
- * @param mode 0 or 1; use defined constants: INVERT_ON or INVERT_OFF
- */
-void TFT_invertDisplay(const uint8_t mode);
-
-/**
  * @brief Select gamma curve
  * @param gm gama curve, values 0~3
  */
 void TFT_setGammaCurve(uint8_t gm);
 
 /**
- * @brief Compare two color structures
- * @return 0 if equal, 1 if not equal
- *
- * @param c1, c2 colors to be compared
- */
-int TFT_compare_colors(color_t c1, color_t c2);
-
-/**
  * @brief returns the string width in pixels. Useful for positions strings on the screen.
  * @return The string width.
  */
@@ -506,19 +384,6 @@
 void TFT_clearStringRect(int x, int y, char *str);
 
 /**
- * @brief Converts the components of a color, as specified by the HSB model,
- *        to an equivalent set of values for the default RGB model.
- *
- *        The color structure that is returned by HSBtoRGB encodes the value of a color as R, G & B component
- *
- * @param _hue any number, the floor of this number is subtracted from it to create a fraction between 0 and 1.
- * 	       This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model.
- * @param _sat 0 ~ 1.0
- * @param _brightness 0 ~ 1.0
- */
-color_t HSBtoRGB(float _hue, float _sat, float _brightness);
-
-/**
  * @brief Get the touch panel coordinates.
  *        The coordinates are adjusted to screen orientation if raw=0
  *
@@ -530,22 +395,4 @@
  */
 int TFT_read_touch(int *x, int* y, uint8_t raw);
 
-
-/**
- * @brief Compile font c source file to .fnt file
- *        which can be used in TFT_setFont() function to select external font
- *        Created file have the same name as source file and extension .fnt
- *
- * @param fontfile pointer to c source font file name; must have .c extension
- * @param dbg if set to 1, prints debug information
- *
- * @return 0 on success, err no on error
- */
-int compile_font_file(char *fontfile, uint8_t dbg);
-
-/**
- * @brief Get all font's characters to buffer
- */
-void getFontCharacters(uint8_t *buf);
-
 #endif
--- a/main/config.h	Fri Oct 26 21:23:46 2018 +0200
+++ b/main/config.h	Fri Oct 26 22:19:48 2018 +0200
@@ -80,7 +80,7 @@
 #include "task_http.h"
 
 
-#define	VERSION		"0.2.5"		///< Application version
+#define	VERSION		"0.2.6"		///< Application version
 
 
 

mercurial