Skip to content

Commit 73d62b7

Browse files
committed
Merge pull request #1867 from petermm/fix-ledc.ex
Fix LEDC.ex low_speed_mode() These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents accda35 + 7ff88a7 commit 73d62b7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

libs/exavmlib/lib/LEDC.ex

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,18 +344,23 @@ defmodule LEDC do
344344
do: throw(:nif_error)
345345

346346
@doc """
347-
Convenience function for setting ledc speed mode
347+
Convenience function for setting ledc speed mode, note that not all targets support high speed mode.
348+
Function returns low speed mode on boards that do not support high speed mode.
348349
"""
349350
@spec high_speed_mode() :: 0
350351
def high_speed_mode(),
351352
do: 0
352353

353354
@doc """
354-
Convenience function for setting ledc speed mode
355-
"""
356-
@spec low_speed_mode() :: 1
357-
def low_speed_mode(),
358-
do: 1
355+
Convenience function for setting ledc low speed mode.
356+
"""
357+
@spec low_speed_mode() :: 0 | 1
358+
def low_speed_mode() do
359+
case :erlang.system_info(:esp32_chip_info) do
360+
%{model: :esp32} -> 1
361+
_ -> 0
362+
end
363+
end
359364

360365
@doc """
361366
Convenience function for setting ledc fade mode

0 commit comments

Comments
 (0)