mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Merge branch 'main' into 2027
This commit is contained in:
@@ -10,6 +10,13 @@ package edu.wpi.first.hal;
|
||||
* @see "hal/AddressableLED.h"
|
||||
*/
|
||||
public class AddressableLEDJNI extends JNIWrapper {
|
||||
public static final int COLOR_ORDER_RGB = 0;
|
||||
public static final int COLOR_ORDER_RBG = 1;
|
||||
public static final int COLOR_ORDER_BGR = 2;
|
||||
public static final int COLOR_ORDER_BRG = 3;
|
||||
public static final int COLOR_ORDER_GBR = 4;
|
||||
public static final int COLOR_ORDER_GRB = 5;
|
||||
|
||||
/**
|
||||
* Initialize Addressable LED using a PWM Digital handle.
|
||||
*
|
||||
@@ -27,6 +34,16 @@ public class AddressableLEDJNI extends JNIWrapper {
|
||||
*/
|
||||
public static native void free(int handle);
|
||||
|
||||
/**
|
||||
* Sets the color order for the addressable LED output. The default order is GRB.
|
||||
*
|
||||
* <p>This will take effect on the next call to {@link #setData(int, byte[])}.
|
||||
*
|
||||
* @param handle the Addressable LED handle
|
||||
* @param colorOrder the color order
|
||||
*/
|
||||
public static native void setColorOrder(int handle, int colorOrder);
|
||||
|
||||
/**
|
||||
* Sets the length of the LED strip.
|
||||
*
|
||||
|
||||
@@ -15,6 +15,19 @@ using namespace wpi::java;
|
||||
|
||||
static_assert(sizeof(jbyte) * 4 == sizeof(HAL_AddressableLEDData));
|
||||
|
||||
static_assert(edu_wpi_first_hal_AddressableLEDJNI_COLOR_ORDER_RGB ==
|
||||
HAL_ALED_RGB);
|
||||
static_assert(edu_wpi_first_hal_AddressableLEDJNI_COLOR_ORDER_RBG ==
|
||||
HAL_ALED_RBG);
|
||||
static_assert(edu_wpi_first_hal_AddressableLEDJNI_COLOR_ORDER_BGR ==
|
||||
HAL_ALED_BGR);
|
||||
static_assert(edu_wpi_first_hal_AddressableLEDJNI_COLOR_ORDER_BRG ==
|
||||
HAL_ALED_BRG);
|
||||
static_assert(edu_wpi_first_hal_AddressableLEDJNI_COLOR_ORDER_GBR ==
|
||||
HAL_ALED_GBR);
|
||||
static_assert(edu_wpi_first_hal_AddressableLEDJNI_COLOR_ORDER_GRB ==
|
||||
HAL_ALED_GRB);
|
||||
|
||||
extern "C" {
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AddressableLEDJNI
|
||||
@@ -46,6 +59,22 @@ Java_edu_wpi_first_hal_AddressableLEDJNI_free
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AddressableLEDJNI
|
||||
* Method: setColorOrder
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_AddressableLEDJNI_setColorOrder
|
||||
(JNIEnv* env, jclass, jint handle, jint colorOrder)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetAddressableLEDColorOrder(
|
||||
static_cast<HAL_AddressableLEDHandle>(handle),
|
||||
static_cast<HAL_AddressableLEDColorOrder>(colorOrder), &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AddressableLEDJNI
|
||||
* Method: setLength
|
||||
|
||||
@@ -36,6 +36,17 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
*/
|
||||
void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle);
|
||||
|
||||
/**
|
||||
* Sets the color order for the addressable LED output. The default order is
|
||||
* GRB. This will take effect on the next call to HAL_WriteAddressableLEDData().
|
||||
* @param[in] handle the Addressable LED handle
|
||||
* @param[in] colorOrder the color order
|
||||
* @param[out] status the error code, or 0 for success
|
||||
*/
|
||||
void HAL_SetAddressableLEDColorOrder(HAL_AddressableLEDHandle handle,
|
||||
HAL_AddressableLEDColorOrder colorOrder,
|
||||
int32_t* status);
|
||||
|
||||
/**
|
||||
* Set the Addressable LED PWM Digital port.
|
||||
*
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/** max length of LED strip supported by FPGA. */
|
||||
@@ -16,3 +17,21 @@ struct HAL_AddressableLEDData {
|
||||
uint8_t r; ///< red value
|
||||
uint8_t padding;
|
||||
};
|
||||
|
||||
/**
|
||||
* Order that color data is sent over the wire.
|
||||
*/
|
||||
HAL_ENUM(HAL_AddressableLEDColorOrder) {
|
||||
HAL_ALED_RGB,
|
||||
HAL_ALED_RBG,
|
||||
HAL_ALED_BGR,
|
||||
HAL_ALED_BRG,
|
||||
HAL_ALED_GBR,
|
||||
HAL_ALED_GRB
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
constexpr auto format_as(HAL_AddressableLEDColorOrder order) {
|
||||
return static_cast<int32_t>(order);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -91,6 +91,10 @@ void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle) {
|
||||
SimAddressableLEDData[led->index].initialized = false;
|
||||
}
|
||||
|
||||
void HAL_SetAddressableLEDColorOrder(HAL_AddressableLEDHandle handle,
|
||||
HAL_AddressableLEDColorOrder colorOrder,
|
||||
int32_t* status) {}
|
||||
|
||||
void HAL_SetAddressableLEDOutputPort(HAL_AddressableLEDHandle handle,
|
||||
HAL_DigitalHandle outputPort,
|
||||
int32_t* status) {
|
||||
|
||||
@@ -30,6 +30,13 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
|
||||
void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle) {}
|
||||
|
||||
void HAL_SetAddressableLEDColorOrder(HAL_AddressableLEDHandle handle,
|
||||
HAL_AddressableLEDColorOrder colorOrder,
|
||||
int32_t* status) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
void HAL_SetAddressableLEDOutputPort(HAL_AddressableLEDHandle handle,
|
||||
HAL_DigitalHandle outputPort,
|
||||
int32_t* status) {
|
||||
|
||||
Reference in New Issue
Block a user