Commit 42f0ca27 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files
parents 5131f4b7 3c01763d
[submodule "blc_core.wiki"]
path = blc_core.wiki
url = git@framagit.org:blaar/blc_core.wiki.git
INSTALL
=======
You are advised to used standard [blaar install](https://framagit.org/blaar/blaar/wikis/INSTALL) but you are free to make a manual installation
You are advised to used standard [blaar install](https://blaar.org) but you are free to make a manual installation
Manual install with cmake
-------------------------
......@@ -19,7 +19,7 @@ brew install git cmake
You can copy past the following code:
```sh
git clone https://framagit.org/blaar/blc_core.git
git clone https://promethe.u-cergy.fr/blibs/blc_core.git
cd blc_core
mkdir build
cd build
......@@ -28,10 +28,6 @@ make
sudo make install
```
The created library `libblc_core.{so|dylib}` and `libblc_core.a` will be in `/usr/local/lib`. Includes in `/usr/local/include/blc_core` and a cmake config file in `/usr/local/share/blc_core`
You can create a debian package (.deb) with:
make package
Manual install with simple makefiles
====================================
......
Core of Basic Libraries for C/C++
Copyright ETIS — ENSEA, University of Cergy-Pontoise, CNRS (2011 - 2018)
Author: Arnaud Blanchard
This software is a computer program whose purpose is to simulate neural networks and control robots or simulations.
This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security.
The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
This license is fully compatible with the GPL v2
BLC core : Core of Basic Libraries for C/C++
============================================
- 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)
Core functions used by almost all the projects of BLAAR
Core functions used by almost all the projects of [BLAAR](https://framagit.org/blaar/blaar)
It is composed of five main files for Linux and Mac OSX.
It is composed of five main files (need a POSIX system), for Linux and OSX.
- **[blc_text](include/blc_text.h)** manage ASCII terminals (colors, cursor, sizes)
- **[blc_tools](include/blc_tools.h)** macros and functions to simplify coding and memory management
- **[blc_mem](include/blc_mem.h)** a memory structure (data pointer and size) essentially to manage dynamic memory buffers
- **[blc_array](include/blc_array.h)** a structure to manage n-dimensional arrays. It also manage type and format of the data
- **[blc_realtime](include/blc_realtime.h)** few helpers to use time, POSIX semaphore and pthreads
- **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 install](https://framagit.org/blaar/blaar/wikis/install) automatically installs it.
Install
=======
However, independently of blaar, you can [manually build the library](https://framagit.org/blaar/blc_core/blob/master/INSTALL)
This library is installed with any configuration of blaar. However, independently of blaar, you can [manually build the library](INSTALL.md)
Tutorials
=========
Exemple of simple text functions
===============================
```c
#include "blc_core.h"
int main(int argc, char **argv){
int rows_nb, columns_nb;
float values[3]={1.3, 4.2, 5.5};
color_printf(BLC_BLUE, "\nWriting in blue\n\n");
underline_printf('=', "Writing with inlining with '='");
//printing 3 floats of the array values
fprint_tsv_floats(stderr, values, 3);
//Getting the size in characters of the current terminal
blc_terminal_get_size(&columns_nb, &rows_nb);
printf("\nSize of the terminal %dx%d\n", columns_nb, rows_nb);
//Writing size in human readable format
fprint_human_size(stdout, 1000456670); //1Kb = 1024b
printf("\n");
return EXIT_SUCCESS;
}
```
Exemple of text graphs
======================
[image not found](t_array_1)
This is the output of **blc_core/t_array** see the [code](t_array/main.cpp) and the [cmake config file](t_array/CMakeLists.txt)
### Manipulating **blc_array** vector
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
==============================
[image not found](t_array_2)
These displays could be dynamical as well
[More details and examples](https://framagit.org/blaar/blc_core/wikis/home)
......@@ -53,6 +53,7 @@ Blc core is composed of these five modules (one file each):
///Number of gradual colors we can use.
#define BLC_BAR_COLORS_NB 12
///Bright color
#define BLC_BRIGHT 0x8
///Code to be used in text coloring function (color_id).
......@@ -78,12 +79,19 @@ enum BLC_COLORS{
///eprint for info print (stderr) to oppose standard cursor (stdout) usually not used
#define blc_eprint_cursor_position(row, column) eprintf_escape_command("%d;%dH", row, column);
///eprint for info print (stderr) to oppose standard cursor (stdout) usually not used
#define blc_eprint_cursor_up(rows_nb) eprintf_escape_command("%dA", rows_nb);
///eprint for info print (stderr) to oppose standard cursor (stdout) usually not used
#define blc_eprint_cursor_down(rows_nb) eprintf_escape_command("%dB", rows_nb);
///eprint for info print (stderr) to oppose standard cursor (stdout) usually not used
#define blc_eprint_cursor_up_left(rows_nb) eprintf_escape_command("%dF", rows_nb);
///eprint for info print (stderr) to oppose standard cursor (stdout) usually not used
#define blc_eprint_cursor_down_right(rows_nb) eprintf_escape_command("%dE", rows_nb);
///eprint for info print (stderr) to oppose standard cursor (stdout) usually not used
#define blc_eprint_del_end_line() eprintf_escape_command("0K");
///eprint for info print (stderr) to oppose standard cursor (stdout) usually not used
#define blc_eprint_del_end_screen() eprintf_escape_command("0J");
///eprint for info print (stderr) to oppose standard cursor (stdout) usually not used
#define blc_fprint_del_end_line(file) fprintf_escape_command(file, "0K");
///Shortcut to escape directly on stdout
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment