Edi Wang

.NET and Azure Developer

Windows

Azure Fire Alarm by Raspberry Pi and Windows 10 IoT Core

防火是日常生活中非常重要的意识,如果你是一只恩爱狗,出门在外,家里被FFF团点了,那真是太惨(hao)了。如果你恰好有Windows 10的设备,比如Lumia,Surface,能及时收到火警是至(mei)关(sha)重(luan)要(yong)的。今天就教大家如何用Microsoft Azure公有云+Windows 10 IoT Core在树莓派上实现一个远程火警系统。 阅读这篇文章,你需要的前置知识: Windows 10,UWP的基本开发能力 MVVM基础知识 ASP.NET MVC的基础知识 树莓派、GPIO及逻辑电路的基本知识(也就是大学里的计算机电路) Azure公有云的使用经验 ……当然,还要有对微软的信仰 一、设计原理 基本想法是,通过火焰传感器的输入信号,触发一个警报,把消息发送到Azure上的Notification Hub,这个服务是专门给 …
Windows Azure IoT Raspberry Pi

Get system font and characters in Windows 10 UWP

There used to be a {x:Static Fonts.SystemFontFamilies} in WPF that can bind to system font list very easy. However, this is gong in UWP! How stupid it is! These days I wrote a character map UWP application, that would use system fonts, so I did some research. In order to get system font in UWP, we must use DirectX. Install these 3 NuGet pacakges into your project: "SharpDX": "3.0.1", " …
Windows UWP DirectX

How to Remove ListView Default Selection in Windows 10 UWP

A lot of people including me has encounter a problem where on UWP apps, if a ListView control is being data binded, it will get a default selected item like this: It not only will display as selected item, it also fires SelectionChanged event. However, if we want to make ListView clickable, a popular way is to write the SelectionChanged event handler like this: private void StationsList_ …
Windows UWP

How to make a modal progress dialog in Windows 10 UWP

Windows 10 Mobile上的文件管理器有这样一个进度指示器,它是一个模态框,不带任何按钮,只有进度条和文本: 今天我琢磨了很久,绕了一些弯路,发现其实要做一个这样的模态进度指示器很简单。只要用ContentDialog就行。 平时我们用ContentDialog有些思维定势,就觉得这个对话框一定要提供按钮给用户操作。其实它是可以不设置任何按钮的,这样就有了初步的雏形: XAML C# private async void BtnSitAndRelax_OnClick(object sender, RoutedEventArgs e) { // show progress await ModalProgressDig.ShowAsync(); } …
Windows UWP

Windows 10 UWP开发:拼音首字母分组如何去掉“拼音”前缀并支持切换系统语言

Windows 10里面有个脑残设计,就是系统默认的CharacterGroupings类型在中文版系统上会产生除了A-Z字母以外的带“拼音”前缀的另外24个分组。比如开屎菜单里就是这样: 如果我们用这个CharacterGroupings类型去创建带分组的ListView,就会变成这样: 更蛋疼的是,如果用户的系统是英文语言的,他就会发现分组变成空白了,没有任何数据。用户不知道这是微软干的,又得给我们的APP打1星,还要骂我们傻逼。 今天经过研究,终于把这个问题给解决了,不仅去掉了“拼音”前缀,也不用担心用户系统是什么语言的,都能正常显示分组列表。 我们先看看原来的代码。 public class AlphaKeyGroup<T> : List<T> { const string GlobeGroupKey = "?"; …
Windows UWP

Sharing Images in Windows 10 UWP

Starting from Windows 8, one big feature for Windows Store Apps is to share data using Charm Bar across Apps. Although the Charm Bar is removed in Windows 10, but the API for sharing is still in the fight.  For example, in my "Image Portray" App, I can share ink to OneNote or Outlook. Today, I added same capability for my "Shanghai Metro" App. Here's how to do it. First, to share data across …
Windows UWP

315MHz Remote Door Control by Windows 10 IoT

这几天我用树莓派实现了一个模仿车库遥控门的设备,分享给大家。(优酷视频 http://v.youku.com/v_show/id_XMTU3ODk1NDY2OA==.html )   一、遥控模块 首先介绍一下我用的遥控器和接收板,这种遥控模块在中国随处可以买到,基本都是长这样的。很多卷帘门、车库门都是用这种遥控模块的。做无线电实验购买的是非锁的版本,注意最好同时购买天线。天线用的是50欧姆单芯导线,其实就是个铜丝,注意购买时候要看好频率,中国大陆的无线电许可频率是315MHz,国外也有用443MHz的,我买的遥控器是315MHz。注意遥控器发射频率和接收频率要匹配就行。遥控接收端芯片是PT2272-M4,M4的意思是点动模式,即按住遥控器按钮输出高电平,松开停止输出。遥控板的ANT端焊接天线,方向要是竖直向上的(相对你的设备)。 遥控板的接口有7个: 接口 含义 GND 电源负 …
Windows IoT Raspberry Pi

Reed Controlled Light by Windows 10 IoT Core

Reed switch is an electronic component to connect / disconnect the switch by magnetic field. When it touchs magnetic field, the two iron sheets inside the tube will clip together, so the switch is connected.  The application of Reed Swith: Door light controller: When you open the door, turn the light on. When you close the door, turn off the light. This is simply install a reed switch on your …
Windows IoT Raspberry Pi

74HC595 4 Digits LED Tube with Windows 10

One of the commonly used LED Tube driver chip is 74HC595, by using the Chip, you can save GPIO ports. I bought an LED Tube with 595 chip, it only needs 3 GPIO ports to display 4 digits. However, there is no existing posts about how to drive the 74HC595 LED Tube from Windows 10. So, I can only try for myself. …
Windows IoT Raspberry Pi

Using stepper motor in Windows 10 IoT Core

如果你需要精确控制设备的转动角度,普通电机是做不到的,通常我们会选用步进马达。比如28BYJ-48这个型号的,很容易买到。 步进马达得配合驱动板使用,最常用的是ULN2003芯片的驱动板,就像下图。不过注意,你买到的驱动板长相可能不太一样,不过没关系,只要芯片上写的是ULN2003,就可以使用,它们的接口都是一样的。关于步进马达的原理,可以看这篇: https://en.wikipedia.org/wiki/Stepper_motor  拿到驱动板和步进马达后,将马达插入驱动板的白色插槽中,这个接口有防呆设计,所以不会插反。 关于Windows 10 IoT如何驱动步进马达,有一篇很好的英文材料: https://www.hackster.io/erickbp/stepper-motor-and-windows-10-iot-core-d3c5d6 我的例子就是基于上面这 …
Windows IoT Raspberry Pi