Skip to content

Commit

Permalink
improve: appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
panxuc committed Aug 4, 2023
1 parent 7c59c2f commit 688462e
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 87 deletions.
Binary file added .readme/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# XPrism

![appicon](.readme/appicon.png)

清华大学电子工程系硬件设计大赛参赛作品。

XPrism 是基于 ESP32-PICO-D4 开发的智能眼镜。
XPrism 是基于 ESP32-PICO-D4 开发的智能眼镜。

此仓库同时包含基于 .NET MAUI 开发的 Android 端控制器。

Copyright © 2023 [潘徐成](https://github.com/Panxuc) [孙宇琦](https://github.com/always-del)

6 changes: 5 additions & 1 deletion android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@

- [ ] 完成 UI 设计
- [ ] 实现 WiFi 或蓝牙连接
- [ ] 读取手机信息
- [x] 读取设备基本信息
- [x] 获取天气
- [ ] 获取导航
- [ ] 获取设备通知
- [ ] 发送与接收信息
- [ ] TBA
2 changes: 1 addition & 1 deletion android/XPrism/XPrism/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Label Text=" " />
<Label Text="设备信息" FontSize="Title" HorizontalOptions="Center" />
<Label Text="获取失败" x:Name="deviceInfo" />
<Button Text="刷新设备信息" Clicked="OnRefreshClicked" />
<Button Text="刷新设备信息" Clicked="OnRefreshClicked" FontSize="18" />
<Label Text=" " />
<Label Text="License" FontSize="Title" HorizontalOptions="Center" />
<Label Text="MIT License" FontAttributes="Bold" HorizontalOptions="Center" />
Expand Down
6 changes: 3 additions & 3 deletions android/XPrism/XPrism/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<ScrollView>
<VerticalStackLayout Margin="24">
<Button Text="设置天气" ImageSource="material_weather_partly_cloudy_white.png" ContentLayout="Left, 0" Clicked="OnWeatherClicked" />
<Button Text="设置天气" ImageSource="material_weather_partly_cloudy_white.png" ContentLayout="Left, 0" Clicked="OnWeatherClicked" FontSize="18" />
<Label></Label>
<Button Text="发送信息" ImageSource="material_message_white.png" ContentLayout="Left, 0" Clicked="OnSendClicked" />
<Button Text="发送信息" ImageSource="material_message_white.png" ContentLayout="Left, 0" Clicked="OnSendClicked" FontSize="18" />
<Label></Label>
<Button Text="关于 XPrism" ImageSource="material_information_white.png" ContentLayout="Left, 0" Clicked="OnAboutClicked" />
<Button Text="关于 XPrism" ImageSource="material_information_white.png" ContentLayout="Left, 0" Clicked="OnAboutClicked" FontSize="18" />
</VerticalStackLayout>
</ScrollView>

Expand Down
24 changes: 12 additions & 12 deletions android/XPrism/XPrism/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
public partial class MainPage : ContentPage
{

public MainPage()
{
InitializeComponent();
public MainPage()
{
InitializeComponent();
Application.Current.UserAppTheme = AppTheme.Light;
}

public async void OnWeatherClicked(object sender, System.EventArgs e)
{
public async void OnWeatherClicked(object sender, System.EventArgs e)
{
// 打开天气页面
await Navigation.PushAsync(new WeatherPage());
}

public async void OnSendClicked(object sender, System.EventArgs e)
{
public async void OnSendClicked(object sender, System.EventArgs e)
{
// 打开发送页面
await Navigation.PushAsync(new SendPage());
}

public async void OnAboutClicked(object sender, System.EventArgs e)
{
// 打开关于页面
await Navigation.PushAsync(new AboutPage());
}
public async void OnAboutClicked(object sender, System.EventArgs e)
{
// 打开关于页面
await Navigation.PushAsync(new AboutPage());
}
}

22 changes: 11 additions & 11 deletions android/XPrism/XPrism/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ namespace XPrism;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
});
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
});

return builder.Build();
}
return builder.Build();
}
}
10 changes: 5 additions & 5 deletions android/XPrism/XPrism/Platforms/Android/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ namespace XPrism;
[Application(UsesCleartextTraffic = true)]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
12 changes: 4 additions & 8 deletions android/XPrism/XPrism/SendPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
x:Class="XPrism.SendPage"
Title="发送信息">
<ScrollView>
<VerticalStackLayout Margin="16">
<Editor x:Name="editor"
Placeholder="请输入您要发送的内容"
HeightRequest="250"
TextChanged="OnEditorTextChanged"
Completed="OnEditorCompleted" />
<Button Text="发送" />
</VerticalStackLayout>
<VerticalStackLayout Margin="16">
<Editor x:Name="editor" Placeholder="请输入您要发送的内容" HeightRequest="250" TextChanged="OnEditorTextChanged" Completed="OnEditorCompleted" FontSize="18" />
<Button Text="发送" FontSize="18" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
8 changes: 4 additions & 4 deletions android/XPrism/XPrism/SendPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ namespace XPrism;

public partial class SendPage : ContentPage
{
public SendPage()
{
InitializeComponent();
}
public SendPage()
{
InitializeComponent();
}

public void OnEditorTextChanged(object sender, TextChangedEventArgs e)
{
Expand Down
76 changes: 39 additions & 37 deletions android/XPrism/XPrism/WeatherPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Title="设置天气">
<ScrollView>
<VerticalStackLayout Margin="10">
<Label Text="选择城市" FontSize="Title" />
<Label Text="选择城市" FontSize="Title" HorizontalTextAlignment="Center" />
<!--<Picker x:Name="picker" Title="选择一个城市">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:String}">
Expand All @@ -23,44 +23,46 @@
</Picker.ItemsSource>
</Picker>-->

<Entry x:Name="cityEntry" Placeholder="请输入城市名称" />
<Entry x:Name="cityEntry" Placeholder="请输入城市名称(建议输入英文)" HorizontalTextAlignment="Center" ClearButtonVisibility="WhileEditing" FontSize="18" />

<Button Text="查询" Clicked="OnSearchClicked" />

<Label Text="查询结果:" FontSize="Title" />
<StackLayout Orientation="Horizontal">
<Label Text="城市:" />
<Label x:Name="cityLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="天气:" />
<Label x:Name="weatherLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="温度:" />
<Label x:Name="temperatureLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="风向:" />
<Label x:Name="windDirectionLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="风速:" />
<Label x:Name="windSpeedLabel" />
<Button Text="查询" Clicked="OnSearchClicked" FontSize="18" />
<Label></Label>
<Label Text="查询结果" FontSize="Title" HorizontalTextAlignment="Center" />
<Label></Label>
<StackLayout HorizontalOptions="Center">
<StackLayout Orientation="Horizontal">
<Label Text="城市:" />
<Label x:Name="cityLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="天气:" />
<Label x:Name="weatherLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="温度:" />
<Label x:Name="temperatureLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="风向:" />
<Label x:Name="windDirectionLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="风速:" />
<Label x:Name="windSpeedLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="湿度:" />
<Label x:Name="humidityLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="更新时间:" />
<Label x:Name="reportTimeLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="数据来源:" />
<Label x:Name="sourceLabel" />
</StackLayout>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="湿度:" />
<Label x:Name="humidityLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="更新时间:" />
<Label x:Name="reportTimeLabel" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="数据来源:" />
<Label x:Name="sourceLabel" />
</StackLayout>


</VerticalStackLayout>
</ScrollView>
Expand Down
20 changes: 16 additions & 4 deletions android/XPrism/XPrism/WeatherPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#define OPENWEATHERMAP // OPENWEATHERMAP or ACCUWEATHER

using Android.App;
using CommunityToolkit.Maui.Core;
using CommunityToolkit.Maui.Alerts;
using System.Text.Json;

namespace XPrism;
Expand Down Expand Up @@ -42,31 +44,41 @@ public async void OnSearchClicked(object sender, System.EventArgs e)
var weather = JsonSerializer.Deserialize<Weather>(content);
if (weather.cod != 200)
{
await DisplayAlert("错误", "城市名称错误", "确定");
await DisplayAlert("错误", "城市名称错误或网络错误", "确定");
return;
}
cityLabel.Text = city;
cityLabel.Text = weather.name;
weatherLabel.Text = weather.weather[0].description;
temperatureLabel.Text = weather.main.temp.ToString() + "℃";
windDirectionLabel.Text = weather.wind.deg.ToString() + "°";
windSpeedLabel.Text = weather.wind.speed.ToString() + "m/s";
humidityLabel.Text = weather.main.humidity.ToString() + "%";
reportTimeLabel.Text = weather.dt.ToString();
reportTimeLabel.Text = UnixTimeStampToDateTime(weather.dt).ToString();
var toast = Toast.Make("查询成功", ToastDuration.Short, 14);
await toast.Show();
}
else
{
await DisplayAlert("错误", "城市名称错误", "确定");
await DisplayAlert("错误", "城市名称错误或网络错误", "确定");
return;
}
}
}
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
{
// Unix timestamp is seconds past epoch
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dateTime = dateTime.AddSeconds(unixTimeStamp).ToLocalTime();
return dateTime;
}
}
class Weather
{
public int cod { get; set; }
public WeatherMain main { get; set; }
public WeatherWind wind { get; set; }
public WeatherWeather[] weather { get; set; }
public string name { get; set; }
public int dt { get; set; }
}
class WeatherMain
Expand Down
Binary file added docs/esp32-pico-d4_datasheet_cn.pdf
Binary file not shown.
Binary file added docs/esp32-pico-d4_datasheet_en.pdf
Binary file not shown.

0 comments on commit 688462e

Please sign in to comment.