Debugging today, there are two problems: one is that the user wants to display a value that contains positive or negative values, the first digit is only used to display the minus sign, and the other is the need to convert the received two-dimensional matrix into a thermal map.
is the C language problem, it is not swim. The first direct Baidu "use of sprintf function". In fact, as long as the "%" after the%f directly add a space, the problem solved.
The relevant content is also posted here:
the specifications for the sprintf format are shown below. The section in [] is optional.
%[Specifies the parameter [identifier] [width] [. precision] Indicator
If you want to output '% ' itself, use ' percent ' processing.
1. Handle the character orientation. The minus sign is treated from the back forward.
2. Fill in the blanks. 0 words means blank 0, space is the default value, indicating that the space is placed.
3. The total width of the characters. To the minimum width.
4. Accuracy. Refers to the number of floating-point digits after the decimal point.
The other is to display the two-dimensional matrix into a heat force diagram. The first is implemented using the IF else structure. Later thought, this way of realization is really inefficient, with nios run exhausted it. So a change of mind, the idea of using a mapping table to achieve the highest efficiency. A 256-color array of size 256 is created, and the color information is written in advance. The data of the two-dimensional matrix is assigned to itself by taking the value of the 256-color array as the address. The transformation of the two-dimensional matrix can be accomplished by polling it again. The rest of the time Nios will be able to concentrate on the display of things.
NIOS II encountered in the C problem