Skip to content

Commit c22a2c8

Browse files
Merge branch 'dev'
2 parents 1160b79 + 21c2804 commit c22a2c8

Some content is hidden

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

46 files changed

+479
-449
lines changed

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ env:
44
global:
55
- CI40_SDK="OpenWrt-SDK-0.10.4-pistachio-marduk_gcc-5.3.0_musl-1.1.14.Linux-x86_64"
66
- CI40_SDK_URL="https://downloads.creatordev.io/pistachio/marduk/"
7+
- GIST_LOC="https://gist.githubusercontent.com/francois-berder/0082cf4b5633546edf20af0d9c74053c/raw/81c50a4f6d180721b56822b46a6c787c5e4f84e5/"
78
before_install:
89
- sudo apt-get -qq update
910
- sudo apt-get install -y gnupg git-core build-essential libssl-dev libncurses5-dev unzip gawk subversion mercurial
1011
script:
1112
- mkdir -p $HOME/build/letmecreatefeed/letmecreate && ln -s $TRAVIS_BUILD_DIR $HOME/build/letmecreatefeed/letmecreate/LetMeCreate
12-
- cp $TRAVIS_BUILD_DIR/miscellaneous/Makefile.devel $HOME/build/letmecreatefeed/letmecreate/Makefile
13-
- cp $TRAVIS_BUILD_DIR/miscellaneous/Config.in.devel $HOME/build/letmecreatefeed/letmecreate/Config.in
13+
- cd $HOME/build/letmecreatefeed/letmecreate/
14+
- wget $GIST_LOC/Makefile
15+
- wget $GIST_LOC/Config.in
1416
- export CI40_FILE_URL="$CI40_SDK_URL$CI40_SDK.tar.bz2"
15-
- echo $CI40_FILE_URL
1617
- cd $HOME/build && wget $CI40_FILE_URL && tar xfj $CI40_SDK.tar.bz2
17-
- cd $CI40_SDK && echo src-link custom $HOME/build/letmecreatefeed/ >> feeds.conf.default
18+
- cd $CI40_SDK && sed --in-place '/Creator-feed/d' feeds.conf.default
19+
- echo src-link custom $HOME/build/letmecreatefeed/ >> feeds.conf.default
1820
- ./scripts/feeds update -a && ./scripts/feeds install -a
1921
- make package/letmecreate/compile -j1 V=s

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 3)
7+
set(LETMECREATE_MINOR_VERSION 4)
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.3.0
41+
PROJECT_NUMBER = 1.4.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: 66 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,42 @@
1+
![logo](https://static.creatordev.io/logo-md-s.svg)
2+
13
# LetMeCreate library
24

35
## Build status
46

5-
Master
7+
**Master**
68
[![Build Status](https://travis-ci.org/francois-berder/LetMeCreate.svg?branch=master)](https://travis-ci.org/francois-berder/LetMeCreate)
79

8-
9-
Dev
10+
**Dev**
1011
[![Build Status](https://travis-ci.org/francois-berder/LetMeCreate.svg?branch=dev)](https://travis-ci.org/francois-berder/LetMeCreate)
1112

1213
## Introduction
1314

14-
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.
15-
16-
Interface supported:
17-
- I²C
18-
- SPI
19-
- UART
20-
- LED's
21-
- Switch
22-
- GPIO (Mikrobus and Raspberry Pi interfaces)
23-
- PWM
24-
- ADC
25-
26-
MikroClick board supported:
27-
- 7Seg
28-
- 8x8R (Led Matrix)
29-
- Accel
30-
- ADC
31-
- Air quality
32-
- Alcohol
33-
- Alphanum
34-
- Bargraph
35-
- CO
36-
- Color
37-
- Color2
38-
- EVE
39-
- Fan
40-
- GYRO
41-
- IR distance
42-
- IR eclipse
43-
- Joystick
44-
- Light
45-
- Motion
46-
- OLED
47-
- Opto
48-
- Proximity
49-
- Relay (partial support)
50-
- Relay2
51-
- Relay4 (partial support)
52-
- RTC
53-
- Thermo3
54-
- Weather
15+
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. There exists a Python binding of this library called [PyLetMeCreate](https://github.com/francois-berder/PyLetMeCreate).
16+
17+
Supported interfaces:
18+
19+
|Interface|-|
20+
|:------------| :-------------------|
21+
|I²C|SPI|
22+
|UART|LED's|
23+
|Switch|GPIO (Mikrobus and Raspberry Pi interfaces)|
24+
|PWM| ADC|
25+
26+
MikroClick board supported:
27+
28+
|Interface|||
29+
|:------------|:-------------------|:-------------------|
30+
|7Seg|8x8R (Led Matrix)|Accel|
31+
|ADC|Air quality|Alcohol|
32+
|Alphanum|Bargraph|CO|
33+
|Color|Color2|EVE|
34+
|Fan|GYRO|IR distance|
35+
|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|
5540

5641
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).
5742

@@ -74,66 +59,61 @@ Keep examples very simple and avoid parsing arguments. Examples are there to sho
7459

7560
## Integration in Openwrt
7661

77-
To add new packages, Openwrt relies on feeds: a collection of packages.
78-
79-
### Installation steps
80-
81-
Clone the library and openwrt somewhere on you computer:
62+
The library is already part of Imagination Technologies' OpenWrt.
63+
To compile the library (only possible once you built Openwrt once):
8264

8365
```sh
84-
$ mkdir ci-40
85-
$ cd ci-40
86-
$ git clone https://github.com/CreatorDev/openwrt.git
87-
$ mkdir -p custom/letmecreate
88-
$ cd custom/letmecreate
66+
$ make package/letmecreate/{clean,compile} -j1 V=s
8967
```
9068

91-
#### Stable release
92-
93-
If you are only interested in getting the latest release of LetMeCreate library, then download a copy of Makefile.stable and Config.in.stable located in miscellaneous folder. Copy these files inside the letmecreate folder you have just created and rename it to Makefile and Config.in respectively.
94-
95-
#### Development configuration
69+
### Installation steps
9670

97-
If you are interested in modifying the library, getting the lastest changes, then clone it:
71+
You can install LetMeCreate package on OpenWRT executing:
9872

9973
```sh
100-
$ git clone https://github.com/francois-berder/LetMeCreate.git
74+
$ opkg install letmecreate
10175
```
10276

103-
Copy the Makefile and the Config.in to the right location:
77+
Each release has the ipk as an attachment. You can download the ipk, copy it to your Ci40 and install with opkg:
78+
10479
```sh
105-
$ cp LetMeCreate/miscellaneous/Makefile.devel Makefile
106-
$ cp LetMeCreate/miscellaneous/Config.in.devel Config.in
80+
$ opkg install path-to-the-ipk
10781
```
10882

109-
This project uses two branches. The dev branch contains all the latest changes and should not be considered as stable. The dev branch is sometimes merged to master once new features are considered stable.
83+
### Usage example
84+
```c
85+
/**
86+
* This example shows how to use the Thermo3 Click wrapper of the LetMeCreate
87+
* library.
88+
*
89+
* It reads the temperature from the sensor and exits.
90+
*
91+
* The Thermo3 Click must be inserted in Mikrobus 1 before running this program.
92+
*/
11093

111-
#### Register the library in Openwrt
94+
#include <stdio.h>
95+
#include <letmecreate/letmecreate.h>
11296

113-
To register the feed in openwrt, go back in openwrt folder and open feeds.conf.default.
114-
Add this line:
115-
```
116-
src-link custom /change/this/path/to/the/location/of/ci-40/custom/directory/
117-
```
11897

119-
Update and install all feeds:
120-
```sh
121-
$ ./scripts/feeds update -a
122-
$ ./scripts/feeds install -a
123-
```
124-
In make menuconfig, select Libraries, you should see an entry for letmecreate library:
98+
int main(void)
99+
{
100+
float temperature = 0.f;
125101

126-
![Libraries menu](/miscellaneous/libraries_menu.png)
102+
i2c_init();
103+
i2c_select_bus(MIKROBUS_1);
127104

128-
Select the letmecreate library in make menuconfig, and compile Openwrt:
105+
thermo3_click_enable(0);
106+
thermo3_click_get_temperature(&temperature);
107+
printf("temperature: %.3f°C\n", temperature);
108+
thermo3_click_disable();
129109

130-
```sh
131-
$ make -j1 V=s
132-
```
133-
In the image (a tarball in bin/pistachio), you should see the examples in /usr/bin/letmecreate_examples.
134-
135-
To compile only the library (only possible once you built Openwrt once):
110+
i2c_release();
136111

112+
return 0;
113+
}
114+
```
115+
You can compile the C code example using **GCC**. Execute:
137116
```sh
138-
$ make package/letmecreate/{clean,compile} -j1 V=s
117+
$ gcc thermo3.c -o thermo3 -lletmecreate_core -lletmecreate_click
118+
$ ./thermo3
139119
```

examples/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,7 @@ install(TARGETS letmecreate_alphanum_example RUNTIME DESTINATION bin)
8585
add_executable(letmecreate_oled_example oled/main.c)
8686
target_link_libraries(letmecreate_oled_example letmecreate_click letmecreate_core)
8787
install(TARGETS letmecreate_oled_example RUNTIME DESTINATION bin)
88+
89+
add_executable(letmecreate_rpisensehat_example rpisensehat/main.c)
90+
target_link_libraries(letmecreate_rpisensehat_example letmecreate_rpisensehat letmecreate_core)
91+
install(TARGETS letmecreate_rpisensehat_example RUNTIME DESTINATION bin)

examples/accel/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int main(void)
3535

3636
spi_init();
3737
spi_select_bus(MIKROBUS_1);
38+
accel_click_use_spi();
3839
accel_click_enable();
3940

4041
printf("Press Ctrl+c to exit program.\n");

examples/motion/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
#include "examples/common.h"
1414

1515

16-
void flash_leds(uint8_t __attribute__ ((unused))null)
16+
void flash_leds(uint8_t arg)
1717
{
18+
/* Only flash LED's when motion starts getting detected. */
19+
if (arg != 1)
20+
return;
21+
1822
int x = 0;
1923
for(; x < 10; ++x) {
2024
led_switch_on(ALL_LEDS);

examples/relay2/main.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/**
2+
* This examples shows how to use the Relay2 Click wrapper of the LetMeCreate
3+
*library.
4+
*
5+
* It switches on/off relays in the following order:
6+
* - relay 1 off, relay 2 off
7+
* - relay 1 on, relay 2 off
8+
* - relay 1 off, relay 2 on
9+
* - relay 1 on, relay 2 on
10+
*
11+
* Relay2 Click must be inserted in mikrobus 1 before running this program.
12+
*/
13+
114
#include <unistd.h>
215
#include <letmecreate/letmecreate.h>
316

@@ -8,7 +21,7 @@ int main(void)
821
switch (counter % 4) {
922
case 0:
1023
relay2_click_disable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_1);
11-
relay2_click_disable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_1);
24+
relay2_click_disable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_2);
1225
break;
1326
case 1:
1427
relay2_click_enable_relay(MIKROBUS_1, RELAY2_CLICK_RELAY_1);

examples/rpisensehat/main.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <stdio.h>
2+
#include <unistd.h>
3+
#include <letmecreate/letmecreate.h>
4+
5+
int main(void)
6+
{
7+
float t = 0.f, h = 0.f, p = 0.f;
8+
9+
i2c_init();
10+
rpisensehat_init();
11+
12+
rpisensehat_get_temperature(&t);
13+
rpisensehat_get_humidity(&h);
14+
rpisensehat_get_pressure(&p);
15+
16+
printf("temperature: %f degrees celsius\n", t);
17+
printf("humidity: %f%%\n", h);
18+
printf("pressure: %fhPa\n", p);
19+
20+
rpisensehat_display_rainbow();
21+
22+
sleep(5);
23+
24+
rpisensehat_release();
25+
i2c_release();
26+
27+
return 0;
28+
}

examples/rtc/main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,30 @@
1515
#include <unistd.h>
1616
#include <letmecreate/letmecreate.h>
1717

18+
enum WEEKDAY {
19+
MONDAY,
20+
TUESDAY,
21+
WEDNESDAY,
22+
THURSDAY,
23+
FRIDAY,
24+
SATURDAY,
25+
SUNDAY
26+
};
27+
28+
enum MONTH {
29+
JANUARY,
30+
FEBRUARY,
31+
MARCH,
32+
APRIL,
33+
MAY,
34+
JUNE,
35+
JULY,
36+
AUGUST,
37+
SEPTEMBER,
38+
OCTOBER,
39+
NOVEMBER,
40+
DECEMBER
41+
};
1842

1943
static char *weekday_str[] = {
2044
"Monday",

0 commit comments

Comments
 (0)