Skip to content

Commit cb36640

Browse files
Merge branch 'dev'
2 parents c22a2c8 + 82cc3d5 commit cb36640

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1936
-483
lines changed

CMakeLists.txt

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

55

66
set(LETMECREATE_MAJOR_VERSION 1)
7-
set(LETMECREATE_MINOR_VERSION 4)
7+
set(LETMECREATE_MINOR_VERSION 5)
88
set(LETMECREATE_PATCH_VERSION 0)
99
set(LETMECREATE_VERSION ${LETMECREATE_MAJOR_VERSION}.${LETMECREATE_MINOR_VERSION}.${LETMECREATE_PATCH_VERSION})
1010
set(PROJECT_VERSION ${LETMECREATE_VERSION})

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.4.0
41+
PROJECT_NUMBER = 1.5.0
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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
## Build status
66

77
**Master**
8-
[![Build Status](https://travis-ci.org/francois-berder/LetMeCreate.svg?branch=master)](https://travis-ci.org/francois-berder/LetMeCreate)
8+
[![Build Status](https://travis-ci.org/CreatorDev/LetMeCreate.svg?branch=master)](https://travis-ci.org/CreatorDev/LetMeCreate)
99

1010
**Dev**
11-
[![Build Status](https://travis-ci.org/francois-berder/LetMeCreate.svg?branch=dev)](https://travis-ci.org/francois-berder/LetMeCreate)
11+
[![Build Status](https://travis-ci.org/CreatorDev/LetMeCreate.svg?branch=dev)](https://travis-ci.org/CreatorDev/LetMeCreate)
1212

1313
## Introduction
1414

@@ -33,10 +33,11 @@ MikroClick board supported:
3333
|Color|Color2|EVE|
3434
|Fan|GYRO|IR distance|
3535
|IR eclipse|Joystick|Light|
36-
|LIN Hall|Motion|OLED|
37-
|Opto|Proximity|Relay (partial support)|
38-
|Relay2|Relay4 (partial support)|RTC|
39-
|Thermo3|UNI Hall|Weather|
36+
|LIN Hall|Lora|Motion|
37+
|OLED|Opto|Proximity|
38+
|Relay (partial support)|Relay2|Relay4 (partial support)|
39+
|RTC|Thermo3|UNI Hall|
40+
|Weather|||
4041

4142
The Raspberry PI sense Hat is supported by the library, except the EEPROM because the pins are not connected on the I2C bus. The atmel chip is confusing the I2C driver of the Ci40 which makes it sometimes impossible to communicate with the hat. Inserting the hat after the board finished booting often solves the issue (assuming it does not cause a reset of the Ci40 because of a brown-out reset).
4243

examples/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,15 @@ install(TARGETS letmecreate_oled_example RUNTIME DESTINATION bin)
8989
add_executable(letmecreate_rpisensehat_example rpisensehat/main.c)
9090
target_link_libraries(letmecreate_rpisensehat_example letmecreate_rpisensehat letmecreate_core)
9191
install(TARGETS letmecreate_rpisensehat_example RUNTIME DESTINATION bin)
92+
93+
add_executable(letmecreate_lora_example lora/main.c)
94+
target_link_libraries(letmecreate_lora_example letmecreate_click letmecreate_core)
95+
install(TARGETS letmecreate_lora_example RUNTIME DESTINATION bin)
96+
97+
add_executable(letmecreate_switch_example switch/main.c)
98+
target_link_libraries(letmecreate_switch_example letmecreate_core)
99+
install(TARGETS letmecreate_switch_example RUNTIME DESTINATION bin)
100+
101+
add_executable(letmecreate_uni_hall_example uni_hall/main.c)
102+
target_link_libraries(letmecreate_uni_hall_example letmecreate_click letmecreate_core)
103+
install(TARGETS letmecreate_uni_hall_example RUNTIME DESTINATION bin)

examples/alphanum/main.c

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,30 @@
22
* This example shows how to use the Alphanum Click wrapper of the LetMeCreate
33
* to display characters.
44
*
5-
* It displays "Ci" using both displays by enabling them one after the other at
6-
* 100Hz to give the illusion that both characters are displayed at the same
7-
* time. The user has to interrupt the program to exit it by pressing Ctrl+C.
5+
* It displays "Ci" during 5 seconds on the Alphanum Click.
86
*
97
* The Alphanum Click must be inserted in Mikrobus 1 before running this
108
* program.
119
*/
1210

13-
14-
#include <signal.h>
15-
#include <stdbool.h>
16-
#include <stdio.h>
11+
#include <unistd.h>
1712
#include <letmecreate/letmecreate.h>
18-
#include "examples/common.h"
19-
20-
static volatile bool running = true;
2113

22-
static void exit_program(int __attribute__ ((unused))signo)
23-
{
24-
running = false;
25-
}
2614

2715
int main(void)
2816
{
29-
/* Set signal handler to exit program when Ctrl+c is pressed */
30-
struct sigaction action = {
31-
.sa_handler = exit_program,
32-
.sa_flags = 0
33-
};
34-
sigemptyset(&action.sa_mask);
35-
sigaction (SIGINT, &action, NULL);
36-
37-
printf("Press Ctrl+c to exit program.\n");
38-
3917
spi_init();
4018
spi_select_bus(MIKROBUS_1);
4119

4220
if (alphanum_click_init(MIKROBUS_1) < 0)
43-
return 1;
21+
return -1;
4422

4523
if (alphanum_click_write('C', 'i') < 0)
46-
return 1;
47-
48-
/* This alternately switches on the output of either the two shift registers
49-
* to appear to print two characters at the same time.
50-
*/
51-
while (running) {
52-
alphanum_click_select_left_display();
53-
sleep_ms(5);
54-
alphanum_click_select_right_display();
55-
sleep_ms(5);
56-
}
24+
return -1;
25+
26+
sleep(5);
5727

28+
alphanum_click_release();
5829
spi_release();
5930

6031
return 0;

examples/lora/main.c

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/**
2+
* This example shows how to use the Lora Click wrapper of the LetMeCreate to
3+
* send or receive data.
4+
*
5+
* Depending on the mode selected, it either continuously sends a message every
6+
* second, or it waits for data and prints what it receives.
7+
* The user has to interrupt the program to exit it by pressing Ctrl+C.
8+
*
9+
* To run the example in send mode:
10+
* $ ./letmecreate_lora_example s
11+
*
12+
* To run the example in receive mode:
13+
* $ ./letmecreate_lora_example r
14+
*
15+
* The Lora Click must be inserted in Mikrobus 1 before running this program.
16+
*/
17+
18+
19+
20+
#include <signal.h>
21+
#include <stdio.h>
22+
#include <string.h>
23+
#include <unistd.h>
24+
#include <letmecreate/letmecreate.h>
25+
26+
static volatile bool running = true;
27+
28+
static void exit_program(int __attribute__ ((unused))signo)
29+
{
30+
running = false;
31+
}
32+
33+
static void receive(void)
34+
{
35+
char buffer[16];
36+
37+
if (lora_click_receive((uint8_t*)buffer, sizeof(buffer) - 1) < 0)
38+
return;
39+
40+
buffer[15] = '\0';
41+
printf("Received \"%s\"\n", buffer);
42+
}
43+
44+
static void send(unsigned int n)
45+
{
46+
char buffer[255];
47+
sprintf(buffer, "Hello, World! %u", n);
48+
49+
if (lora_click_send((uint8_t*)buffer, strlen(buffer)) < 0)
50+
return;
51+
52+
printf("Sent \"%s\"\n", buffer);
53+
}
54+
55+
int main(int argc, char** argv)
56+
{
57+
uint32_t n = 0;
58+
char mode;
59+
60+
/* Set signal handler to exit program when Ctrl+c is pressed */
61+
struct sigaction action = {
62+
.sa_handler = exit_program,
63+
.sa_flags = 0
64+
};
65+
sigemptyset(&action.sa_mask);
66+
sigaction (SIGINT, &action, NULL);
67+
68+
if (argc < 2) {
69+
fprintf(stderr, "%s r|s\n", argv[0]);
70+
return -1;
71+
}
72+
73+
mode = argv[1][0];
74+
if (mode != 's' && mode != 'r') {
75+
fprintf(stderr, "Invalid mode.\n");
76+
return -1;
77+
}
78+
79+
printf("Press Ctrl+c to exit program.\n");
80+
81+
uart_init();
82+
uart_select_bus(MIKROBUS_1);
83+
uart_set_baudrate(UART_BD_57600);
84+
lora_click_init(MIKROBUS_1, lora_click_get_default_configuration());
85+
86+
while (running) {
87+
if (mode == 's') {
88+
send(n);
89+
sleep(1);
90+
}
91+
else if (mode == 'r')
92+
receive();
93+
94+
++n;
95+
}
96+
97+
uart_release();
98+
99+
return 0;
100+
}

examples/switch/main.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* This example shows how to use the Switch wrapper of the LetMeCreate library.
3+
*
4+
* It attaches a callback to all switch events for 15 seconds. Each time an
5+
* event happens, it prints hello on the screen.
6+
*/
7+
8+
#include <stdio.h>
9+
#include <unistd.h>
10+
#include <letmecreate/letmecreate.h>
11+
12+
static void print_hello(void)
13+
{
14+
printf("hello\n");
15+
}
16+
17+
int main(void)
18+
{
19+
switch_init();
20+
switch_add_callback(SWITCH_ALL_EVENTS, print_hello);
21+
printf("Switch callback are now active for 15 seconds.\n");
22+
printf("Press a switch to print \"hello\" on screen.\n");
23+
sleep(15);
24+
switch_release();
25+
26+
return 0;
27+
}

examples/uni_hall/main.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* This example shows how to use the UNI Hall Click wrapper of the LetMeCreate
3+
* library.
4+
*
5+
* It attaches a callback that prints hello everytime it starts/stops detecting
6+
* the north pole of a magnet during 10 seconds.
7+
*
8+
* The UNI Hall Click must be inserted in Mikrobus 1 before running the program.
9+
*/
10+
11+
12+
#include <letmecreate/letmecreate.h>
13+
#include <stdio.h>
14+
#include <unistd.h>
15+
16+
void print_hello(uint8_t arg)
17+
{
18+
if (arg == GPIO_FALLING)
19+
printf("Hello, starts dectecting north pole\n");
20+
else if (arg == GPIO_RAISING)
21+
printf("Hello, stops dectecting north pole\n");
22+
}
23+
24+
int main(void)
25+
{
26+
uni_hall_click_attach_callback(MIKROBUS_1, print_hello);
27+
printf("Callback is now active for 15 seconds.\n");
28+
printf("Move the north pole of a magnet over the sensor to print \"hello\".\n");
29+
sleep(15);
30+
31+
return 0;
32+
}

include/letmecreate/bosch/bme280.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
#ifndef __BME280_H__
6060
#define __BME280_H__
6161

62+
#ifdef __cplusplus
63+
extern "C" {
64+
#endif
65+
6266
#include <letmecreate/bosch/export.h>
6367

6468
/*!
@@ -1712,4 +1716,9 @@ s32 v_uncom_pressure_s32);
17121716
*/
17131717
BME280_RETURN_FUNCTION_TYPE LETMECREATE_BOSCH_EXPORT bme280_compute_wait_time(u8
17141718
*v_delaytime_u8);
1719+
1720+
#ifdef __cplusplus
1721+
}
1722+
#endif
1723+
17151724
#endif

include/letmecreate/click.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#ifndef __LETMECREATE_CLICK_H__
1010
#define __LETMECREATE_CLICK_H__
1111

12+
#ifdef __cplusplus
13+
extern "C"{
14+
#endif
15+
1216
#include <letmecreate/click/7seg.h>
1317
#include <letmecreate/click/accel.h>
1418
#include <letmecreate/click/adc.h>
@@ -29,6 +33,7 @@
2933
#include <letmecreate/click/led_matrix.h>
3034
#include <letmecreate/click/light.h>
3135
#include <letmecreate/click/lin_hall.h>
36+
#include <letmecreate/click/lora.h>
3237
#include <letmecreate/click/motion.h>
3338
#include <letmecreate/click/oled.h>
3439
#include <letmecreate/click/opto.h>
@@ -41,4 +46,8 @@
4146
#include <letmecreate/click/uni_hall.h>
4247
#include <letmecreate/click/weather.h>
4348

49+
#ifdef __cplusplus
50+
}
51+
#endif
52+
4453
#endif

0 commit comments

Comments
 (0)