PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Simple Libraries
Convert
libabvolts
libabvolts.c
1
/*
2
* @file libabvolts.c
3
*
4
* @author Andy Lindsay
5
*
6
* @copyright
7
* Copyright (C) Parallax, Inc. 2014. All Rights MIT Licensed.
8
*
9
* @brief Project and test harness for the abvolts library.
10
*/
11
12
13
#include "simpletools.h"
// Include simpletools
14
#include "abvolts.h"
// Include adcDCpropab
15
16
int
main
()
// Main function
17
{
18
pause(1000);
// Wait 1 s for Terminal app
19
ad_init(21, 20, 19, 18);
// CS=21, SCL=20, DO=19, DI=18
20
da_init(26, 27);
// P26 -> CH0, P27 -> CH1
21
22
da_setupScale();
23
da_useScale();
24
25
float
dacvolts = 0.0;
26
int
dacval = 0;
27
28
int
i = 0;
// Index variable
29
30
while
(1)
// Loop repeats indefinitely
31
{
32
dacvolts = dacvolts + 0.025;
33
if
(dacvolts > 3.3) dacvolts = 0.0;
34
da_volts(0, dacvolts);
35
da_volts(1, dacvolts/2);
36
37
if
(i == 4)
// After index = 3
38
{
39
i = 0;
// Reset to zero
40
print(
"%c"
, HOME);
// Cursor home
41
}
42
print(
"adc[%d] = %d%c\n"
, i,
// Display raw ADC
43
ad_in(i), CLREOL);
44
print(
"volts[%d] = %1.2f%c\n\n"
,
// Display volts
45
i, ad_volts(i), CLREOL);
46
i++;
// Add 1 to index
47
pause(100);
// Wait 1/10 s
48
}
49
}
50
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Sat Aug 27 2016 00:58:09 for PropWare by
1.8.12