基于stm32f4的三维旋转显示平台
Position;
_iq yPosition;
_iq zPosition;
};
//after you get the intersection points in 3d coordinate, you need to remap it into 2d coordinate on the very electrical plane,
//and the conversion is quite simple Coordinate_2D.yPosition = Coordinate_3D.zPosition; Coordinate_2D.xPosition = sqrt(xPosition^2+yPosition^2)
struct Coordinate_2D
{
char xPosition;
char yPosition;
};
struct Line
{
struct Coordinate_3D beginPoint;
struct Coordinate_3D endPoint;
unsigned char color;
};
//frame structure to store the visible points in one electrical frame
//need to be discussed
//here's the prototype of the Frame structure, and basically the frame struture should contain the visible points,
//and the zero points. As we have enclosed the number of zero points after each visible points in their own data structure,
//only the number of zero points at the beginning of the whole frame should be enclosed in the frame struture
struct Frame
{
int zerosBefore;
PointQueue_t visiblePointQueue;
};
//we need a union structure like color plane with bit fields to store the color imformation of every four FPGAs in one data segment
//actually, it's a kind of frustrateing thing that we had to rebind the data into such an odd form.
union ColorPalette
{
struct
{
unsigned char color1 : 4;
unsigned char color2 : 4;
unsigned char color3 : 4;
unsigned char color3 : 4;
}distributedColor;
unsigned short unionColor;
};
//and now we need a complete point structure to sotre all the imformation above
//here we add a weight field = yPosition*96 + xPosition, which will facilitate
//our sort and calculation of the zero points number between each visible point
//it's important to understand that, 4 corresponding points on the LED panel
//will share one visiblepoint data structure.(一块stm32负责4块16*16的LED,每块对应的点的4位颜色信息,拼成16位的数据段)
struct VisiblePoint
{
struct Coordinate_2D coord;
union Colorplane ColorPalette;
int weight;
int zerosAfter;
};
//as now you can see, we need some thing to store the visible points array
typedef struct QueueNode
{
struct VisiblePoint pointData;
struct QueueNode * nextNode;
}QueueNode_t, *QueueNode_ptr;
typedef struct
{
QueueNode_ptr front;
QueueNode_ptr rear;
}PointQueue_t;
//finally, we will have 16*16 words(16 bits)to write into the fifo after each electrial frame sync cmd.
//it may hard for us to decide the frame structure now, let's see how will the work flow of the algorithm be.
//firstly, the overall function will be like this
void Real3DExt(struct Line inputLines[], int lineNumber, struct Frame outputFrames[])
//then we need some real implementation function to calculate the intersection points
//with 0 = no intersection points, 1 = only have one intersection points, 2 = the input line coincides the given electrical plane
//2 need to be treated as an exception
//the range of the degree is 0-359
//it's important to mention that each intersection point we calculate, we need to
//remap its coordinate from a 32*32 field to x,y = 0-15, as each stm32 only have a 32*32
//effective field(those intersection points out of this range belong to other stm32), which can be decided by its address
int InterCal(struct Line inputLine, struct VisiblePoint * outputPoint, int degree)
//so we will need something like this in the Real3DExt function:
for (int j = 0; j < 360; j++)
{
for(int i = 0; i < lineNumber; i++ )
InterCal(struct Line inputLine, struct VisiblePoint outputPoint, int degree);
......
}
/******************************************/
//simple float format version of InterCal
/******************************************/
//calculate
- 从入门到开发,STM32F407单片机全中文教程(06-04)
- STM32F407单片机使用攻略:中文手册、实战问答20篇(06-04)
- STM32F4入手调试USART,ADC-DMA(12-02)
- 接触STM32F407芯片的总结(12-01)
- 使用STM32F4XX自带数学库“arm_math.h“(11-27)
- STM32F4入门前的热身之一:认识stm32F4 Cortex-M4(11-27)