Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Diff: examples/cn0216_example/main.cpp
- Revision:
- 17:b8356808e8ad
- Parent:
- 13:66c8e4ce4ff1
- Child:
- 19:fb92949e59c9
- Child:
- 18:7d35420ff4aa
diff -r b8a49ec95bad -r b8356808e8ad examples/cn0216_example/main.cpp
--- a/examples/cn0216_example/main.cpp Fri Apr 29 17:16:55 2016 +0300
+++ b/examples/cn0216_example/main.cpp Fri Apr 29 17:34:07 2016 +0300
@@ -53,8 +53,8 @@
void flush_serial_buffer(void)
{
- while (pc.readable()) pc.getc();
- return;
+ while (pc.readable()) pc.getc();
+ return;
}
void display_data(uint32_t data, float weight)
@@ -75,7 +75,7 @@
int main()
{
/* Main variables */
- CN0216 cn0216;
+ CN0216 cn0216;
#ifdef SINGLE_CONVERSION
cn0216.init(CAL_WEIGHT);
#elif defined CONTINOUS_CONVERSION
@@ -84,7 +84,7 @@
#error define SINGLE_CONVERSION or CONTINOUS_CONVERSION, but not both
#endif
/* Calibration sequence */
-
+
pc.printf("\r\n Calibrating zero scale. Remove all weights from scale. Press any key to begin ..");
while(!pc.readable());
flush_serial_buffer();
@@ -100,14 +100,14 @@
pc.printf("done ! ");
pc.printf("\r\n Calibration successful ");
- cn0216.calibrate(CN0216::COMPUTE_GRAM_PER_BIT);
+ cn0216.calibrate(CN0216::COMPUTE_UNITS_PER_BIT);
/* Infinite loop */
while (1) {
wait_ms(1000);
{
uint32_t data = cn0216.read_u32();
- float weight = cn0216.compute_weight(data); // Convert ADC data to voltage
+ float weight = cn0216.compute_weight(data); // Convert ADC data to voltage
display_data(data, weight); // Display data thru UART
}
}
CN0357 - Toxic gas measurement
CN0216 - Weight Scale