MakeBlock Drive Updated Updated library for MakeBlock Ranger

Loading...
Searching...
No Matches
MePm25Sensor.h
Go to the documentation of this file.
1
59#ifndef MePm25Sensor_H
60#define MePm25Sensor_H
61
62#include <stdint.h>
63#include <stdbool.h>
64#include <Arduino.h>
65#include "MeConfig.h"
66#include "MeSerial.h"
67
68#define START_SYSEX1 0x32
69#define START_SYSEX2 0x3d
70#define LENGTH 28//帧长度
71
72//#define DEFAULT_UART_BUF_SIZE 32
73
74 typedef struct{
75// uint16_t head;//0x323d
76 uint16_t len;
77 uint16_t data1;
78 uint16_t data2;
79 uint16_t data3;
80 uint16_t data4;
81 uint16_t data5;
82 uint16_t data6;
83 uint16_t data7;
84 uint16_t data8;
85 uint16_t data9;
86 uint16_t data10;//default
87 uint16_t data11;//default
88 uint16_t data12;//default
89 uint16_t data13;//default
90 uint16_t checksum;
91}PM25DATASTRUCT;
92
93
94 union PM25DATAUINO{
95 uint8_t storedInputData[31];
96 PM25DATASTRUCT val;
97};
98
99#ifdef ME_PORT_DEFINED
100#include "MePort.h"
101#endif /* ME_PORT_DEFINED */
102
108#ifndef ME_PORT_DEFINED
109 class MePm25Sensor
110#else /* !ME_PORT_DEFINED */
111class MePm25Sensor : public MeSerial
112#endif
113/* !ME_PORT_DEFINED */
114{
115 public:
116#ifdef ME_PORT_DEFINED
123 MePm25Sensor();
124
131 MePm25Sensor(uint8_t port);
132#else // ME_PORT_DEFINED
143 MePm25Sensor(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic);
144#endif // ME_PORT_DEFINED
161 uint16_t readPm1_0Concentration(void);//PM1.0 ug/m^3
178 uint16_t readPm2_5Concentration(void);//PM2.5 ug/m^3
195 uint16_t readPm10Concentration(void);//PM10 ug/m^3
212 uint16_t read0_3NumIn100ml(void);//0.1L空气中直径在0.3um的颗粒物个数
229 uint16_t read0_5NumIn100ml(void);//0.1L空气中直径在0.5um的颗粒物个数
246 uint16_t read1_0NumIn100ml(void);//0.1L空气中直径在1.0um的颗粒物个数
263 uint16_t read2_5NumIn100ml(void);//0.1L空气中直径在2.5um的颗粒物个数
280 uint16_t read5_0NumIn100ml(void);//0.1L空气中直径在5.0um的颗粒物个数
297 uint16_t read10NumIn100ml(void);//0.1L空气中直径在10um的颗粒物个数
314 uint16_t setOuputCompatibility(void);//设置输出兼容
331 uint16_t turnOnFanLaser(void);//打开风扇激光
348 uint16_t turnOffFanLaser(void);//关闭风扇激光
365 uint16_t OutputIntimeOn(void);//定时输出开
382 uint16_t OutputIntimeOff(void);//定时输出关
399 uint16_t setOutputIntimePeriod(uint16_t settime);//设定定时输出间隔
416 uint16_t askForData(void);//请求输出数据
433 uint16_t coreSelfTest(void);//滤芯检测
450 uint16_t returnCoreSelfTest(void);//返回自检结果
467 uint16_t setCoreSelfTestTime(uint8_t settime);//设定检测时间 0~255s
484 uint16_t setCoreEfficient(uint8_t efficent);//设定滤芯使用效率
499 void rxloop(void);
514 uint16_t returnlen(void);//返回有效数据长度
529 uint16_t returnchecksum(void);//返回校验值
530 private:
531 union PM25DATAUINO sysex,rxbuf;
532 // uint8_t buffer_flag;
533 volatile int16_t sysexBytesRead;
534 // volatile uint16_t resFlag;
535 // volatile servo_device_type servo_dev_list[8];
536 // volatile long cmdTimeOutValue;
537 volatile boolean parsingSysex;
538};
539
540#endif
MeConfig.h
Configuration file of library.
MePort.h
Header for MePort.cpp module.
MeSerial.h
Header for for MeSerial.cpp module.
MePm25Sensor
Driver for Me PM2.5 sensor device.
Definition MePm25Sensor.h:114
MePm25Sensor::MePm25Sensor
MePm25Sensor()
Definition MePm25Sensor.cpp:71
MePm25Sensor::returnchecksum
uint16_t returnchecksum(void)
Definition MePm25Sensor.cpp:733
MePm25Sensor::returnlen
uint16_t returnlen(void)
Definition MePm25Sensor.cpp:714
MeSerial
Driver for serial.
Definition MeSerial.h:67
PM25DATASTRUCT
Definition MePm25Sensor.h:74
PM25DATAUINO
Definition MePm25Sensor.h:94