PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Sensor
libsoundimpact
libsoundimpact.c
1
/*
2
libsoundimpact.c
3
4
Test harness for the sound impact library.
5
6
By Andy Lindsay, Parallax Inc., 3/11/14.
7
8
Copyright (C) Parallax, Inc. 2014. All Rights MIT Licensed.
9
*/
10
11
#include "
simpletools.h
"
// Include simpletools
12
#include "
soundimpact.h
"
// Include soundimpact
13
14
int
main
()
// Main function
15
{
16
print
(
"Tracks sound impacts and \n"
);
// User prompt
17
print
(
"updates every 3 seconds.\n"
);
18
19
int
*cog =
soundImpact_run
(4);
// Run in other cog
20
21
// Check 10 times, every 3 seconds.
22
for
(
int
s = 0; s < 30; s += 3)
// Count to 30 in steps of 3
23
{
24
int
count
=
soundImpact_getCount
();
// Get impact count
25
print
(
"count = %d\n"
,
count
);
// Display
26
pause
(3000);
// Wait 3 seconds
27
}
28
29
print
(
"Ending sound impact cog.\n"
);
// User info
30
print
(
"Cog is now free for other\n"
);
31
print
(
"process.\n"
);
32
33
soundImpact_end
(cog);
// Stop sound impact cog
34
}
35
soundImpact_getCount
int soundImpact_getCount(void)
Get number of impacts since last call to soundImpact_getCount.
Definition:
soundimpact.c:31
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
soundImpact_end
void soundImpact_end(int *processID)
End sound impact tracking process and recovers cog and stack memory for other purposes.
Definition:
soundimpact.c:26
main
int main(void)
Definition:
GraphicsTest.c:20
soundimpact.h
Monitor sound impact occurrences from another cog. IMPORTANT: This library is only for making moni...
count
long count(int pin, long duration)
Count number of low to high transitions an external input applies to an I/O pin over a certain period...
Definition:
count.c:19
soundImpact_run
int * soundImpact_run(int pin)
Runs the sound impact tracking process in another cog.
Definition:
soundimpact.c:19
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17