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
5 changes: 5 additions & 0 deletions nanoFramework.Hardware.Esp32.Rmt.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

using nanoFramework.Benchmark;
using System;
using System.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System.Collections;
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

using nanoFramework.Benchmark;
using nanoFramework.Benchmark.Attributes;
using System.Collections;

// ReSharper disable InconsistentNaming
namespace nanoFramework.Hardware.Esp32.Rmt.Benchmarks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System.Collections;
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

using nanoFramework.TestFramework;
using System.Collections;
// ReSharper disable InconsistentNaming

namespace nanoFramework.Hardware.Esp32.Rmt.UnitTests
Expand Down
28 changes: 14 additions & 14 deletions nanoFramework.Hardware.Esp32.Rmt/ReceiverChannelSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public ushort IdleThreshold
/// Gets or sets the filter state.
/// If enabled, the receiver will ignore pulses with widths less than specified in <see cref="FilterThreshold"/>.
/// </summary>
public bool EnableFilter
{
get => _enableFilter;
public bool EnableFilter
{
get => _enableFilter;
set => _enableFilter = value;
}

Expand All @@ -71,18 +71,18 @@ public bool EnableFilter
/// If the <see cref="RmtChannelSettings.ClockDivider"/> is set to 80 then the clock (80Mhz) will tick at a rate of 1Mhz (80Mhz / 80 = 1Mhz) making each clock tick equal to 1 microsecond.
/// Therefore, setting <see cref="FilterThreshold"/> to a value like 100 will cause the receiver channel to ignore any pulses that are shorter than 100 microseconds.
/// </remarks>
public byte FilterThreshold
{
get => _filterThreshold;
public byte FilterThreshold
{
get => _filterThreshold;
set => _filterThreshold = value;
}

/// <summary>
/// Gets or sets the timeout threshold for the <see cref="ReceiverChannel.GetAllItems"/> call. Defaults to 1 second.
/// </summary>
public TimeSpan ReceiveTimeout
{
get => _receiveTimeout;
public TimeSpan ReceiveTimeout
{
get => _receiveTimeout;
set => _receiveTimeout = value;
}

Expand Down Expand Up @@ -176,7 +176,7 @@ public ReceiverChannelSettings(int channel, int pinNumber) : base(channel, pinNu
_enableDemodulation = true;
_carrierWaveFrequency = 38_000;
_carrierWaveDutyPercentage = 33;
_carrierLevel= true;
_carrierLevel = true;
}

/// <summary>
Expand All @@ -189,10 +189,10 @@ internal ReceiverChannelSettings(ReceiverChannelSettings other) : base(other)
_enableFilter = other.EnableFilter;
_filterThreshold = other.FilterThreshold;
_receiveTimeout = other.ReceiveTimeout;
_enableDemodulation= other.EnableDemodulation;
_carrierWaveFrequency= other.CarrierWaveFrequency;
_carrierWaveDutyPercentage= other.CarrierWaveDutyPercentage;
_carrierLevel= other.CarrierLevel;
_enableDemodulation = other.EnableDemodulation;
_carrierWaveFrequency = other.CarrierWaveFrequency;
_carrierWaveDutyPercentage = other.CarrierWaveDutyPercentage;
_carrierLevel = other.CarrierLevel;
}
}
}
20 changes: 10 additions & 10 deletions nanoFramework.Hardware.Esp32.Rmt/RmtChannelSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public byte ClockDivider
/// Channel 0 can use at most 8 blocks of memory, accordingly channel 7 can only use one memory block.
/// </remarks>
/// <exception cref="ArgumentOutOfRangeException">Value cannot be 0 or more than 8.</exception>
public byte NumberOfMemoryBlocks
{
get => _numberOfMemoryBlocks;
public byte NumberOfMemoryBlocks
{
get => _numberOfMemoryBlocks;
set
{
if (value < 1 || value > 8)
Expand All @@ -111,20 +111,20 @@ public byte NumberOfMemoryBlocks
/// For receive channels, Incoming <see cref="RmtCommand"/>s are moved to the ring buffer after the <see cref="ReceiverChannelSettings.IdleThreshold"/> has lapsed.
/// For transmit channels, <see cref="RmtCommand"/>s are automatically copied over to the channel's memory block and written to the transmitter.
/// </remarks>
public int BufferSize
{
get => _bufferSize;
public int BufferSize
{
get => _bufferSize;
set => _bufferSize = value;
}

/// <summary>
/// Gets or sets a value indicating if the RMT module should invert the incoming/outgoing signal.
/// </summary>
/// <remarks>This works like an external inverter connected to the GPIO of certain RMT channel.</remarks>
public bool SignalInverterEnabled
{
get => _signalInverterEnabled;
set => _signalInverterEnabled = value;
public bool SignalInverterEnabled
{
get => _signalInverterEnabled;
set => _signalInverterEnabled = value;
}

/// <summary>
Expand Down
14 changes: 9 additions & 5 deletions nanoFramework.Hardware.Esp32.Rmt/RmtCommandSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
using System.Collections;
using System.Runtime.CompilerServices;
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

using System.Collections;

#nullable enable
namespace nanoFramework.Hardware.Esp32.Rmt
{
internal static class RmtCommandSerializer
{
/// <summary>
/// Serialize commands to rmt_item32_t native byte format
/// Serialize commands to rmt_item32_t native byte format.
/// </summary>
/// <returns>The serialized commands</returns>
/// <returns><see langword="byte"/> array with the serialized commands.</returns>
public static byte[] SerializeCommands(ArrayList commands)
{
var index = 0;
var serializedCommands = new byte[commands.Count * 4];

for (var i = 0; i < commands.Count; i++)
{
var command = (RmtCommand) commands[i];
var command = (RmtCommand)commands[i];

var highByte1 = (byte)(command.Duration0 >> 8);
var lowByte1 = (byte)(command.Duration0 & 0xFF);
Expand Down