Skip to content

Commit 51a80d4

Browse files
committed
Changes needed for compatibility with upm 1.x+
Signed-off-by: deadprogram <[email protected]>
1 parent 156537f commit 51a80d4

File tree

23 files changed

+75
-73
lines changed

23 files changed

+75
-73
lines changed

access-control/cpp/cpp.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "src/access-control.cpp",
3-
"ldflags": "-lmraa -lupm-i2clcd -lpaho-mqtt3cs -lupm-biss0001 -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl ",
3+
"ldflags": "-lmraa -lupm-i2clcd -lupm-jhd1313m1 -lpaho-mqtt3cs -lupm-biss0001 -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl ",
44
"cxxflags": "-std=c++1y"
55
}

access-control/cpp/src/access-control.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* @cc
3838
* @cxx -std=c++1y
39-
* @ld -lupm-i2clcd -lupm-biss0001 -lpaho-mqtt3cs -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl
39+
* @ld -lupm-i2clcd -lupm-jhd1313m1 -lupm-biss0001 -lpaho-mqtt3cs -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl
4040
*
4141
* Additional source files required to build this example:
4242
* @req datastore.cpp

alarm-clock/cpp/cpp.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "src/alarm-clock.cpp",
3-
"ldflags": "-lmraa -lupm-i2clcd -lupm-buzzer -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl -lpaho-mqtt3cs ",
3+
"ldflags": "-lmraa -lupm-i2clcd -lupm-jhd1313m1 -lupm-buzzer -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl -lpaho-mqtt3cs ",
44
"cxxflags": "-std=c++1y"
55
}

alarm-clock/cpp/src/alarm-clock.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*
3939
* @cc
4040
* @cxx -std=c++1y
41-
* @ld -lupm-i2clcd -lupm-buzzer -lpaho-mqtt3cs -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl
41+
* @ld -lupm-i2clcd -lupm-jhd1313m1 -lupm-buzzer -lpaho-mqtt3cs -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl
4242
*
4343
* Additional source files required to build this example:
4444
* @req datastore.cpp

close-call-reporter/cpp/cpp.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "src/close-call-reporter.cpp",
3-
"ldflags": "-lmraa -lupm-rfr359f -lpaho-mqtt3cs -lupm-ublox6 -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl ",
3+
"ldflags": "-lmraa -lupm-rfr359f -lpaho-mqtt3cs -lupm-nmea_gps -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lcurl ",
44
"cxxflags": "-std=c++1y"
55
}

close-call-reporter/cpp/src/dfrobotkit.hpp

+10-25
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <string>
3434
#include <signal.h>
3535

36-
#include <ublox6.hpp>
36+
#include <nmea_gps.hpp>
3737
#include <rfr359f.hpp>
3838

3939
using namespace std;
@@ -42,16 +42,15 @@ using namespace std;
4242
struct Devices
4343
{
4444
upm::RFR359F* detector;
45-
upm::Ublox6* nmea;
45+
upm::NMEAGPS *nmea;
4646

4747
Devices(){
4848
};
4949

5050
// Initialization function
5151
void init() {
5252
detector = new upm::RFR359F(2);
53-
nmea = new upm::Ublox6(0);
54-
initPort();
53+
nmea = new upm::NMEAGPS(0, 38400, -1);
5554
};
5655

5756
// Cleanup on exit
@@ -60,28 +59,18 @@ struct Devices
6059
delete nmea;
6160
}
6261

63-
int initPort(){
64-
if (!nmea->setupTty(B38400)) {
65-
cerr << "Failed to setup tty port parameters" << endl;
66-
return 1;
67-
}
68-
return 0;
69-
}
70-
7162
// Get GPS data
7263
string gps_info(){
7364
size_t bufferLength = 256;
7465
string result;
75-
char nmeaBuffer[bufferLength];
7666

77-
if (nmea->dataAvailable()) {
78-
int rv = nmea->readData(nmeaBuffer, bufferLength);
79-
if (rv > 0) {
80-
result = nmeaBuffer;
81-
return result;
67+
if (nmea->dataAvailable(bufferLength)) {
68+
string rv = nmea->readStr(bufferLength);
69+
if (rv.length() > 0) {
70+
return rv;
8271
}
8372

84-
if (rv < 0) {
73+
if (rv.length() < 0) {
8574
cerr << "Port read error." << endl;
8675
return "GPS Error";
8776
}
@@ -91,12 +80,8 @@ struct Devices
9180
}
9281

9382
// Check to see if any object is within range
94-
void check_object_detected(){
95-
if (detector->objectDetected()) {
96-
notify("object-detected", gps_info());
97-
} else {
98-
cout << "Area is clear" << endl;
99-
}
83+
bool objectDetected(){
84+
return detector->objectDetected();
10085
}
10186
};
10287

close-call-reporter/cpp/src/grovekit.hpp

+8-19
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <string>
3434
#include <signal.h>
3535

36-
#include <ublox6.hpp>
36+
#include <nmea_gps.hpp>
3737
#include <rfr359f.hpp>
3838

3939
using namespace std;
@@ -42,16 +42,15 @@ using namespace std;
4242
struct Devices
4343
{
4444
upm::RFR359F* detector;
45-
upm::Ublox6* nmea;
45+
upm::NMEAGPS *nmea;
4646

4747
Devices(){
4848
};
4949

5050
// Initialization function
5151
void init() {
5252
detector = new upm::RFR359F(2);
53-
nmea = new upm::Ublox6(0);
54-
initPort();
53+
nmea = new upm::NMEAGPS(0, 9600, -1);
5554
};
5655

5756
// Cleanup on exit
@@ -60,28 +59,18 @@ struct Devices
6059
delete nmea;
6160
}
6261

63-
int initPort(){
64-
if (!nmea->setupTty(B38400)) {
65-
cerr << "Failed to setup tty port parameters" << endl;
66-
return 1;
67-
}
68-
return 0;
69-
}
70-
7162
// Get GPS data
7263
string gps_info(){
7364
size_t bufferLength = 256;
7465
string result;
75-
char nmeaBuffer[bufferLength];
7666

77-
if (nmea->dataAvailable()) {
78-
int rv = nmea->readData(nmeaBuffer, bufferLength);
79-
if (rv > 0) {
80-
result = nmeaBuffer;
81-
return result;
67+
if (nmea->dataAvailable(bufferLength)) {
68+
string rv = nmea->readStr(bufferLength);
69+
if (rv.length() > 0) {
70+
return rv;
8271
}
8372

84-
if (rv < 0) {
73+
if (rv.length() < 0) {
8574
cerr << "Port read error." << endl;
8675
return "GPS Error";
8776
}

doorbell/cpp/cpp.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "src/doorbell.cpp",
3-
"ldflags": "-lmraa -lupm-i2clcd -lcurl -lupm-ttp223 -lupm-buzzer -lupm-grove -lpaho-mqtt3cs ",
3+
"ldflags": "-lmraa -lupm-i2clcd -lupm-jhd1313m1 -lcurl -lupm-ttp223 -lupm-buzzer -lupm-grove -lpaho-mqtt3cs ",
44
"cxxflags": "-std=c++1y"
55
}

doorbell/cpp/src/doorbell.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @cc
3939
* @cxx -std=c++1y
40-
* @ld -lupm-ttp223 -lupm-buzzer -lupm-i2clcd -lcurl
40+
* @ld -lupm-ttp223 -lupm-buzzer -lupm-i2clcd -lupm-jhd1313m1 -lcurl
4141
*
4242
* Additional source files required to build this example:
4343
* @req datastore.cpp

earthquake-detector/cpp/cpp.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "src/earthquake-detector.cpp",
3-
"ldflags": "-lmraa -lupm-i2clcd -lcurl -lupm-mma7660 ",
3+
"ldflags": "-lmraa -lupm-i2clcd -upm-jhd1313m1 -lcurl -lupm-mma7660 ",
44
"cxxflags": "-std=c++1y"
55
}

earthquake-detector/cpp/src/earthquake-detector.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* @cc
3838
* @cxx -std=c++1y
39-
* @ld -lupm-mma7660 -lupm-i2clcd -lcurl
39+
* @ld -lupm-mma7660 -lupm-i2clcd -lupm-jhd1313m1 -lcurl
4040
*
4141
* Additional source files required to build this example:
4242
*

earthquake-detector/cpp/src/grovekit.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct Devices
7575
accel = new upm::MMA7660(i2cBus, MMA7660_DEFAULT_I2C_ADDR);
7676

7777
accel->setModeStandby();
78-
accel->setSampleRate(upm::MMA7660::AUTOSLEEP_64);
78+
accel->setSampleRate(MMA7660_AUTOSLEEP_64);
7979
accel->setModeActive();
8080

8181
// screen connected to the i2c bus
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "src/equipment-activity.cpp",
3-
"ldflags": "-lmraa -lupm-i2clcd -lpaho-mqtt3cs -lcurl -lupm-mic -lupm-ldt0028 -lupm-grove ",
3+
"ldflags": "-lmraa -lupm-i2clcd -lupm-jhd1313m1 -lpaho-mqtt3cs -lcurl -lupm-mic -lupm-ldt0028 -lupm-grove ",
44
"cxxflags": "-std=c++1y"
55
}

equipment-activity-monitor/cpp/src/equipment-activity.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @cc
3939
* @cxx -std=c++1y
40-
* @ld -lupm-i2clcd -lump-mic -lupm-ldt0028 -lpaho-mqtt3cs -lcurl
40+
* @ld -lupm-i2clcd -lupm-jhd1313m1 -lump-mic -lupm-ldt0028 -lpaho-mqtt3cs -lcurl
4141
*
4242
* Additional source files required to build this example:
4343
* @req datastore.cpp

fire-alarm/cpp/cpp.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "src/fire-alarm.cpp",
3-
"ldflags": "-lmraa -lupm-i2clcd -lpaho-mqtt3cs -lcurl -lssl -lcrypto -lupm-grove -lupm-buzzer ",
3+
"ldflags": "-lmraa -lupm-i2clcd -lupm-jhd1313m1 -lpaho-mqtt3cs -lcurl -lssl -lcrypto -lupm-grove -lupm-buzzer ",
44
"cxxflags": "-std=c++1y"
55
}

fire-alarm/cpp/src/fire-alarm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @cc
3939
* @cxx -std=c++1y
40-
* @ld -lupm-i2clcd -lupm-buzzer -lpaho-mqtt3cs -lupm-grove -lssl -lcrypto -lcurl
40+
* @ld -lupm-i2clcd -lupm-jhd1313m1 -lupm-buzzer -lpaho-mqtt3cs -lupm-grove -lssl -lcrypto -lcurl
4141
*
4242
* Additional source files required to build this example:
4343
* @req datastore.cpp

line-following-robot/cpp/src/line-finder-robot.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ struct Devices
135135
stepLeft->setSpeed(5);
136136
stepRight->setSpeed(5);
137137

138-
stepLeft->setDirection(upm::ULN200XA::DIR_CW);
139-
stepRight->setDirection(upm::ULN200XA::DIR_CW);
138+
stepLeft->setDirection(ULN200XA_DIR_CW);
139+
stepRight->setDirection(ULN200XA_DIR_CW);
140140

141141
stepLeft->stepperSteps(1024);
142142
stepRight->stepperSteps(1024);
@@ -149,8 +149,8 @@ struct Devices
149149
stepLeft->setSpeed(5);
150150
stepRight->setSpeed(5);
151151

152-
stepLeft->setDirection(upm::ULN200XA::DIR_CW);
153-
stepRight->setDirection(upm::ULN200XA::DIR_CCW);
152+
stepLeft->setDirection(ULN200XA_DIR_CW);
153+
stepRight->setDirection(ULN200XA_DIR_CCW);
154154

155155
stepLeft->stepperSteps(512);
156156
stepRight->stepperSteps(512);

plant-lighting-system/cpp/cpp.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "src/plant-lighting-system.cpp",
3-
"ldflags": "-lmraa -lupm-i2clcd -lupm-grovemoisture -lupm-ldt0028 -lpaho-mqtt3cs -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lssl -lcrypto -lcurl ",
3+
"ldflags": "-lmraa -lupm-i2clcd -lupm-jhd1313m1 -lupm-grovemoisture -lupm-ldt0028 -lpaho-mqtt3cs -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lssl -lcrypto -lcurl ",
44
"cxxflags": "-std=c++1y"
55
}

plant-lighting-system/cpp/src/plant-lighting-system.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @cc
3939
* @cxx -std=c++1y
40-
* @ld -lupm-i2clcd -lupm-grovemoisture -lupm-ldt0028 -lpaho-mqtt3cs -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lssl -lcrypto -lcurl
40+
* @ld -lupm-i2clcd -lupm-jhd1313m1 -lupm-grovemoisture -lupm-ldt0028 -lpaho-mqtt3cs -lupm-grove -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time -lpthread -lssl -lcrypto -lcurl
4141
*
4242
* Additional source files required to build this example:
4343
* @req datastore.cpp

range-finder-scanner/cpp/src/html.h

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
static unsigned char _/range_finder_scanner/cpp/html/index_html[] = {
1+
/*
2+
* Copyright (c) 2015 - 2016 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+
24+
static unsigned char index_html[] = {
225
0x3c, 0x21, 0x64, 0x6f, 0x63, 0x74, 0x79, 0x70, 0x65, 0x20, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a,
326
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x3d, 0x22, 0x65, 0x6e, 0x22, 0x3e,
427
0x0a, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74,
@@ -9662,5 +9685,5 @@ static unsigned char _/range_finder_scanner/cpp/html/index_html[] = {
96629685
0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x2c, 0x20, 0x35, 0x30,
96639686
0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
96649687
0x3e, 0x0a, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0a, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c,
9665-
0x3e, 0x0a,
9688+
0x3e, 0x0a,
96669689
};

range-finder-scanner/cpp/src/range-finder-scanner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct Devices
9696

9797
// Moves the stepper motor around and around
9898
void move(){
99-
stepper->setDirection(upm::ULN200XA::DIR_CW);
99+
stepper->setDirection(ULN200XA_DIR_CW);
100100
stepper->setSpeed(5);
101101
stepper->stepperSteps(4096/360);
102102
}

robot-arm/cpp/src/robot-arm.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -101,32 +101,32 @@ struct Devices
101101

102102
//functions to set speed and direction of motors
103103
//steps 4096 is one full revolution of the motor
104-
void move(upm::ULN200XA* motor, upm::ULN200XA::ULN200XA_DIRECTION_T direction) {
104+
void move(upm::ULN200XA* motor, ULN200XA_DIRECTION_T direction) {
105105
motor->setSpeed(5);
106106
motor->setDirection(direction);
107107
motor->stepperSteps(512);
108108
}
109109

110110
void stop(upm::ULN200XA* motor) {
111111
motor->setSpeed(5);
112-
motor->setDirection(upm::ULN200XA::DIR_CW);
112+
motor->setDirection(ULN200XA_DIR_CW);
113113
motor->stepperSteps(0);
114114
}
115115

116116
void move_1_clockwise() {
117-
move(stepperOne, upm::ULN200XA::DIR_CW);
117+
move(stepperOne, ULN200XA_DIR_CW);
118118
}
119119

120120
void move_1_counter_clockwise() {
121-
move(stepperOne, upm::ULN200XA::DIR_CCW);
121+
move(stepperOne, ULN200XA_DIR_CCW);
122122
}
123123

124124
void move_2_clockwise() {
125-
move(stepperTwo, upm::ULN200XA::DIR_CW);
125+
move(stepperTwo, ULN200XA_DIR_CW);
126126
}
127127

128128
void move_2_counter_clockwise() {
129-
move(stepperTwo, upm::ULN200XA::DIR_CCW);
129+
move(stepperTwo, ULN200XA_DIR_CCW);
130130
}
131131

132132
// function to turn the joystick input -1, 0, or 1

smart-stove-top/cpp/src/grovekit.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ struct Devices
112112
speaker->playSound('c', true, "high");
113113
}
114114

115+
// Not used by Grove kit
116+
void stopAlarm() {
117+
return;
118+
}
119+
115120
// Reads the flame sensor
116121
bool flameDetected() {
117122
return flame->flameDetected();

0 commit comments

Comments
 (0)