Browse Source

ecs1030: move example and fix doc

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
Brendan Le Foll 10 years ago
parent
commit
b347f47406
3 changed files with 55 additions and 48 deletions
  1. 1
    1
      examples/CMakeLists.txt
  2. 0
    0
      examples/ecs1030.cxx
  3. 54
    47
      src/ecs1030/ecs1030.h

+ 1
- 1
examples/CMakeLists.txt View File

28
 add_executable (nrf8001-helloworld-example nrf8001_helloworld.cxx)
28
 add_executable (nrf8001-helloworld-example nrf8001_helloworld.cxx)
29
 add_executable (lpd8806-example lpd8806-example.cxx)
29
 add_executable (lpd8806-example lpd8806-example.cxx)
30
 add_executable (mlx90614-example mlx90614-example.cxx)
30
 add_executable (mlx90614-example mlx90614-example.cxx)
31
-add_executable (ecs1030-example ecs1030-example.cxx)
31
+add_executable (ecs1030-example ecs1030.cxx)
32
 add_executable (mq2-example mq2-example.cxx)
32
 add_executable (mq2-example mq2-example.cxx)
33
 add_executable (mq3-example mq3-example.cxx)
33
 add_executable (mq3-example mq3-example.cxx)
34
 add_executable (mq5-example mq5-example.cxx)
34
 add_executable (mq5-example mq5-example.cxx)

examples/ecs1030-example.cxx → examples/ecs1030.cxx View File


+ 54
- 47
src/ecs1030/ecs1030.h View File

28
 #include <mraa/aio.h>
28
 #include <mraa/aio.h>
29
 #include <mraa/gpio.h>
29
 #include <mraa/gpio.h>
30
 
30
 
31
+namespace upm {
32
+
31
 #define NUMBER_OF_SAMPLES  500
33
 #define NUMBER_OF_SAMPLES  500
32
 #define ADC_RESOLUTION     1024
34
 #define ADC_RESOLUTION     1024
33
 #define SUPPLYVOLTAGE      5100
35
 #define SUPPLYVOLTAGE      5100
39
 #define TRUE               HIGH
41
 #define TRUE               HIGH
40
 #define FALSE              LOW
42
 #define FALSE              LOW
41
 
43
 
42
-namespace upm {
43
-    class ECS1030 {
44
-        public:
45
-            static const uint8_t DELAY_MS  = 20000 / NUMBER_OF_SAMPLES; /* 1/50Hz is 20ms period */
46
-            static const uint8_t VOLT_M    = 5.1 / 1023;
47
-            static const uint8_t R_LOAD    = 2000.0 / CURRENT_RATIO;
44
+/**
45
+ * @brief C++ API for ECS1030 (electricity sensor)
46
+ *
47
+ * @snippet ecs1030.cxx Interesting
48
+ */
49
+
50
+class ECS1030 {
51
+    public:
52
+        static const uint8_t DELAY_MS  = 20000 / NUMBER_OF_SAMPLES; /* 1/50Hz is 20ms period */
53
+        static const uint8_t VOLT_M    = 5.1 / 1023;
54
+        static const uint8_t R_LOAD    = 2000.0 / CURRENT_RATIO;
48
 
55
 
49
-            /**
50
-             * Instanciates a ECS1030 (current sensor) object
51
-             *
52
-             * @param pinNumber number of the data pin
53
-             */
54
-            ECS1030 (uint8_t pinNumber);
56
+        /**
57
+         * Instanciates a ECS1030 (current sensor) object
58
+         *
59
+         * @param pinNumber number of the data pin
60
+         */
61
+        ECS1030 (uint8_t pinNumber);
55
 
62
 
56
-            /**
57
-             * ECS1030 object destructor, basicaly it close the GPIO.
58
-             */
59
-            ~ECS1030 ();
63
+        /**
64
+         * ECS1030 object destructor, basicaly it close the GPIO.
65
+         */
66
+        ~ECS1030 ();
60
 
67
 
61
-            /**
62
-             * Return currency data for the sampled period
63
-             */
64
-            double getCurrency_A ();
68
+        /**
69
+         * Return currency data for the sampled period
70
+         */
71
+        double getCurrency_A ();
65
 
72
 
66
-            /**
67
-             * Return power data for the sampled period
68
-             */
69
-            double getPower_A ();
73
+        /**
74
+         * Return power data for the sampled period
75
+         */
76
+        double getPower_A ();
70
 
77
 
71
-            /**
72
-             * Return currency data for the sampled period
73
-             */
74
-            double getCurrency_B ();
78
+        /**
79
+         * Return currency data for the sampled period
80
+         */
81
+        double getCurrency_B ();
75
 
82
 
76
-            /**
77
-             * Return power data for the sampled period
78
-             */
79
-            double getPower_B ();
83
+        /**
84
+         * Return power data for the sampled period
85
+         */
86
+        double getPower_B ();
80
 
87
 
81
-            /**
82
-             * Return name of the component
83
-             */
84
-            std::string name() {
85
-                return m_name;
86
-            }
87
-        private:
88
-            std::string         m_name;
89
-            mraa_aio_context    m_dataPinCtx;
88
+        /**
89
+         * Return name of the component
90
+         */
91
+        std::string name() {
92
+            return m_name;
93
+        }
94
+    private:
95
+        std::string         m_name;
96
+        mraa_aio_context    m_dataPinCtx;
90
 
97
 
91
-            double              m_calibration;
92
-            int                 m_lastSample;
93
-            double              m_lastFilter;
94
-            int                 m_sample;
95
-            double              m_filteredSample;
96
-    };
98
+        double              m_calibration;
99
+        int                 m_lastSample;
100
+        double              m_lastFilter;
101
+        int                 m_sample;
102
+        double              m_filteredSample;
103
+};
97
 }
104
 }