Skip to content

Commit 47a51e4

Browse files
committed
pbio/light_animation: Make API public.
Separation of powers is nice, but since we have #include "../src/light/light_matrix.h" there is clearly something not quite right. Let's be pragmatic and make the APIs for animations public.
1 parent ecf1342 commit 47a51e4

File tree

9 files changed

+28
-44
lines changed

9 files changed

+28
-44
lines changed
File renamed without changes.

lib/pbio/include/pbio/light_matrix.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,32 @@
1111

1212
#include <stdint.h>
1313

14+
#include <pbdrv/led.h>
15+
1416
#include <pbio/config.h>
1517
#include <pbio/error.h>
1618
#include <pbio/geometry.h>
19+
#include <pbio/light_animation.h>
1720

1821
/** A light matrix instance. */
19-
typedef struct _pbio_light_matrix_t pbio_light_matrix_t;
22+
typedef struct {
23+
/** Animation instance for background animation. */
24+
pbio_light_animation_t animation;
25+
/** Animation cell data. */
26+
const uint8_t *animation_cells;
27+
/** The number of cells in @p animation_cells */
28+
uint8_t num_animation_cells;
29+
/** The index of the currently displayed animation cell. */
30+
uint8_t current_cell;
31+
/** Animation update rate in milliseconds. */
32+
uint16_t interval;
33+
/** Size of the matrix (assumes matrix is square). */
34+
uint8_t size;
35+
/** Orientation of the matrix: which side is "up". */
36+
pbio_geometry_side_t up_side;
37+
/** The driver for this light matrix. */
38+
pbdrv_led_array_dev_t *led_array_dev;
39+
} pbio_light_matrix_t;
2040

2141
#if PBIO_CONFIG_LIGHT_MATRIX
2242

lib/pbio/src/light/animation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <pbio/util.h>
1414

15-
#include "animation.h"
15+
#include <pbio/light_animation.h>
1616

1717
/**
1818
* This is used as a value for the next_animation field to indicate when an

lib/pbio/src/light/color_light.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <pbio/light.h>
1515
#include <pbio/util.h>
1616

17-
#include "animation.h"
17+
#include <pbio/light_animation.h>
1818
#include "color_light.h"
1919

2020
/**

lib/pbio/src/light/color_light.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <pbio/error.h>
88
#include <pbio/light.h>
99

10-
#include "animation.h"
10+
#include <pbio/light_animation.h>
1111

1212
#ifndef _PBIO_LIGHT_COLOR_LIGHT_H_
1313
#define _PBIO_LIGHT_COLOR_LIGHT_H_

lib/pbio/src/light/light_matrix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <pbio/light_matrix.h>
1212
#include <pbio/util.h>
1313

14-
#include "animation.h"
15-
#include "light_matrix.h"
14+
#include <pbio/light_animation.h>
15+
#include <pbio/light_matrix.h>
1616

1717
static pbio_light_matrix_t light_matrices[PBIO_CONFIG_LIGHT_MATRIX_NUM_DEV];
1818

lib/pbio/src/light/light_matrix.h

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

lib/pbio/src/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
#include <pbio/battery.h>
1616
#include <pbio/image.h>
1717
#include <pbio/imu.h>
18+
#include <pbio/light_animation.h>
1819
#include <pbio/motor_process.h>
1920
#include <pbio/port_interface.h>
2021

21-
#include "light/animation.h"
22-
2322
/**
2423
* Initialize the Pybricks I/O Library. This function must be called once,
2524
* usually at the beginning of a program, before using any other functions in

lib/pbio/sys/light_matrix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <pbsys/config.h>
1919
#include <pbsys/status.h>
2020

21-
#include "../src/light/light_matrix.h"
21+
#include <pbio/light_matrix.h>
2222
#include "hmi.h"
2323

2424
#if PBSYS_CONFIG_HUB_LIGHT_MATRIX

0 commit comments

Comments
 (0)