libpruio  0.2
Input/Output driver for digital/analog lines on Beagleboard hardware
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
1.bas
Go to the documentation of this file.
1 /'* \file 1.bas
2 \brief Example: minimal code for ADC input.
3 
4 This file contains an short and simple example for text output of the
5 analog input lines. It's designed for the description pages and shows
6 the basic usage of libpruio with a minimum of source code, translatable
7 between FreeBASIC and C.
8 
9 Licence: GPLv3
10 
11 Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net
12 
13 
14 Compile by: `fbc -w all 1.bas`
15 
16 '/
17 
18 
19 '#INCLUDE ONCE "../pruio/pruio.bas" ' include source
20 #INCLUDE ONCE "../pruio/pruio.bi" ' include header
21 VAR io = NEW PruIo() '*< create new driver UDT
22 
23 IF io->config() THEN ' upload (default) settings, start IO mode
24  PRINT"config failed (" & *io->Errr & ")"
25 ELSE
26 '' now current ADC samples are available for AIN0 to AIN7 in array Adc->Value[]
27 
28  FOR n AS LONG = 1 TO 13 '' print some lines
29  FOR i AS LONG = 1 TO 8 '' all steps
30  PRINT " " & HEX(io->Adc->Value[i], 4); ''output one channel in hex
31  NEXT
32  PRINT '' next line
33  NEXT
34 END IF
35 
36 '' we're done
37 
38 DELETE io ' destroy driver UDT
39 
40 '' help Doxygen to dokument the main code
41 '&/** The main function. */
42 '&int main() {PruIo::PruIo(); PruIo::config(); PruIo::~PruIo();}
43