forked from starfactorypixel/PixelCANLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpix_utils.cpp
More file actions
29 lines (25 loc) · 818 Bytes
/
Copy pathpix_utils.cpp
File metadata and controls
29 lines (25 loc) · 818 Bytes
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
#include "pix_utils.h"
/*******************************************************************************************\
*
* Reverse array with temp variable. XOR-method is about 2 times slower.
*
\*******************************************************************************************/
void reverse_array(uint8_t *array, uint8_t array_size)
{
uint8_t temp = 0;
uint8_t i = 0;
uint8_t j = array_size - 1;
while (i < j)
{
// swap with temporary variable (9 ms with very big array)
temp = array[i];
array[i] = array[j];
array[j] = temp;
// swap with XOR (15-16 ms with very big array)
//array[i] = array[i] ^ array[j];
//array[j] = array[i] ^ array[j];
//array[i] = array[i] ^ array[j];
i++;
j--;
}
}