-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths7.h
156 lines (138 loc) · 5.13 KB
/
s7.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#ifndef S7_include
#define S7_include
/*
Íàñòðàèâàåìûé çíàêîãåíåðàòîð äëÿ ñåìèñåãìåíòíîãî èíäèêàòîðà
a.hordieiev@ukr.net 2009-2021
--------------------------------------------------------------------------------
Äî âñòàâêè ýòîãî ôàéëà íåîáõîäèìî îïðåäåëèòü:
1. Ïðèâÿçêà "áèò-ñåãìåíò" (ïî óìîë÷àíèþ A-0,B-1..P-7)
#define S7_SEG_A 0 (Ñåãìåíò À -- âèñèò íà áèòå 0)
.. B C D E F G
#define S7_SEG_P 7 (Ñåãìåíò P -- âèñèò íà áèòå 7) -- ýòî òî÷êà
Ðàñïîëîæåíèå ñåãìåíòîâ ñì. íèæå
2. Z7_SET ìîæíî ñôîðìèðîâàòü ìàññèâ çíàêîãåíåðàòîðà. Ïî óìîë÷àíèþ â íåì òîëüêî öèôðû
Íàïðèìåð: S7_NUMS, S7_SPACE, S7_CHAR(1,1,0,0,1,1,1,0)
--------------------------------------------------------------------------------
ÏÎÑËÅ #include ZG7.h ìû ïîëó÷èì â èñïîëüçîâàíèå îïðåäåëåíèÿ ñèìâîëîâ S7_*
Èç íèõ íóæíî ñôîðìèðîâàòü è îáúÿâèòü ìàññèâ çíàêîãíåíåðàòîðà S7, êîòîðûé â ýòîì ôàéëå îèøü îáúÿâëåí.
Íàïðèìåð (main.c avr-gcc):
const unsigned char PROGMEM S7[] = {S7_SET, S7_MINUS}; // 0-9 è ìèíóñ
--------------------------------------------------------------------------------
Ðàñïîëîæåíèå ñåãìåíòîâ â èíäèêàòîðå
??A??
F B
??G??
E C
??D??P
*/
#include <avr/pgmspace.h>
//Çíà÷åèå ïî óìîë÷àíèþ äëÿ ñâÿçêè áèò-ñåãìåíò
#ifndef S7_SEG_A
#define S7_SEG_A 0
#endif
#ifndef S7_SEG_B
#define S7_SEG_B 1
#endif
#ifndef S7_SEG_C
#define S7_SEG_C 2
#endif
#ifndef S7_SEG_D
#define S7_SEG_D 3
#endif
#ifndef S7_SEG_E
#define S7_SEG_E 4
#endif
#ifndef S7_SEG_F
#define S7_SEG_F 5
#endif
#ifndef S7_SEG_G
#define S7_SEG_G 6
#endif
#ifndef S7_SEG_P
#define S7_SEG_P 7
#endif
//Ìàêðîñ "ñáîðêè" áàéòà çíàêîãåíåðàòîðà èç îïðåäåëåíèé "áèò-ñåãìåíò" è "ïîëÿðíîñòü ïîäæèãà" (1/0-çàæå÷ü/ïîòóøèòü).
#define S7_CHAR(xA,xB,xC,xD,xE,xF,xG,xP) ((unsigned char)((xA<<S7_SEG_A)|(xB<<S7_SEG_B)|(xC<<S7_SEG_C)|(xD<<S7_SEG_D)|(xE<<S7_SEG_E)|(xF<<S7_SEG_F)|(xG<<S7_SEG_G)|(xP<<S7_SEG_P)))
#define S7_ADD_POINT(buf) ((buf) |= S7_POINT)
//Íåáîëüøèå ìàêðîñû äëÿ ïðîáåëà/çàáîÿ/òî÷êè/öèôð
#define S7_SPACE S7_CHAR(0,0,0,0,0,0,0,0)
#define S7_ALL S7_CHAR(1,1,1,1,1,1,1,0)
#define S7_POINT S7_CHAR(0,0,0,0,0,0,0,1)
#define S7_MINUS S7_CHAR(0,0,0,0,0,0,1,0)
#define S7_0 S7_CHAR(1,1,1,1,1,1,0,0)
#define S7_1 S7_CHAR(0,1,1,0,0,0,0,0)
#define S7_2 S7_CHAR(1,1,0,1,1,0,1,0)
#define S7_3 S7_CHAR(1,1,1,1,0,0,1,0)
#define S7_4 S7_CHAR(0,1,1,0,0,1,1,0)
#define S7_5 S7_CHAR(1,0,1,1,0,1,1,0)
#define S7_6 S7_CHAR(1,0,1,1,1,1,1,0)
#define S7_7 S7_CHAR(1,1,1,0,0,0,0,0)
#define S7_8 S7_CHAR(1,1,1,1,1,1,1,0)
#define S7_9 S7_CHAR(1,1,1,1,0,1,1,0)
#define S7_A S7_CHAR(1,1,1,0,1,1,1,0)
#define S7_b S7_CHAR(0,0,1,1,1,1,1,0)
#define S7_c S7_CHAR(0,0,0,1,1,0,1,0)
#define S7_C S7_CHAR(1,0,0,1,1,1,0,0)
#define S7_d S7_CHAR(0,1,1,1,1,0,1,0)
#define S7_E S7_CHAR(1,0,0,1,1,1,1,0)
#define S7_F S7_CHAR(1,0,0,0,1,1,1,0)
#define S7_G S7_CHAR(1,0,1,1,1,1,0,0)
#define S7_h S7_CHAR(0,0,1,0,1,1,1,0)
#define S7_j S7_CHAR(0,1,1,1,0,0,0,0)
#define S7_L S7_CHAR(0,0,0,1,1,1,0,0)
#define S7_n S7_CHAR(0,0,1,0,1,0,1,0)
#define S7_o S7_CHAR(0,0,1,1,1,0,1,0)
#define S7_P S7_CHAR(1,1,0,0,1,1,1,0)
#define S7_r S7_CHAR(0,0,0,0,1,0,1,0)
#define S7_S S7_CHAR(1,0,1,1,0,1,1,0)
#define S7_t S7_CHAR(0,0,0,1,1,1,1,0)
#define S7_u S7_CHAR(0,0,1,1,1,0,0,0)
//#define S7_ S7_CHAR(0,0,0,0,0,0,0,0)
/*
S7_SET ìàêðîñ ñ ñîäåðæèìûì ìàñèâà çíàêîãåíåðàòîðà.
Ïî óìîë÷àíèþ â íåãî âñòàâëÿåòñÿ ëèøü íàáîð ÷èñåë.
Ìîæíî ïåðåîïðåäåëåèòü S7_SET, ñôîðìèðîâàâ íóæíûé íàáîð êîäîâ. Ó÷òè, ÷òî öèôðû â íà÷àëå ìàññèâà íóæíû äëÿ ôóíêöèé ôîðìàòèðîâàíèÿ.
*/
#ifndef S7_SET
#define S7_SET S7_0, S7_1, S7_2, S7_3, S7_4, S7_5, S7_6, S7_7, S7_8, S7_9
#endif
// Îáúÿâëåíèå ìàññèâà çíàêîãåíåðàòîðà
#ifdef __GNUC__ // GNU Compiler
extern const unsigned char PROGMEM S7[];
#elif defined(__CODEVISIONAVR__) // CodeVision
extern flash unsigned char S7[];
#elif defined(__ICCAVR__) // IAR C Compiler
extern __flash unsigned char S7[];
#else
#error Unknown compiler
#endif
/*
Ïðèíèìàåò ñòðîêó, çàïîëíÿåò âèäåîïàìÿòü ÿêîáû â áóôåðå ÷èñëî ñ ðàñ÷åòîì dig çíàêîâ â èíäèêàòîðå, dec çíàêîâ ïîñëå çàïÿòîé
Ïóñòîå ìåñòî çàáèâàåòñÿ S7_SPACE, ïðîñòàâëÿþòñÿ íåäîñòàþùèå íóëè S7_0 è ñòàâèòñÿ òî÷êà.
?? Äîáàâëÿåò âòîðîé öèêë, íî çàòî Áóôåð äîëæåí ñîäåðæàòü óæå êîäû äëÿ âèäåîïàìÿòè, à íå ÷èñëî
Åñëè ÷èñëî ñëèøêîì áîëüøîå, òî âûâîäèòñÿ "00".
@todo ïî õîðîøåìó òóò áû âûïàñòü â áîëüøóþ îøèáêó è ñîõðàíèòü å¸ êîä.
*/
extern void s7Str2fixPoint(char* buf, char* v, uint8_t digits, uint8_t decimal);
extern char s7AddPoint(char* v);
#endif
/* i8 n = dec + 1 - len; // 1180
if(n < 0){
n = 0;
}
i8 s = dig - n - len;
if(s < 0){
s = 0;
}
char* v = video;
char* b = buf;
for(i8 i = 0 - s - n; i < dig - s - n; i++){
if(i < 0 - n){
*v++ = S7_space;
}else if(i < 0){
*v++ = ZG7[0];
}else{
*v++ = pgm_read_byte(&ZG7[*b++ - '0']);
}
}
*/