Skip to content

Commit

Permalink
Update to version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-rabault committed Oct 20, 2023
1 parent 1f1e328 commit 62fec02
Show file tree
Hide file tree
Showing 34 changed files with 195 additions and 167 deletions.
6 changes: 3 additions & 3 deletions Apps/Blinker_app/blinker.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ volatile time_luos_t blinktime;
unsigned long my_time; // Used to keep track of time
volatile control_t control_app;

static void Blinker_MsgHandler(service_t *service, msg_t *msg);
static void Blinker_MsgHandler(service_t *service, const msg_t *msg);

void Blinker_Init(void)
{
Expand Down Expand Up @@ -70,7 +70,7 @@ void Blinker_Loop(void)
}
}

static void Blinker_MsgHandler(service_t *service, msg_t *msg)
static void Blinker_MsgHandler(service_t *service, const msg_t *msg)
{
if (msg->header.cmd == CONTROL)
{
Expand All @@ -83,4 +83,4 @@ static void Blinker_MsgHandler(service_t *service, msg_t *msg)
TimeOD_TimeFromMsg((time_luos_t *)&blinktime, msg);
return;
}
}
}
31 changes: 19 additions & 12 deletions Apps/Blinker_app/blinker.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
#ifndef BOOTLOADER_H
#define BOOTLOADER_H

#ifdef __cplusplus
extern "C"
{
#endif
#include "luos_engine.h"

/*******************************************************************************
* Definitions
******************************************************************************/
/*******************************************************************************
* Definitions
******************************************************************************/

/*******************************************************************************
* Variables
******************************************************************************/
/*******************************************************************************
* Variables
******************************************************************************/

/*******************************************************************************
* Function
******************************************************************************/
void Blinker_Init(void);
void Blinker_Loop(void);
/*******************************************************************************
* Function
******************************************************************************/
void Blinker_Init(void);
void Blinker_Loop(void);

#endif /* LED_H */
#ifdef __cplusplus
}
#endif
#endif /* LED_H */
9 changes: 6 additions & 3 deletions Arduino/lib/Led/led.c → Arduino/lib/Led/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/*******************************************************************************
* Function
******************************************************************************/
static void Led_MsgHandler(service_t *service, msg_t *msg);
static void Led_MsgHandler(service_t *service, const msg_t *msg);

/******************************************************************************
* @brief init must be call in project init
Expand All @@ -28,7 +28,10 @@ void Led_Init(void)
{
pinMode(LED_BUILTIN, OUTPUT);

revision_t revision = {.major = 1, .minor = 0, .build = 0};
revision_t revision;
revision.major = 1;
revision.minor = 0;
revision.build = 0;
Luos_CreateService(Led_MsgHandler, STATE_TYPE, "led", revision);
}
/******************************************************************************
Expand All @@ -43,7 +46,7 @@ void Led_Loop(void) {}
* @param Msg receive
* @return None
******************************************************************************/
static void Led_MsgHandler(service_t *service, msg_t *msg)
static void Led_MsgHandler(service_t *service, const msg_t *msg)
{
if (msg->header.cmd == IO_STATE)
{
Expand Down
5 changes: 3 additions & 2 deletions Arduino/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ build_flags =
-O1
-include node_config.h
-D LUOSHAL=ATSAMD21_ARDUINO
-D ROBUSHAL=ATSAMD21_ARDUINO
-D GATEFORMAT=TinyJSON
-D PIPEMODE=SERIAL
-D PIPEHAL=ARDUINO
lib_deps =
luos_engine@^2.9.2
luos_engine@^3.0.0
robus_network
Led
Blinker_App
Pipe
Gate
Inspector
lib_extra_dirs =
$PROJECT_DIR/../Apps
lib
Expand Down
13 changes: 3 additions & 10 deletions Arduino/src/Arduino.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
#include <Arduino.h>

#ifdef __cplusplus
extern "C"
{
#endif

#include "luos_engine.h"
#include "led.h"
#include "blinker.h"
#include "pipe.h"
#include "gate.h"

#ifdef __cplusplus
}
#endif
#include "robus_network.h"

/******************************************************************************
* @brief Setup ardiuno
Expand All @@ -23,6 +14,7 @@ extern "C"
void setup()
{
Luos_Init();
Robus_Init();
Led_Init();
Pipe_Init();
Gate_Init();
Expand All @@ -36,6 +28,7 @@ void setup()
void loop()
{
Luos_Loop();
Robus_Loop();
Led_Loop();
Pipe_Loop();
Gate_Loop();
Expand Down
10 changes: 5 additions & 5 deletions ESP32-DevKit/lib/Led/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(srcs "led.c")
set(srcs "led")

set(inc ".")
set(inc ".")

idf_component_register( SRCS ${srcs}
INCLUDE_DIRS ${inc}
REQUIRES luos_engine led_strip)
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${inc}
REQUIRES luos_engine)
8 changes: 4 additions & 4 deletions ESP32-DevKit/lib/Led/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ https://github.com/Luos-io/examples/blob/master/LICENSE)
[![](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Unleash%20electronic%20devices%20as%20microservices%20thanks%20to%20Luos&https://luos.io&via=Luos_io&hashtags=embeddedsystems,electronics,microservices,api)
[![](https://img.shields.io/badge/LinkedIn-Share-0077B5?style=social&logo=linkedin)](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgithub.com%2Fluos-io)

# Button driver
Driver for using a push button in your projects with Luos.
# Led driver
Driver for using a led in your projects with Luos.

# Linked project
This driver is linked to the [Button project](../../Projects/button).
This driver is linked to the [led project](../../Projects/led).

[![](https://img.shields.io/discourse/topics?server=https%3A%2F%2Fcommunity.luos.io&logo=Discourse)](https://community.luos.io)
[![](https://img.shields.io/badge/Luos-Documentation-34A3B4)](https://docs.luos.io)
[![](https://img.shields.io/badge/Luos-Documentation-34A3B4)](https://www.luos.io/docs/)
[![](https://img.shields.io/badge/LinkedIn-Follow%20us-0077B5?style=flat&logo=linkedin)](https://www.linkedin.com/company/luos)
10 changes: 5 additions & 5 deletions ESP32-DevKit/lib/Led/led.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/******************************************************************************
* @file led
* @brief driver example a simple led
* @file button
* @brief driver example a simple button
* @author Luos
* @version 0.0.0
******************************************************************************/
#ifndef LED_H
#define LED_H
#ifndef BUTTON_H
#define BUTTON_H

#include "luos_engine.h"
/*******************************************************************************
Expand All @@ -22,4 +22,4 @@
void Led_Init(void);
void Led_Loop(void);

#endif /* LED_H */
#endif /* BUTTON_H */
8 changes: 4 additions & 4 deletions ESP32-DevKit/lib/Led/library.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "led",
"keywords": "robus,network,microservice,luos,operating system,os,embedded,communication,container,ST",
"description": "a simple button driver",
"keywords": "robus,network,microservice,luos,operating system,os,embedded,communication,service,ST",
"description": "a simple led driver",
"version": "1.0.0",
"authors": {
"name": "Luos",
"url": "https://luos.io"
},
"licence": "MIT",
"dependencies": {
"luos/luos_engine": "^2.9.0"
"luos_engine": "^3.0.0"
}
}
}
61 changes: 15 additions & 46 deletions ESP32-DevKit/lib/Led/led.c → ESP32-DevKit/lib/led/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,34 @@
* @author Luos
* @version 0.0.0
******************************************************************************/
#include <Arduino.h>
#include "led.h"
#include "driver/gpio.h"

#ifndef CONFIG_IDF_TARGET_ESP32
#include "led_strip.h"
#endif

/*******************************************************************************
* Definitions
******************************************************************************/
#ifdef CONFIG_IDF_TARGET_ESP32
#define LED_GPIO (GPIO_NUM_18)
#else
#define LED_GPIO (GPIO_NUM_8)
static led_strip_t *pStrip_a;
#endif
#define LED_PIN 18
/*******************************************************************************
* Variables
******************************************************************************/
uint8_t Led_last_state = 0;

/*******************************************************************************
* Function
******************************************************************************/
static void Led_MsgHandler(service_t *service, msg_t *msg);
static void Led_MsgHandler(service_t *service, const msg_t *msg);
/******************************************************************************
* @brief init must be call in project init
* @param None
* @return None
******************************************************************************/
void Led_Init(void)
{
revision_t revision = {.major = 1, .minor = 0, .build = 0};
#ifdef CONFIG_IDF_TARGET_ESP32
gpio_config_t LedConfig;

gpio_reset_pin(LED_GPIO);
LedConfig.intr_type = GPIO_INTR_DISABLE;
LedConfig.mode = GPIO_MODE_OUTPUT;
LedConfig.pin_bit_mask = (1ULL << LED_GPIO);
LedConfig.pull_down_en = GPIO_PULLDOWN_DISABLE;
LedConfig.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&LedConfig);
revision_t revision;
revision.major = 1;
revision.minor = 0;
revision.build = 0;
pinMode(LED_PIN, OUTPUT);
Luos_CreateService(Led_MsgHandler, STATE_TYPE, "led", revision);
#else
pStrip_a = led_strip_init(0, LED_GPIO, 1);
pStrip_a->set_pixel(pStrip_a, 0, 0, 0, 0);
pStrip_a->refresh(pStrip_a, 50);
Luos_CreateService(Led_MsgHandler, COLOR_TYPE, "led_rgb", revision);
#endif
}
/******************************************************************************
* @brief loop must be call in project loop
Expand All @@ -69,26 +47,17 @@ void Led_Loop(void)
* @param Msg receive
* @return None
******************************************************************************/
static void Led_MsgHandler(service_t *service, msg_t *msg)
static void Led_MsgHandler(service_t *service, const msg_t *msg)
{
#ifdef CONFIG_IDF_TARGET_ESP32
if (msg->header.cmd == IO_STATE)
{
if (msg->data[0] != Led_last_state)
if (msg->data[0] == 0)
{
Led_last_state = msg->data[0];
gpio_set_level(LED_GPIO, Led_last_state);
digitalWrite(LED_PIN, false);
}
else
{
digitalWrite(LED_PIN, true);
}
}
#else
color_t rgb;
if (msg->header.cmd == COLOR)
{
IlluminanceOD_ColorFromMsg((color_t *)&rgb, msg);
/* Set the LED pixel using RGB from 0 (0%) to 255 (100%) for each color */
pStrip_a->set_pixel(pStrip_a, 0, rgb.r, rgb.g, rgb.b);
/* Refresh the strip to send data */
pStrip_a->refresh(pStrip_a, 50);
}
#endif
}
9 changes: 4 additions & 5 deletions ESP32-DevKit/node_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
* NBR_RETRY | 10 | Send Retry number in case of NACK or collision
******************************************************************************/

#define MSG_BUFFER_SIZE 1024
#define PIPE_SERIAL_BAUDRATE 115200
#define DEFAULTBAUDRATE 500000
#define MSG_BUFFER_SIZE 1024
#define PIPE_SERIAL_BAUDRATE 115200
#define ROBUS_NETWORK_BAUDRATE 500000

/*******************************************************************************
* LUOS HAL LIBRARY DEFINITION
Expand Down Expand Up @@ -98,13 +98,12 @@
*******************************************************************************
* Define | Default Value | Description
* :-------------------------|------------------------------------------------------
* MAX_RTB_ENTRY | 40 | max number entry in routing table
* MAX_NODE_NUMBER | 20 | max number of node in the network
* GATE_BUFF_SIZE | 1024 | Json receive buffer size
* PIPE_TX_BUFFER_SIZE | 1024 | Receive pipe buffer size
* PIPE_RX_BUFFER_SIZE | 2048 | Transmit pipe buffer size
* INIT_TIME | 150 | Wait init time before first detection
******************************************************************************/
#define MAX_RTB_ENTRY 40
#define GATE_BUFF_SIZE 2048
#define PIPE_RX_BUFFER_SIZE 2048
#define PIPE_TX_BUFFER_SIZE 4096
Expand Down
5 changes: 3 additions & 2 deletions ESP32-DevKit/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ build_flags =
-O1
-include node_config.h
-D LUOSHAL=ESP32
-D ROBUSHAL=ESP32
-D GATEFORMAT=TinyJSON
-D PIPEMODE=SERIAL
-D PIPEHAL=ARDUINO
lib_deps =
luos_engine@^2.9.2
luos_engine@^3.0.0
robus_network
Led
Blinker_App
Pipe
Gate
Inspector
lib_extra_dirs =
$PROJECT_DIR/../Apps
lib
Expand Down
Loading

0 comments on commit 62fec02

Please sign in to comment.