libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
rb_oszi.bas File Reference

Example: fetch ADC samples in a ring buffer and draw graf. More...

#include "BBB/pruio.bi"
#include "fbgfx.bi"
Include dependency graph for rb_oszi.bas:

Go to the source code of this file.

Macros

#define DRAW_GRAF()
 Macro to draw a graph from the valid half of the ring buffer. More...
 

Functions

int main ()
 

Variables

VAR S_W = 0
 The screen width.
 
VAR S_H = 0
 The srceen hight.
 
VAR BPP = 0
 The bits per plain number.
 
VAR full = fb.GFX_FULLSCREEN
 Fullscreen or windowed mode.
 
VAR p = INSTR(COMMAND, "x")
 The position of the 'x' character (if any). More...
 
VAR w = VALINT(COMMAND)
 The required window width.
 
VAR h = VALINT(MID(COMMAND, p + 1))
 The required window hight.
 
UInt32 col [...]
 The colors for the lines (= channels). More...
 
VAR io = NEW PruIo()
 Create a PruIo structure, wakeup subsystems.
 
VAR samp = S_W SHL 1
 The number of samples to fetch (ring buffer size).
 
VAR scale = S_H / 65520
 The scaling factor.
 
VAR half = .Adc->Samples SHR 1
 half size of the ring buffer
 

Detailed Description

Example: fetch ADC samples in a ring buffer and draw graf.

This file contains an example on how to use the ring buffer mode of libpruio. A fixed step mask of AIN-4 and AIN-7 get sampled and drawn as a line graf to a grafic window. Unlike IO mode, the step mask cannot get changed in RB mode at run-time. Find a functional description in section rb_oszi.

Licence: GPLv3, Copyright 2014-2023 by Thomas{ doT ]Freiherr[ At ]gmx[ DoT }net

Compile by: fbc -w all rb_oszi.bas

Since
0.2

Definition in file rb_oszi.bas.

Macro Definition Documentation

◆ DRAW_GRAF

#define DRAW_GRAF ( )
Value:
/* (multi line FreeBASIC #MACRO)
LINE (0, 0) - (S_W, S_H), RGB(250, 250, 250), BF
FOR c AS INTEGER = 0 TO .Adc->ChAz - 1
VAR i = c + .Adc->ChAz
LINE (0, S_H - CUINT(p[c] * scale)) - _
(1, S_H - CUINT(p[i] * scale)), col(c)
FOR x AS INTEGER = 2 TO S_W
i += .Adc->ChAz
LINE - (x, S_H - CUINT(p[i] * scale)), col(c)
NEXT
NEXT
#ENDMACRO */

Macro to draw a graph from the valid half of the ring buffer.

Definition at line 58 of file rb_oszi.bas.

Function Documentation

◆ main()

int main ( )

The main function.

Definition at line 97 of file rb_oszi.bas.

Here is the call graph for this function:

Variable Documentation

◆ col

UInt32 col[...]
Initial value:
= {
, RGBA(255, 0, 0, 255)
, RGBA( 0, 255, 0, 255)
, RGBA( 0, 0, 255, 255)
, RGBA(255, 255, 0, 255)
, RGBA(255, 0, 255, 255)
, RGBA( 0, 255, 255, 255)
, RGBA(127, 127, 127, 255)
}

The colors for the lines (= channels).

Definition at line 46 of file rb_oszi.bas.

◆ p

VAR p = INSTR(COMMAND, "x")

The position of the 'x' character (if any).

local pointer to the samples

Definition at line 28 of file rb_oszi.bas.