Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Iot
提交
f2fd649f
I
Iot
项目概览
jobily
/
Iot
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f2fd649f
编写于
7月 29, 2019
作者:
G
Greg Ingram
提交者:
Jose Perez Rodriguez
7月 29, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed naming for seconds (#636)
上级
74be68ef
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
17 deletion
+17
-17
src/System.Device.Gpio.Tests/GpioControllerTestBase.cs
src/System.Device.Gpio.Tests/GpioControllerTestBase.cs
+12
-12
src/System.Device.Gpio/System/Device/Pwm/Channels/UnixPwmChannel.Linux.cs
...e.Gpio/System/Device/Pwm/Channels/UnixPwmChannel.Linux.cs
+5
-5
未找到文件。
src/System.Device.Gpio.Tests/GpioControllerTestBase.cs
浏览文件 @
f2fd649f
...
...
@@ -16,7 +16,7 @@ namespace System.Device.Gpio.Tests
private
const
int
LedPin
=
18
;
private
const
int
OutputPin
=
16
;
private
const
int
InputPin
=
12
;
private
static
readonly
int
WaitMilli
S
econds
=
1000
;
private
static
readonly
int
WaitMilli
s
econds
=
1000
;
[
Fact
]
public
void
ControllerCanTurnOnLEDs
()
...
...
@@ -143,7 +143,7 @@ namespace System.Device.Gpio.Tests
controller
.
Write
(
OutputPin
,
PinValue
.
Low
);
controller
.
RegisterCallbackForPinValueChangedEvent
(
InputPin
,
PinEventTypes
.
Rising
,
callback
);
controller
.
Write
(
OutputPin
,
PinValue
.
High
);
Thread
.
Sleep
(
WaitMilli
S
econds
);
Thread
.
Sleep
(
WaitMilli
s
econds
);
Assert
.
True
(
wasCalled
);
}
...
...
@@ -164,7 +164,7 @@ namespace System.Device.Gpio.Tests
controller
.
Write
(
OutputPin
,
PinValue
.
Low
);
controller
.
RegisterCallbackForPinValueChangedEvent
(
InputPin
,
PinEventTypes
.
Falling
,
callback
);
controller
.
Write
(
OutputPin
,
PinValue
.
High
);
Thread
.
Sleep
(
WaitMilli
S
econds
);
Thread
.
Sleep
(
WaitMilli
s
econds
);
Assert
.
False
(
wasCalled
);
}
...
...
@@ -203,9 +203,9 @@ namespace System.Device.Gpio.Tests
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
controller
.
Write
(
OutputPin
,
PinValue
.
High
);
Thread
.
Sleep
(
WaitMilli
S
econds
);
Thread
.
Sleep
(
WaitMilli
s
econds
);
controller
.
Write
(
OutputPin
,
PinValue
.
Low
);
Thread
.
Sleep
(
WaitMilli
S
econds
);
Thread
.
Sleep
(
WaitMilli
s
econds
);
}
Assert
.
Equal
(
25
,
risingEventOccuredCount
);
...
...
@@ -243,16 +243,16 @@ namespace System.Device.Gpio.Tests
controller
.
RegisterCallbackForPinValueChangedEvent
(
InputPin
,
PinEventTypes
.
Rising
,
callback4
);
controller
.
Write
(
OutputPin
,
PinValue
.
High
);
Thread
.
Sleep
(
WaitMilli
S
econds
);
Thread
.
Sleep
(
WaitMilli
s
econds
);
controller
.
UnregisterCallbackForPinValueChangedEvent
(
InputPin
,
callback1
);
controller
.
UnregisterCallbackForPinValueChangedEvent
(
InputPin
,
callback2
);
controller
.
UnregisterCallbackForPinValueChangedEvent
(
InputPin
,
callback3
);
controller
.
UnregisterCallbackForPinValueChangedEvent
(
InputPin
,
callback4
);
Thread
.
Sleep
(
WaitMilli
S
econds
);
Thread
.
Sleep
(
WaitMilli
s
econds
);
controller
.
Write
(
OutputPin
,
PinValue
.
Low
);
Thread
.
Sleep
(
WaitMilli
S
econds
);
Thread
.
Sleep
(
WaitMilli
s
econds
);
controller
.
Write
(
OutputPin
,
PinValue
.
High
);
Assert
.
Equal
(
1
,
risingEventOccuredCount
);
...
...
@@ -283,11 +283,11 @@ namespace System.Device.Gpio.Tests
[
Fact
]
[
Trait
(
"SkipOnTestRun"
,
"Windows_NT"
)]
// The windows driver is returning none as the event type.
public
void
WaitForEventCancelAfter10Milli
S
econdsTest
()
public
void
WaitForEventCancelAfter10Milli
s
econdsTest
()
{
using
(
GpioController
controller
=
new
GpioController
(
GetTestNumberingScheme
(),
GetTestDriver
()))
{
CancellationTokenSource
tokenSource
=
new
CancellationTokenSource
(
WaitMilli
S
econds
);
CancellationTokenSource
tokenSource
=
new
CancellationTokenSource
(
WaitMilli
s
econds
);
controller
.
OpenPin
(
InputPin
,
PinMode
.
Input
);
controller
.
OpenPin
(
OutputPin
,
PinMode
.
Output
);
controller
.
Write
(
OutputPin
,
PinValue
.
Low
);
...
...
@@ -311,7 +311,7 @@ namespace System.Device.Gpio.Tests
Task
.
Run
(()
=>
{
Thread
.
Sleep
(
WaitMilli
S
econds
);
Thread
.
Sleep
(
WaitMilli
s
econds
);
controller
.
Write
(
OutputPin
,
PinValue
.
High
);
});
...
...
@@ -335,7 +335,7 @@ namespace System.Device.Gpio.Tests
Task
.
Run
(()
=>
{
controller
.
Write
(
OutputPin
,
PinValue
.
High
);
Thread
.
Sleep
(
WaitMilli
S
econds
);
Thread
.
Sleep
(
WaitMilli
s
econds
);
controller
.
Write
(
OutputPin
,
PinValue
.
Low
);
});
...
...
src/System.Device.Gpio/System/Device/Pwm/Channels/UnixPwmChannel.Linux.cs
浏览文件 @
f2fd649f
...
...
@@ -77,7 +77,7 @@ namespace System.Device.Pwm.Channels
/// </summary>
/// <param name="frequency">The frequency in hertz.</param>
/// <returns>The frequency period in nanoseconds.</returns>
private
static
int
GetPeriodInNano
S
econds
(
int
frequency
)
private
static
int
GetPeriodInNano
s
econds
(
int
frequency
)
{
// In Linux, the period needs to be a whole number and can't have a decimal point.
return
(
int
)((
1.0
/
frequency
)
*
1
_000_000_000
);
...
...
@@ -94,8 +94,8 @@ namespace System.Device.Pwm.Channels
throw
new
ArgumentOutOfRangeException
(
nameof
(
frequency
),
frequency
,
"Value must not be negative."
);
}
int
periodInNano
Seconds
=
GetPeriodInNanoS
econds
(
frequency
);
File
.
WriteAllText
(
$"
{
_channelPath
}
/period"
,
Convert
.
ToString
(
periodInNano
S
econds
));
int
periodInNano
seconds
=
GetPeriodInNanos
econds
(
frequency
);
File
.
WriteAllText
(
$"
{
_channelPath
}
/period"
,
Convert
.
ToString
(
periodInNano
s
econds
));
_frequency
=
frequency
;
}
...
...
@@ -111,8 +111,8 @@ namespace System.Device.Pwm.Channels
}
// In Linux, the period needs to be a whole number and can't have decimal point.
int
dutyCycleInNano
Seconds
=
(
int
)(
GetPeriodInNanoS
econds
(
_frequency
)
*
dutyCyclePercentage
);
File
.
WriteAllText
(
$"
{
_channelPath
}
/duty_cycle"
,
Convert
.
ToString
(
dutyCycleInNano
S
econds
));
int
dutyCycleInNano
seconds
=
(
int
)(
GetPeriodInNanos
econds
(
_frequency
)
*
dutyCyclePercentage
);
File
.
WriteAllText
(
$"
{
_channelPath
}
/duty_cycle"
,
Convert
.
ToString
(
dutyCycleInNano
s
econds
));
_dutyCyclePercentage
=
dutyCyclePercentage
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录