Skip to content

Commit 9f2a978

Browse files
Merge branch 'dev'
2 parents 9c7ef3d + b8f3fa7 commit 9f2a978

File tree

10 files changed

+74
-11
lines changed

10 files changed

+74
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ project(LetMeCreate)
55

66
set(LETMECREATE_MAJOR_VERSION 1)
77
set(LETMECREATE_MINOR_VERSION 0)
8-
set(LETMECREATE_PATCH_VERSION 2)
8+
set(LETMECREATE_PATCH_VERSION 3)
99
set(LETMECREATE_VERSION ${LETMECREATE_MAJOR_VERSION}.${LETMECREATE_MINOR_VERSION}.${LETMECREATE_PATCH_VERSION})
1010
set(PROJECT_VERSION ${LETMECREATE_VERSION})
1111

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "LetMeCreate"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 1.0.2
41+
PROJECT_NUMBER = 1.0.3
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

Readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LetMeCreate library
22

3-
This library is a collection of small wrappers for some interfaces of the Ci-40. It aims at making easier to develop on this platform. Also, it provides some wrappers for a few clicks.
3+
This library is a collection of small wrappers for some interfaces of the Ci40. It aims at making easier to develop on this platform. Also, it provides some wrappers for a few clicks. Notice that you cannot compile the library on Ci40 because cmake cannot run on it.
44

55
Interface supported:
66
- I²C
@@ -23,6 +23,7 @@ MikroClick board supported:
2323
- Accel (SPI only)
2424
- 8x8R (Led Matrix)
2525
- Alcohol
26+
- IR eclipse
2627

2728
Examples are installed in /usr/bin/letmecreate_examples.
2829
Tests are installed in /usr/bin/letmecreate_tests.

examples/motion/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <stdio.h>
12
#include <time.h>
23
#include <letmecreate/letmecreate.h>
34

include/letmecreate/click.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "letmecreate/click/alcohol.h"
1515
#include "letmecreate/click/color.h"
1616
#include "letmecreate/click/common.h"
17+
#include "letmecreate/click/ir_eclipse.h"
1718
#include "letmecreate/click/joystick.h"
1819
#include "letmecreate/click/led_matrix.h"
1920
#include "letmecreate/click/motion.h"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef __LETMECREATE_CLICK_IR_ECLIPSE_H__
2+
#define __LETMECREATE_CLICK_IR_ECLIPSE_H__
3+
4+
#include <stdint.h>
5+
6+
/**
7+
* @brief Attach callback triggered if an object is detected.
8+
*
9+
* To remove this callback, call gpio_monitor_remove_callback function with
10+
* the callback ID returned by this function.
11+
*
12+
* @param[in] mikrobus_index Index of the mikrobus
13+
* @param[in] callback Must not be null.
14+
* @return A callback ID (positive integer) if successful, -1 otherwise
15+
*/
16+
int ir_eclipse_click_add_callback(uint8_t mikrobus_index, void (*callback)(uint8_t));
17+
18+
#endif

miscellaneous/Makefile.devel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=letmecreate
4-
PKG_VERSION:=1.0.2
4+
PKG_VERSION:=1.0.3
55

66
PKG_LICENSE_FILE:=LICENSE
77
PKG_LICENSE:=BSD-3-Clause
@@ -53,7 +53,7 @@ endef
5353

5454
define Build/InstallDev
5555
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/letmecreate
56-
$(CP) $(PKG_INSTALL_DIR)/usr/include/letmecreate $(STAGING_DIR)/usr/include/letmecreate
56+
$(CP) $(PKG_INSTALL_DIR)/usr/include/letmecreate $(STAGING_DIR)/usr/include/
5757

5858
$(INSTALL_DIR) $(STAGING_DIR)/usr/lib
5959
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so $(STAGING_DIR)/usr/lib/
@@ -77,7 +77,7 @@ define Package/letmecreate/install
7777
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so $(1)/usr/lib/
7878

7979
$(INSTALL_DIR) $(1)/usr/include/letmecreate
80-
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/letmecreate
80+
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
8181

8282
$(INSTALL_DIR) $(1)/usr/lib/cmake/LetMeCreate
8383
$(CP) $(PKG_INSTALL_DIR)/usr/lib/cmake/LetMeCreate/*.cmake $(1)/usr/lib/cmake/LetMeCreate

miscellaneous/Makefile.stable

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=letmecreate
4-
PKG_VERSION:=1.0.2
4+
PKG_VERSION:=1.0.3
55

66
PKG_SOURCE_VERSION:=HEAD
77
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
8-
PKG_SOURCE_URL:= git@github.com:francois-berder/LetMeCreate.git
8+
PKG_SOURCE_URL:= https://github.com/francois-berder/LetMeCreate.git
99
PKG_SOURCE_PROTO:=git
1010
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
1111

@@ -36,7 +36,7 @@ CMAKE_OPTIONS += $(if $(CONFIG_LETMECREATE_BUILD_EXAMPLES),-DBUILD_EXAMPLES=ON)
3636

3737
define Build/InstallDev
3838
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/letmecreate
39-
$(CP) $(PKG_INSTALL_DIR)/usr/include/letmecreate $(STAGING_DIR)/usr/include/letmecreate
39+
$(CP) $(PKG_INSTALL_DIR)/usr/include/letmecreate $(STAGING_DIR)/usr/include/
4040

4141
$(INSTALL_DIR) $(STAGING_DIR)/usr/lib
4242
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so $(STAGING_DIR)/usr/lib/
@@ -55,7 +55,7 @@ define Package/letmecreate/install
5555
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so $(1)/usr/lib/
5656

5757
$(INSTALL_DIR) $(1)/usr/include/letmecreate
58-
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/letmecreate
58+
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
5959

6060
$(INSTALL_DIR) $(1)/usr/lib/cmake/LetMeCreate
6161
$(CP) $(PKG_INSTALL_DIR)/usr/lib/cmake/LetMeCreate/*.cmake $(1)/usr/lib/cmake/LetMeCreate

src/click/alcohol.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
int alcohol_click_get_measure(uint8_t mikrobus_index, uint16_t *measure)
88
{
9+
float tmp = 0.f;
10+
911
if (measure == NULL) {
1012
fprintf(stderr, "alcohol: Cannot store measurement in null variable.\n");
1113
return -1;
@@ -16,5 +18,10 @@ int alcohol_click_get_measure(uint8_t mikrobus_index, uint16_t *measure)
1618
return -1;
1719
}
1820

19-
return adc_get_value(mikrobus_index, measure);
21+
if (adc_get_value(mikrobus_index, &tmp) < 0)
22+
return -1;
23+
24+
*measure = (tmp / 5.f) * 1023;
25+
26+
return 0;
2027
}

src/click/ir_eclipse.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <stdio.h>
2+
#include "letmecreate/click/ir_eclipse.h"
3+
#include "letmecreate/core/common.h"
4+
#include "letmecreate/core/gpio.h"
5+
#include "letmecreate/core/gpio_monitor.h"
6+
7+
8+
int ir_eclipse_click_add_callback(uint8_t mikrobus_index, void (*callback)(uint8_t))
9+
{
10+
uint8_t gpio_pin;
11+
12+
switch (mikrobus_index) {
13+
case MIKROBUS_1:
14+
gpio_pin = MIKROBUS_1_INT;
15+
break;
16+
case MIKROBUS_2:
17+
gpio_pin = MIKROBUS_2_INT;
18+
break;
19+
default:
20+
fprintf(stderr, "ir_eclipse: Invalid mikrobus index.\n");
21+
return -1;
22+
}
23+
24+
if (callback == NULL) {
25+
fprintf(stderr, "ir_eclipse: Callback must not be null.\n");
26+
return -1;
27+
}
28+
29+
if (gpio_init(gpio_pin) < 0
30+
|| gpio_set_direction(gpio_pin, GPIO_INPUT) < 0
31+
|| gpio_monitor_init() < 0)
32+
return -1;
33+
34+
return gpio_monitor_add_callback(gpio_pin, GPIO_EDGE, callback);
35+
}

0 commit comments

Comments
 (0)