PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Sensor
Sound Impact
SoundImpactSensor OtherCogFeatures.c
1
/*
2
SoundImpactSensor OtherCogFeatures.c
3
4
Expands on "SoundImpactSensor OtherCog" by demonstrating cog run
5
and end features.
6
7
Connect: SIG to (R = 2.2 k) to P4, 5V to 5V, GND to GND
8
9
http://www.parallax.com/product/29132
10
*/
11
12
#include "
simpletools.h
"
// Include simpletools
13
#include "
soundimpact.h
"
// Include soundimpact
14
15
int
main
()
// Main function
16
{
17
print
(
"Tracks sound impacts and \n"
);
// User prompt
18
print
(
"updates every 3 seconds.\n"
);
19
20
int
*cog =
soundImpact_run
(4);
// Run in other cog
21
22
// Check 10 times, every 3 seconds.
23
for
(
int
s = 0; s < 30; s += 3)
// Count to 30 in steps of 3
24
{
25
int
count
=
soundImpact_getCount
();
// Get impact count
26
print
(
"count = %d\n"
,
count
);
// Display
27
pause
(3000);
// Wait 3 seconds
28
}
29
30
print
(
"Ending sound impact cog.\n"
);
// User info
31
print
(
"Cog is now free for other\n"
);
32
print
(
"process.\n"
);
33
34
soundImpact_end
(cog);
// Stop sound impact cog
35
}
36
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:04 for PropWare by
1.8.17