In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use the embedded C language look-up table method in the project, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
Embedded C practical Project Development skills: a method of displacement Operation on a regular Array Table
Like the table below.
An article with the above title is about traversing the data in the table in the way of displacement, which is very efficient. However, if you want to realize a disordered running light or racing lantern, it is not advisable to think about such an algorithm. It takes a lot of time and brain, so today we will talk about the look-up table method. If you use the look-up table method in the program, no matter how complex the program is. As long as it meets a table, it can be achieved, very simple, just physical work, and then take a look at the following program to operate the above one.
# include # include / / the lines here can be written freely, so there are no restrictions, and you can have any effect you want. Int array[][10] = {0x03,0x00,0x00,0x00,0x00,//第一列 0x00,0x02,0x00,0x00,0x00, 0x0C,0x00,0x00,0x00,0x00,//第二列 0x00,0x04,0x00,0x00,0x00, 0x10,0x00,0x00,0x00,0x00,//第三列 0x00,0x08,0x00,0x00,0x00, 0x60,0x00,0x00,0x00,0x00,//第四列 0x00,0x10,0x00,0x00,0x00, 0x80,0x01,0x00,0x00,0x00,//第五列 0x00,0x20,0x00,0x00,0x00, 0xAA,0x55,0x00,0x00,0xC0,//end 0x00,0x00,0x00,0x00,0x00,};void to_Q112_cmd_designator_LED(int *array){ int i; for(i = 0; i < 10; i++) {printf(" %3d ", *(array+i));} printf("\n"); } void delay_500ms (void) {Sleep (500);} int main (void) {int iJournal j; int tick; int count = 0 While (Array [count] [0]! = 0xAA | | array [count] [1]! = 0x55) / / if the 0th column of the count row of the array equals 0xAA, or the first column of the count row equals 0x55, then exit, otherwise the traversal data {to_Q112_cmd_designator_LED ((int *) (& array [0] [0] + count*10)) is iterated; / / the first element is offset 10 bytes delay_500ms () each time; } return 0;}
Running result:
3 0 0 0 2 0 0 0
12 0 0 0 4 0 0 0
16 0 0 0 8 0 0 0
96 0 0 0 16 0 0 0
128 1 0 0 0 32 0 0 0
Thank you for reading this article carefully. I hope the article "how to use embedded C language lookup table in the project" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.