The day before yesterday when playing OLED want to finish always want to make a thing, is simple single-chip computer game. Because the memory of STM32 and nRF51822 is sufficient, the image is displayed using the cached array method (I don't know what the term is, anyway, it's a two-dimensional array of 128x64 in memory, which refreshes the entire array on the screen when the display is updated). And the two OLED is the serial port (there is a 128x32 OLED, the same serial port, even drive timing and drive functions are the same, two are too small, but also so expensive ... ), four IO ports can be driven (two or the power of VCC and GND), so unlike the previous mini 12864 screen, it is 8-bit with the port, with read and write function, and this serial port can only write, can not read (that Mini12864 is 5V, I try not to add the circuit with STM32 did not drive success, may be my level is not enough, and a total of more than 10 pins, the full conversion circuit is too complex, and the STM32 5V compatibility at that time I do not know, has been put, not in use STM32 tried, in order to use 12864 simple point, also for the completion of the set, Bought both 3.3V), so opening up a cache array can solve the problem of reading the content of the screen. (In the future, you can think of three kinds of 12864 photos to fill it up)
But at the beginning of the program, there was a problem, that is, the definition of two-dimensional array and reference problems. Now solved, Gu summarized as follows (only I know and just solved).
1: Two-dimensional array when the function is defined, it is defined to the column, where the number of columns is consistent with the number of column vectors of the two-dimensional array to be passed. Such as:
Define a two-dimensional array:
unsigned char t_image[4][6]={//is a graphic of a Russian block of four-directional transformations of a graph
{0,1,0,1,1,1},
{1,0,1,1,1,0},
{1,1,1,0,1,0},
{0,1,1,1,0,1}};
2: Then define a function, this function can call the above two-dimensional array, but not limited to the above one, is defined as: void Position_change (struct Position pos,unsigned char ch[][6]), note the definition of an array of , which is defined to the column vector, and the subscript value is equivalent to the column vector subscript of the array to be referenced, and the row vector subscript does not need to be written (so it is best to unify the values of the rows and columns when the two-dimensional array is defined above). When used, a defined two-dimensional array can be passed directly, as called in Main: Position_change (pos,t_image); You can do it.
3: If another function is called in this defined function draw_position, the function is to use the function passed by ch[][6], when defining this function, as in the above function, defined to the column vector: void draw_position (unsigned Char ch[][6]), and then Draw_position (CH) when it is called in the above function, that is, the two-dimensional array variable as the transfer function only need to write the name in front of the square brackets, do not need to write square brackets, and do not need to be accurate to the column vector, The same function as the one above is called in the main function. That is, the whole is written as:
void Position_change (struct Position pos,unsigned char ch[][6])
{draw_position (CH);
}
4: If there is a for loop for passing a two-dimensional array in the function, you just need to manipulate the two-dimensional array in the definition:
for (i=0;i<4;i++)
for (n=0;n<6;n++)
if (ch[i][n]==0) ...//ch is the name of the parameter variable when it is defined, and the definition of why it should be written.
else ...
Well, the basic is finished. In fact, this is very simple, but when the study did not feel this important, simple and past.
Later to write a point to the application of nRF51822 experience, want to start from the beginning of the box (the amount, used for a long time, skip it, from how to connect the computer settings kile5 and SWD download start), but do not know people allow it ...
This article level is limited, the content many words because the knowledge question is not rigorous or is very outrageous, but mainly as the record function, can understand is good, hoped later oneself and passes the great God to criticize and the guidance to the necessary mistake, does not ridicule to the ridiculous mistake, pointed out I will correct.
nRF51800 Bluetooth learning process record 2: About two-dimensional array practice