-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxtm1638.config.h
197 lines (160 loc) · 8.71 KB
/
xtm1638.config.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#pragma no-cache
/* xtm1638 library compiler options
Software related info in: xtm1638.h & xtml1638.h (please read it first)
CHANGE THIS FILE ONLY WHEN THERE ARE ISSUES ON:
o PORT SETTINGS
o AUTO DETECTION FEATURES (FAILING)
o COMPATIBILITY
o SPEED OR GLOBAL PERFORMANCE
o PROGRAM VERSUS DYNAMIC MEMORY USAGE
PERFORMANCE STATS (Arduino Nano stress test - see xtm1638example04.ino)
-----------------------------------------------------------------------
Mode: Score: Minutes: no-leds score: no-leds minutes:
Register+Multiply 94177ms 1.57 minutes 72077ms 1.20 minutes
Register+Divide 86952ms 1.44 minutes 64852ms 1.08 minutes
Register+ShiftDivide 76404ms 1.2734 minutes 58314ms 0.972 minutes(!)
Register+ShiftDivide-PROGMEM 76374ms 1.2729 minutes 58283ms 0.971 minutes(!)
Compatible Mode+Multiply 321876ms 5.36 minutes 232628ms 3.88 minutes
Compatible Mode+Divide 314652ms 5.25 minutes 226404ms 3.77 minutes
Compatible Mode+ShiftDivide 304093ms 5.07 minutes 219866ms 3.66 minutes
----
26 jan 2019 update: New records with caching (buffering)!
Register+ShiftDivide+caching 39435ms 0.65725 minutes 22512ms 0.375 minutes(!) - speed gain: 1.9x/2.5x
Compatible Mode+ShiftDivide+ 142392ms 2.3732 minutes 59284ms 0.988 minutes(!) - speed gain: 2.1x/3.7x
caching
29 jan 2019 update (1): New records by using assembler (ASM)!
ASM+ShiftDivide 37125ms 0.618 minutes(!) 30239ms 0.504 minutes(!) - speed gain: 2.1x/1.9x
ASM+ShiftDivide+caching 23889ms 0.398 minutes(!) 17004ms 0.283 minutes(!) - speed gain: 3.1x/3.4x
29 jan 2019 update (2): New records by using assembler (ASM) + font-table in dynamic memory!
ASM+ShiftDivide 37095ms 0.617 minutes(!) 30209ms 0.503 minutes(!) - speed gain: 2.1x/1.9x
ASM+ShiftDivide+caching 23860ms 0.397 minutes(!) 16974ms 0.282 minutes(!) - speed gain: 3.2x/3.5x
30 jan 2019:
Another gain can be reached by using new define (which is default now), XTM_AVR_SHIFTWISE_DIVIDE_ASM.
At this moment I don't have the time to update the tables above again. Fastest speed is 12756ms =
0.213 minutes = 12.756 seconds to count up to 100000 and display it. To achieve this, use fastest
config settings specified below.
----
FASTEST CONFIG (highest mem usage) AVERAGE CONFIG (fast) SLOWEST CONFIG (very slow compared to all others)
# XTM_AVR_ASM_MODE # XTM_APPLY_CACHED_SEGMENTS # XTM_ARDUINO_COMPATIBLE
# XTM_APPLY_CACHED_SEGMENTS # XTM_SHIFTWISE_DIVIDE # XTM_ARITHMETIC_MULTIPLY
# XTM_NOPROGMEM
# XTM_SHIFTWISE_DIVIDE
# XTM_AVR_SHIFTWISE_DIVIDE_ASM
NOTICE: Compile sizes and memory usage may vary between different versions of the Arduino IDE and library.
*/
/* XTM_ARDUINO_COMPATIBLE: (default = disabled)
-------------------------
By enabling this (uncomment it), forces the xtm1638 class to use Arduino
compatible mode (disables auto detection), which means it performs the
same on any Andruino library supported board/processor.
Enable this when there are (detection) problems or for testing proposal
/debugging. When enabling this for AVR's, drop in performance will be noticeable.
NOTICE: You can improve performance significantly by enabling the define
XTM_APPLY_CACHED_SEGMENTS below.
*/
//#define XTM_ARDUINO_COMPATIBLE
// Used when enabled and creating object without parameters:
#ifdef XTM_ARDUINO_COMPATIBLE
#define XTM_ARD_AUTO_PIN_DATAIO 8
#define XTM_ARD_AUTO_PIN_CLOCK 9
#define XTM_ARD_AUTO_PIN_STROBE 10
#endif
/* XTM_AVR_ASM_MODE: (default = disabled)
-------------------
By enabling this (uncomment it), forces the xtm1638 class to use optimized
assembler instructions to manipulate pins (AVR only). Overall the
fastest method of all to use, however, requires an extra library called
FastGPIO (by Pololu Corporation) and it requires to configure static pin
assignments below (not configurable via constructor).
Reason: The FastGPIO::Pin class provides static functions for manipulating pins.
This class can only be used if the pin number is known at compile time, which
means it does not come from a variable that might change and it does not come
from the result of a complicated calculation.
You can download the FastGPIO library from here:
- https://github.com/pololu/fastgpio-arduino
*/
#define XTM_AVR_ASM_MODE
#ifdef XTM_AVR_ASM_MODE
#define XTM_AVR_ASM_PIN_DATAIO 8
#define XTM_AVR_ASM_PIN_CLOCK 9
#define XTM_AVR_ASM_PIN_STROBE 10
#endif
/* XTM_APPLY_CACHED_SEGMENTS: (default = enabled)
----------------------------
By enabling this (uncommented state), enables the xtm1638 class to use
a 8 byte buffer to cache the display content. Which means it performs
about 1.9x up to 3.7x faster (see also updated PERFORMANCE STATS table on top
of this file).
The class doesn't write to the bus when a char is already send once. This is
a very effective way to avoid unnecessary delays and to unstress the MCU.
Disable this only when almost out of memory, when you want to save some
memory (8 bytes of dynamic memory), your project doesn't need SUPERB
performance or you discovered some bug.
*/
#define XTM_APPLY_CACHED_SEGMENTS
/* XTM_NOPROGMEM: (default = disabled)
----------------
By enabling this (uncomment it), forces the xtm1638 class to use program/
dynamic memory, instead of storage flash memory, it disables the auto
detection feature. Disabling or enabling this feature does not effect or will
suit any performance gain at general speed configurations (ASM_MODE and cache
enabled slightly will). However, if capacity is low on storage memory but not
on dynamic memory, you can decide to enable this option permanently.
*/
//#define XTM_NOPROGMEM
/* XTM_ARITHMETIC_MULTIPLY: (default = disabled)
--------------------------
By enabling this (uncomment it), forces the xtm1638 class to use standard
multiply arithmetic operations, it disables the "XTM_SHIFTWISE_DIVIDE" option
(see below). Enable this when there are performance/compatibility problems
or for testing proposal/debugging only.
Enabling this is most of the time an overall PERFORMANCE DROP.
*/
//#define XTM_ARITHMETIC_MULTIPLY
/* XTM_SHIFTWISE_DIVIDE: (default = enabled)
XTM_AVR_SHIFTWISE_DIVIDE_ASM: (default = enabled)
-------------------------------
By disabling this (comment it), forces the xtm1638 class to use standard
multiply or divide arithmetic operations, it can be overridden by the previous
listed "XTM_ARITHMETIC_MULTIPLY" option. Disable this when there are
performance/compatibility problems or for testing proposal/debugging only.
Disabling this is most of the time an overall PERFORMANCE DROP.
To make it perform a little faster, you can decide to enable the assembler
version of this (AVR only) by uncomment the XTM_AVR_SHIFTWISE_DIVIDE_ASM
option below.
*/
#define XTM_SHIFTWISE_DIVIDE
#define XTM_AVR_SHIFTWISE_DIVIDE_ASM
/* DEFINE A PORT TO USE (NOT REQUIRED WHEN COMPATIBLE MODE OR ASM MODE):
------------------------------------------------------------------------
NOTE: All three pins used must be bits on the same PORT
register (ex. PORTB).
------------------------------------------------------------------------
PORTB (XTM_PORTB) PORTD (XTM_PORTD) PORTC (XTM_PORTC)
PB0 D8 PD0 D0/RX PC0 A0
PB1 D9 PD1 D1/TX PC1 A1
PB2 D10 PD2 D2 PC2 A2
PB3 D11/MOSI PD3 D3 PC3 A3
PB4 D12/MISO PD4 D4 PC4 A4
PB5 D13/SCK PD5 D5 PC5 A5
PD6 D6
PD7 D7
Just uncomment only one port option:
*/
#define XTM_PORT XTM_PORTB
//#define XTM_PORT XTM_PORTC
//#define XTM_PORT XTM_PORTD
// Used when creating object without parameters:
#define XTM_REG_DEF_PIN_DATAIO PB0
#define XTM_REG_DEF_PIN_CLOCK PB1
#define XTM_REG_DEF_PIN_STROBE PB2
/* SOME DEFINES FOR YOU CONVENIENCE:
-----------------------------------
Disable, enable or add what you like
*/
#define PB4 4 //D12
#define PB3 3 //D11
#define PB2 2 //D10
#define PD5 5 //D5
#define PD4 4 //D4
#define PD3 3 //D3