Преглед на файлове

Added functions for variable width font.

Vladimir N. Shilov преди 1 година
родител
ревизия
32d181d19e
променени са 6 файла, в които са добавени 310 реда и са изтрити 68 реда
  1. 225 54
      lib/st7735/arial_8_ukr.c
  2. 4 7
      lib/st7735/arial_8_ukr.h
  3. 0 1
      lib/st7735/fonts.h
  4. 79 3
      lib/st7735/st7735.c
  5. 0 1
      lib/stab/stab_param.h
  6. 2 2
      main.c

+ 225 - 54
lib/st7735/arial_8_ukr.c

@@ -1,4 +1,4 @@
-#include "fonts.h"
+#include "arial_8_ukr.h"
 
 /*
  *  Font data for Arial 8pt
@@ -6,7 +6,8 @@
 
 /* Character bitmaps for Arial 8pt */
 // Height = 10 bit
-static const uint16_t Arial8x10 [] =
+
+static const uint16_t Arial8x10 [1670] =
 {
 	/* @0 ' ' (2 pixels wide) */
 	0x0000, //
@@ -20,7 +21,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @13 '!' (1 pixels wide) */
+	/* @1 '!' (1 pixels wide) */
 	0x0000, //
 	0x8000, // #
 	0x8000, // #
@@ -32,7 +33,7 @@ static const uint16_t Arial8x10 [] =
 	0x8000, // #
 	0x0000, //
 
-	/* @26 '"' (3 pixels wide) */
+	/* @2 '"' (3 pixels wide) */
 	0x0000, //
 	0xA000, // # #
 	0xA000, // # #
@@ -44,7 +45,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @39 '#' (5 pixels wide) */
+	/* @3 '#' (5 pixels wide) */
 	0x0000, //
 	0x2800, //   # #
 	0x2800, //   # #
@@ -56,7 +57,7 @@ static const uint16_t Arial8x10 [] =
 	0xA000, // # #
 	0x0000, //
 
-	/* @52 '$' (5 pixels wide) */
+	/* @4 '$' (5 pixels wide) */
 	0x2000, //   #
 	0x7000, //  ###
 	0xA800, // # # #
@@ -68,7 +69,7 @@ static const uint16_t Arial8x10 [] =
 	0x7000, //  ###
 	0x2000, //   #
 
-	/* @65 '%' (9 pixels wide) */
+	/* @5 '%' (9 pixels wide) */
 	0x0000, //
 	0x6200, //  ##   #
 	0x9400, // #  # #
@@ -80,7 +81,7 @@ static const uint16_t Arial8x10 [] =
 	0x2300, //   #   ##
 	0x0000, //
 
-	/* @91 '&' (6 pixels wide) */
+	/* @6 '&' (6 pixels wide) */
 	0x0000, //
 	0x3000, //   ##
 	0x4800, //  #  #
@@ -92,7 +93,7 @@ static const uint16_t Arial8x10 [] =
 	0x7400, //  ### #
 	0x0000, //
 
-	/* @104 ''' (1 pixels wide) */
+	/* @7 ''' (1 pixels wide) */
 	0x0000, //
 	0x8000, // #
 	0x8000, // #
@@ -104,7 +105,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @117 '(' (3 pixels wide) */
+	/* @8 '(' (3 pixels wide) */
 	0x2000, //   #
 	0x4000, //  #
 	0x8000, // #
@@ -116,7 +117,7 @@ static const uint16_t Arial8x10 [] =
 	0x4000, //  #
 	0x2000, //   #
 
-	/* @130 ')' (3 pixels wide) */
+	/* @9 ')' (3 pixels wide) */
 	0x8000, // #
 	0x4000, //  #
 	0x2000, //   #
@@ -128,7 +129,7 @@ static const uint16_t Arial8x10 [] =
 	0x4000, //  #
 	0x8000, // #
 
-	/* @143 '*' (3 pixels wide) */
+	/* @10 '*' (3 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x4000, //  #
@@ -140,7 +141,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @156 '+' (5 pixels wide) */
+	/* @11 '+' (5 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -152,7 +153,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @169 ',' (1 pixels wide) */
+	/* @12 ',' (1 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -164,7 +165,7 @@ static const uint16_t Arial8x10 [] =
 	0x8000, // #
 	0x8000, // #
 
-	/* @182 '-' (3 pixels wide) */
+	/* @13 '-' (3 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -176,7 +177,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @195 '.' (1 pixels wide) */
+	/* @14 '.' (1 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -188,7 +189,7 @@ static const uint16_t Arial8x10 [] =
 	0x8000, // #
 	0x0000, //
 
-	/* @208 '/' (3 pixels wide) */
+	/* @15 '/' (3 pixels wide) */
 	0x0000, //
 	0x2000, //   #
 	0x2000, //   #
@@ -200,7 +201,7 @@ static const uint16_t Arial8x10 [] =
 	0x8000, // #
 	0x0000, //
 
-	/* @221 '0' (5 pixels wide) */
+	/* @16 '0' (5 pixels wide) */
 	0x0000, //
 	0x7000, //  ###
 	0x8800, // #   #
@@ -212,7 +213,7 @@ static const uint16_t Arial8x10 [] =
 	0x7000, //  ###
 	0x0000, //
 
-	/* @234 '1' (3 pixels wide) */
+	/* @17 '1' (3 pixels wide) */
 	0x0000, //
 	0x2000, //   #
 	0x6000, //  ##
@@ -224,7 +225,7 @@ static const uint16_t Arial8x10 [] =
 	0x2000, //   #
 	0x0000, //
 
-	/* @247 '2' (5 pixels wide) */
+	/* @18 '2' (5 pixels wide) */
 	0x0000, //
 	0x7000, //  ###
 	0x8800, // #   #
@@ -236,7 +237,7 @@ static const uint16_t Arial8x10 [] =
 	0xF800, // #####
 	0x0000, //
 
-	/* @260 '3' (5 pixels wide) */
+	/* @19 '3' (5 pixels wide) */
 	0x0000, //
 	0x7000, //  ###
 	0x8800, // #   #
@@ -248,7 +249,7 @@ static const uint16_t Arial8x10 [] =
 	0x7000, //  ###
 	0x0000, //
 
-	/* @273 '4' (5 pixels wide) */
+	/* @20 '4' (5 pixels wide) */
 	0x0000, //
 	0x1000, //    #
 	0x3000, //   ##
@@ -260,7 +261,7 @@ static const uint16_t Arial8x10 [] =
 	0x1000, //    #
 	0x0000, //
 
-	/* @286 '5' (5 pixels wide) */
+	/* @21 '5' (5 pixels wide) */
 	0x0000, //
 	0x7800, //  ####
 	0x4000, //  #
@@ -272,7 +273,7 @@ static const uint16_t Arial8x10 [] =
 	0x7000, //  ###
 	0x0000, //
 
-	/* @299 '6' (5 pixels wide) */
+	/* @22 '6' (5 pixels wide) */
 	0x0000, //
 	0x7000, //  ###
 	0x8800, // #   #
@@ -284,7 +285,7 @@ static const uint16_t Arial8x10 [] =
 	0x7000, //  ###
 	0x0000, //
 
-	/* @312 '7' (5 pixels wide) */
+	/* @23 '7' (5 pixels wide) */
 	0x0000, //
 	0xF800, // #####
 	0x1000, //    #
@@ -296,7 +297,7 @@ static const uint16_t Arial8x10 [] =
 	0x4000, //  #
 	0x0000, //
 
-	/* @325 '8' (5 pixels wide) */
+	/* @24 '8' (5 pixels wide) */
 	0x0000, //
 	0x7000, //  ###
 	0x8800, // #   #
@@ -308,7 +309,7 @@ static const uint16_t Arial8x10 [] =
 	0x7000, //  ###
 	0x0000, //
 
-	/* @338 '9' (5 pixels wide) */
+	/* @25 '9' (5 pixels wide) */
 	0x0000, //
 	0x7000, //  ###
 	0x8800, // #   #
@@ -320,7 +321,7 @@ static const uint16_t Arial8x10 [] =
 	0x7000, //  ###
 	0x0000, //
 
-	/* @351 ':' (1 pixels wide) */
+	/* @26 ':' (1 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x8000, // #
@@ -332,7 +333,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @364 ';' (1 pixels wide) */
+	/* @27 ';' (1 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x8000, // #
@@ -344,7 +345,7 @@ static const uint16_t Arial8x10 [] =
 	0x8000, // #
 	0x8000, // #
 
-	/* @377 '<' (5 pixels wide) */
+	/* @28 '<' (5 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -356,7 +357,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @390 '=' (5 pixels wide) */
+	/* @29 '=' (5 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -368,7 +369,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @403 '>' (5 pixels wide) */
+	/* @30 '>' (5 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -380,7 +381,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @416 '?' (5 pixels wide) */
+	/* @31 '?' (5 pixels wide) */
 	0x0000, //
 	0x7000, //  ###
 	0x8800, // #   #
@@ -392,7 +393,7 @@ static const uint16_t Arial8x10 [] =
 	0x2000, //   #
 	0x0000, //
 
-	/* @429 '@' (10 pixels wide) */
+	/* @32 '@' (10 pixels wide) */
 	0x1F00, //    #####
 	0x6080, //  ##     #
 	0x4D40, //  #  ## # #
@@ -404,7 +405,7 @@ static const uint16_t Arial8x10 [] =
 	0x4040, //  #       #
 	0x3F80, //   #######
 
-	/* @455 'A' (7 pixels wide) */
+	/* @33 'A' (7 pixels wide) */
 	0x0000, //
 	0x1000, //    #
 	0x2800, //   # #
@@ -416,7 +417,7 @@ static const uint16_t Arial8x10 [] =
 	0x8200, // #     #
 	0x0000, //
 
-	/* @468 'B' (6 pixels wide) */
+	/* @34 'B' (6 pixels wide) */
 	0x0000, //
 	0xF800, // #####
 	0x8400, // #    #
@@ -788,7 +789,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @884 'a' (5 pixels wide) */
+	/* @65 'a' (5 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -1088,7 +1089,7 @@ static const uint16_t Arial8x10 [] =
 	0x2000, //   #
 	0x4000, //  #
 
-	/* @1222 'z' (5 pixels wide) */
+	/* @90 'z' (5 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -1100,7 +1101,7 @@ static const uint16_t Arial8x10 [] =
 	0xF800, // #####
 	0x0000, //
 
-	/* @1235 '{' (3 pixels wide) */
+	/* @91 '{' (3 pixels wide) */
 	0x2000, //   #
 	0x4000, //  #
 	0x4000, //  #
@@ -1112,7 +1113,7 @@ static const uint16_t Arial8x10 [] =
 	0x4000, //  #
 	0x2000, //   #
 
-	/* @1248 '|' (1 pixels wide) */
+	/* @92 '|' (1 pixels wide) */
 	0x8000, // #
 	0x8000, // #
 	0x8000, // #
@@ -1124,7 +1125,7 @@ static const uint16_t Arial8x10 [] =
 	0x8000, // #
 	0x8000, // #
 
-	/* @1261 '}' (3 pixels wide) */
+	/* @93 '}' (3 pixels wide) */
 	0x8000, // #
 	0x4000, //  #
 	0x4000, //  #
@@ -1136,7 +1137,7 @@ static const uint16_t Arial8x10 [] =
 	0x4000, //  #
 	0x8000, // #
 
-	/* @1274 '~' (5 pixels wide) */
+	/* @94 '~' (5 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -1148,7 +1149,7 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 	0x0000, //
 
-	/* @1287 'Ё' (5 pixels wide) */
+	/* @95 'Ё' (5 pixels wide) */
 	0x2800, //   # #
 	0x0000, //
 	0xF800, // #####
@@ -1160,7 +1161,7 @@ static const uint16_t Arial8x10 [] =
 	0xF800, // #####
 	0x0000, //
 
-	/* @1300 'ё' (5 pixels wide) */
+	/* @96 'ё' (5 pixels wide) */
 	0x0000, //
 	0x5000, //  # #
 	0x0000, //
@@ -1172,7 +1173,7 @@ static const uint16_t Arial8x10 [] =
 	0x7000, //  ###
 	0x0000, //
 
-	/* @1313 'Є' (6 pixels wide) */
+	/* @97 'Є' (6 pixels wide) */
 	0x0000, //
 	0x3800, //   ###
 	0x4400, //  #   #
@@ -1184,7 +1185,7 @@ static const uint16_t Arial8x10 [] =
 	0x3800, //   ###
 	0x0000, //
 
-	/* @1326 'є' (5 pixels wide) */
+	/* @98 'є' (5 pixels wide) */
 	0x0000, //
 	0x0000, //
 	0x0000, //
@@ -1196,7 +1197,7 @@ static const uint16_t Arial8x10 [] =
 	0x7000, //  ###
 	0x0000, //
 
-	/* @1339 'Ї' (3 pixels wide) */
+	/* @99 'Ї' (3 pixels wide) */
 	0xA000, // # #
 	0x0000, //
 	0x4000, //  #
@@ -1208,7 +1209,7 @@ static const uint16_t Arial8x10 [] =
 	0x4000, //  #
 	0x0000, //
 
-	/* @1352 'ї' (3 pixels wide) */
+	/* @100 'ї' (3 pixels wide) */
 	0x0000, //
 	0xA000, // # #
 	0x0000, //
@@ -1220,7 +1221,7 @@ static const uint16_t Arial8x10 [] =
 	0x4000, //  #
 	0x0000, //
 
-	/* @1365 'І' (1 pixels wide) */
+	/* @101 'І' (1 pixels wide) */
 	0x0000, //
 	0x8000, // #
 	0x8000, // #
@@ -1232,7 +1233,7 @@ static const uint16_t Arial8x10 [] =
 	0x8000, // #
 	0x0000, //
 
-	/* @1378 'і' (1 pixels wide) */
+	/* @102 'і' (1 pixels wide) */
 	0x0000, //
 	0x8000, // #
 	0x0000, //
@@ -1244,7 +1245,7 @@ static const uint16_t Arial8x10 [] =
 	0x8000, // #
 	0x0000, //
 
-	/* @1391 'А' (7 pixels wide) */
+	/* @103 'А' (7 pixels wide) */
 	0x0000, //
 	0x1000, //    #
 	0x2800, //   # #
@@ -2013,7 +2014,178 @@ static const uint16_t Arial8x10 [] =
 	0x0000, //
 };
 
-static const uint8_t ArialFontWidthTable[] =
+static const uint16_t ArialfontPositionTable[167] = 
+{
+	0,		//	' ',	0
+	10,		//	'!',	1
+	20,		//	'"',	2
+	30,		//	'#',	3
+	40,		//	'$',	4
+	50,		//	'%',	5
+	60,		//	'&',	6
+	70,		//	''',	7
+	80,		//	'(',	8
+	90,		//	')',	9
+	100,		//	'*',	10
+	110,		//	'+',	11
+	120,		//	',',	12
+	130,		//	'-',	13
+	140,		//	'.',	14
+	150,		//	'/',	15
+	160,		//	'0',	16
+	170,		//	'1',	17
+	180,		//	'2',	18
+	190,		//	'3',	19
+	200,		//	'4',	20
+	210,		//	'5',	21
+	308,		//	'6',	22
+	322,		//	'7',	23
+	336,		//	'8',	24
+	350,		//	'9',	25
+	364,		//	':',	26
+	378,		//	';',	27
+	392,		//	'<',	28
+	406,		//	'=',	29
+	420,		//	'>',	30
+	434,		//	'?',	31
+	448,		//	'@',	32
+	462,		//	'A',	33
+	476,		//	'B',	34
+	490,		//	'C',	35
+	504,		//	'D',	36
+	518,		//	'E',	37
+	532,		//	'F',	38
+	546,		//	'G',	39
+	560,		//	'H',	40
+	574,		//	'I',	41
+	588,		//	'J',	42
+	602,		//	'K',	43
+	616,		//	'L',	44
+	630,		//	'M',	45
+	644,		//	'N',	46
+	658,		//	'O',	47
+	672,		//	'P',	48
+	686,		//	'Q',	49
+	700,		//	'R',	50
+	714,		//	'S',	51
+	728,		//	'T',	52
+	742,		//	'U',	53
+	756,		//	'V',	54
+	770,		//	'W',	55
+	784,		//	'X',	56
+	798,		//	'Y',	57
+	812,		//	'Z',	58
+	826,		//	'[',	59
+	840,		//	'\',	60
+	854,		//	']',	61
+	868,		//	'^',	62
+	882,		//	'_',	63
+	896,		//	'`',	64
+	910,		//	'a',	65
+	924,		//	'b',	66
+	938,		//	'c',	67
+	952,		//	'd',	68
+	966,		//	'e',	69
+	980,		//	'f',	70
+	994,		//	'g',	71
+	1008,		//	'h',	72
+	1022,		//	'i',	73
+	1036,		//	'j',	74
+	1050,		//	'k',	75
+	1064,		//	'l',	76
+	1078,		//	'm',	77
+	1092,		//	'n',	78
+	1106,		//	'o',	79
+	1120,		//	'p',	80
+	1134,		//	'q',	81
+	1148,		//	'r',	82
+	1162,		//	's',	83
+	1176,		//	't',	84
+	1190,		//	'u',	85
+	1204,		//	'v',	86
+	1218,		//	'w',	87
+	1232,		//	'x',	88
+	1246,		//	'y',	89
+	1260,		//	'z',	90
+	1274,		//	'{',	91
+	1288,		//	'|',	92
+	1302,		//	'}',	93
+	1316,		//	'~',	94
+	1330,		//	'Ё',	95
+	1344,		//	'ё',	96
+	1358,		//	'Є',	97
+	1372,		//	'є',	98
+	1386,		//	'Ї',	99
+	1400,		//	'ї',	100
+	1414,		//	'І',	101
+	1428,		//	'і',	102
+	1442,		//	'А',	103
+	1456,		//	'Б',	104
+	1470,		//	'В',	105
+	1484,		//	'Г',	106
+	1498,		//	'Д',	107
+	1512,		//	'Е',	108
+	1526,		//	'Ж',	109
+	1540,		//	'З',	110
+	1554,		//	'И',	111
+	1568,		//	'Й',	112
+	1582,		//	'К',	113
+	1596,		//	'Л',	114
+	1610,		//	'М',	115
+	1624,		//	'Н',	116
+	1638,		//	'О',	117
+	1652,		//	'П',	118
+	1666,		//	'Р',	119
+	1680,		//	'С',	120
+	1694,		//	'Т',	121
+	1708,		//	'У',	122
+	1722,		//	'Ф',	123
+	1736,		//	'Х',	124
+	1750,		//	'Ц',	125
+	1764,		//	'Ч',	126
+	1778,		//	'Ш',	127
+	1792,		//	'Щ',	128
+	1806,		//	'Ъ',	129
+	1820,		//	'Ы',	130
+	1834,		//	'Ь',	131
+	1848,		//	'Э',	132
+	1862,		//	'Ю',	133
+	1876,		//	'Я',	134
+	1890,		//	'а',	135
+	1904,		//	'б',	136
+	1918,		//	'в',	137
+	1932,		//	'г',	138
+	1946,		//	'д',	139
+	1960,		//	'е',	140
+	1974,		//	'ж',	141
+	1988,		//	'з',	142
+	2002,		//	'и',	143
+	2016,		//	'й',	144
+	2030,		//	'к',	145
+	2044,		//	'л',	146
+	2058,		//	'м',	147
+	2072,		//	'н',	148
+	2086,		//	'о',	149
+	2100,		//	'п',	150
+	2114,		//	'р',	151
+	2128,		//	'с',	152
+	2142,		//	'т',	153
+	2156,		//	'у',	154
+	2170,		//	'ф',	155
+	2184,		//	'х',	156
+	2198,		//	'ц',	157
+	2212,		//	'ч',	158
+	2226,		//	'ш',	159
+	1600,		//	'щ',	160
+	1610,		//	'ъ',	161
+	1620,		//	'ы',	162
+	1630,		//	'ь',	163
+	1640,		//	'э',	164
+	1650,		//	'ю',	165
+	1660,		//	'я',	166
+};
+
+static const uint8_t ArialFontWidthTable[167] =
 {
 	2,		//	' ',	0
 	1,		//	'!',	1
@@ -2184,5 +2356,4 @@ static const uint8_t ArialFontWidthTable[] =
 	4,		//	'я',	166
 };
 
-//FontDef Font_8x10 = {8, 10, Arial8x10, ArialFontWidthTable};
-FontDef Font_8x10 = {8, 10, Arial8x10};
+FontDefV Arial_8x10 = {10, ArialFontWidthTable, Arial8x10};

+ 4 - 7
lib/st7735/arial_8_ukr.h

@@ -1,17 +1,14 @@
-/* vim: set ai et ts=4 sw=4: */
 #ifndef __ARIAL_8_UKR_H__
 #define __ARIAL_8_UKR_H__
 
 #include <stdint.h>
-/*
+
 typedef struct {
-  const uint8_t width;
   uint8_t height;
-  const uint16_t *data;
   const uint8_t *width;
-} FontDef;
-*/
+  const uint16_t *data;
+} FontDefV;
 
-extern FontDef Font_8x10;
+extern FontDefV Arial_8x10;
 
 #endif // __ARIAL_8_UKR_H__

+ 0 - 1
lib/st7735/fonts.h

@@ -1,4 +1,3 @@
-/* vim: set ai et ts=4 sw=4: */
 #ifndef __FONTS_H__
 #define __FONTS_H__
 

+ 79 - 3
lib/st7735/st7735.c

@@ -131,7 +131,7 @@ static void ST7735_WriteData(uint8_t* buff, size_t buff_size) {
 }
 
 /**
- * @brief Send 16-bit data trough reg
+ * @brief Send 16-bit data trough reg, with end wait.
  * 
  * @param data to send to display
  */
@@ -224,6 +224,16 @@ void ST7735_DrawPixel(uint16_t x, uint16_t y, uint16_t color) {
   ST7735_Unselect();
 }
 
+/**
+ * @brief Draw fixed width font char.
+ * 
+ * @param x coordinate,
+ * @param y coordinate,
+ * @param ch char to draw,
+ * @param font fixed width font
+ * @param color char color
+ * @param bgcolor background color
+ */
 static void ST7735_WriteChar(uint16_t x, uint16_t y, char ch, FontDef font, uint16_t color, uint16_t bgcolor) {
   uint32_t i, b, j;
 
@@ -268,6 +278,74 @@ void ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, u
   ST7735_Unselect();
 }
 
+/**
+ * @brief Draw variable width font char.
+ * 
+ * @param x coordinate,
+ * @param y coordinate,
+ * @param ch char to draw,
+ * @param font variable width font
+ * @param color char color
+ * @param bgcolor background color
+ */
+static void ST7735_WriteCharV(uint16_t x, uint16_t y, char ch, FontDefV font, uint16_t color, uint16_t bgcolor) {
+  uint32_t i, b, j;
+  uint8_t c, w, h;
+
+  c = ch - 32;
+  w = font.width[c];
+  h = font.height;
+
+  ST7735_SetAddressWindow(x, y, w-1, h-1);
+
+  LCD_DC_DATA;
+  SPI1->CR1 |= SPI_CR1_DFF;
+
+  for(i = 0; i < h; i++) {
+    b = font.data[c * h + i]; // ??? замінити на масив позицій
+    for(j = 0; j < w; j++) {
+      if (b & 0x8000) {
+        while (!(SPI1->SR & SPI_SR_TXE));
+        SPI1->DR = color;
+      } else {
+        while (!(SPI1->SR & SPI_SR_TXE));
+        SPI1->DR = bgcolor;
+      }
+      b <<= 1;
+    }
+  }
+
+  while (!(SPI1->SR & SPI_SR_TXE));
+  while ((SPI1->SR & SPI_SR_BSY));
+  SPI1->CR1 &= ~(SPI_CR1_DFF);
+}
+
+void ST7735_WriteStringV(uint16_t x, uint16_t y, const char* str, FontDefV font, uint16_t color, uint16_t bgcolor) {
+  ST7735_Select();
+
+  while (*str) {
+    if (x + font.width[(uint8_t)*str] >= ST7735_WIDTH) {
+      x = 0;
+      y += font.height;
+      if (y + font.height >= ST7735_HEIGHT) {
+        break;
+      }
+
+      if (*str == ' ') {
+        // skip spaces in the beginning of the new line
+        str ++;
+        continue;
+      }
+    }
+
+    ST7735_WriteCharV(x, y, *str, font, color, bgcolor);
+    x += font.width[(uint8_t)*str];
+    str ++;
+  }
+
+  ST7735_Unselect();
+}
+
 void ST7735_FillRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) {
   // clipping
   if ((x >= ST7735_WIDTH) || (y >= ST7735_HEIGHT)) {
@@ -283,7 +361,6 @@ void ST7735_FillRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16
   ST7735_Select();
   ST7735_SetAddressWindow(x, y, x+w-1, y+h-1);
 
-  LCD_DC_DATA;
   for (y = h; y > 0; y--) {
     for (x = w; x > 0; x--) {
       ST7735_WriteData16(color);
@@ -315,7 +392,6 @@ void ST7735_FillRectangleFast(uint16_t x, uint16_t y, uint16_t w, uint16_t h, ui
     memcpy(line + x * sizeof(pixel), pixel, sizeof(pixel));
   }
 
-  LCD_DC_DATA;
   for (y=h; y>0; y--) {
     spiSend(&ST7735_SPI_PORT, w * sizeof(pixel), line);
   }

+ 0 - 1
lib/stab/stab_param.h

@@ -161,7 +161,6 @@
 //
 #define ASOled LD // Заюзаем уже созданный в библиотеке дисплея объект LD
 //
-#define EMPTY_CELL_VALUE 0xFFFF  // Содержимое пустой ячейки памяти EEPROM
 #define SRVDATA_ARR_SIZE 14 // Размер блока памяти для вспомогательных данных
 #define Pnom_ARR_SIZE 8   // Макс. размер массива записанных номинальных мощностей ТЭНа sizeof(Pnom_arr)/sizeof(Pnom_arr[0])
 #define PDMset_ARR_SIZE 6     // Размер массива уставок мощности ТЭНа sizeof(PDMset)/sizeof(PDMset[0]) (ставить не меньше 4)

+ 2 - 2
main.c

@@ -92,9 +92,9 @@ int main(void) {
 
   ST7735_FillScreen(ST7735_BLACK);
   ST7735_WriteString(0, 0, "Font_7x10, red on black, lorem ipsum dolor sit amet", Font_7x10, ST7735_RED, ST7735_BLACK);
-  ST7735_WriteString(0, 32, "Font_8x10, green on black, lorem ipsum dolor sit amet", Font_8x10, ST7735_GREEN, ST7735_BLACK);
+  ST7735_WriteStringV(0, 32, "Arial_8x10, green on black, lorem ipsum dolor sit amet", Arial_8x10, ST7735_GREEN, ST7735_BLACK);
   ST7735_WriteString(0, 64, "Font_7x10, blue on black, lorem ipsum dolor sit amet", Font_7x10, ST7735_BLUE, ST7735_BLACK);
-  ST7735_WriteString(0, 96, "Font_8x10, yellow on black, lorem ipsum dolor sit amet", Font_8x10, ST7735_YELLOW, ST7735_BLACK);
+  ST7735_WriteStringV(0, 96, "Arial_8x10, yellow on black, lorem ipsum dolor sit amet", Arial_8x10, ST7735_YELLOW, ST7735_BLACK);
 
   /*
    * Normal main() thread activity.