forked from wpilibsuite/allwpilib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package edu.wpi.first.hal; | ||
|
||
public class LEDJNI extends JNIWrapper { | ||
public enum RadioLEDState { | ||
kOff(0), | ||
kGreen(1), | ||
kRed(2), | ||
kOrange(3); | ||
|
||
final int m_value; | ||
|
||
RadioLEDState(int value) { | ||
m_value = value; | ||
} | ||
} | ||
|
||
public static native void setRadioLEDState(int state); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
#include <unistd.h> | ||
|
||
#include <fstream> | ||
|
||
#include <wpi/fs.h> | ||
|
||
#include "hal/Errors.h" | ||
#include "hal/HALBase.h" | ||
|
||
static const fs::path radioLEDGreenFilePath = | ||
"/sys/class/leds/nilrt:wifi:primary/brightness"; | ||
static const fs::path radioLEDRedFilePath = | ||
"/sys/class/leds/nilrt:wifi:secondary/brightness"; | ||
|
||
static const char* onStr = "1"; | ||
static const char* offStr = "0"; | ||
|
||
void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status) { | ||
std::error_code ec; | ||
fs::file_t greenFile = fs::OpenFileForWrite(radioLEDGreenFilePath, ec, | ||
fs::CD_OpenExisting, fs::OF_Text); | ||
if (ec) { | ||
*status = INCOMPATIBLE_STATE; | ||
return; | ||
} | ||
fs::file_t redFile = fs::OpenFileForWrite(radioLEDRedFilePath, ec, | ||
fs::CD_OpenExisting, fs::OF_Text); | ||
if (ec) { | ||
*status = INCOMPATIBLE_STATE; | ||
return; | ||
} | ||
|
||
write(greenFile, state & HAL_RadioLED_kGreen ? onStr : offStr, 1); | ||
write(redFile, state & HAL_RadioLED_kRed ? onStr : offStr, 1); | ||
|
||
fs::CloseFile(greenFile); | ||
fs::CloseFile(redFile); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
#include <fmt/core.h> | ||
|
||
#include "HALUtil.h" | ||
#include "edu_wpi_first_hal_LEDJNI.h" | ||
#include "hal/HALBase.h" | ||
|
||
using namespace hal; | ||
/* | ||
* Class: edu_wpi_first_hal_LEDJNI | ||
* Method: setRadioLEDState | ||
* Signature: (I)V | ||
*/ | ||
JNIEXPORT void JNICALL | ||
Java_edu_wpi_first_hal_LEDJNI_setRadioLEDState | ||
(JNIEnv* env, jclass, jint state) | ||
{ | ||
int32_t status = 0; | ||
HAL_SetRadioLEDState((HAL_RadioLEDState)state, &status); | ||
CheckStatus(env, status); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
#include "hal/HALBase.h" | ||
|
||
void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status) {} |