圆角屏幕+netutils_pkg
This commit is contained in:
parent
938611ff84
commit
03a8ff6ec6
19
.config
19
.config
|
@ -555,7 +555,24 @@ CONFIG_RW007_RST_PIN=111
|
|||
|
||||
# CONFIG_PKG_USING_COAP is not set
|
||||
# CONFIG_PKG_USING_NOPOLL is not set
|
||||
# CONFIG_PKG_USING_NETUTILS is not set
|
||||
CONFIG_PKG_USING_NETUTILS=y
|
||||
CONFIG_PKG_NETUTILS_PATH="/packages/iot/netutils"
|
||||
# CONFIG_PKG_NETUTILS_TFTP is not set
|
||||
# CONFIG_PKG_NETUTILS_IPERF is not set
|
||||
# CONFIG_PKG_NETUTILS_NETIO is not set
|
||||
CONFIG_PKG_NETUTILS_NTP=y
|
||||
CONFIG_NTP_USING_AUTO_SYNC=y
|
||||
CONFIG_NTP_AUTO_SYNC_FIRST_DELAY=30
|
||||
CONFIG_NTP_AUTO_SYNC_PERIOD=3600
|
||||
CONFIG_NETUTILS_NTP_HOSTNAME="cn.ntp.org.cn"
|
||||
CONFIG_NETUTILS_NTP_HOSTNAME2="ntp.rt-thread.org"
|
||||
CONFIG_NETUTILS_NTP_HOSTNAME3="edu.ntp.org.cn"
|
||||
# CONFIG_PKG_NETUTILS_TELNET is not set
|
||||
# CONFIG_PKG_NETUTILS_TCPDUMP is not set
|
||||
CONFIG_PKG_USING_NETUTILS_LATEST_VERSION=y
|
||||
# CONFIG_PKG_USING_NETUTILS_V133 is not set
|
||||
CONFIG_PKG_NETUTILS_VER="latest"
|
||||
CONFIG_PKG_NETUTILS_VER_NUM=0x99999
|
||||
# CONFIG_PKG_USING_CMUX is not set
|
||||
# CONFIG_PKG_USING_PPP_DEVICE is not set
|
||||
# CONFIG_PKG_USING_AT_DEVICE is not set
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
|
@ -21,18 +21,80 @@
|
|||
#include <rttlogo.h>
|
||||
|
||||
/* 配置 LED 灯引脚 */
|
||||
#define PIN_LED_B GET_PIN(F, 11) // PF11 : LED_B --> LED
|
||||
#define PIN_LED_R GET_PIN(F, 12) // PF12 : LED_R --> LED
|
||||
#define PIN_LED_B GET_PIN(F, 11) // PF11 : LED_B --> LED
|
||||
#define PIN_LED_R GET_PIN(F, 12) // PF12 : LED_R --> LED
|
||||
#define LCD_MAX 240
|
||||
|
||||
int roundxy[4][2] = {
|
||||
{0, 0},
|
||||
{0, LCD_MAX},
|
||||
{LCD_MAX, 0},
|
||||
{LCD_MAX, LCD_MAX},
|
||||
};
|
||||
int xymove[4][2] = {
|
||||
{1, 1},
|
||||
{1, -1},
|
||||
{-1, 1},
|
||||
{-1, -1},
|
||||
};
|
||||
|
||||
extern void wlan_autoconnect_init(void);
|
||||
|
||||
void lcd_black(int x, int y)
|
||||
{
|
||||
lcd_address_set(x, y, x, y);
|
||||
lcd_write_half_word(BLACK);
|
||||
}
|
||||
void xy_round(int x, int y, int x2, int y2, int r,int ii)
|
||||
{
|
||||
rt_kprintf("x:%d,y:%d,x2:%d,y2:%d,r:%d\n", x, y, x2, y2, r);
|
||||
for (int i = x; i != x2; i+=xymove[ii][0])
|
||||
{
|
||||
for (int j = y; j != y2; j+=xymove[ii][1])
|
||||
{
|
||||
int newi = x2 - i;
|
||||
int newj = y2 - j;
|
||||
rt_kprintf("(%d,%d,%d)",(newi * newi + newj * newj), newi, newj);
|
||||
if ((newi * newi + newj * newj) > (r * r))
|
||||
{
|
||||
// rt_kprintf("x:%d,y:%d\n", i, j);
|
||||
lcd_black(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void my_round(int r)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
xy_round(roundxy[i][0], roundxy[i][1], roundxy[i][0] + r * xymove[i][0], roundxy[i][1] + r * xymove[i][1], r,i);
|
||||
}
|
||||
}
|
||||
void xy_sink()
|
||||
{
|
||||
for (int i = 0; i < 240; i++)
|
||||
{
|
||||
for (int j = 0; j <= 240; j++)
|
||||
{
|
||||
lcd_black(j, 240 - i);
|
||||
rt_thread_mdelay(1);
|
||||
}
|
||||
// rt_kprintf("(%d,...) Blacked\n", i);
|
||||
}
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
// /* init Wi-Fi auto connect feature */
|
||||
char str[] = "wifi join Dong abcd07691234";
|
||||
my_round(20);
|
||||
|
||||
rt_wlan_config_autoreconnect(RT_TRUE);
|
||||
rt_wlan_connect("Dong", "abcd07691234");
|
||||
system(str);
|
||||
|
||||
/* init Wi-Fi auto connect feature */
|
||||
// wlan_autoconnect_init();
|
||||
// /* enable auto reconnect on WLAN device */
|
||||
// rt_wlan_config_autoreconnect(RT_TRUE);
|
||||
// rt_wlan_connect("ssid", "password");
|
||||
/* enable auto reconnect on WLAN device */
|
||||
|
||||
// lcd_clear(WHITE);
|
||||
|
||||
// /* show RT-Thread logo */
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
#### LCD 显示温湿度
|
||||
![LCD温湿度](lcdtemp.jpg)
|
||||
![LCD温湿度](lcdtemp.jpg)
|
||||
左上角是(0,0) →x,↓y
|
|
@ -44,6 +44,7 @@ float Humi, Temp;
|
|||
rt_uint16_t ps_data;
|
||||
float brightness;
|
||||
int lcd_y;
|
||||
int int_tmp;
|
||||
|
||||
void ath_init(void);
|
||||
void mqt_init(void);
|
||||
|
@ -113,30 +114,40 @@ static int example_subscribe(void *handle)
|
|||
}
|
||||
int plus_lcd_y(int pls)
|
||||
{
|
||||
int_tmp = lcd_y;
|
||||
lcd_y+=pls;
|
||||
return lcd_y;
|
||||
return int_tmp;
|
||||
}
|
||||
void easy_show_lcd(char *title, float Temp)
|
||||
{
|
||||
lcd_show_string(10, plus_lcd_y(24), 24, title);
|
||||
sprintf(tmp, "%f", Temp);
|
||||
lcd_show_string(10, plus_lcd_y(32), 32, tmp);
|
||||
}
|
||||
void show_lcd()
|
||||
{
|
||||
lcd_y = 0;
|
||||
lcd_show_string(10, plus_lcd_y(10), 24, "Temperature:");
|
||||
sprintf(tmp, "%f", Temp);
|
||||
lcd_show_string(10, plus_lcd_y(24), 32, tmp);
|
||||
lcd_y = 10;
|
||||
easy_show_lcd("Temperature:", Temp);
|
||||
easy_show_lcd("Humidity:", Humi);
|
||||
easy_show_lcd("Brightness:(lux)", brightness);
|
||||
easy_show_lcd("Ps data:", (float)ps_data);
|
||||
// lcd_show_string(10, plus_lcd_y(10), 24, "Temperature:");
|
||||
// sprintf(tmp, "%f", Temp);
|
||||
// lcd_show_string(10, plus_lcd_y(24), 32, tmp);
|
||||
|
||||
lcd_show_string(10, plus_lcd_y(32), 24, "Humidity:");
|
||||
sprintf(tmp, "%f", Humi);
|
||||
lcd_show_string(10, plus_lcd_y(24), 32, tmp);
|
||||
// lcd_show_string(10, plus_lcd_y(32), 24, "Humidity:");
|
||||
// sprintf(tmp, "%f", Humi);
|
||||
// lcd_show_string(10, plus_lcd_y(24), 32, tmp);
|
||||
|
||||
lcd_show_string(10, plus_lcd_y(32), 24, "Brightness:");
|
||||
sprintf(tmp, "%f(lux)", brightness);
|
||||
lcd_show_string(10, plus_lcd_y(24), 32, tmp);
|
||||
// lcd_show_string(10, plus_lcd_y(32), 24, "Brightness:");
|
||||
// sprintf(tmp, "%f(lux)", brightness);
|
||||
// lcd_show_string(10, plus_lcd_y(24), 32, tmp);
|
||||
}
|
||||
|
||||
void make_file()
|
||||
{
|
||||
//文件描述符
|
||||
int fd;
|
||||
|
||||
//用只写方式打开文件,如果没有该文件,则创建一个文件
|
||||
fd = open("/fal/test/Data.txt", O_WRONLY | O_CREAT | O_APPEND); //和原来相比,只是把O_TRUNC参数更改为O_APPEND,即更改为打开后,如果再进行写入,将从文件的末尾位置开始写。
|
||||
// rt_kprintf("\n%f %f tmp:%s\n",Humi,Temp,String);
|
||||
|
@ -145,18 +156,14 @@ void make_file()
|
|||
{
|
||||
//写入文件
|
||||
write(fd, tmp, sizeof(tmp));
|
||||
|
||||
// rt_kprintf("Write done.\n");
|
||||
|
||||
//关闭文件
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("File Open Fail.\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
int cnt = 0;
|
||||
|
@ -167,12 +174,13 @@ void tmp_payload(void)
|
|||
Temp = aht10_read_temperature(Dev);
|
||||
brightness = ap3216c_read_ambient_light(dev);
|
||||
ps_data = ap3216c_read_ps_data(dev);
|
||||
memset(tmp, 0, sizeof(tmp));
|
||||
sprintf(tmp, "Temp: %.1f;Humi: %.1f;Count: %d\n", Temp, Humi,++cnt);
|
||||
// icm20608_get_accel(icm20608_device_t dev, rt_int16_t *accel_x, rt_int16_t *accel_y, rt_int16_t *accel_z)
|
||||
// memset(tmp, 0, sizeof(tmp));
|
||||
// sprintf(tmp, "Temp: %.1f;Humi: %.1f;Count: %d\n", Temp, Humi,++cnt);
|
||||
// rt_kprintf("\n%f %f tmp:%s\n",Humi,Temp,tmp);
|
||||
make_file();
|
||||
// make_file();
|
||||
show_lcd();
|
||||
sprintf(tmp, "{\"params\":{\"temperature\":%.2f,\"humidity\":%.2f}}", Temp, Humi);
|
||||
sprintf(tmp, "{\"params\":{\"temperature\":%.2f,\"humidity\":%.2f,,\"LightLux\":%.2f,\"Psdata\":%d}}", Temp, Humi,brightness,ps_data);
|
||||
return;
|
||||
}
|
||||
void test_lcd()
|
||||
|
@ -300,12 +308,20 @@ void mqt_init(void)
|
|||
}
|
||||
int ap3_init(void){
|
||||
const char* i2c_bus_name = "i2c2";
|
||||
rt_thread_t tid;
|
||||
|
||||
dev = ap3216c_init(i2c_bus_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
// void i20_init(void)
|
||||
// {
|
||||
// const char* i2c_bus_name = "i2c2";
|
||||
|
||||
// icm20608_init(i2c_bus_name)
|
||||
|
||||
// return 0;
|
||||
|
||||
// }
|
||||
void my_project(void)
|
||||
{
|
||||
ath_init();
|
||||
|
|
10
rtconfig.h
10
rtconfig.h
|
@ -331,6 +331,16 @@
|
|||
|
||||
/* end of CYW43439 WiFi */
|
||||
/* end of Wi-Fi */
|
||||
#define PKG_USING_NETUTILS
|
||||
#define PKG_NETUTILS_NTP
|
||||
#define NTP_USING_AUTO_SYNC
|
||||
#define NTP_AUTO_SYNC_FIRST_DELAY 30
|
||||
#define NTP_AUTO_SYNC_PERIOD 3600
|
||||
#define NETUTILS_NTP_HOSTNAME "cn.ntp.org.cn"
|
||||
#define NETUTILS_NTP_HOSTNAME2 "ntp.rt-thread.org"
|
||||
#define NETUTILS_NTP_HOSTNAME3 "edu.ntp.org.cn"
|
||||
#define PKG_USING_NETUTILS_LATEST_VERSION
|
||||
#define PKG_NETUTILS_VER_NUM 0x99999
|
||||
|
||||
/* IoT Cloud */
|
||||
|
||||
|
|
Loading…
Reference in New Issue