Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion headers/addons/spi_analog_ads1256.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SPIAnalog1256Input : public GPAddon {
float values[ADS1256_CHANNEL_COUNT]; // Cache for latest read values
bool enableTriggers;
uint8_t readChannelCount; // Number of channels to read from the ADC
float analogMax = ADS1256_MAX_3V;
float analogMax = ADS1256_MAX_3V * 10.0f;
};

#endif // SPI_ANALOG_ADS1256_H_
2 changes: 1 addition & 1 deletion src/addons/spi_analog_ads1256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void SPIAnalog1256Input::setup() {
PeripheralSPI* spi = PeripheralManager::getInstance().getSPI(options.spiBlock);
enableTriggers = options.enableTriggers;
readChannelCount = 4 + (enableTriggers ? 2 : 0);
analogMax = options.avdd;
analogMax = options.avdd / 10.0f;

Gamepad * gamepad = Storage::getInstance().GetGamepad();
gamepad->hasAnalogTriggers = enableTriggers;
Expand Down
2 changes: 1 addition & 1 deletion src/config_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ void ConfigUtils::initUnsetPropertiesWithDefaults(Config& config)
INIT_UNSET_PROPERTY(config.addonOptions.analogADS1256Options, spiBlock, (SPI_ANALOG1256_BLOCK == spi0) ? 0 : 1)
INIT_UNSET_PROPERTY(config.addonOptions.analogADS1256Options, csPin, SPI_ANALOG1256_CS_PIN);
INIT_UNSET_PROPERTY(config.addonOptions.analogADS1256Options, drdyPin, SPI_ANALOG1256_DRDY_PIN);
INIT_UNSET_PROPERTY(config.addonOptions.analogADS1256Options, avdd, ADS1256_MAX_3V);
INIT_UNSET_PROPERTY(config.addonOptions.analogADS1256Options, avdd, (ADS1256_MAX_3V * 10));
INIT_UNSET_PROPERTY(config.addonOptions.analogADS1256Options, enableTriggers, false);

INIT_UNSET_PROPERTY(config.addonOptions.dualDirectionalOptions, enabled, !!DUAL_DIRECTIONAL_ENABLED);
Expand Down
24 changes: 12 additions & 12 deletions src/webconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,24 +1817,24 @@ std::string setAddonOptions()
AnalogADS1256Options& ads1256Options = Storage::getInstance().getAddonOptions().analogADS1256Options;
docToValue(ads1256Options.enabled, doc, "Analog1256Enabled");
docToValue(ads1256Options.spiBlock, doc, "analog1256Block");
docToValue(ads1256Options.csPin, doc, "analog1256CsPin");
docToValue(ads1256Options.drdyPin, doc, "analog1256DrdyPin");
docToPin(ads1256Options.csPin, doc, "analog1256CsPin");
docToPin(ads1256Options.drdyPin, doc, "analog1256DrdyPin");
docToValue(ads1256Options.avdd, doc, "analog1256AnalogMax");
docToValue(ads1256Options.enableTriggers, doc, "analog1256EnableTriggers");

RotaryOptions& rotaryOptions = Storage::getInstance().getAddonOptions().rotaryOptions;
docToValue(rotaryOptions.enabled, doc, "RotaryAddonEnabled");
docToValue(rotaryOptions.encoderOne.enabled, doc, "encoderOneEnabled");
docToValue(rotaryOptions.encoderOne.pinA, doc, "encoderOnePinA");
docToValue(rotaryOptions.encoderOne.pinB, doc, "encoderOnePinB");
docToPin(rotaryOptions.encoderOne.pinA, doc, "encoderOnePinA");
docToPin(rotaryOptions.encoderOne.pinB, doc, "encoderOnePinB");
docToValue(rotaryOptions.encoderOne.mode, doc, "encoderOneMode");
docToValue(rotaryOptions.encoderOne.pulsesPerRevolution, doc, "encoderOnePPR");
docToValue(rotaryOptions.encoderOne.resetAfter, doc, "encoderOneResetAfter");
docToValue(rotaryOptions.encoderOne.allowWrapAround, doc, "encoderOneAllowWrapAround");
docToValue(rotaryOptions.encoderOne.multiplier, doc, "encoderOneMultiplier");
docToValue(rotaryOptions.encoderTwo.enabled, doc, "encoderTwoEnabled");
docToValue(rotaryOptions.encoderTwo.pinA, doc, "encoderTwoPinA");
docToValue(rotaryOptions.encoderTwo.pinB, doc, "encoderTwoPinB");
docToPin(rotaryOptions.encoderTwo.pinA, doc, "encoderTwoPinA");
docToPin(rotaryOptions.encoderTwo.pinB, doc, "encoderTwoPinB");
docToValue(rotaryOptions.encoderTwo.mode, doc, "encoderTwoMode");
docToValue(rotaryOptions.encoderTwo.pulsesPerRevolution, doc, "encoderTwoPPR");
docToValue(rotaryOptions.encoderTwo.resetAfter, doc, "encoderTwoResetAfter");
Expand Down Expand Up @@ -2269,8 +2269,8 @@ std::string getAddonOptions()
AnalogADS1256Options& ads1256Options = Storage::getInstance().getAddonOptions().analogADS1256Options;
writeDoc(doc, "Analog1256Enabled", ads1256Options.enabled);
writeDoc(doc, "analog1256Block", ads1256Options.spiBlock);
writeDoc(doc, "analog1256CsPin", ads1256Options.csPin);
writeDoc(doc, "analog1256DrdyPin", ads1256Options.drdyPin);
writeDoc(doc, "analog1256CsPin", cleanPin(ads1256Options.csPin));
writeDoc(doc, "analog1256DrdyPin", cleanPin(ads1256Options.drdyPin));
writeDoc(doc, "analog1256AnalogMax", ads1256Options.avdd);
writeDoc(doc, "analog1256EnableTriggers", ads1256Options.enableTriggers);

Expand All @@ -2283,16 +2283,16 @@ std::string getAddonOptions()
RotaryOptions& rotaryOptions = Storage::getInstance().getAddonOptions().rotaryOptions;
writeDoc(doc, "RotaryAddonEnabled", rotaryOptions.enabled);
writeDoc(doc, "encoderOneEnabled", rotaryOptions.encoderOne.enabled);
writeDoc(doc, "encoderOnePinA", rotaryOptions.encoderOne.pinA);
writeDoc(doc, "encoderOnePinB", rotaryOptions.encoderOne.pinB);
writeDoc(doc, "encoderOnePinA", cleanPin(rotaryOptions.encoderOne.pinA));
writeDoc(doc, "encoderOnePinB", cleanPin(rotaryOptions.encoderOne.pinB));
writeDoc(doc, "encoderOneMode", rotaryOptions.encoderOne.mode);
writeDoc(doc, "encoderOnePPR", rotaryOptions.encoderOne.pulsesPerRevolution);
writeDoc(doc, "encoderOneResetAfter", rotaryOptions.encoderOne.resetAfter);
writeDoc(doc, "encoderOneAllowWrapAround", rotaryOptions.encoderOne.allowWrapAround);
writeDoc(doc, "encoderOneMultiplier", rotaryOptions.encoderOne.multiplier);
writeDoc(doc, "encoderTwoEnabled", rotaryOptions.encoderTwo.enabled);
writeDoc(doc, "encoderTwoPinA", rotaryOptions.encoderTwo.pinA);
writeDoc(doc, "encoderTwoPinB", rotaryOptions.encoderTwo.pinB);
writeDoc(doc, "encoderTwoPinA", cleanPin(rotaryOptions.encoderTwo.pinA));
writeDoc(doc, "encoderTwoPinB", cleanPin(rotaryOptions.encoderTwo.pinB));
writeDoc(doc, "encoderTwoMode", rotaryOptions.encoderTwo.mode);
writeDoc(doc, "encoderTwoPPR", rotaryOptions.encoderTwo.pulsesPerRevolution);
writeDoc(doc, "encoderTwoResetAfter", rotaryOptions.encoderTwo.resetAfter);
Expand Down
8 changes: 4 additions & 4 deletions www/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,23 +535,23 @@ app.get('/api/getAddonsOptions', (req, res) => {
analog1256Block: 0,
analog1256CsPin: -1,
analog1256DrdyPin: -1,
analog1256AnalogMax: 3.3,
analog1256EnableTriggers: false,
analog1256AnalogMax: 33,
analog1256EnableTriggers: 0,
encoderOneEnabled: 0,
encoderOnePinA: -1,
encoderOnePinB: -1,
encoderOneMode: 0,
encoderOnePPR: 24,
encoderOneResetAfter: 0,
encoderOneAllowWrapAround: false,
encoderOneAllowWrapAround: 0,
encoderOneMultiplier: 1,
encoderTwoEnabled: 0,
encoderTwoPinA: -1,
encoderTwoPinB: -1,
encoderTwoMode: 0,
encoderTwoPPR: 24,
encoderTwoResetAfter: 0,
encoderTwoAllowWrapAround: false,
encoderTwoAllowWrapAround: 0,
encoderTwoMultiplier: 1,
muxChannels: 8,
muxADCPin0: 26,
Expand Down
26 changes: 21 additions & 5 deletions www/src/Addons/Analog1256.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import { SPI_BLOCKS } from '../Data/Peripherals';
import WebApi from '../Services/WebApi';
import { AddonPropTypes } from '../Pages/AddonsConfigPage';

const ANALOG_MAX_VALUES = [
{ label: '3.3v', value: 33 },
{ label: '5.0v', value: 50 },
];

export const analog1256Scheme = {
Analog1256Enabled: yup.number().label('Analog1256 Input Enabled'),
analog1256Block: yup
Expand All @@ -24,15 +29,23 @@ export const analog1256Scheme = {
.number()
.label('Analog1256 DRDY Pin')
.validatePinWhenValue('Analog1256Enabled'),
analog1256AnalogMax: yup
.number()
.label('Analog1256 Analog Max')
.validateSelectionWhenValue('Analog1256Enabled', ANALOG_MAX_VALUES),
analog1256EnableTriggers: yup
.number()
.label('Analog1256 Enable Triggers')
.validateRangeWhenValue('Analog1256Enabled', 0, 1),
};

export const analog1256State = {
Analog1256Enabled: 0,
analog1256Block: 0,
analog1256CsPin: -1,
analog1256DrdyPin: -1,
analog1256AnalogMax: 3.3,
analog1256EnableTriggers: false,
analog1256AnalogMax: 33,
analog1256EnableTriggers: 0,
};

const Analog1256 = ({ values, errors, handleChange, handleCheckbox }: AddonPropTypes) => {
Expand Down Expand Up @@ -159,15 +172,18 @@ const Analog1256 = ({ values, errors, handleChange, handleCheckbox }: AddonPropT
isInvalid={Boolean(errors.analog1256AnalogMax)}
onChange={handleChange}
>
<option value="3.3">{'3.3v'}</option>
<option value="5.0">{'5v'}</option>
{ANALOG_MAX_VALUES.map((o, i) => (
<option key={`analog1256AnalogMax-${i}`} value={o.value}>
{o.label}
</option>
))}
</FormSelect>
</Row>
<Row>
<FormCheck
label={t('AddonsConfig:analog1256-enable-triggers')}
type="switch"
id="analog1256EnableTriggers"
id="Analog1256EnableTriggers"
className="col-sm-3 ms-3"
isInvalid={false}
checked={Boolean(values.analog1256EnableTriggers)}
Expand Down
8 changes: 4 additions & 4 deletions www/src/Addons/Rotary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const rotaryScheme = {
.label('Encoder One Reset After')
.required(),
encoderOneAllowWrapAround: yup
.boolean()
.number()
.required()
.label('Encoder One Allow Wrap Around'),
encoderOneMultiplier: yup.number().label('Encoder One Multiplier').required(),
Expand All @@ -90,7 +90,7 @@ export const rotaryScheme = {
.label('Encoder Two Reset After')
.required(),
encoderTwoAllowWrapAround: yup
.boolean()
.number()
.required()
.label('Encoder Two Allow Wrap Around'),
encoderTwoMultiplier: yup.number().label('Encoder Two Multiplier').required(),
Expand Down Expand Up @@ -229,7 +229,7 @@ const Rotary = ({ values, errors, handleChange, handleCheckbox }: AddonPropTypes
<FormCheck
label={t('Rotary:encoder-allow-wrap-around-label')}
type="switch"
id="encoderOneAllowWrapAround"
id="EncoderOneAllowWrapAround"
isInvalid={false}
checked={Boolean(values.encoderOneAllowWrapAround)}
onChange={(e) => {
Expand Down Expand Up @@ -337,7 +337,7 @@ const Rotary = ({ values, errors, handleChange, handleCheckbox }: AddonPropTypes
<FormCheck
label={t('Rotary:encoder-allow-wrap-around-label')}
type="switch"
id="encoderTwoAllowWrapAround"
id="EncoderTwoAllowWrapAround"
isInvalid={false}
checked={Boolean(values.encoderTwoAllowWrapAround)}
onChange={(e) => {
Expand Down
4 changes: 2 additions & 2 deletions www/src/Pages/InputMacroAddonPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,9 @@ export default function MacrosPage() {
<Row>
<Col>
<Form.Label>
<em>
<div className="alert alert-info" role="alert">
{t('InputMacroAddon:input-macro-sub-header')}
</em>
</div>
</Form.Label>
</Col>
</Row>
Expand Down
5 changes: 1 addition & 4 deletions www/src/Pages/LEDConfigPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,8 @@ export default function LEDConfigPage() {
<Trans
ns="LedConfig"
i18nKey="player.rgb-sub-header-text"
rgbLedStartIndex={rgbLedStartIndex}
values={{rgbLedStartIndex}}
>
For RGB LEDs, the indexes must be after the last LED button
defined in <em>RGB LED Button Order</em> section and likely{' '}
<strong>starts at index {{ rgbLedStartIndex }}</strong>.
</Trans>
</p>
</Form.Group>
Expand Down
1 change: 0 additions & 1 deletion www/src/Pages/PeripheralMappingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export default function PeripheralMappingPage() {
<div>
<Form noValidate onSubmit={handleSubmit}>
<Section title={t('PeripheralMapping:header-text')}>
<p>{t('PeripheralMapping:sub-header-text')}</p>
{PERIPHERAL_DEVICES.map((peripheral, i) => (
<Form.Group
key={`peripheral-${peripheral.value}`}
Expand Down