Skip to content

Commit ece3f74

Browse files
author
Alexandru Radovici
committed
deviceintel setup
1 parent e2a65f5 commit ece3f74

File tree

9 files changed

+80
-44
lines changed

9 files changed

+80
-44
lines changed

CMakeLists.txt

+6-18
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,18 @@ configure_file (
3333

3434
# Options
3535
option (RASPBERRYPI "Build for the RaspberryPi." OFF)
36-
option (GALILEO "Build for the Intel Galileo." OFF)
37-
option (EDISON "Build for the Intel Galileo." OFF)
36+
option (DEVICEINTEL "Build for the Intel Galileo." OFF)
3837
option (BEAGLEBONE "Build for the Beaglebone." OFF)
39-
option (MINNOWBOARDMAX "Build for the Minnowboard Max." OFF)
4038
option (REDPITAYA "Build for the RedPitaya." OFF)
4139
option (UDOONEO "Build for the UDOO NEO." OFF)
4240
option (SERVER "Build for the Server." OFF)
4341

4442
# Option management
45-
if (GALILEO)
46-
add_definitions (-DARDUINOGALILEO)
43+
if (DEVICEINTEL)
44+
add_definitions (-DDEVICEINTEL)
4745
pkg_check_modules (MRAA REQUIRED mraa>=0.4.0)
4846
message (INFO "found libmraa version: ${MRAA_VERSION}")
49-
set(FLAGS "-DARDUINOGALILEO")
50-
51-
elseif (EDISON)
52-
add_definitions (-DEDISON)
53-
pkg_check_modules (MRAA REQUIRED mraa>=0.4.0)
54-
message (INFO "found libmraa version: ${MRAA_VERSION}")
55-
set(FLAGS "-DEDISON")
56-
57-
elseif (MINNOWBOARDMAX)
58-
add_definitions (-DMINNOWBOARDMAX)
59-
pkg_check_modules (MRAA REQUIRED mraa>=0.4.0)
60-
message (INFO "found libmraa version: ${MRAA_VERSION}")
61-
set(FLAGS "-DMINNOWBOARDMAX")
47+
set(FLAGS "-DDEVICEINTEL")
6248

6349
elseif (RASPBERRYPI)
6450
add_definitions (-DRASPBERRYPI)
@@ -144,6 +130,8 @@ set (wyliodrin_LIB_SRCS
144130
add_subdirectory (src)
145131
add_subdirectory (languages)
146132

133+
add_subdirectory (wylio)
134+
147135
if (SERVER)
148136
else ()
149137
install (FILES scripts/install_social DESTINATION bin/ PERMISSIONS WORLD_READ WORLD_EXECUTE)

src/libraries/LiquidCrystal.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@ void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) {
327327

328328
/*********** mid level commands, for sending data/cmds */
329329

330-
inline void LiquidCrystal::command(uint8_t value) {
330+
void LiquidCrystal::command(uint8_t value) {
331331
send(value, LOW);
332332
}
333333

334-
inline size_t LiquidCrystal::write(uint8_t value) {
334+
size_t LiquidCrystal::write(uint8_t value) {
335335
send(value, HIGH);
336336
return 1;
337337
}

src/libraries/Servo.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Servo::Servo()
2323
this->index = INVALID_SERVO; // too many servos
2424
}
2525

26-
#ifdef ARDUINOGALILEO
26+
#ifdef DEVICEINTEL
2727
m_currentAngle = 180;
2828
#endif
2929

@@ -70,7 +70,7 @@ uint8_t Servo::attach(int pin, int min, int max)
7070
this->is188hz = true;
7171
this->isAttached = true;
7272

73-
#ifdef ARDUINOGALILEO
73+
#ifdef DEVICEINTEL
7474
m_pwmServoContext = mraa_pwm_init (this->pin);
7575
write (0);
7676
#endif
@@ -116,7 +116,7 @@ void Servo::write(int val)
116116
else if (val > 180)
117117
val = 180;
118118

119-
#ifdef ARDUINOGALILEO
119+
#ifdef DEVICEINTEL
120120
int period = (max - min) / 180;
121121

122122
int cycles = (int)(100.0 * ((float)abs (m_currentAngle - val) / 180));
@@ -133,7 +133,7 @@ void Servo::write(int val)
133133
// std::cout << "angle = " << angle << " ,pulse = " << calcPulseTraveling(angle) << ", cycles " << cycles << std::endl;
134134

135135
m_currentAngle = val;
136-
#endif
136+
#endif
137137
}
138138
else
139139
{
@@ -145,7 +145,7 @@ void Servo::write(int val)
145145

146146
int Servo::read()
147147
{
148-
#ifdef ARDUINOGALILEO
148+
#ifdef DEVICEINTEL
149149
return this->m_currentAngle;
150150
#else
151151
return 0;

src/libraries/Servo.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include <stdint.h>
2121

22-
#ifdef ARDUINOGALILEO
22+
#ifdef DEVICEINTEL
2323
#include <mraa/pwm.h>
2424

2525
#define MAX_PERIOD 7968
@@ -58,7 +58,7 @@ class Servo
5858
bool is188hz;
5959
int lastByteInDuty; // to avoid jitter caused by analogWrite()
6060
int calcPulseTraveling (int value);
61-
#ifdef ARDUINOGALILEO
61+
#ifdef DEVICEINTEL
6262
int m_currentAngle;
6363
mraa_pwm_context m_pwmServoContext;
6464
#endif

src/wiring/arduinogalileo.c

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11

2-
#if defined(ARDUINOGALILEO) || defined (EDISON) || defined (MINNOWBOARDMAX)
2+
#if defined(DEVICEINTEL) // defined(ARDUINOGALILEO) || defined (EDISON) || defined (MINNOWBOARDMAX)
33

44
#include "wiring.h"
55
#include <pthread.h>
66
#include <stdio.h>
7+
#include <string.h>
78
#include <math.h>
89

910
static mraa_gpio_context gpio_pins[MAX_GPIO_PINS];
@@ -102,6 +103,7 @@ int wiringSetup ()
102103
adc_power = pow (2, adc_raw_bits)-1;
103104
pthread_mutex_init(&lockspi, NULL);
104105
pthread_mutex_init(&locki2c, NULL);
106+
return 0;
105107
}
106108

107109
void pinReset (int pin)
@@ -506,15 +508,21 @@ int i2c_openadapter(uint8_t i2c_bus)
506508
{
507509
if (i2c_bus == 255)
508510
{
509-
#ifdef ARDUINOGALILEO
510-
i2c_bus = 0;
511-
#endif
512-
#ifdef EDISON
513-
i2c_bus = 6;
514-
#endif
515-
#ifdef MINNOWBOARDMAX
516-
i2c_bus = 0;
517-
#endif
511+
const char *platform = mraa_get_platform_name ();
512+
if (strncmp (platform, "Intel Galileo ", 14)==0)
513+
{
514+
i2c_bus = 0;
515+
}
516+
else if (strncmp (platform, "Intel Edison", 12)==0)
517+
{
518+
i2c_bus = 6;
519+
}
520+
else if (strncmp (platform, "MinnowBoard MAX",15)==0)
521+
{
522+
i2c_bus = 0;
523+
}
524+
else
525+
i2c_bus = 0;
518526
}
519527
i2c_buses[i2cId] = mraa_i2c_init (i2c_bus);
520528
}

src/wiring/wiring.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
#define MAX_I2C_PINS 10
7979
#endif /* UDOONEO */
8080

81-
#if defined(ARDUINOGALILEO) || defined(EDISON)
81+
#if defined(DEVICEINTEL)//defined(ARDUINOGALILEO) || defined(EDISON)
8282
#include <mraa/gpio.h>
8383
#include <mraa/aio.h>
8484
#include <mraa/pwm.h>

wylio/CMakeLists.txt

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
cmake_minimum_required (VERSION 2.8.8)
2+
3+
project (wylio)
4+
5+
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
6+
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
7+
8+
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
9+
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
10+
11+
12+
13+
# Dependencies
14+
find_package (PkgConfig REQUIRED)
15+
find_package (Hiredis REQUIRED)
16+
include_directories (${HIREDIS_INCLUDE_DIR})
17+
find_package (Jansson REQUIRED)
18+
include_directories (${JANSSON_INCLUDE_DIR})
19+
pkg_check_modules (EVENT REQUIRED libevent)
20+
21+
22+
add_definitions ("-Wall -DDEBUG")
23+
24+
25+
include_directories (${PROJECT_BINARY_DIR})
26+
27+
28+
29+
# Sources
30+
set (wylio_SRCS
31+
# Core
32+
${PROJECT_SOURCE_DIR}/wylio.c
33+
)
34+
35+
add_executable (wylio
36+
${wylio_SRCS}
37+
)
38+
39+
target_link_libraries (wylio wyliodrin -levent)
40+
41+
42+
43+
install (TARGETS wylio DESTINATION bin)
44+
45+

wylio/Makefile

-5
This file was deleted.

wylio/wylio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <stdio.h>
22
#include <string.h>
3-
#include <Wyliodrin.h>
3+
#include "../src/Wyliodrin.h"
44

55
int main(int argc, char **argv) {
66
if (argc == 2) {

0 commit comments

Comments
 (0)