Skip to content

Commit 3d06849

Browse files
authored
Merge pull request #10 from J-Rios/development
Version v1.2.0 (command setup and callbacks)
2 parents 41c24b6 + 9a4ba69 commit 3d06849

File tree

123 files changed

+7781
-401
lines changed

Some content is hidden

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

123 files changed

+7781
-401
lines changed

.github/workflows/build_avr.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
branches:
66
- main
7+
- development
78

89
jobs:
910
build_avr:
@@ -26,6 +27,11 @@ jobs:
2627
sudo apt-get -y install cflow
2728
- name: Build
2829
run: |
29-
cd examples/avr/basic_usage/build
30+
cd examples/avr/
31+
cd basic_usage/build/
32+
make clean
33+
make build DEVICE=atmega328p F_CPU=16000000L
34+
cd ../../
35+
cd basic_usage_callbacks/build/
3036
make clean
3137
make build DEVICE=atmega328p F_CPU=16000000L

.github/workflows/build_linux.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
branches:
66
- main
7+
- development
78

89
jobs:
910
build_linux:
@@ -26,6 +27,11 @@ jobs:
2627
sudo apt-get -y install cflow
2728
- name: Build
2829
run: |
29-
cd examples/linux/basic_usage/build
30+
cd examples/linux/
31+
cd basic_usage/build/
32+
make clean
33+
make build
34+
cd ../../
35+
cd basic_usage_callbacks/build/
3036
make clean
3137
make build

.github/workflows/build_pio_arduino.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ on:
44
pull_request:
55
branches:
66
- main
7+
- development
78

89
jobs:
910
build_pio_arduino:
1011

1112
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
example: [examples/arduino/basic_usage/src/main.cpp]
15-
1613
steps:
1714
- uses: actions/checkout@v2
1815
- name: Cache pip
@@ -33,6 +30,10 @@ jobs:
3330
python -m pip install --upgrade pip
3431
pip install --upgrade platformio
3532
- name: Run PlatformIO
36-
run: pio ci --project-conf="examples/arduino/basic_usage/platformio.ini"
37-
env:
38-
PLATFORMIO_CI_SRC: ${{ matrix.example }}
33+
run: |
34+
pio run -c examples/arduino/platformio.ini \
35+
-d examples/arduino/basic_usage \
36+
-e arduino_uno_atmega328 -e arduino_esp32 -e arduino_esp8266
37+
pio run -c examples/arduino/platformio.ini \
38+
-d examples/arduino/basic_usage_callbacks \
39+
-e arduino_uno_atmega328 -e arduino_esp32 -e arduino_esp8266

.github/workflows/build_pio_espidf.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ on:
44
pull_request:
55
branches:
66
- main
7+
- development
78

89
jobs:
910
build_pio_espidf:
1011

1112
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
example: [examples/espidf/basic_usage/src/main.cpp]
15-
1613
steps:
1714
- uses: actions/checkout@v2
1815
- name: Cache pip
@@ -33,6 +30,10 @@ jobs:
3330
python -m pip install --upgrade pip
3431
pip install --upgrade platformio
3532
- name: Run PlatformIO
36-
run: pio ci --project-conf="examples/espidf/basic_usage/platformio.ini"
37-
env:
38-
PLATFORMIO_CI_SRC: ${{ matrix.example }}
33+
run: |
34+
pio run -c examples/espidf/platformio.ini \
35+
-d examples/espidf/basic_usage \
36+
-e espidf_esp32 -e espidf_esp32_c3
37+
pio run -c examples/espidf/platformio.ini \
38+
-d examples/espidf/basic_usage_callbacks \
39+
-e espidf_esp32 -e espidf_esp32_c3

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
**/*.hex
1010
**/memory_ram.txt
1111
**/memory_program.txt
12+
13+
build/
14+
src/main.cpp
15+
src/main.c

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.rulers": [ 79 ]
3+
}

README.md

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,63 @@ hal/newdev
2929

3030
**Note:** Use any of the other device support implementation of minbasecli_X.h/cpp files as example to edit.
3131

32-
2. Include new device support sources in "minbasecli.h" using an existing global define that allows to know wich device/framework is being compiled (this define should exists in some way in device framework, otherwise, you need to pass it to the compiler at build time, i.e. using -DMY_NEW_DEV for gcc compiler):
32+
2. Include new device support sources in "minbasecli_hal_select.h" using an existing global define that allows to know which device/framework is being compiled (this define should exists in some way in device framework, otherwise, you need to pass it to the compiler at build time, i.e. using -DMY_NEW_DEV for gcc compiler):
3333

3434
```c++
3535

3636
/* ... */
3737

38-
/* Use Specific HAL for build system */
39-
40-
#if defined(__linux__)
41-
#include "hal/linux/minbasecli_linux.h"
42-
#define MINBASECLI_HAL MINBASECLI_LINUX
43-
#elif defined(_WIN32) || defined(_WIN64)
44-
#include "hal/windows/minbasecli_windows.h"
45-
#define MINBASECLI_HAL MINBASECLI_WINDOWS
46-
#elif defined(ARDUINO)
47-
#include "hal/arduino/minbasecli_arduino.h"
48-
#define MINBASECLI_HAL MINBASECLI_ARDUINO
49-
#elif defined(__AVR)
50-
#include "hal/avr/minbasecli_avr.h"
51-
#define MINBASECLI_HAL MINBASECLI_AVR
52-
#elif defined(ESP_PLATFORM)
53-
#include "hal/espidf/minbasecli_espidf.h"
54-
#define MINBASECLI_HAL MINBASECLI_ESPIDF
55-
#elif defined(MY_NEW_DEV) // This has been include
56-
#include "hal/newdev/minbasecli_newdev.h" // This has been include
57-
#define MINBASECLI_HAL MINBASECLI_NEWDEV // This has been include
58-
#else
59-
#warning "minbasecli - Unsupported device/system."
60-
#define HAL_NONE
61-
#include "hal/none/minbasecli_none.h"
62-
#define MINBASECLI_HAL MINBASECLI_NONE
63-
#endif
38+
/*****************************************************************************/
39+
40+
/* Hardware Abstraction Layer: NewDevice */
41+
42+
#elif defined(MY_NEW_DEV)
43+
44+
// Interface HAL Selection
45+
#include "hal/newdev/minbasecli_newdev.h"
46+
#define MINBASECLI_HAL MINBASECLI_NEWDEV
47+
48+
// Default CLI Baud Rate Speed to use if not provided
49+
#if !defined(MINBASECLI_DEFAULT_BAUDS)
50+
#define MINBASECLI_DEFAULT_BAUDS 115200
51+
#endif
52+
53+
// Maximum CLI read buffer size
54+
#if !defined(MINBASECLI_MAX_READ_SIZE)
55+
#define MINBASECLI_MAX_READ_SIZE 64
56+
#endif
57+
58+
// Maximum CLI Command length
59+
#if !defined(MINBASECLI_MAX_CMD_LEN)
60+
#define MINBASECLI_MAX_CMD_LEN 24
61+
#endif
62+
63+
// Maximum CLI Command Argument length
64+
#if !defined(MINBASECLI_MAX_ARGV_LEN)
65+
#define MINBASECLI_MAX_ARGV_LEN 32
66+
#endif
67+
68+
// Maximum number of arguments to check on a received CLI command
69+
#if !defined(MINBASECLI_MAX_ARGV)
70+
#define MINBASECLI_MAX_ARGV 4
71+
#endif
72+
73+
// Maximum Print formatted number array size
74+
#if !defined(MINBASECLI_MAX_PRINT_SIZE)
75+
#define MINBASECLI_MAX_PRINT_SIZE 22
76+
#endif
77+
78+
// Maximum number of commands that can be added to the CLI
79+
#if !defined(MINBASECLI_MAX_CMD_TO_ADD)
80+
#define MINBASECLI_MAX_CMD_TO_ADD 16
81+
#endif
82+
83+
// Maximum length of command description text
84+
#if !defined(MINBASECLI_MAX_CMD_DESCRIPTION)
85+
#define MINBASECLI_MAX_CMD_DESCRIPTION 64
86+
#endif
87+
88+
/*****************************************************************************/
6489

6590
/* ... */
6691

examples/arduino/basic_usage/platformio.ini

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
[platformio]
1111
default_envs = arduino_esp32 ; Build ESP32 with Arduino Framework
12+
;default_envs = arduino_esp32_c3 ; Build ESP32-C3 with Arduino Framework
1213
;default_envs = arduino_esp8266 ; Build ESP8266 with Arduino Framework
1314
;default_envs = arduino_uno_atmega328 ; Build Arduino Uno with Arduino Framework
1415
;default_envs = arduino_mega_atmega2560 ; Build Arduino Mega with Arduino Framework
@@ -19,51 +20,58 @@ default_envs = arduino_esp32 ; Build ESP32 with Arduino Framework
1920
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2021

2122
[env]
22-
lib_deps = minbasecli@1.1.1
23+
lib_deps = minbasecli
2324

2425
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2526

2627
; Arduino Build Configs
2728

2829
; ESP32 Arduino
2930
[env:arduino_esp32]
30-
platform = espressif32@3.5.0
31+
platform = espressif32@5.0.0
3132
board = esp32dev
3233
framework = arduino
3334

35+
; ESP32-C3 Arduino
36+
[env:arduino_esp32_c3]
37+
38+
board = esp32-c3-devkitm-1
39+
framework = arduino
40+
board_build.mcu = esp32c3
41+
3442
; ESP8266 Arduino
3543
[env:arduino_esp8266]
36-
platform = espressif8266@3.2.0
44+
platform = espressif8266@4.0.1
3745
board = esp12e
3846
framework = arduino
3947

4048
; Arduino Uno (atmega328)
4149
[env:arduino_uno_atmega328]
42-
platform = atmelavr@3.3.0
50+
platform = atmelavr@4.0.0
4351
board = uno
4452
framework = arduino
4553

4654
; Arduino Mega (atmega2560)
4755
[env:arduino_mega_atmega2560]
48-
platform = atmelavr@3.3.0
56+
platform = atmelavr@4.0.0
4957
board = megaatmega2560
5058
framework = arduino
5159

5260
; Arduino Nano (atmega168)
5361
[env:arduino_nano_atmega168]
54-
platform = atmelavr@3.3.0
62+
platform = atmelavr@4.0.0
5563
board = nanoatmega168
5664
framework = arduino
5765

5866
; Arduino Nano (atmega328)
5967
[env:arduino_nano_atmega328]
60-
platform = atmelavr@3.3.0
68+
platform = atmelavr@4.0.0
6169
board = nanoatmega328
6270
framework = arduino
6371

6472
; Arduino Pro Micro (atmega32u4)
6573
[env:arduino_micro_atmega32u4]
66-
platform = atmelavr@3.3.0
74+
platform = atmelavr@4.0.0
6775
board = micro
6876
framework = arduino
6977
;build_flags = -DUSBCON=1

examples/arduino/basic_usage/src/main.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @file examples/arduino/basic_usage/basic_usage.ino
2+
* @file examples/arduino/basic_usage/src/main.cpp
33
* @author Jose Miguel Rios Rubio <[email protected]>
4-
* @date 02-04-2022
5-
* @version 1.0.1
4+
* @date 05-03-2023
5+
* @version 1.0.3
66
*
77
* @section DESCRIPTION
88
*
@@ -75,7 +75,7 @@ void setup()
7575
Serial.begin(SERIAL_BAUDS);
7676

7777
// CLI init to use Serial as interface
78-
Cli.setup(&Serial);
78+
Cli.setup(&Serial, SERIAL_BAUDS);
7979
Cli.printf("\nCommand Line Interface is ready\n\n");
8080
}
8181

@@ -84,58 +84,58 @@ void loop()
8484
t_cli_result cli_read;
8585

8686
// If any command was received
87-
if(Cli.manage(&cli_read))
87+
if (Cli.manage(&cli_read))
8888
{
8989
// Show read result element
9090
Cli.printf("Command received: %s\n", cli_read.cmd);
91-
Cli.printf("Number of arguments: %d\n", (int)(cli_read.argc));
92-
for(int i = 0; i < cli_read.argc; i++)
93-
Cli.printf(" Argument %d: %s", i, cli_read.argv[i]);
91+
Cli.printf("Number of arguments: %d\n"), (int)(cli_read.argc);
92+
for (int i = 0; i < cli_read.argc; i++)
93+
{ Cli.printf(" Argument %d: %s", i, cli_read.argv[i]); }
9494
Cli.printf("\n");
9595

9696
// Handle Commands
97-
if(strcmp(cli_read.cmd, "help") == 0)
97+
if (strcmp(cli_read.cmd, "help") == 0)
9898
{
9999
Cli.printf("Available Commands:\n");
100100
Cli.printf(" help - Current info.\n");
101-
Cli.printf(" led [on/off] - Turn LED ON or OFF\n");
102-
Cli.printf(" version - Shows current firmware version\n");
101+
Cli.printf(" led [on/off] - Turn LED ON or OFF.\n");
102+
Cli.printf(" version - Shows current firmware version.\n");
103103
}
104-
else if(strcmp(cli_read.cmd, "led") == 0)
104+
else if (strcmp(cli_read.cmd, "led") == 0)
105105
{
106106
bool invalid_argv = false;
107107
char* led_mode = NULL;
108108

109109
// Check for argument
110-
if(cli_read.argc == 0)
111-
invalid_argv = true;
110+
if (cli_read.argc == 0)
111+
{ invalid_argv = true; }
112112
else
113113
{
114114
led_mode = cli_read.argv[0];
115-
if(strcmp(led_mode, "on") == 0)
115+
if (strcmp(led_mode, "on") == 0)
116116
{
117117
Cli.printf("Turning LED ON.\n");
118118
digitalWrite(COMMAND_LED, HIGH);
119119
}
120-
else if(strcmp(led_mode, "off") == 0)
120+
else if (strcmp(led_mode, "off") == 0)
121121
{
122122
Cli.printf("Turning LED OFF.\n");
123123
digitalWrite(COMMAND_LED, LOW);
124124
}
125125
else
126-
invalid_argv = true;
126+
{ invalid_argv = true; }
127127
}
128128

129-
if(invalid_argv)
130-
Cli.printf("led command needs \"on\" or \"off\" arg.\n");
129+
if (invalid_argv)
130+
{ Cli.printf("led command needs \"on\" or \"off\" arg.\n"); }
131131
}
132-
else if(strcmp(cli_read.cmd, "version") == 0)
132+
else if (strcmp(cli_read.cmd, "version") == 0)
133133
{
134134
Cli.printf("FW App Version: %s\n", FW_APP_VERSION);
135135
}
136136
// ...
137137
else
138-
Cli.printf("Unkown command.\n");
138+
{ Cli.printf("Unkown command.\n"); }
139139
Cli.printf("\n");
140140
}
141141
}

0 commit comments

Comments
 (0)