Skip to content

Commit

Permalink
XY2_100 protocol up and running
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-rabault committed Jan 19, 2024
1 parent faf3780 commit 9068ad5
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 82 deletions.
46 changes: 24 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- review_requested
push:

concurrency:
concurrency:
group: dev-build-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

Expand Down Expand Up @@ -46,9 +46,9 @@ jobs:
- if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y lcov
lcov -d .pio/build/native/ -c -o lcov.info
lcov --remove lcov.info '*/usr/*' '*/Platforms/*' '*/bootloader/*' '*/.pio/*' '*/HAL/*' '*/test/*' '*/network/*' -o lcov.info
sudo apt-get install -y lcov
lcov -d .pio/build/native/ -c -o lcov.info
lcov --remove lcov.info '*/usr/*' '*/Platforms/*' '*/bootloader/*' '*/.pio/*' '*/HAL/*' '*/test/*' '*/network/*' -o lcov.info
- if: matrix.os == 'ubuntu-latest'
name: Coveralls
Expand All @@ -59,8 +59,7 @@ jobs:
needs: tests-run
runs-on: ubuntu-latest
steps:
- run: echo "Tests succeed!"

- run: echo "Tests succeed!"

code-format:
name: Code format
Expand All @@ -77,7 +76,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: "14"

- name: Install dependencies
run: npm install -g [email protected]
Expand All @@ -90,20 +89,23 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
project_folders: [examples/projects/l0,
examples/projects/Arduino,
examples/projects/NUCLEO-L432KC,
examples/projects/STM32F4-discovery,
examples/projects/NUCLEO-F401RE,
examples/projects/NUCLEO-F410RB,
examples/projects/NUCLEO-G431KB,
examples/projects/NUCLEO-G474RE,
examples/projects/NUCLEO-F072RB,
examples/projects/NUCLEO-L073RZ,
examples/projects/STM32L4S5_discovery,
examples/projects/ESP32,
examples/projects/native
]
project_folders:
[
examples/projects/l0,
examples/projects/Arduino,
examples/projects/NUCLEO-L432KC,
examples/projects/NUCLEO-L476RG,
examples/projects/STM32F4-discovery,
examples/projects/NUCLEO-F401RE,
examples/projects/NUCLEO-F410RB,
examples/projects/NUCLEO-G431KB,
examples/projects/NUCLEO-G474RE,
examples/projects/NUCLEO-F072RB,
examples/projects/NUCLEO-L073RZ,
examples/projects/STM32L4S5_discovery,
examples/projects/ESP32,
examples/projects/native,
]
os: [macos-latest, windows-latest, ubuntu-latest]

steps:
Expand Down Expand Up @@ -152,4 +154,4 @@ jobs:
needs: examples-build
runs-on: ubuntu-latest
steps:
- run: echo "Build succeed!"
- run: echo "Build succeed!"
24 changes: 0 additions & 24 deletions examples/projects/NUCLEO-L476RG/laser/lib/Galvo/_galvo.h

This file was deleted.

52 changes: 39 additions & 13 deletions examples/projects/NUCLEO-L476RG/laser/lib/Galvo/galvo.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@
* @version 0.0.0
******************************************************************************/
#include "galvo.h"
#include "_galvo.h"
#include "xy2-100.h"
#include "product_config.h"

/*******************************************************************************
* Definitions
******************************************************************************/
uint8_t buf[40] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40};
typedef struct
{
uint16_t x;
uint16_t y;
} __attribute__((packed)) pos_2d_t;

pos_2d_t stream_buf[512];
streaming_channel_t stream;
time_luos_t period;
control_t control;

/*******************************************************************************
* Variables
Expand All @@ -24,6 +30,7 @@ uint8_t buf[40] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
* Function
******************************************************************************/
static void Galvo_MsgHandler(service_t *service, const msg_t *msg);

/******************************************************************************
* @brief init must be call in project init
* @param None
Expand All @@ -34,9 +41,12 @@ void Galvo_Init(void)
Xy_Init();

revision_t revision = {.major = 1, .minor = 0, .build = 0};
Luos_CreateService(Galvo_MsgHandler, STATE_TYPE, "galvo", revision);
Xy_Start(buf, 40);
Luos_CreateService(Galvo_MsgHandler, GRAPH_2D, "galvo", revision);
stream = Streaming_CreateChannel(stream_buf, 41, 2 * sizeof(uint16_t));
period = TimeOD_TimeFrom_s(1.0 / 100.0); // Configure the trajectory samplerate at 100Hz
control.flux = STOP;
}

/******************************************************************************
* @brief loop must be call in project loop
* @param None
Expand All @@ -45,6 +55,7 @@ void Galvo_Init(void)
void Galvo_Loop(void)
{
}

/******************************************************************************
* @brief Msg Handler call back when a msg receive for this service
* @param Service destination
Expand All @@ -55,12 +66,27 @@ static void Galvo_MsgHandler(service_t *service, const msg_t *msg)
{
if (msg->header.cmd == GET_CMD)
{
// The galvo don't send anything back
return;
}
}

uint32_t Galvo_GetData(uint8_t **data)
{
*data = buf;
return 40;
if (msg->header.cmd == CONTROL)
{
// Get the control value
control_t last_control = control;
ControlOD_ControlFromMsg(&control, msg);
if (control.flux == PLAY && last_control.flux != PLAY)
{
// Start the trajectory
Xy_Start(&stream, period);
}
else
{
// Stop the trajectory
Xy_Stop();
}
}
if (msg->header.cmd == POSITION_2D)
{
Luos_ReceiveStreaming(service, msg, &stream);
}
}
10 changes: 10 additions & 0 deletions examples/projects/NUCLEO-L476RG/laser/lib/Galvo/galvo_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
#define GALVO_Y_PIN GPIO_PIN_3
#endif

// ENABLE Pinout
#ifndef GALVO_ENABLE_PIN
#define GALVO_ENABLE_PIN GPIO_PIN_4
#endif

// ********************* TIMER *********************
#ifndef GALVO_TIMER
#define GALVO_TIMER TIM6
Expand Down Expand Up @@ -84,4 +89,9 @@
#define GALVO_DMA_IRQHANDLER() DMA1_Channel3_IRQHandler()
#endif

// ********************* BUFFER *********************
#ifndef GALVO_BUFFER_SIZE
#define GALVO_BUFFER_SIZE 4000 // Buffer size need to be a multiple of 40
#endif

#endif /* _GALVO_HAL_CONFIG_H_ */
Loading

0 comments on commit 9068ad5

Please sign in to comment.