Skip to content

Commit 3db78ad

Browse files
committed
Bring current with other live branches
1 parent 8d7fa53 commit 3db78ad

File tree

747 files changed

+79663
-6666
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

747 files changed

+79663
-6666
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
Test libdac2ch.c
3+
4+
Test the dac2ch library.
5+
*/
6+
7+
#include "simpletools.h"
8+
#include "dac2ch.h"
9+
10+
dac2ch *dacA;
11+
dac2ch *dacB;
12+
13+
int main()
14+
{
15+
// Start two DAC processes, one 8-bit and one 10 bit
16+
dacA = dac2ch_start(8);
17+
dacB = dac2ch_start(10);
18+
19+
// Set P26 and P27 to 1.65 V, and P5 and P6 to 0.825 V.
20+
dac2ch_set(dacA, 26, 0, 128);
21+
dac2ch_set(dacB, 27, 0, 512);
22+
dac2ch_set(dacA, 5, 1, 64);
23+
dac2ch_set(dacB, 6, 1, 256);
24+
pause(3000);
25+
26+
// Stop signals on P26 and P5 -> inputs
27+
dac2ch_set(dacA, 26, 0, -1);
28+
dac2ch_set(dacA, 5, 1, -1);
29+
pause(3000);
30+
31+
// Switch outputs that were on P27 and P6 to P26 and P5.
32+
dac2ch_set(dacB, 26, 0, 768);
33+
dac2ch_set(dacB, 5, 1, 192);
34+
pause(3000);
35+
36+
// End the dac2ch processes
37+
dac2ch_stop(dacA);
38+
dac2ch_stop(dacB);
39+
}
40+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Test libdac2ch.c
2+
>compiler=C
3+
>memtype=cmm main ram compact
4+
>optimize=-Os
5+
>-m32bit-doubles
6+
>-fno-exceptions
7+
>defs::-std=c99
8+
>-lm
9+
>BOARD::ACTIVITYBOARD
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Test libpwm2ch.c
3+
4+
Test the pwm2ch library.
5+
*/
6+
7+
#include "simpletools.h"
8+
#include "pwm2ch.h"
9+
10+
pwm2ch *pwmA;
11+
pwm2ch *pwmB;
12+
13+
int main()
14+
{
15+
// Start PWM process A. Frequency = 1 kHz -> pulse period = 1 ms.
16+
// Start PWM process B. Frequency = 1.2 kHz -> pulse period = 0.8333.. ms.
17+
pwmA = pwm2ch_start(1000);
18+
pwmB = pwm2ch_start(1200);
19+
20+
// Set all four available channels.
21+
pwm2ch_set(pwmA, 3, 0, 300);
22+
pwm2ch_set(pwmA, 4, 1, 600);
23+
pwm2ch_set(pwmB, 5, 0, 100);
24+
pwm2ch_set(pwmB, 6, 1, 200);
25+
pause(3000);
26+
27+
// Stop signals on P3 and P5 -> inputs
28+
pwm2ch_set(pwmA, 3, 0, -1);
29+
pwm2ch_set(pwmB, 5, 0, -1);
30+
pause(1000);
31+
32+
// Re-start channels with different duty cycles.
33+
pwm2ch_set(pwmA, 3, 0, 100);
34+
pwm2ch_set(pwmB, 5, 0, 50);
35+
pause(1000);
36+
37+
// Turn off channels again
38+
pwm2ch_set(pwmA, 3, 0, -1);
39+
pwm2ch_set(pwmB, 5, 0, -1);
40+
pause(1000);
41+
42+
// Move signals from other channels to P3 and P5
43+
pwm2ch_set(pwmA, 3, 1, 600);
44+
pwm2ch_set(pwmB, 5, 1, 600);
45+
pause(1000);
46+
47+
// Move channels that were disabled to the ones just
48+
// vacated.
49+
pwm2ch_set(pwmA, 4, 0, 300);
50+
pwm2ch_set(pwmB, 6, 0, 300);
51+
pause(1000);
52+
53+
// Set A process channels low.
54+
// Set B process channels to inputs.
55+
pwm2ch_set(pwmA, 3, 0, 0);
56+
pwm2ch_set(pwmA, 4, 1, 0);
57+
pwm2ch_set(pwmB, 5, 0, -1);
58+
pwm2ch_set(pwmB, 6, 1, -1);
59+
pause(1000);
60+
61+
// Restart A channels in B channels that were just vacated.
62+
pwm2ch_set(pwmA, 5, 0, 600);
63+
pwm2ch_set(pwmA, 6, 1, 600);
64+
pause(3000);
65+
66+
// Stop again
67+
pwm2ch_set(pwmA, 5, 0, -1);
68+
pwm2ch_set(pwmA, 6, 1, -1);
69+
70+
// End the pwm2ch process
71+
pwm2ch_stop(pwmA);
72+
pwm2ch_stop(pwmB);
73+
}
74+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Test libpwm2ch.c
2+
>compiler=C
3+
>memtype=cmm main ram compact
4+
>optimize=-Os
5+
>-m32bit-doubles
6+
>-fno-exceptions
7+
>defs::-std=c99
8+
>-lm
9+
>BOARD::ACTIVITYBOARD
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/**
2+
* @file bme680_adjust_sensor_settings.c
3+
*
4+
* @author Matthew Matz
5+
*
6+
* @version 0.5
7+
*
8+
* @copyright
9+
* Copyright (C) Parallax, Inc. 2019. All Rights MIT Licensed.
10+
*
11+
* @brief Example demonstrating how to adjust the sensor's settings
12+
* before taking a reading.
13+
*/
14+
15+
16+
17+
#include "simpletools.h" // Include simple tools
18+
#include "bme680.h"
19+
20+
21+
bme680 *mySensor; // Create a new sensor instance
22+
23+
24+
int main() {
25+
26+
// Open the sensor using an SPI interface
27+
// SDO, CLK, SDI, CS
28+
mySensor = bme680_openSPI(20, 21, 22, 23);
29+
30+
31+
32+
// Set the ambient temperature used (in deg C) by the gas sensor's calculations.
33+
// A temperature measurement could be taken and fed back into this setting for increased
34+
// accuracy.
35+
bme680_configure(mySensor, BME680_SETTING_AMB_TEMP, 20);
36+
37+
// Set the temperature of the gas sensor's heating element (in deg C).
38+
bme680_configure(mySensor, BME680_SETTING_HEATER_TEMP, 300);
39+
40+
// Set how long the gas sensor's heating element is turned on
41+
// during a measurement (in milliseconds).
42+
bme680_configure(mySensor, BME680_SETTING_HEATER_DURATION, 120);
43+
44+
// Set the low-pass filter used by the sensor. Higher values reduce jitter
45+
// but decrease accuracy.
46+
// Available settings are: BME680_FILTER_SIZE_1, BME680_FILTER_SIZE_3,
47+
// BME680_FILTER_SIZE_7, BME680_FILTER_SIZE_15, BME680_FILTER_SIZE_31.
48+
bme680_configure(mySensor, BME680_SETTING_FILTER_SIZE, BME680_FILTER_SIZE_15);
49+
50+
// Set the oversample (number of samples taken per measurement)
51+
// for the temperature sensor.
52+
// Available settings are: BME680_OS_1X, BME680_OS_2X, BME680_OS_4X
53+
// BME680_OS_8X, BME680_OS_16X.
54+
bme680_configure(mySensor, BME680_SETTING_TEMP_SAMPLES, BME680_OS_16X);
55+
56+
// Set the oversample (number of samples taken per measurement)
57+
// for the pressure sensor.
58+
// Available settings are: BME680_OS_1X, BME680_OS_2X, BME680_OS_4X
59+
// BME680_OS_8X, BME680_OS_16X.
60+
bme680_configure(mySensor, BME680_SETTING_PRESSURE_SAMPLES, BME680_OS_8X);
61+
62+
// Set the oversample (number of samples taken per measurement)
63+
// for the humidity sensor.
64+
// Available settings are: BME680_OS_1X, BME680_OS_2X, BME680_OS_4X
65+
// BME680_OS_8X, BME680_OS_16X.
66+
bme680_configure(mySensor, BME680_SETTING_HUMIDITY_SAMPLES, BME680_OS_4X);
67+
68+
69+
70+
while(1) {
71+
72+
// Read the sensor
73+
char rslt = bme680_readSensor(mySensor);
74+
75+
// Make sure the reading is available and valid
76+
if (rslt >= 0) {
77+
// Print the last read temaperature in CELSIUS (FAHRENHEIT and KELVIN are also options)
78+
print("Temperature: %.2f deg C\r", bme680_temperature(mySensor, CELSIUS));
79+
80+
// Print the last read pressure in hPa (PASCALS divided by 100), (INHG, MMHG, and PSI are also options)
81+
print("Pressure: %.2f hPa\r", bme680_pressure(mySensor, PASCALS) / 100.0);
82+
83+
// Print an estimate of the altitude, based on the last read pressure
84+
// in METERS, (FEET are also options)
85+
print("Altitude: %.2f m\r", bme680_altitude(mySensor, METERS));
86+
87+
// Print the last read relative humidity
88+
print("Humidity: %.2f%%\r", bme680_humidity(mySensor));
89+
90+
// Print the last read gas sensor resistance value in kOhm (returns Ohms, then divide by 100)
91+
print("Gas Resistance: %.2f kOhms\r\r", bme680_gasResistance(mySensor) / 1000.0);
92+
93+
} else {
94+
print("No reading available\r\r");
95+
}
96+
97+
// Wait 3 seconds before taking another reading.
98+
// Reading the sensor more frequently with the gas
99+
// sensor's heating element ON can cause the
100+
// temperature and humidity readings to be skewed.
101+
pause(3000);
102+
}
103+
}
104+
105+
106+
/**
107+
* TERMS OF USE: MIT License
108+
*
109+
* Permission is hereby granted, free of charge, to any person obtaining a
110+
* copy of this software and associated documentation files (the "Software"),
111+
* to deal in the Software without restriction, including without limitation
112+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
113+
* and/or sell copies of the Software, and to permit persons to whom the
114+
* Software is furnished to do so, subject to the following conditions:
115+
*
116+
* The above copyright notice and this permission notice shall be included in
117+
* all copies or substantial portions of the Software.
118+
*
119+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
120+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
121+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
122+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
123+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
124+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
125+
* DEALINGS IN THE SOFTWARE.
126+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bme680_adjust_sensor_settings.c
2+
>compiler=C
3+
>memtype=cmm main ram compact
4+
>optimize=-Os
5+
>-m32bit-doubles
6+
>-fno-exceptions
7+
>defs::-std=c99
8+
>-lm
9+
>BOARD::ACTIVITYBOARD
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* @file bme680_display_values_using_SPI.c
3+
*
4+
* @author Matthew Matz
5+
*
6+
* @version 0.5
7+
*
8+
* @copyright
9+
* Copyright (C) Parallax, Inc. 2019. All Rights MIT Licensed.
10+
*
11+
* @brief Sensor driver for the Bosch BME680 air quality sensor.
12+
* This library supports i2c and 4-wire SPI connections, reads
13+
* temperature, pressure, relative humidity, and VOC levels, and
14+
* provides limited support for adjusting the sensors settings.
15+
*/
16+
17+
18+
19+
#include "simpletools.h" // Include simple tools
20+
#include "bme680.h"
21+
22+
23+
bme680 *mySensor; // Create a new sensor instance
24+
25+
int main() {
26+
27+
// Open the sensor using an SPI interface
28+
// SDO, CLK, SDI, CS
29+
mySensor = bme680_openSPI(20, 21, 22, 23);
30+
31+
while(1) {
32+
33+
// Read the sensor
34+
char rslt = bme680_readSensor(mySensor);
35+
36+
// Make sure the reading is available and valid
37+
if (rslt >= 0) {
38+
// Print the last read temaperature in CELSIUS (FAHRENHEIT and KELVIN are also options)
39+
print("Temperature: %.2f deg C\r", bme680_temperature(mySensor, CELSIUS));
40+
41+
// Print the last read pressure in hPa (PASCALS divided by 100), (INHG, MMHG, and PSI are also options)
42+
print("Pressure: %.2f hPa\r", bme680_pressure(mySensor, PASCALS) / 100.0);
43+
44+
// Print an estimate of the altitude, based on the last read pressure
45+
// in METERS, (FEET are also options)
46+
print("Altitude: %.2f m\r", bme680_altitude(mySensor, METERS));
47+
48+
// Print the last read relative humidity
49+
print("Humidity: %.2f%%\r", bme680_humidity(mySensor));
50+
51+
// Print the last read gas sensor resistance value in kOhm (returns Ohms, then divide by 100)
52+
print("Gas Resistance: %.2f kOhms\r\r", bme680_gasResistance(mySensor) / 1000.0);
53+
54+
} else {
55+
print("No reading available\r\r");
56+
}
57+
58+
// Wait 3 seconds before taking another reading.
59+
// Reading the sensor more frequently with the gas
60+
// sensor's heating element ON can cause the
61+
// temperature and humidity readings to be skewed.
62+
pause(3000);
63+
}
64+
}
65+
66+
67+
/**
68+
* TERMS OF USE: MIT License
69+
*
70+
* Permission is hereby granted, free of charge, to any person obtaining a
71+
* copy of this software and associated documentation files (the "Software"),
72+
* to deal in the Software without restriction, including without limitation
73+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
74+
* and/or sell copies of the Software, and to permit persons to whom the
75+
* Software is furnished to do so, subject to the following conditions:
76+
*
77+
* The above copyright notice and this permission notice shall be included in
78+
* all copies or substantial portions of the Software.
79+
*
80+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
81+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
82+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
83+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
84+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
85+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
86+
* DEALINGS IN THE SOFTWARE.
87+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bme680_display_values_using_SPI.c
2+
>compiler=C
3+
>memtype=cmm main ram compact
4+
>optimize=-Os
5+
>-m32bit-doubles
6+
>-fno-exceptions
7+
>defs::-std=c99
8+
>-lm
9+
>BOARD::ACTIVITYBOARD

0 commit comments

Comments
 (0)