README.md 2.69 KB
Newer Older
Arnaud Blanchard's avatar
Arnaud Blanchard committed
1
2
3
BLC core
========

Arnaud Blanchard's avatar
Arnaud Blanchard committed
4
5
6
- Copyright : [ETIS](http://www.etis.ensea.fr/neurocyber) - ENSEA, University of Cergy-Pontoise, CNRS (2011-2016)
- Author    : [Arnaud Blanchard](http://arnaudblanchard.thoughtsheet.com)
- Licence   : [CeCILL v2.1](http://www.cecill.info/licences/Licence_CeCILL_V2-en.html)
Arnaud Blanchard's avatar
Arnaud Blanchard committed
7

Arnaud Blanchard's avatar
Arnaud Blanchard committed
8
Core functions used by almost all the projects of [BLAAR](https://framagit.org/blaar/blaar/wikis/home)
Arnaud Blanchard's avatar
Arnaud Blanchard committed
9

Arnaud Blanchard's avatar
Arnaud Blanchard committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Core of Basic Libraries for C/C++
---------------------------------
It is composed of five main files (need a POSIX system), for Linux and OSX.

- **blc_text** manage ASCII terminals (colors, cursor, sizes)
- **blc_tools** macros and functions to simplify coding and memory management
- **blc_mem** a memory structure (data pointer and size) essentially to manage dynamic memory buffers
- **blc_array** a structure to manage n-dimensional arrays. It also manage type and format of the data
- **blc_realtime** few helpers to use time, POSIX semaphore and pthreads

[Standard blaar](https://framagit.org/blaar/blaar/wikis/home) automatically install it.

However, independently of blaar, you can [manually build the library](Install)

Exemple of text graphs
======================

This is the output of **blc_core/t_array** see the [code]( https://framagit.org/blaar/blc_core/blob/master/t_array/main.cpp) and the [cmake config file](https://framagit.org/blaar/blc_core/blob/master/t_array/CMakeLists.txt)

### Manipulating **blc_array** vector

![t_array_1](/uploads/70f0b7d3b97b05da7780be0364fecbc5/t_array_1.png)

You can modify the code to dynamically refresh the graph with something like:

```c++
...
//We display 100 times the graph with the sinusoid shifted each time
for(shift =0;  shift <100; shift ++){
   // We set a sinusoid in the vector (converting [-1f, 1f] -> [0, 255]) and we  shift it
   for(i=0; i!=vector.size; i++) vector.uchars[i]=128+127*sinf(i/2.f+ shift);
   //If it is not the first time we erase the previous graph by putting back (ANSI escape code) the cursor 16 lines (height of the graph) up. 'sprint' stand for fprint on stderr
   if (shift != 0) blc_eprint_cursor_up(16); //blc_text.h function
   /*We graph the vector, with title "vector test", the height of 16 chars, the limit max 256 and limit min 0.
   Text on abscissa "position" and text on ordinate "intensity"*/
   vector.fprint_graph_uchars(stderr, "Vector test", 16, 256, 0, "position", "intensity");
   //We stop 100ms to let time to the user to see the graph.
   usleep(100000);
}
...
```
Which produces :
![blc_core sinusoid video](http://www.etis.ensea.fr/neurocyber/blaar/videos/blc_core_sinusoid.mp4)

### Manipulating **blc_array** 2D matrix

![t_array_2](/uploads/fbdcda2237070183dcdc6ef813b1fb1c/t_array_2.png)

These displays could be dynamical as well
Arnaud Blanchard's avatar
Arnaud Blanchard committed
59
60