Browse Source

tm1637: Removing from upm due to possible derivation from lgpl code.

Signed-off-by: John Van Drasek <john.r.van.drasek@intel.com>
John Van Drasek 9 years ago
parent
commit
4a80a216c7

+ 3
- 3
docs/building.md View File

@@ -91,11 +91,11 @@ make _pyupm_i2clcd
91 91
 
92 92
 Sometimes you want to build a small C++ example against an installed library.
93 93
 This is fairly easy if installed system-wide. Just link against the correct
94
-library (in this case libupm-tm1637) and then add /usr/include/upm to the
94
+library (in this case libupm-i2clcd) and then add /usr/include/upm to the
95 95
 loader path:
96 96
 
97 97
 ~~~~~~~~~~~~
98
-g++ test.cxx -lupm_tm1637 -I/usr/include/upm
98
+g++ test.cxx -lupm-i2clcd -I/usr/include/upm
99 99
 ~~~~~~~~~~~~
100 100
 
101 101
 You can also use pkg-config to return the information to you, which is
@@ -103,5 +103,5 @@ considered the correct way if including UPM in a build system like cmake or
103 103
 autotools on linux.
104 104
 
105 105
 ~~~~~~~~~~~
106
-pkg-config --cflags --libs upm-tm1637
106
+pkg-config --cflags --libs upm-i2clcd
107 107
 ~~~~~~~~~~~

+ 0
- 3
examples/c++/CMakeLists.txt View File

@@ -14,7 +14,6 @@ add_executable (jhd1313m1-lcd-example jhd1313m1-lcd.cxx)
14 14
 add_executable (buzzer-sound-example buzzer-sound.cxx)
15 15
 add_executable (my9221-ledbar-example my9221-ledbar.cxx)
16 16
 add_executable (my9221-updown-example my9221-updown.cxx)
17
-add_executable (tm1637-example tm1637.cxx)
18 17
 add_executable (nrf24l01-transmitter-example nrf24l01-transmitter.cxx)
19 18
 add_executable (nrf24l01-receiver-example nrf24l01-receiver.cxx)
20 19
 add_executable (nrf24l01-broadcast-example nrf24l01-broadcast.cxx)
@@ -110,7 +109,6 @@ include_directories (${PROJECT_SOURCE_DIR}/src/grove)
110 109
 include_directories (${PROJECT_SOURCE_DIR}/src/lcd)
111 110
 include_directories (${PROJECT_SOURCE_DIR}/src/buzzer)
112 111
 include_directories (${PROJECT_SOURCE_DIR}/src/my9221)
113
-include_directories (${PROJECT_SOURCE_DIR}/src/tm1637)
114 112
 include_directories (${PROJECT_SOURCE_DIR}/src/nrf24l01)
115 113
 include_directories (${PROJECT_SOURCE_DIR}/src/servo)
116 114
 include_directories (${PROJECT_SOURCE_DIR}/src/hcsr04)
@@ -203,7 +201,6 @@ target_link_libraries (jhd1313m1-lcd-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
203 201
 target_link_libraries (buzzer-sound-example buzzer ${CMAKE_THREAD_LIBS_INIT})
204 202
 target_link_libraries (my9221-ledbar-example my9221 ${CMAKE_THREAD_LIBS_INIT})
205 203
 target_link_libraries (my9221-updown-example my9221 ${CMAKE_THREAD_LIBS_INIT})
206
-target_link_libraries (tm1637-example tm1637 ${CMAKE_THREAD_LIBS_INIT})
207 204
 target_link_libraries (nrf24l01-transmitter-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
208 205
 target_link_libraries (nrf24l01-receiver-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
209 206
 target_link_libraries (nrf24l01-broadcast-example nrf24l01 ${CMAKE_THREAD_LIBS_INIT})

+ 0
- 42
examples/c++/tm1637.cxx View File

@@ -1,42 +0,0 @@
1
-/*
2
- * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3
- * Copyright (c) 2014 Intel Corporation.
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files (the
7
- * "Software"), to deal in the Software without restriction, including
8
- * without limitation the rights to use, copy, modify, merge, publish,
9
- * distribute, sublicense, and/or sell copies of the Software, and to
10
- * permit persons to whom the Software is furnished to do so, subject to
11
- * the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
-
25
-#include <unistd.h>
26
-#include <iostream>
27
-#include "tm1637.h"
28
-
29
-int
30
-main(int argc, char **argv)
31
-{
32
-    //! [Interesting]
33
-    upm::TM1637 *display = new upm::TM1637(8, 9); // di - 8, dcki - 9
34
-    display->write ("1337");
35
-    //! [Interesting]
36
-    
37
-    std::cout << "exiting application" << std::endl;
38
-
39
-    delete display;
40
-
41
-    return 0;
42
-}

+ 0
- 25
examples/python/4digitdisplay.py View File

@@ -1,25 +0,0 @@
1
-# Author: Brendan Le Foll <brendan.le.foll@intel.com>
2
-# Copyright (c) 2014 Intel Corporation.
3
-#
4
-# Permission is hereby granted, free of charge, to any person obtaining
5
-# a copy of this software and associated documentation files (the
6
-# "Software"), to deal in the Software without restriction, including
7
-# without limitation the rights to use, copy, modify, merge, publish,
8
-# distribute, sublicense, and/or sell copies of the Software, and to
9
-# permit persons to whom the Software is furnished to do so, subject to
10
-# the following conditions:
11
-#
12
-# The above copyright notice and this permission notice shall be
13
-# included in all copies or substantial portions of the Software.
14
-#
15
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
-
23
-import pyupm_tm1637 as d
24
-x = d.TM1637(8, 9)
25
-x.write("1337")

+ 0
- 5
src/tm1637/CMakeLists.txt View File

@@ -1,5 +0,0 @@
1
-set (libname "tm1637")
2
-set (libdescription "upm 4 digit display tm1637")
3
-set (module_src ${libname}.cxx)
4
-set (module_h ${libname}.h)
5
-upm_module_init()

+ 0
- 8
src/tm1637/jsupm_tm1637.i View File

@@ -1,8 +0,0 @@
1
-%module jsupm_tm1637
2
-%include "../upm.i"
3
-
4
-%{
5
-    #include "tm1637.h"
6
-%}
7
-
8
-%include "tm1637.h"

+ 0
- 9
src/tm1637/pyupm_tm1637.i View File

@@ -1,9 +0,0 @@
1
-%module pyupm_tm1637
2
-%include "../upm.i"
3
-
4
-%feature("autodoc", "3");
5
-
6
-%include "tm1637.h"
7
-%{
8
-    #include "tm1637.h"
9
-%}

+ 0
- 191
src/tm1637/tm1637.cxx View File

@@ -1,191 +0,0 @@
1
-/*
2
- * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3
- * Copyright (c) 2014 Intel Corporation.
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files (the
7
- * "Software"), to deal in the Software without restriction, including
8
- * without limitation the rights to use, copy, modify, merge, publish,
9
- * distribute, sublicense, and/or sell copies of the Software, and to
10
- * permit persons to whom the Software is furnished to do so, subject to
11
- * the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
-
25
-#include <iostream>
26
-#include <unistd.h>
27
-#include <stdlib.h>
28
-
29
-#include "tm1637.h"
30
-
31
-using namespace upm;
32
-
33
-const uint8_t digitToSegment[] = {
34
-     // XGFEDCBA
35
-    0b00111111,    // 0
36
-    0b00000110,    // 1
37
-    0b01011011,    // 2
38
-    0b01001111,    // 3
39
-    0b01100110,    // 4
40
-    0b01101101,    // 5
41
-    0b01111101,    // 6
42
-    0b00000111,    // 7
43
-    0b01111111,    // 8
44
-    0b01101111,    // 9
45
-    0b01110111,    // A
46
-    0b01111100,    // B
47
-    0b00111001,    // C
48
-    0b01000111,    // D
49
-    0b01111001,    // E
50
-    0b01110001     // F
51
-};
52
-
53
-TM1637::TM1637 (uint8_t di, uint8_t dcki) {
54
-    mraa_result_t error = MRAA_SUCCESS;
55
-    mraa_init();
56
-
57
-    // init clock context
58
-    m_clkPinCtx = mraa_gpio_init(dcki);
59
-    if (m_clkPinCtx == NULL) {
60
-        fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", dcki);
61
-        exit(1);
62
-    }
63
-    // init data context
64
-    m_dataPinCtx = mraa_gpio_init(di);
65
-    if (m_dataPinCtx == NULL) {
66
-        fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", di);
67
-        exit(1);
68
-    }
69
-
70
-    // set direction (out)
71
-    error = mraa_gpio_dir(m_clkPinCtx, MRAA_GPIO_IN);
72
-    if (error != MRAA_SUCCESS) {
73
-        mraa_result_print(error);
74
-    }
75
-
76
-    // set direction (out)
77
-    error = mraa_gpio_dir(m_dataPinCtx, MRAA_GPIO_IN);
78
-    if (error != MRAA_SUCCESS) {
79
-        mraa_result_print(error);
80
-    }
81
-
82
-    error = mraa_gpio_write (m_dataPinCtx, LOW);
83
-    error = mraa_gpio_write (m_clkPinCtx, LOW);
84
-}
85
-
86
-TM1637::~TM1637() {
87
-    mraa_result_t error = MRAA_SUCCESS;
88
-    error = mraa_gpio_close (m_dataPinCtx);
89
-    if (error != MRAA_SUCCESS) {
90
-        mraa_result_print(error);
91
-    }
92
-    error = mraa_gpio_close (m_clkPinCtx);
93
-    if (error != MRAA_SUCCESS) {
94
-        mraa_result_print(error);
95
-    }
96
-}
97
-
98
-mraa_result_t
99
-TM1637::setBrightness (uint8_t level) {
100
-    m_brightness = level;
101
-}
102
-
103
-mraa_result_t
104
-TM1637::setSegments (const uint8_t segments[], uint8_t length, uint8_t pos) {
105
-    start();
106
-    writeByte(TM1637_I2C_COMM1);
107
-    stop();
108
-
109
-    start();
110
-    writeByte(TM1637_I2C_COMM2 + (pos & 0x03));
111
-    for (uint8_t idx = 0; idx < length; idx++) {
112
-        writeByte(segments[idx]);
113
-    }
114
-    stop();
115
-
116
-    start();
117
-    writeByte(TM1637_I2C_COMM3 + (m_brightness & 0x0f));
118
-    stop();
119
-}
120
-
121
-mraa_result_t
122
-TM1637::write (std::string msg) {
123
-    char leter = '\0';
124
-    uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 };
125
-    for (uint8_t idx = 0; idx < msg.length(); idx++) {
126
-        leter = msg[idx];
127
-        if (idx < 4) {
128
-            data[idx] = digitToSegment[strtol(&leter, NULL, 16)];
129
-        }
130
-    }
131
-    setBrightness (0x0f);
132
-    setSegments(data);
133
-}
134
-
135
-mraa_result_t
136
-TM1637::pinMode (mraa_gpio_context ctx, gpio_dir_t mode) {
137
-    mraa_result_t error = MRAA_SUCCESS;
138
-    error = mraa_gpio_dir(ctx, mode);
139
-    if (error != MRAA_SUCCESS) {
140
-        mraa_result_print(error);
141
-    }
142
-}
143
-
144
-mraa_result_t
145
-TM1637::start() {
146
-    pinMode (m_dataPinCtx, MRAA_GPIO_OUT);
147
-    usleep(PULSE_LENGTH);
148
-}
149
-
150
-mraa_result_t
151
-TM1637::stop() {
152
-    pinMode (m_dataPinCtx, MRAA_GPIO_OUT);
153
-    usleep(PULSE_LENGTH);
154
-    pinMode (m_clkPinCtx, MRAA_GPIO_IN);
155
-    usleep(PULSE_LENGTH);
156
-    pinMode (m_dataPinCtx, MRAA_GPIO_IN);
157
-    usleep(PULSE_LENGTH);
158
-}
159
-
160
-mraa_result_t
161
-TM1637::writeByte(uint8_t value) {
162
-    for (uint8_t idx = 0; idx < 8; idx++) {
163
-        pinMode(m_clkPinCtx, MRAA_GPIO_OUT);
164
-        usleep(PULSE_LENGTH);
165
-        if (value & 0x01) {
166
-              pinMode(m_dataPinCtx, MRAA_GPIO_IN);
167
-        } else {
168
-              pinMode(m_dataPinCtx, MRAA_GPIO_OUT);
169
-        }
170
-        usleep(PULSE_LENGTH);
171
-
172
-        pinMode(m_clkPinCtx, MRAA_GPIO_IN);
173
-        usleep(PULSE_LENGTH);
174
-        value = value >> 1;
175
-    }
176
-
177
-    pinMode(m_clkPinCtx, MRAA_GPIO_OUT);
178
-    pinMode(m_dataPinCtx, MRAA_GPIO_IN);
179
-    usleep(PULSE_LENGTH);
180
-
181
-    pinMode(m_clkPinCtx, MRAA_GPIO_IN);
182
-    usleep(PULSE_LENGTH);
183
-
184
-    uint8_t ack = mraa_gpio_read (m_dataPinCtx);
185
-    if (ack == 0) {
186
-        pinMode(m_dataPinCtx, MRAA_GPIO_OUT);
187
-    } usleep(PULSE_LENGTH);
188
-
189
-    pinMode(m_clkPinCtx, MRAA_GPIO_OUT);
190
-    usleep(50);
191
-}

+ 0
- 138
src/tm1637/tm1637.h View File

@@ -1,138 +0,0 @@
1
-/*
2
- * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3
- * Copyright (c) 2014 Intel Corporation.
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files (the
7
- * "Software"), to deal in the Software without restriction, including
8
- * without limitation the rights to use, copy, modify, merge, publish,
9
- * distribute, sublicense, and/or sell copies of the Software, and to
10
- * permit persons to whom the Software is furnished to do so, subject to
11
- * the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
-#pragma once
25
-
26
-#include <string>
27
-#include <mraa/aio.h>
28
-#include <mraa/gpio.h>
29
-
30
-#define SEG_A               0b00000001
31
-#define SEG_B               0b00000010
32
-#define SEG_C               0b00000100
33
-#define SEG_D               0b00001000
34
-#define SEG_E               0b00010000
35
-#define SEG_F               0b00100000
36
-#define SEG_G               0b01000000
37
-
38
-#define TM1637_I2C_COMM1    0x40
39
-#define TM1637_I2C_COMM2    0xC0
40
-#define TM1637_I2C_COMM3    0x80
41
-
42
-#define PULSE_LENGTH        50
43
-
44
-#define HIGH                1
45
-#define LOW                 0
46
-
47
-namespace upm {
48
- /**
49
- * @brief C++ API for Seven segments screen
50
- *
51
- *   This file defines the TM1637 C++ interface for lib4digitdisplay
52
- *
53
- * @defgroup tm1637 libupm-tm1637
54
- * @ingroup seeed gpio display
55
- */
56
-/**
57
- * @library tm1637
58
- * @sensor tm1637
59
- * @comname Seven segment screen display
60
- * @type display
61
- * @man seeed
62
- * @web http://www.seeedstudio.com/wiki/Grove_-_4-Digit_Display
63
- * @con gpio
64
- *
65
- * @brief C++ API for Seven segments screen
66
- * 
67
- *   This file defines the TM1637 C++ interface for lib4digitdisplay
68
- *      A
69
- *     ---
70
- *  F |   | B
71
- *     -G-
72
- *  E |   | C
73
- *     ---
74
- *      D
75
- *
76
- * @snippet tm1637.cxx Interesting
77
- */
78
-class TM1637 {
79
-    public:
80
-        /**
81
-         * Instanciates a TM1637 object
82
-         *
83
-         * @param di data pin
84
-         * @param dcki clock pin
85
-         */
86
-        TM1637 (uint8_t di, uint8_t dcki);
87
-        /**
88
-         * TM1637 object destructor, this will close all used Gpio
89
-         * pins  (di and dcki)
90
-         */
91
-        ~TM1637 ();
92
-
93
-        /**
94
-         * Set the brightness of the seven segment display
95
-         *
96
-         * @param level The brightness level of leds
97
-         */
98
-        mraa_result_t setBrightness (uint8_t level);
99
-
100
-        /**
101
-         * Set the the segment screen data and number of segments
102
-         *
103
-         * @param segments data to write on the segments, each elemnt
104
-         * in array is segment
105
-         * @param length number of elements in segments array
106
-         * @param pos data writing offset
107
-         */
108
-        mraa_result_t setSegments (const uint8_t segments[], uint8_t length = 4, uint8_t pos = 0);
109
-
110
-        /**
111
-         * Write message on the screen.
112
-         *
113
-         * @param msg The message to be written on the sreen
114
-         */
115
-        mraa_result_t write (std::string msg);
116
-
117
-        /**
118
-         * Return name of the component
119
-         */
120
-        std::string name()
121
-        {
122
-            return m_name;
123
-        }
124
-
125
-    private:
126
-        mraa_result_t start();
127
-        mraa_result_t stop();
128
-        mraa_result_t writeByte (uint8_t value);
129
-        mraa_result_t pinMode (mraa_gpio_context ctx, gpio_dir_t mode);
130
-
131
-        mraa_gpio_context m_clkPinCtx;
132
-        mraa_gpio_context m_dataPinCtx;
133
-
134
-        std::string m_name;
135
-        uint8_t m_brightness;
136
-};
137
-
138
-}