在這篇文章中我們展示如何采集溫濕度計,今天向大家介紹采集溫度后顯示于墨水屏。并實現深度休眠模式,同時展示工作、休眠的電流檢測。
1、增加墨水屏顯示:
創建epaper文件夾并加入下圖所示的spi驅動、墨水屏顯示、繪畫、字庫等:
2、main.c的實現:
#include
#include
#include "sensor_renesas_hs300x.h"
#include "drv_gpio.h"
#include
#include "Display_EPD_w21.h"
#include "Display_EPD_W21_spi.h"
#include "fonts.h"
#include "GUI_Paint.h"
#define USE_SECONDS_FOR_ALARM 10
#define LONG_GLITCH_DELAY_MS 100u /* in ms */
#define RTC_INTERRUPT_PRIORITY 3u
void set_rtc_alarm_date_time(void);
cyhal_rtc_t rtc_obj;
unsigned char BlackImage[4736];//Define canvas space
extern struct hs300x_device temp_humi_dev;
int main(void)
{
cy_rslt_t result;
float temp, humi;
uint8_t show_str[20] = {0};
EPD_GPIO_Init(); //EPD GPIO initialization
__enable_irq();
rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
Paint_NewImage(BlackImage, 128, 296, 270, WHITE); //Set screen size and display orientation
Paint_SelectImage(BlackImage);//Set the virtual canvas data storage location
Paint_NewImage(BlackImage, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
Paint_SelectImage(BlackImage);//Set the virtual canvas data storage location
EPD_DeepSleep();
/* Initialize RTC */
cyhal_rtc_enable_event(&rtc_obj, CYHAL_RTC_ALARM, RTC_INTERRUPT_PRIORITY, true);
set_rtc_alarm_date_time();
for (;;)
{
/* Go to deep sleep */
cyhal_syspm_deepsleep();
set_rtc_alarm_date_time();
hs300x_read_data(&temp_humi_dev, &humi, &temp);
EPD_HW_Init(); //Electronic paper initialization
EPD_HW_Init_GUI(); //EPD init GUI
Paint_Clear(WHITE);
sprintf(show_str,"溫度%02d.%02d℃",(int)temp, (int)(temp*100)%100);
Paint_DrawString_CN(40,0,show_str, &Font24CN, WHITE, BLACK);
sprintf(show_str,"濕度%02d.%02d%%",(int)humi, (int)(humi*100)%100);
Paint_DrawString_CN(40,40,show_str, &Font24CN, WHITE, BLACK);
EPD_Display(BlackImage); //display image
EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!
}
}
實現的效果:
上傳開發板以后工作電流為19MA,休眠電流為450uA左右。
-
SPI接口
+關注
關注
0文章
259瀏覽量
34554 -
溫濕度計
+關注
關注
1文章
23瀏覽量
8166
發布評論請先 登錄
相關推薦
基于PSoC62開發板的智能室內環境監測系統
如何在PSoC62 Evaluation kit開發板上運行RT-Thread呢?
![如何在<b class='flag-5'>PSoC62</b> Evaluation kit開發板上運行RT-Thread呢?](https://file1.elecfans.com/web2/M00/C1/40/wKgZomXdTiCALqQxAABSO4fFgn4963.jpg)
![](https://file.elecfans.com/web2/M00/AA/09/pYYBAGR7QxqAHk-AAAJ7Zw4oCD4091.png)
英飛凌PSoC62 實現超低功耗溫濕度計
基于STM32的低功耗溫濕度采集器的設計與實現
![基于STM32的低<b class='flag-5'>功耗</b><b class='flag-5'>溫濕</b>度<b class='flag-5'>采集</b>器的設計與實現](https://file1.elecfans.com//web2/M00/A7/1C/wKgZomUMQnCALfPkAAAfVpM82nE724.png)
【RT-Thread Studio更新】英飛凌 PSOC62-IFX-PROTO-KIT 開發環境搭建指南
英飛凌聯合 RT-Thread 發布 PSoC? 62 with CAPSENSE ? evaluation kit開發板
基于PSOC62 CAPSENSE evaluation kit的遠程空調遙控器設計
![基于<b class='flag-5'>PSOC62</b> CAPSENSE evaluation kit的遠程空調遙控器設計](https://file1.elecfans.com/web2/M00/8D/2C/wKgZomS3i6GACADQAAC2v1BiYVA672.jpg)
評論