Skip to content

Commit 1160b79

Browse files
Merge branch 'dev'
2 parents c1f9f29 + cc65cf7 commit 1160b79

Some content is hidden

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

60 files changed

+7033
-260
lines changed

CMakeLists.txt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,45 @@ project(LetMeCreate)
44

55

66
set(LETMECREATE_MAJOR_VERSION 1)
7-
set(LETMECREATE_MINOR_VERSION 2)
7+
set(LETMECREATE_MINOR_VERSION 3)
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})
1111

1212
option(BUILD_EXAMPLES "Build examples" OFF)
1313
option(BUILD_TESTS "Build tests" OFF)
1414

15+
file(GLOB bosch_srcs src/bosch/*.c)
1516
file(GLOB core_srcs src/core/*.c)
1617
file(GLOB click_srcs src/click/*.c)
18+
file(GLOB rpisensehat_srcs src/rpisensehat/*.c)
1719

20+
file(GLOB bosch_hdrs include/letmecreate/bosch/*.h)
1821
file(GLOB core_hdrs include/letmecreate/core/*.h)
1922
file(GLOB click_hdrs include/letmecreate/click/*.h)
23+
file(GLOB rpisensehat_hdrs include/letmecreate/rpisensehat/*.h)
2024

2125
include_directories(include)
2226

2327
# Create targets
2428
add_library(letmecreate_core SHARED ${core_srcs} ${core_hdrs})
2529
add_library(letmecreate_click SHARED ${click_srcs} ${click_hdrs})
26-
target_link_libraries(letmecreate_click letmecreate_core)
30+
add_library(letmecreate_bosch SHARED ${bosch_srcs} ${bosch_hdrs})
31+
add_library(letmecreate_rpisensehat SHARED ${rpisensehat_srcs} ${rpisensehat_hdrs})
32+
target_link_libraries(letmecreate_core pthread)
33+
target_link_libraries(letmecreate_click letmecreate_core letmecreate_bosch)
34+
target_link_libraries(letmecreate_rpisensehat letmecreate_core)
2735

2836
# Export symbols
2937
include(GenerateExportHeader)
38+
generate_export_header(letmecreate_bosch EXPORT_FILE_NAME "include/letmecreate/bosch/export.h")
3039
generate_export_header(letmecreate_core EXPORT_FILE_NAME "include/letmecreate/core/export.h")
3140
generate_export_header(letmecreate_click EXPORT_FILE_NAME "include/letmecreate/click/export.h")
41+
generate_export_header(letmecreate_rpisensehat EXPORT_FILE_NAME "include/letmecreate/rpisensehat/export.h")
42+
set_target_properties(letmecreate_bosch PROPERTIES C_VISIBILITY_PRESET hidden)
3243
set_target_properties(letmecreate_core PROPERTIES C_VISIBILITY_PRESET hidden)
3344
set_target_properties(letmecreate_click PROPERTIES C_VISIBILITY_PRESET hidden)
45+
set_target_properties(letmecreate_rpisensehat PROPERTIES C_VISIBILITY_PRESET hidden)
3446

3547
# Enable warnings
3648
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -ggdb3")
@@ -47,6 +59,16 @@ target_include_directories(
4759
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
4860
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
4961
)
62+
target_include_directories(
63+
letmecreate_bosch PUBLIC
64+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
65+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
66+
)
67+
target_include_directories(
68+
letmecreate_rpisensehat PUBLIC
69+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
70+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
71+
)
5072

5173

5274
set(config_install_dir "lib/cmake/${PROJECT_NAME}")
@@ -73,7 +95,7 @@ configure_package_config_file(
7395
)
7496

7597
install(
76-
TARGETS letmecreate_core letmecreate_click
98+
TARGETS letmecreate_core letmecreate_click letmecreate_bosch letmecreate_rpisensehat
7799
EXPORT "${targets_export_name}"
78100
LIBRARY DESTINATION "lib"
79101
ARCHIVE DESTINATION "lib"

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.2.0
41+
PROJECT_NUMBER = 1.3.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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,30 @@ MikroClick board supported:
3030
- ADC
3131
- Air quality
3232
- Alcohol
33+
- Alphanum
3334
- Bargraph
3435
- CO
3536
- Color
3637
- Color2
3738
- EVE
39+
- Fan
40+
- GYRO
3841
- IR distance
3942
- IR eclipse
4043
- Joystick
44+
- Light
4145
- Motion
46+
- OLED
4247
- Opto
4348
- Proximity
4449
- Relay (partial support)
4550
- Relay2
4651
- Relay4 (partial support)
52+
- RTC
4753
- Thermo3
54+
- Weather
55+
56+
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).
4857

4958
Examples are installed in /usr/bin/letmecreate_examples.
5059
Tests are installed in /usr/bin/letmecreate_tests.

examples/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,15 @@ install(TARGETS letmecreate_eve_3_example RUNTIME DESTINATION bin)
7373
add_executable(letmecreate_eve_4_example eve/main4.c)
7474
target_link_libraries(letmecreate_eve_4_example letmecreate_click letmecreate_core)
7575
install(TARGETS letmecreate_eve_4_example RUNTIME DESTINATION bin)
76+
77+
add_executable(letmecreate_rtc_example rtc/main.c)
78+
target_link_libraries(letmecreate_rtc_example letmecreate_click letmecreate_core)
79+
install(TARGETS letmecreate_rtc_example RUNTIME DESTINATION bin)
80+
81+
add_executable(letmecreate_alphanum_example alphanum/main.c $<TARGET_OBJECTS:examples_common>)
82+
target_link_libraries(letmecreate_alphanum_example letmecreate_click letmecreate_core)
83+
install(TARGETS letmecreate_alphanum_example RUNTIME DESTINATION bin)
84+
85+
add_executable(letmecreate_oled_example oled/main.c)
86+
target_link_libraries(letmecreate_oled_example letmecreate_click letmecreate_core)
87+
install(TARGETS letmecreate_oled_example RUNTIME DESTINATION bin)

examples/alphanum/main.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* This example shows how to use the Alphanum Click wrapper of the LetMeCreate
3+
* to display characters.
4+
*
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.
8+
*
9+
* The Alphanum Click must be inserted in Mikrobus 1 before running this
10+
* program.
11+
*/
12+
13+
14+
#include <signal.h>
15+
#include <stdbool.h>
16+
#include <stdio.h>
17+
#include <letmecreate/letmecreate.h>
18+
#include "examples/common.h"
19+
20+
static volatile bool running = true;
21+
22+
static void exit_program(int __attribute__ ((unused))signo)
23+
{
24+
running = false;
25+
}
26+
27+
int main(void)
28+
{
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+
39+
spi_init();
40+
spi_select_bus(MIKROBUS_1);
41+
42+
if (alphanum_click_init(MIKROBUS_1) < 0)
43+
return 1;
44+
45+
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+
}
57+
58+
spi_release();
59+
60+
return 0;
61+
}

examples/oled/main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* This example shows how to use the OLED Click wrapper of the LetMeCreate library.
3+
*
4+
* It displays some text for three seconds and then, it exits.
5+
*
6+
* The OLED Click must be inserted in Mikrobus 1 before running this program.
7+
* In addition, the OLED Click must be configured to use I2C.
8+
*/
9+
10+
#include <stdio.h>
11+
#include <unistd.h>
12+
#include <letmecreate/letmecreate.h>
13+
14+
int main(void)
15+
{
16+
i2c_init();
17+
oled_click_enable(MIKROBUS_1);
18+
oled_click_write_text("Hello Creator!");
19+
sleep(3);
20+
oled_click_disable();
21+
i2c_release();
22+
23+
return 0;
24+
}

examples/relay2/main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ int main(void)
77
while (1) {
88
switch (counter % 4) {
99
case 0:
10-
relay2_click_disable_relay_1(MIKROBUS_1);
11-
relay2_click_disable_relay_2(MIKROBUS_1);
10+
relay2_click_disable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_1);
11+
relay2_click_disable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_1);
1212
break;
1313
case 1:
14-
relay2_click_enable_relay_1(MIKROBUS_1);
15-
relay2_click_disable_relay_2(MIKROBUS_1);
14+
relay2_click_enable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_1);
15+
relay2_click_disable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_2);
1616
break;
1717
case 2:
18-
relay2_click_disable_relay_1(MIKROBUS_1);
19-
relay2_click_enable_relay_2(MIKROBUS_1);
18+
relay2_click_disable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_1);
19+
relay2_click_enable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_2);
2020
break;
2121
case 3:
22-
relay2_click_enable_relay_1(MIKROBUS_1);
23-
relay2_click_enable_relay_2(MIKROBUS_1);
22+
relay2_click_enable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_1);
23+
relay2_click_enable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_2);
2424
break;
2525
}
2626

examples/rtc/main.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* This example shows how to use the RTC Click wrapper of the LetMeCreate to
3+
* obtain the current date.
4+
*
5+
* It sets the date to Friday 28th October, 9:44:0. Then, it prints the current
6+
* date read from the RTC Click every second. Ctrl+C must be pressed to exit
7+
* the program.
8+
*
9+
* The RTC Click must be inserted in Mikrobus 1 before running this program.
10+
*/
11+
12+
#include <signal.h>
13+
#include <stdbool.h>
14+
#include <stdio.h>
15+
#include <unistd.h>
16+
#include <letmecreate/letmecreate.h>
17+
18+
19+
static char *weekday_str[] = {
20+
"Monday",
21+
"Tuesday",
22+
"Wednesday",
23+
"Thursday",
24+
"Friday",
25+
"Saturday",
26+
"Sunday"
27+
};
28+
29+
static char *month_str[] = {
30+
"January",
31+
"Februay",
32+
"March",
33+
"April",
34+
"May",
35+
"June",
36+
"July",
37+
"August",
38+
"September",
39+
"October",
40+
"November",
41+
"December"
42+
};
43+
44+
static volatile bool running = true;
45+
46+
static void exit_program(int __attribute__ ((unused))signo)
47+
{
48+
running = false;
49+
}
50+
51+
int main(void)
52+
{
53+
struct date date = {
54+
.second = 0,
55+
.minute = 44,
56+
.hour = 9,
57+
.weekday = FRIDAY,
58+
.day = 28,
59+
.month = OCTOBER,
60+
.year = 2016
61+
};
62+
struct sigaction action = {
63+
.sa_handler = exit_program,
64+
.sa_flags = 0
65+
};
66+
sigemptyset(&action.sa_mask);
67+
sigaction (SIGINT, &action, NULL);
68+
69+
i2c_init();
70+
rtc_click_init(2016);
71+
rtc_click_set_date(date);
72+
73+
while (running) {
74+
rtc_click_get_date(&date);
75+
printf("%s %u %s %u, %u:%u:%u\n", weekday_str[date.weekday],
76+
date.day,
77+
month_str[date.month],
78+
date.year,
79+
date.hour, date.minute, date.second);
80+
sleep(1);
81+
}
82+
83+
i2c_release();
84+
85+
return 0;
86+
}

0 commit comments

Comments
 (0)