mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
Merge pull request #275 from biveraxe/ver4dev
Модули S8, Encoder, поддержка 8285. Пробуем реанимировать ESP32Cam - пока промежуточный результат.
This commit is contained in:
@@ -192,7 +192,19 @@
|
|||||||
"header": "Сенсоры"
|
"header": "Сенсоры"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "13. Acs712 Ток",
|
"name": "13. A02 Дальность",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "A02Distance",
|
||||||
|
"id": "dist",
|
||||||
|
"widget": "anydataCm",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "Дальность",
|
||||||
|
"int": 5,
|
||||||
|
"round": 1,
|
||||||
|
"num": 13
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "14. Acs712 Ток",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Acs712",
|
"subtype": "Acs712",
|
||||||
"id": "amp",
|
"id": "amp",
|
||||||
@@ -207,11 +219,11 @@
|
|||||||
"sens": 100,
|
"sens": 100,
|
||||||
"adczero": 512,
|
"adczero": 512,
|
||||||
"btn-setZero": "nil",
|
"btn-setZero": "nil",
|
||||||
"num": 13
|
"num": 14
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "14. AHTXX Температура",
|
"name": "15. AHTXX Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "AhtXXt",
|
"subtype": "AhtXXt",
|
||||||
"id": "Temp20",
|
"id": "Temp20",
|
||||||
@@ -222,11 +234,11 @@
|
|||||||
"addr": "0x38",
|
"addr": "0x38",
|
||||||
"shtType": 1,
|
"shtType": 1,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 14
|
"num": 15
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "15. AHTXX Влажность",
|
"name": "16. AHTXX Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "AhtXXh",
|
"subtype": "AhtXXh",
|
||||||
"id": "Hum20",
|
"id": "Hum20",
|
||||||
@@ -237,11 +249,11 @@
|
|||||||
"addr": "0x38",
|
"addr": "0x38",
|
||||||
"shtType": 1,
|
"shtType": 1,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 15
|
"num": 16
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "16. Аналоговый сенсор",
|
"name": "17. Аналоговый сенсор",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "AnalogAdc",
|
"subtype": "AnalogAdc",
|
||||||
"id": "t",
|
"id": "t",
|
||||||
@@ -255,11 +267,11 @@
|
|||||||
"pin": 0,
|
"pin": 0,
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"avgSteps": 1,
|
"avgSteps": 1,
|
||||||
"num": 16
|
"num": 17
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "17. BME280 Температура",
|
"name": "18. BME280 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bme280t",
|
"subtype": "Bme280t",
|
||||||
"id": "Tmp3",
|
"id": "Tmp3",
|
||||||
@@ -269,11 +281,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 17
|
"num": 18
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "18. BME280 Давление",
|
"name": "19. BME280 Давление",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bme280p",
|
"subtype": "Bme280p",
|
||||||
"id": "Press3",
|
"id": "Press3",
|
||||||
@@ -283,11 +295,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 18
|
"num": 19
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "19. BME280 Влажность",
|
"name": "20. BME280 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bme280h",
|
"subtype": "Bme280h",
|
||||||
"id": "Hum3",
|
"id": "Hum3",
|
||||||
@@ -297,11 +309,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 19
|
"num": 20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "20. BME280 Tочка росы",
|
"name": "21. BME280 Tочка росы",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bme280dp",
|
"subtype": "Bme280dp",
|
||||||
"id": "Dew3",
|
"id": "Dew3",
|
||||||
@@ -311,11 +323,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 20
|
"num": 21
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "21. BMP280 Температура",
|
"name": "22. BMP280 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bmp280t",
|
"subtype": "Bmp280t",
|
||||||
"id": "tmp3",
|
"id": "tmp3",
|
||||||
@@ -325,11 +337,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 21
|
"num": 22
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "22. BMP280 Давление",
|
"name": "23. BMP280 Давление",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bmp280p",
|
"subtype": "Bmp280p",
|
||||||
"id": "Press3",
|
"id": "Press3",
|
||||||
@@ -339,11 +351,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 22
|
"num": 23
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "23. DHT11 Температура",
|
"name": "24. DHT11 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Dht1122t",
|
"subtype": "Dht1122t",
|
||||||
"id": "tmp3",
|
"id": "tmp3",
|
||||||
@@ -353,11 +365,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"pin": 0,
|
"pin": 0,
|
||||||
"senstype": "dht11",
|
"senstype": "dht11",
|
||||||
"num": 23
|
"num": 24
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "24. DHT11 Влажность",
|
"name": "25. DHT11 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Dht1122h",
|
"subtype": "Dht1122h",
|
||||||
"id": "Hum3",
|
"id": "Hum3",
|
||||||
@@ -367,11 +379,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"pin": 0,
|
"pin": 0,
|
||||||
"senstype": "dht11",
|
"senstype": "dht11",
|
||||||
"num": 24
|
"num": 25
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "25. DS18B20 Температура",
|
"name": "26. DS18B20 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Ds18b20",
|
"subtype": "Ds18b20",
|
||||||
"id": "dstmp",
|
"id": "dstmp",
|
||||||
@@ -383,11 +395,11 @@
|
|||||||
"index": 0,
|
"index": 0,
|
||||||
"addr": "",
|
"addr": "",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 25
|
"num": 26
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "26. Аналоговый счетчик импульсов",
|
"name": "27. Аналоговый счетчик импульсов",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "Impulse",
|
"subtype": "Impulse",
|
||||||
"id": "impulse",
|
"id": "impulse",
|
||||||
@@ -400,11 +412,11 @@
|
|||||||
"pinMode": "INPUT",
|
"pinMode": "INPUT",
|
||||||
"debounceDelay": 3,
|
"debounceDelay": 3,
|
||||||
"multiply": 1,
|
"multiply": 1,
|
||||||
"num": 26
|
"num": 27
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "27. PZEM 004t Напряжение",
|
"name": "28. PZEM 004t Напряжение",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004v",
|
"subtype": "Pzem004v",
|
||||||
"id": "v",
|
"id": "v",
|
||||||
@@ -414,11 +426,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 27
|
"num": 28
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "28. PZEM 004t Сила тока",
|
"name": "29. PZEM 004t Сила тока",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004a",
|
"subtype": "Pzem004a",
|
||||||
"id": "a",
|
"id": "a",
|
||||||
@@ -428,11 +440,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 28
|
"num": 29
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "29. PZEM 004t Мощность",
|
"name": "30. PZEM 004t Мощность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004w",
|
"subtype": "Pzem004w",
|
||||||
"id": "w",
|
"id": "w",
|
||||||
@@ -442,11 +454,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 29
|
"num": 30
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "30. PZEM 004t Энергия",
|
"name": "31. PZEM 004t Энергия",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004wh",
|
"subtype": "Pzem004wh",
|
||||||
"id": "wh",
|
"id": "wh",
|
||||||
@@ -456,11 +468,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 30
|
"num": 31
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "31. PZEM 004t Частота",
|
"name": "32. PZEM 004t Частота",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004hz",
|
"subtype": "Pzem004hz",
|
||||||
"id": "hz",
|
"id": "hz",
|
||||||
@@ -470,11 +482,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 31
|
"num": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "32. PZEM 004t Косинус",
|
"name": "33. PZEM 004t Косинус",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004pf",
|
"subtype": "Pzem004pf",
|
||||||
"id": "pf",
|
"id": "pf",
|
||||||
@@ -484,11 +496,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0xF8",
|
"addr": "0xF8",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 32
|
"num": 33
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "33. PZEM настройка",
|
"name": "34. PZEM настройка",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pzem004cmd",
|
"subtype": "Pzem004cmd",
|
||||||
"id": "set",
|
"id": "set",
|
||||||
@@ -500,11 +512,11 @@
|
|||||||
"changeaddr": 0,
|
"changeaddr": 0,
|
||||||
"setaddr": "0x01",
|
"setaddr": "0x01",
|
||||||
"reset": 0,
|
"reset": 0,
|
||||||
"num": 33
|
"num": 34
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "34. Часы реального времени",
|
"name": "35. Часы реального времени",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "RTC",
|
"subtype": "RTC",
|
||||||
"id": "rtc",
|
"id": "rtc",
|
||||||
@@ -520,11 +532,25 @@
|
|||||||
"int": 5,
|
"int": 5,
|
||||||
"btn-setUTime": "0",
|
"btn-setUTime": "0",
|
||||||
"btn-setSysTime": "nil",
|
"btn-setSysTime": "nil",
|
||||||
"num": 34
|
"num": 35
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "36. (S8) Cенсор качества воздуха",
|
||||||
|
"num": 36,
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "S8co",
|
||||||
|
"id": "s8co",
|
||||||
|
"widget": "anydataPpm",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "S8_CO2",
|
||||||
|
"int": 15,
|
||||||
|
"round": 1,
|
||||||
|
"rxPin": 13,
|
||||||
|
"txPin": 15
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "35. Sht20 Температура",
|
"name": "37. Sht20 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht20t",
|
"subtype": "Sht20t",
|
||||||
"id": "tmp2",
|
"id": "tmp2",
|
||||||
@@ -533,11 +559,11 @@
|
|||||||
"descr": "Температура",
|
"descr": "Температура",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 35
|
"num": 37
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "36. Sht20 Влажность",
|
"name": "38. Sht20 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht20h",
|
"subtype": "Sht20h",
|
||||||
"id": "Hum2",
|
"id": "Hum2",
|
||||||
@@ -546,11 +572,11 @@
|
|||||||
"descr": "Влажность",
|
"descr": "Влажность",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 36
|
"num": 38
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "37. Sht30 Температура",
|
"name": "39. Sht30 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht30t",
|
"subtype": "Sht30t",
|
||||||
"id": "tmp30",
|
"id": "tmp30",
|
||||||
@@ -559,11 +585,11 @@
|
|||||||
"descr": "SHT30 Температура",
|
"descr": "SHT30 Температура",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 37
|
"num": 39
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "38. Sht30 Влажность",
|
"name": "40. Sht30 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht30h",
|
"subtype": "Sht30h",
|
||||||
"id": "Hum30",
|
"id": "Hum30",
|
||||||
@@ -572,12 +598,12 @@
|
|||||||
"descr": "SHT30 Влажность",
|
"descr": "SHT30 Влажность",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 38
|
"num": 40
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "39. HC-SR04 Ультразвуковой дальномер",
|
"name": "41. HC-SR04 Ультразвуковой дальномер",
|
||||||
"num": 39,
|
"num": 41,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sonar",
|
"subtype": "Sonar",
|
||||||
"id": "sonar",
|
"id": "sonar",
|
||||||
@@ -589,7 +615,7 @@
|
|||||||
"int": 5
|
"int": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "40. UART",
|
"name": "42. UART",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "UART",
|
"subtype": "UART",
|
||||||
"page": "",
|
"page": "",
|
||||||
@@ -601,14 +627,14 @@
|
|||||||
"line": 2,
|
"line": 2,
|
||||||
"speed": 9600,
|
"speed": 9600,
|
||||||
"eventFormat": 0,
|
"eventFormat": 0,
|
||||||
"num": 40
|
"num": 42
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"header": "Исполнительные устройства"
|
"header": "Исполнительные устройства"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "41. Кнопка подключенная к пину",
|
"name": "43. Кнопка подключенная к пину",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "ButtonIn",
|
"subtype": "ButtonIn",
|
||||||
"id": "btn",
|
"id": "btn",
|
||||||
@@ -623,11 +649,11 @@
|
|||||||
"debounceDelay": 50,
|
"debounceDelay": 50,
|
||||||
"fixState": 0,
|
"fixState": 0,
|
||||||
"inv": 0,
|
"inv": 0,
|
||||||
"num": 41
|
"num": 43
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "42. Управление пином",
|
"name": "44. Управление пином",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "ButtonOut",
|
"subtype": "ButtonOut",
|
||||||
"needSave": 0,
|
"needSave": 0,
|
||||||
@@ -638,11 +664,28 @@
|
|||||||
"int": 0,
|
"int": 0,
|
||||||
"inv": 0,
|
"inv": 0,
|
||||||
"pin": 2,
|
"pin": 2,
|
||||||
"num": 42
|
"num": 44
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "43. Сервопривод",
|
"name": "45. Энкодер",
|
||||||
|
"type": "Writing",
|
||||||
|
"subtype": "Encoder",
|
||||||
|
"id": "enc",
|
||||||
|
"widget": "inputDgt",
|
||||||
|
"page": "Энкодер",
|
||||||
|
"descr": "Громкость",
|
||||||
|
"needSave": 0,
|
||||||
|
"val": "0",
|
||||||
|
"round": 0,
|
||||||
|
"step": 1,
|
||||||
|
"stepOnPress": 5,
|
||||||
|
"pins": "4,5,2",
|
||||||
|
"num": 45
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "46. Сервопривод",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "IoTServo",
|
"subtype": "IoTServo",
|
||||||
"id": "servo",
|
"id": "servo",
|
||||||
@@ -653,11 +696,11 @@
|
|||||||
"pin": 12,
|
"pin": 12,
|
||||||
"apin": -1,
|
"apin": -1,
|
||||||
"amap": "0, 4096, 0, 180",
|
"amap": "0, 4096, 0, 180",
|
||||||
"num": 43
|
"num": 46
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "44. Расширитель портов Mcp23017",
|
"name": "47. Расширитель портов Mcp23017",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Mcp23017",
|
"subtype": "Mcp23017",
|
||||||
"id": "Mcp",
|
"id": "Mcp",
|
||||||
@@ -667,11 +710,11 @@
|
|||||||
"int": "0",
|
"int": "0",
|
||||||
"addr": "0x20",
|
"addr": "0x20",
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"num": 44
|
"num": 47
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "45. MP3 плеер",
|
"name": "48. MP3 плеер",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Mp3",
|
"subtype": "Mp3",
|
||||||
"id": "mp3",
|
"id": "mp3",
|
||||||
@@ -681,11 +724,11 @@
|
|||||||
"int": 1,
|
"int": 1,
|
||||||
"pins": "14,12",
|
"pins": "14,12",
|
||||||
"volume": 20,
|
"volume": 20,
|
||||||
"num": 45
|
"num": 48
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "46. Сенсорная кнопка",
|
"name": "49. Сенсорная кнопка",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "Multitouch",
|
"subtype": "Multitouch",
|
||||||
"id": "impulse",
|
"id": "impulse",
|
||||||
@@ -699,11 +742,11 @@
|
|||||||
"pinMode": "INPUT",
|
"pinMode": "INPUT",
|
||||||
"debounceDelay": 50,
|
"debounceDelay": 50,
|
||||||
"PWMDelay": 500,
|
"PWMDelay": 500,
|
||||||
"num": 46
|
"num": 49
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "47. Расширитель портов Pcf8574",
|
"name": "50. Расширитель портов Pcf8574",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pcf8574",
|
"subtype": "Pcf8574",
|
||||||
"id": "Pcf",
|
"id": "Pcf",
|
||||||
@@ -713,11 +756,11 @@
|
|||||||
"int": "0",
|
"int": "0",
|
||||||
"addr": "0x20",
|
"addr": "0x20",
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"num": 47
|
"num": 50
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "48. PWM ESP8266",
|
"name": "51. PWM ESP8266",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "Pwm8266",
|
"subtype": "Pwm8266",
|
||||||
"id": "pwm",
|
"id": "pwm",
|
||||||
@@ -729,11 +772,11 @@
|
|||||||
"freq": 5000,
|
"freq": 5000,
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"apin": -1,
|
"apin": -1,
|
||||||
"num": 48
|
"num": 51
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "49. Телеграм-Лайт",
|
"name": "52. Телеграм-Лайт",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "TelegramLT",
|
"subtype": "TelegramLT",
|
||||||
"id": "tg",
|
"id": "tg",
|
||||||
@@ -742,14 +785,14 @@
|
|||||||
"descr": "",
|
"descr": "",
|
||||||
"token": "",
|
"token": "",
|
||||||
"chatID": "",
|
"chatID": "",
|
||||||
"num": 49
|
"num": 52
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"header": "Экраны"
|
"header": "Экраны"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "50. LCD экран 2004",
|
"name": "53. LCD экран 2004",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -761,10 +804,10 @@
|
|||||||
"size": "20,4",
|
"size": "20,4",
|
||||||
"coord": "0,0",
|
"coord": "0,0",
|
||||||
"id2show": "id датчика",
|
"id2show": "id датчика",
|
||||||
"num": 50
|
"num": 53
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "51. LCD экран 1602",
|
"name": "54. LCD экран 1602",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -776,6 +819,6 @@
|
|||||||
"size": "16,2",
|
"size": "16,2",
|
||||||
"coord": "0,0",
|
"coord": "0,0",
|
||||||
"id2show": "id датчика",
|
"id2show": "id датчика",
|
||||||
"num": 51
|
"num": 54
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -23,7 +23,52 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "2. Таймер",
|
"name": "2. График",
|
||||||
|
"type": "Writing",
|
||||||
|
"subtype": "Loging",
|
||||||
|
"id": "log",
|
||||||
|
"widget": "chart2",
|
||||||
|
"page": "Графики",
|
||||||
|
"descr": "Температура",
|
||||||
|
"num": 2,
|
||||||
|
"int": 5,
|
||||||
|
"logid": "t",
|
||||||
|
"points": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "3. График по событию",
|
||||||
|
"type": "Writing",
|
||||||
|
"subtype": "Loging",
|
||||||
|
"id": "log",
|
||||||
|
"widget": "chart2",
|
||||||
|
"page": "Графики",
|
||||||
|
"descr": "Температура",
|
||||||
|
"int": 0,
|
||||||
|
"num": 3,
|
||||||
|
"points": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "4. График дневного расхода",
|
||||||
|
"type": "Writing",
|
||||||
|
"subtype": "LogingDaily",
|
||||||
|
"id": "log",
|
||||||
|
"widget": "chart3",
|
||||||
|
"page": "Графики",
|
||||||
|
"descr": "Температура",
|
||||||
|
"num": 4,
|
||||||
|
"int": 1,
|
||||||
|
"logid": "t",
|
||||||
|
"points": 365,
|
||||||
|
"telegram": 0,
|
||||||
|
"test": 0,
|
||||||
|
"btn-defvalue": 0,
|
||||||
|
"btn-reset": "nil"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "5. Таймер",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "Timer",
|
"subtype": "Timer",
|
||||||
"id": "timer",
|
"id": "timer",
|
||||||
@@ -35,11 +80,11 @@
|
|||||||
"ticker": 1,
|
"ticker": 1,
|
||||||
"repeat": 1,
|
"repeat": 1,
|
||||||
"needSave": 0,
|
"needSave": 0,
|
||||||
"num": 2
|
"num": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "3. Окно ввода числа (переменная)",
|
"name": "6. Окно ввода числа (переменная)",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Variable",
|
"subtype": "Variable",
|
||||||
"id": "value",
|
"id": "value",
|
||||||
@@ -53,11 +98,11 @@
|
|||||||
"plus": 0,
|
"plus": 0,
|
||||||
"multiply": 1,
|
"multiply": 1,
|
||||||
"round": 0,
|
"round": 0,
|
||||||
"num": 3
|
"num": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "4. Окно ввода времени",
|
"name": "7. Окно ввода времени",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Variable",
|
"subtype": "Variable",
|
||||||
"id": "time",
|
"id": "time",
|
||||||
@@ -67,11 +112,11 @@
|
|||||||
"descr": "Введите время",
|
"descr": "Введите время",
|
||||||
"int": "0",
|
"int": "0",
|
||||||
"val": "02:00",
|
"val": "02:00",
|
||||||
"num": 4
|
"num": 7
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "5. Окно ввода даты",
|
"name": "8. Окно ввода даты",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Variable",
|
"subtype": "Variable",
|
||||||
"id": "time",
|
"id": "time",
|
||||||
@@ -81,11 +126,11 @@
|
|||||||
"descr": "Введите дату",
|
"descr": "Введите дату",
|
||||||
"int": "0",
|
"int": "0",
|
||||||
"val": "24.05.2022",
|
"val": "24.05.2022",
|
||||||
"num": 5
|
"num": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "6. Окно ввода текста",
|
"name": "9. Окно ввода текста",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Variable",
|
"subtype": "Variable",
|
||||||
"id": "txt",
|
"id": "txt",
|
||||||
@@ -95,11 +140,11 @@
|
|||||||
"descr": "Введите текст",
|
"descr": "Введите текст",
|
||||||
"int": "0",
|
"int": "0",
|
||||||
"val": "текст",
|
"val": "текст",
|
||||||
"num": 6
|
"num": 9
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "7. Вывод значения",
|
"name": "10. Вывод значения",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Variable",
|
"subtype": "Variable",
|
||||||
"id": "vout",
|
"id": "vout",
|
||||||
@@ -113,11 +158,11 @@
|
|||||||
"plus": 0,
|
"plus": 0,
|
||||||
"multiply": 1,
|
"multiply": 1,
|
||||||
"round": 0,
|
"round": 0,
|
||||||
"num": 7
|
"num": 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "8. Цветной текст",
|
"name": "11. Цветной текст",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "VariableColor",
|
"subtype": "VariableColor",
|
||||||
"id": "color",
|
"id": "color",
|
||||||
@@ -127,11 +172,11 @@
|
|||||||
"descr": "Цветной текст",
|
"descr": "Цветной текст",
|
||||||
"val": "...",
|
"val": "...",
|
||||||
"round": 0,
|
"round": 0,
|
||||||
"num": 8
|
"num": 11
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "9. Виртуальная кнопка",
|
"name": "12. Виртуальная кнопка",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "VButton",
|
"subtype": "VButton",
|
||||||
"id": "vbtn",
|
"id": "vbtn",
|
||||||
@@ -141,14 +186,44 @@
|
|||||||
"descr": "Кнопка",
|
"descr": "Кнопка",
|
||||||
"int": "0",
|
"int": "0",
|
||||||
"val": "0",
|
"val": "0",
|
||||||
"num": 9
|
"num": 12
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"header": "Сенсоры"
|
"header": "Сенсоры"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "13. A02 Дальность",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "A02Distance",
|
||||||
|
"id": "dist",
|
||||||
|
"widget": "anydataCm",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "Дальность",
|
||||||
|
"int": 5,
|
||||||
|
"round": 1,
|
||||||
|
"num": 13
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "14. Acs712 Ток",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Acs712",
|
||||||
|
"id": "amp",
|
||||||
|
"widget": "anydataAmp",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "Ток",
|
||||||
|
"round": 3,
|
||||||
|
"pin": 39,
|
||||||
|
"int": 5,
|
||||||
|
"rms": 1,
|
||||||
|
"vref": 5000,
|
||||||
|
"sens": 100,
|
||||||
|
"adczero": 512,
|
||||||
|
"btn-setZero": "nil",
|
||||||
|
"num": 14
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "10. Аналоговый сенсор",
|
"name": "15. Аналоговый сенсор",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "AnalogAdc",
|
"subtype": "AnalogAdc",
|
||||||
"id": "t",
|
"id": "t",
|
||||||
@@ -162,11 +237,67 @@
|
|||||||
"pin": 0,
|
"pin": 0,
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"avgSteps": 1,
|
"avgSteps": 1,
|
||||||
"num": 10
|
"num": 15
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "11. BMP280 Температура",
|
"name": "16. BME280 Температура",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Bme280t",
|
||||||
|
"id": "Tmp3",
|
||||||
|
"widget": "anydataTmp",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "Температура",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0x77",
|
||||||
|
"round": 1,
|
||||||
|
"num": 16
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "17. BME280 Давление",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Bme280p",
|
||||||
|
"id": "Press3",
|
||||||
|
"widget": "anydataMm",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "Давление",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0x77",
|
||||||
|
"round": 1,
|
||||||
|
"num": 17
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "18. BME280 Влажность",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Bme280h",
|
||||||
|
"id": "Hum3",
|
||||||
|
"widget": "anydataHum",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "Влажность",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0x77",
|
||||||
|
"round": 1,
|
||||||
|
"num": 18
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "19. BME280 Tочка росы",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Bme280dp",
|
||||||
|
"id": "Dew3",
|
||||||
|
"widget": "anydataTmp",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "Точка росы",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0x77",
|
||||||
|
"round": 1,
|
||||||
|
"num": 19
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "20. BMP280 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bmp280t",
|
"subtype": "Bmp280t",
|
||||||
"id": "tmp3",
|
"id": "tmp3",
|
||||||
@@ -176,11 +307,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 11
|
"num": 20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "12. BMP280 Давление",
|
"name": "21. BMP280 Давление",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Bmp280p",
|
"subtype": "Bmp280p",
|
||||||
"id": "Press3",
|
"id": "Press3",
|
||||||
@@ -190,11 +321,11 @@
|
|||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0x77",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 12
|
"num": 21
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "13. DS18B20 Температура",
|
"name": "22. DS18B20 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Ds18b20",
|
"subtype": "Ds18b20",
|
||||||
"id": "dstmp",
|
"id": "dstmp",
|
||||||
@@ -206,11 +337,128 @@
|
|||||||
"index": 0,
|
"index": 0,
|
||||||
"addr": "",
|
"addr": "",
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 13
|
"num": 22
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "14. Часы реального времени",
|
"name": "23. Аналоговый счетчик импульсов",
|
||||||
|
"type": "Writing",
|
||||||
|
"subtype": "Impulse",
|
||||||
|
"id": "impulse",
|
||||||
|
"widget": "anydataDef",
|
||||||
|
"page": "Счетчики",
|
||||||
|
"descr": "Импульсов",
|
||||||
|
"needSave": 0,
|
||||||
|
"int": 1,
|
||||||
|
"pin": 16,
|
||||||
|
"pinMode": "INPUT",
|
||||||
|
"debounceDelay": 3,
|
||||||
|
"multiply": 1,
|
||||||
|
"num": 23
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "24. PZEM 004t Напряжение",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Pzem004v",
|
||||||
|
"id": "v",
|
||||||
|
"widget": "anydataVlt",
|
||||||
|
"page": "PZEM",
|
||||||
|
"descr": "Напряжение",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0xF8",
|
||||||
|
"round": 1,
|
||||||
|
"num": 24
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "25. PZEM 004t Сила тока",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Pzem004a",
|
||||||
|
"id": "a",
|
||||||
|
"widget": "anydataAmp",
|
||||||
|
"page": "PZEM",
|
||||||
|
"descr": "Сила тока",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0xF8",
|
||||||
|
"round": 1,
|
||||||
|
"num": 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "26. PZEM 004t Мощность",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Pzem004w",
|
||||||
|
"id": "w",
|
||||||
|
"widget": "anydataWt",
|
||||||
|
"page": "PZEM",
|
||||||
|
"descr": "Мощность",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0xF8",
|
||||||
|
"round": 1,
|
||||||
|
"num": 26
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "27. PZEM 004t Энергия",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Pzem004wh",
|
||||||
|
"id": "wh",
|
||||||
|
"widget": "anydataWth",
|
||||||
|
"page": "PZEM",
|
||||||
|
"descr": "Энергия",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0xF8",
|
||||||
|
"round": 1,
|
||||||
|
"num": 27
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "28. PZEM 004t Частота",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Pzem004hz",
|
||||||
|
"id": "hz",
|
||||||
|
"widget": "anydataHtz",
|
||||||
|
"page": "PZEM",
|
||||||
|
"descr": "Частота",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0xF8",
|
||||||
|
"round": 1,
|
||||||
|
"num": 28
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "29. PZEM 004t Косинус",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Pzem004pf",
|
||||||
|
"id": "pf",
|
||||||
|
"widget": "anydata",
|
||||||
|
"page": "PZEM",
|
||||||
|
"descr": "Косинус F",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0xF8",
|
||||||
|
"round": 1,
|
||||||
|
"num": 29
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "30. PZEM настройка",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Pzem004cmd",
|
||||||
|
"id": "set",
|
||||||
|
"widget": "nil",
|
||||||
|
"page": "",
|
||||||
|
"descr": "",
|
||||||
|
"int": 15,
|
||||||
|
"addr": "0xF8",
|
||||||
|
"changeaddr": 0,
|
||||||
|
"setaddr": "0x01",
|
||||||
|
"reset": 0,
|
||||||
|
"num": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "31. Часы реального времени",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "RTC",
|
"subtype": "RTC",
|
||||||
"id": "rtc",
|
"id": "rtc",
|
||||||
@@ -226,11 +474,11 @@
|
|||||||
"int": 5,
|
"int": 5,
|
||||||
"btn-setUTime": "0",
|
"btn-setUTime": "0",
|
||||||
"btn-setSysTime": "nil",
|
"btn-setSysTime": "nil",
|
||||||
"num": 14
|
"num": 31
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "15. Sht20 Температура",
|
"name": "32. Sht20 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht20t",
|
"subtype": "Sht20t",
|
||||||
"id": "tmp2",
|
"id": "tmp2",
|
||||||
@@ -239,11 +487,11 @@
|
|||||||
"descr": "Температура",
|
"descr": "Температура",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 15
|
"num": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "16. Sht20 Влажность",
|
"name": "33. Sht20 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht20h",
|
"subtype": "Sht20h",
|
||||||
"id": "Hum2",
|
"id": "Hum2",
|
||||||
@@ -252,11 +500,11 @@
|
|||||||
"descr": "Влажность",
|
"descr": "Влажность",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 16
|
"num": 33
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "17. Sht30 Температура",
|
"name": "34. Sht30 Температура",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht30t",
|
"subtype": "Sht30t",
|
||||||
"id": "tmp30",
|
"id": "tmp30",
|
||||||
@@ -265,11 +513,11 @@
|
|||||||
"descr": "SHT30 Температура",
|
"descr": "SHT30 Температура",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 17
|
"num": 34
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "18. Sht30 Влажность",
|
"name": "35. Sht30 Влажность",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht30h",
|
"subtype": "Sht30h",
|
||||||
"id": "Hum30",
|
"id": "Hum30",
|
||||||
@@ -278,12 +526,12 @@
|
|||||||
"descr": "SHT30 Влажность",
|
"descr": "SHT30 Влажность",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"round": 1,
|
"round": 1,
|
||||||
"num": 18
|
"num": 35
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "19. HC-SR04 Ультразвуковой дальномер",
|
"name": "36. HC-SR04 Ультразвуковой дальномер",
|
||||||
"num": 19,
|
"num": 36,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sonar",
|
"subtype": "Sonar",
|
||||||
"id": "sonar",
|
"id": "sonar",
|
||||||
@@ -294,12 +542,27 @@
|
|||||||
"pinEcho": 4,
|
"pinEcho": 4,
|
||||||
"int": 5
|
"int": 5
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "37. UART",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "UART",
|
||||||
|
"page": "",
|
||||||
|
"descr": "",
|
||||||
|
"widget": "nil",
|
||||||
|
"id": "u",
|
||||||
|
"tx": 4,
|
||||||
|
"rx": 5,
|
||||||
|
"line": 2,
|
||||||
|
"speed": 9600,
|
||||||
|
"eventFormat": 0,
|
||||||
|
"num": 37
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"header": "Исполнительные устройства"
|
"header": "Исполнительные устройства"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "20. Кнопка подключенная к пину",
|
"name": "38. Кнопка подключенная к пину",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "ButtonIn",
|
"subtype": "ButtonIn",
|
||||||
"id": "btn",
|
"id": "btn",
|
||||||
@@ -314,11 +577,11 @@
|
|||||||
"debounceDelay": 50,
|
"debounceDelay": 50,
|
||||||
"fixState": 0,
|
"fixState": 0,
|
||||||
"inv": 0,
|
"inv": 0,
|
||||||
"num": 20
|
"num": 38
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "21. Управление пином",
|
"name": "39. Управление пином",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "ButtonOut",
|
"subtype": "ButtonOut",
|
||||||
"needSave": 0,
|
"needSave": 0,
|
||||||
@@ -329,11 +592,11 @@
|
|||||||
"int": 0,
|
"int": 0,
|
||||||
"inv": 0,
|
"inv": 0,
|
||||||
"pin": 2,
|
"pin": 2,
|
||||||
"num": 21
|
"num": 39
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "22. Расширитель портов Mcp23017",
|
"name": "40. Расширитель портов Mcp23017",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Mcp23017",
|
"subtype": "Mcp23017",
|
||||||
"id": "Mcp",
|
"id": "Mcp",
|
||||||
@@ -343,11 +606,11 @@
|
|||||||
"int": "0",
|
"int": "0",
|
||||||
"addr": "0x20",
|
"addr": "0x20",
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"num": 22
|
"num": 40
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "23. Сенсорная кнопка",
|
"name": "41. Сенсорная кнопка",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "Multitouch",
|
"subtype": "Multitouch",
|
||||||
"id": "impulse",
|
"id": "impulse",
|
||||||
@@ -361,11 +624,11 @@
|
|||||||
"pinMode": "INPUT",
|
"pinMode": "INPUT",
|
||||||
"debounceDelay": 50,
|
"debounceDelay": 50,
|
||||||
"PWMDelay": 500,
|
"PWMDelay": 500,
|
||||||
"num": 23
|
"num": 41
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "24. Расширитель портов Pcf8574",
|
"name": "42. Расширитель портов Pcf8574",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Pcf8574",
|
"subtype": "Pcf8574",
|
||||||
"id": "Pcf",
|
"id": "Pcf",
|
||||||
@@ -375,11 +638,11 @@
|
|||||||
"int": "0",
|
"int": "0",
|
||||||
"addr": "0x20",
|
"addr": "0x20",
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"num": 24
|
"num": 42
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "25. PWM ESP8266",
|
"name": "43. PWM ESP8266",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "Pwm8266",
|
"subtype": "Pwm8266",
|
||||||
"id": "pwm",
|
"id": "pwm",
|
||||||
@@ -391,11 +654,11 @@
|
|||||||
"freq": 5000,
|
"freq": 5000,
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"apin": -1,
|
"apin": -1,
|
||||||
"num": 25
|
"num": 43
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "26. Телеграм-Лайт",
|
"name": "44. Телеграм-Лайт",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "TelegramLT",
|
"subtype": "TelegramLT",
|
||||||
"id": "tg",
|
"id": "tg",
|
||||||
@@ -404,14 +667,14 @@
|
|||||||
"descr": "",
|
"descr": "",
|
||||||
"token": "",
|
"token": "",
|
||||||
"chatID": "",
|
"chatID": "",
|
||||||
"num": 26
|
"num": 44
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"header": "Экраны"
|
"header": "Экраны"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "27. LCD экран 2004",
|
"name": "45. LCD экран 2004",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -423,10 +686,10 @@
|
|||||||
"size": "20,4",
|
"size": "20,4",
|
||||||
"coord": "0,0",
|
"coord": "0,0",
|
||||||
"id2show": "id датчика",
|
"id2show": "id датчика",
|
||||||
"num": 27
|
"num": 45
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "28. LCD экран 1602",
|
"name": "46. LCD экран 1602",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -438,6 +701,6 @@
|
|||||||
"size": "16,2",
|
"size": "16,2",
|
||||||
"coord": "0,0",
|
"coord": "0,0",
|
||||||
"id2show": "id датчика",
|
"id2show": "id датчика",
|
||||||
"num": 28
|
"num": 46
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
152
platformio.ini
152
platformio.ini
@@ -178,7 +178,16 @@ build_src_filter =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
adafruit/Adafruit BME280 Library
|
adafruit/Adafruit BME280 Library
|
||||||
adafruit/Adafruit BMP280 Library
|
adafruit/Adafruit BMP280 Library
|
||||||
plerup/espsoftwareserial
|
https://github.com/milesburton/Arduino-Temperature-Control-Library
|
||||||
|
https://github.com/tremaru/iarduino_RTC
|
||||||
|
robtillaart/SHT2x@^0.1.1
|
||||||
|
WEMOS SHT3x@1.0.0
|
||||||
|
plerup/EspSoftwareSerial
|
||||||
|
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
|
||||||
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
|
https://github.com/robotclass/RobotClass_LiquidCrystal_I2C
|
||||||
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
+<modules/virtual/Cron>
|
+<modules/virtual/Cron>
|
||||||
+<modules/virtual/Loging>
|
+<modules/virtual/Loging>
|
||||||
@@ -187,18 +196,43 @@ build_src_filter =
|
|||||||
+<modules/virtual/Variable>
|
+<modules/virtual/Variable>
|
||||||
+<modules/virtual/VariableColor>
|
+<modules/virtual/VariableColor>
|
||||||
+<modules/virtual/VButton>
|
+<modules/virtual/VButton>
|
||||||
|
+<modules/sensors/A02Distance>
|
||||||
|
+<modules/sensors/Acs712>
|
||||||
|
+<modules/sensors/AnalogAdc>
|
||||||
+<modules/sensors/Bme280>
|
+<modules/sensors/Bme280>
|
||||||
+<modules/sensors/Bmp280>
|
+<modules/sensors/Bmp280>
|
||||||
|
+<modules/sensors/Ds18b20>
|
||||||
|
+<modules/sensors/Impulse>
|
||||||
+<modules/sensors/Pzem004t>
|
+<modules/sensors/Pzem004t>
|
||||||
|
+<modules/sensors/RTC>
|
||||||
|
+<modules/sensors/Sht20>
|
||||||
|
+<modules/sensors/Sht30>
|
||||||
|
+<modules/sensors/Sonar>
|
||||||
+<modules/sensors/UART>
|
+<modules/sensors/UART>
|
||||||
|
+<modules/exec/ButtonIn>
|
||||||
|
+<modules/exec/ButtonOut>
|
||||||
|
+<modules/exec/Mcp23017>
|
||||||
|
+<modules/exec/Multitouch>
|
||||||
|
+<modules/exec/Pcf8574>
|
||||||
|
+<modules/exec/Pwm8266>
|
||||||
+<modules/exec/TelegramLT>
|
+<modules/exec/TelegramLT>
|
||||||
|
+<modules/display/Lcd2004>
|
||||||
|
|
||||||
[env:esp8266_1mb_fromitems]
|
[env:esp8266_1mb_fromitems]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
adafruit/Adafruit BME280 Library
|
adafruit/Adafruit BME280 Library
|
||||||
adafruit/Adafruit BMP280 Library
|
adafruit/Adafruit BMP280 Library
|
||||||
plerup/espsoftwareserial
|
https://github.com/milesburton/Arduino-Temperature-Control-Library
|
||||||
|
IRremote @ ^4.1.2
|
||||||
|
https://github.com/tremaru/iarduino_RTC
|
||||||
|
robtillaart/SHT2x@^0.1.1
|
||||||
|
WEMOS SHT3x@1.0.0
|
||||||
|
plerup/EspSoftwareSerial
|
||||||
|
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
|
||||||
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
|
https://github.com/robotclass/RobotClass_LiquidCrystal_I2C
|
||||||
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
+<modules/virtual/Cron>
|
+<modules/virtual/Cron>
|
||||||
+<modules/virtual/Loging>
|
+<modules/virtual/Loging>
|
||||||
@@ -207,13 +241,28 @@ build_src_filter =
|
|||||||
+<modules/virtual/Variable>
|
+<modules/virtual/Variable>
|
||||||
+<modules/virtual/VariableColor>
|
+<modules/virtual/VariableColor>
|
||||||
+<modules/virtual/VButton>
|
+<modules/virtual/VButton>
|
||||||
|
+<modules/sensors/A02Distance>
|
||||||
|
+<modules/sensors/Acs712>
|
||||||
|
+<modules/sensors/AnalogAdc>
|
||||||
+<modules/sensors/Bme280>
|
+<modules/sensors/Bme280>
|
||||||
+<modules/sensors/Bmp280>
|
+<modules/sensors/Bmp280>
|
||||||
|
+<modules/sensors/Ds18b20>
|
||||||
|
+<modules/sensors/Impulse>
|
||||||
|
+<modules/sensors/IRswitch>
|
||||||
+<modules/sensors/Pzem004t>
|
+<modules/sensors/Pzem004t>
|
||||||
|
+<modules/sensors/RTC>
|
||||||
|
+<modules/sensors/Sht20>
|
||||||
|
+<modules/sensors/Sht30>
|
||||||
|
+<modules/sensors/Sonar>
|
||||||
+<modules/sensors/UART>
|
+<modules/sensors/UART>
|
||||||
+<modules/exec/ButtonIn>
|
+<modules/exec/ButtonIn>
|
||||||
+<modules/exec/ButtonOut>
|
+<modules/exec/ButtonOut>
|
||||||
|
+<modules/exec/Mcp23017>
|
||||||
|
+<modules/exec/Multitouch>
|
||||||
|
+<modules/exec/Pcf8574>
|
||||||
|
+<modules/exec/Pwm8266>
|
||||||
+<modules/exec/TelegramLT>
|
+<modules/exec/TelegramLT>
|
||||||
|
+<modules/display/Lcd2004>
|
||||||
|
|
||||||
[env:esp8266_2mb_fromitems]
|
[env:esp8266_2mb_fromitems]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
@@ -274,27 +323,41 @@ build_src_filter =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
adafruit/Adafruit BME280 Library
|
adafruit/Adafruit BME280 Library
|
||||||
adafruit/Adafruit BMP280 Library
|
adafruit/Adafruit BMP280 Library
|
||||||
milesburton/DallasTemperature@^3.9.1
|
https://github.com/milesburton/Arduino-Temperature-Control-Library
|
||||||
|
https://github.com/tremaru/iarduino_RTC
|
||||||
robtillaart/SHT2x@^0.1.1
|
robtillaart/SHT2x@^0.1.1
|
||||||
WEMOS SHT3x@1.0.0
|
WEMOS SHT3x@1.0.0
|
||||||
|
plerup/EspSoftwareSerial
|
||||||
|
gyverlibs/EncButton @ ^2.0
|
||||||
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
|
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
|
||||||
adafruit/Adafruit BusIO @ ^1.13.2
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
adafruit/Adafruit BusIO @ ^1.13.2
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
|
https://github.com/robotclass/RobotClass_LiquidCrystal_I2C
|
||||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
+<modules/virtual/Cron>
|
+<modules/virtual/Cron>
|
||||||
|
+<modules/virtual/Loging>
|
||||||
|
+<modules/virtual/LogingDaily>
|
||||||
+<modules/virtual/Timer>
|
+<modules/virtual/Timer>
|
||||||
+<modules/virtual/Variable>
|
+<modules/virtual/Variable>
|
||||||
|
+<modules/virtual/VariableColor>
|
||||||
+<modules/virtual/VButton>
|
+<modules/virtual/VButton>
|
||||||
|
+<modules/sensors/A02Distance>
|
||||||
|
+<modules/sensors/Acs712>
|
||||||
+<modules/sensors/AnalogAdc>
|
+<modules/sensors/AnalogAdc>
|
||||||
+<modules/sensors/Bme280>
|
+<modules/sensors/Bme280>
|
||||||
+<modules/sensors/Bmp280>
|
+<modules/sensors/Bmp280>
|
||||||
+<modules/sensors/Ds18b20>
|
+<modules/sensors/Ds18b20>
|
||||||
|
+<modules/sensors/Impulse>
|
||||||
|
+<modules/sensors/Pzem004t>
|
||||||
|
+<modules/sensors/RTC>
|
||||||
+<modules/sensors/Sht20>
|
+<modules/sensors/Sht20>
|
||||||
+<modules/sensors/Sht30>
|
+<modules/sensors/Sht30>
|
||||||
+<modules/sensors/Sonar>
|
+<modules/sensors/Sonar>
|
||||||
|
+<modules/sensors/UART>
|
||||||
+<modules/exec/ButtonIn>
|
+<modules/exec/ButtonIn>
|
||||||
+<modules/exec/ButtonOut>
|
+<modules/exec/ButtonOut>
|
||||||
|
+<modules/exec/Enconder>
|
||||||
+<modules/exec/Mcp23017>
|
+<modules/exec/Mcp23017>
|
||||||
+<modules/exec/Multitouch>
|
+<modules/exec/Multitouch>
|
||||||
+<modules/exec/Pcf8574>
|
+<modules/exec/Pcf8574>
|
||||||
@@ -313,6 +376,61 @@ lib_deps =
|
|||||||
robtillaart/SHT2x@^0.1.1
|
robtillaart/SHT2x@^0.1.1
|
||||||
WEMOS SHT3x@1.0.0
|
WEMOS SHT3x@1.0.0
|
||||||
plerup/EspSoftwareSerial
|
plerup/EspSoftwareSerial
|
||||||
|
gyverlibs/EncButton @ ^2.0
|
||||||
|
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
|
||||||
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
|
dfrobot/DFRobotDFPlayerMini @ ^1.0.5
|
||||||
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
|
https://github.com/robotclass/RobotClass_LiquidCrystal_I2C
|
||||||
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
|
build_src_filter =
|
||||||
|
+<modules/virtual/Cron>
|
||||||
|
+<modules/virtual/Loging>
|
||||||
|
+<modules/virtual/LogingDaily>
|
||||||
|
+<modules/virtual/Timer>
|
||||||
|
+<modules/virtual/Variable>
|
||||||
|
+<modules/virtual/VariableColor>
|
||||||
|
+<modules/virtual/VButton>
|
||||||
|
+<modules/sensors/A02Distance>
|
||||||
|
+<modules/sensors/Acs712>
|
||||||
|
+<modules/sensors/AhtXX>
|
||||||
|
+<modules/sensors/AnalogAdc>
|
||||||
|
+<modules/sensors/Bme280>
|
||||||
|
+<modules/sensors/Bmp280>
|
||||||
|
+<modules/sensors/Dht1122>
|
||||||
|
+<modules/sensors/Ds18b20>
|
||||||
|
+<modules/sensors/Impulse>
|
||||||
|
+<modules/sensors/Pzem004t>
|
||||||
|
+<modules/sensors/RTC>
|
||||||
|
+<modules/sensors/S8>
|
||||||
|
+<modules/sensors/Sht20>
|
||||||
|
+<modules/sensors/Sht30>
|
||||||
|
+<modules/sensors/Sonar>
|
||||||
|
+<modules/sensors/UART>
|
||||||
|
+<modules/exec/ButtonIn>
|
||||||
|
+<modules/exec/ButtonOut>
|
||||||
|
+<modules/exec/Enconder>
|
||||||
|
+<modules/exec/IoTServo>
|
||||||
|
+<modules/exec/Mcp23017>
|
||||||
|
+<modules/exec/Mp3>
|
||||||
|
+<modules/exec/Multitouch>
|
||||||
|
+<modules/exec/Pcf8574>
|
||||||
|
+<modules/exec/Pwm8266>
|
||||||
|
+<modules/exec/TelegramLT>
|
||||||
|
+<modules/display/Lcd2004>
|
||||||
|
|
||||||
|
[env:esp32_4mb_fromitems]
|
||||||
|
lib_deps =
|
||||||
|
https://github.com/enjoyneering/AHTxx.git
|
||||||
|
adafruit/Adafruit BME280 Library
|
||||||
|
adafruit/Adafruit BMP280 Library
|
||||||
|
beegee-tokyo/DHT sensor library for ESPx
|
||||||
|
https://github.com/milesburton/Arduino-Temperature-Control-Library
|
||||||
|
https://github.com/tremaru/iarduino_RTC
|
||||||
|
robtillaart/SHT2x@^0.1.1
|
||||||
|
WEMOS SHT3x@1.0.0
|
||||||
|
plerup/EspSoftwareSerial
|
||||||
|
https://github.com/RoboticsBrno/ServoESP32
|
||||||
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
|
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
|
||||||
adafruit/Adafruit BusIO @ ^1.13.2
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
dfrobot/DFRobotDFPlayerMini @ ^1.0.5
|
dfrobot/DFRobotDFPlayerMini @ ^1.0.5
|
||||||
@@ -337,6 +455,7 @@ build_src_filter =
|
|||||||
+<modules/sensors/Impulse>
|
+<modules/sensors/Impulse>
|
||||||
+<modules/sensors/Pzem004t>
|
+<modules/sensors/Pzem004t>
|
||||||
+<modules/sensors/RTC>
|
+<modules/sensors/RTC>
|
||||||
|
+<modules/sensors/S8>
|
||||||
+<modules/sensors/Sht20>
|
+<modules/sensors/Sht20>
|
||||||
+<modules/sensors/Sht30>
|
+<modules/sensors/Sht30>
|
||||||
+<modules/sensors/Sonar>
|
+<modules/sensors/Sonar>
|
||||||
@@ -348,30 +467,7 @@ build_src_filter =
|
|||||||
+<modules/exec/Mp3>
|
+<modules/exec/Mp3>
|
||||||
+<modules/exec/Multitouch>
|
+<modules/exec/Multitouch>
|
||||||
+<modules/exec/Pcf8574>
|
+<modules/exec/Pcf8574>
|
||||||
+<modules/exec/Pwm8266>
|
+<modules/exec/Pwm32>
|
||||||
+<modules/exec/TelegramLT>
|
+<modules/exec/TelegramLT>
|
||||||
+<modules/display/Lcd2004>
|
+<modules/display/Lcd2004>
|
||||||
|
|
||||||
[env:esp32_4mb_fromitems]
|
|
||||||
lib_deps =
|
|
||||||
adafruit/Adafruit BME280 Library
|
|
||||||
adafruit/Adafruit BMP280 Library
|
|
||||||
https://github.com/tremaru/iarduino_RTC
|
|
||||||
plerup/EspSoftwareSerial
|
|
||||||
build_src_filter =
|
|
||||||
+<modules/virtual/Cron>
|
|
||||||
+<modules/virtual/Loging>
|
|
||||||
+<modules/virtual/LogingDaily>
|
|
||||||
+<modules/virtual/Timer>
|
|
||||||
+<modules/virtual/Variable>
|
|
||||||
+<modules/virtual/VariableColor>
|
|
||||||
+<modules/virtual/VButton>
|
|
||||||
+<modules/sensors/Bme280>
|
|
||||||
+<modules/sensors/Bmp280>
|
|
||||||
+<modules/sensors/Pzem004t>
|
|
||||||
+<modules/sensors/RTC>
|
|
||||||
+<modules/sensors/UART>
|
|
||||||
+<modules/exec/ButtonIn>
|
|
||||||
+<modules/exec/ButtonOut>
|
|
||||||
+<modules/exec/TelegramLT>
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ void* getAPI_Timer(String subtype, String params);
|
|||||||
void* getAPI_Variable(String subtype, String params);
|
void* getAPI_Variable(String subtype, String params);
|
||||||
void* getAPI_VariableColor(String subtype, String params);
|
void* getAPI_VariableColor(String subtype, String params);
|
||||||
void* getAPI_VButton(String subtype, String params);
|
void* getAPI_VButton(String subtype, String params);
|
||||||
|
void* getAPI_A02Distance(String subtype, String params);
|
||||||
void* getAPI_Acs712(String subtype, String params);
|
void* getAPI_Acs712(String subtype, String params);
|
||||||
void* getAPI_AhtXX(String subtype, String params);
|
void* getAPI_AhtXX(String subtype, String params);
|
||||||
void* getAPI_AnalogAdc(String subtype, String params);
|
void* getAPI_AnalogAdc(String subtype, String params);
|
||||||
@@ -17,12 +18,14 @@ void* getAPI_Ds18b20(String subtype, String params);
|
|||||||
void* getAPI_Impulse(String subtype, String params);
|
void* getAPI_Impulse(String subtype, String params);
|
||||||
void* getAPI_Pzem004(String subtype, String params);
|
void* getAPI_Pzem004(String subtype, String params);
|
||||||
void* getAPI_RTC(String subtype, String params);
|
void* getAPI_RTC(String subtype, String params);
|
||||||
|
void* getAPI_S8(String subtype, String params);
|
||||||
void* getAPI_Sht20(String subtype, String params);
|
void* getAPI_Sht20(String subtype, String params);
|
||||||
void* getAPI_Sht30(String subtype, String params);
|
void* getAPI_Sht30(String subtype, String params);
|
||||||
void* getAPI_Sonar(String subtype, String params);
|
void* getAPI_Sonar(String subtype, String params);
|
||||||
void* getAPI_UART(String subtype, String params);
|
void* getAPI_UART(String subtype, String params);
|
||||||
void* getAPI_ButtonIn(String subtype, String params);
|
void* getAPI_ButtonIn(String subtype, String params);
|
||||||
void* getAPI_ButtonOut(String subtype, String params);
|
void* getAPI_ButtonOut(String subtype, String params);
|
||||||
|
void* getAPI_Encoder(String subtype, String params);
|
||||||
void* getAPI_IoTServo(String subtype, String params);
|
void* getAPI_IoTServo(String subtype, String params);
|
||||||
void* getAPI_Mcp23017(String subtype, String params);
|
void* getAPI_Mcp23017(String subtype, String params);
|
||||||
void* getAPI_Mp3(String subtype, String params);
|
void* getAPI_Mp3(String subtype, String params);
|
||||||
@@ -41,6 +44,7 @@ if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI;
|
|||||||
if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_VariableColor(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_VariableColor(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_VButton(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_VButton(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
if ((tmpAPI = getAPI_A02Distance(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_AhtXX(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_AhtXX(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI;
|
||||||
@@ -51,12 +55,14 @@ if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI;
|
|||||||
if ((tmpAPI = getAPI_Impulse(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Impulse(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Pzem004(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Pzem004(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_RTC(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_RTC(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
if ((tmpAPI = getAPI_S8(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Sht30(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Sht30(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Sonar(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Sonar(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_UART(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_UART(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_ButtonIn(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_ButtonIn(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
if ((tmpAPI = getAPI_Encoder(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
|||||||
63
src/modules/exec/Enconder/Enconder.cpp
Normal file
63
src/modules/exec/Enconder/Enconder.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
#include "classes/IoTItem.h"
|
||||||
|
|
||||||
|
#define EB_FAST 30 // таймаут быстрого поворота энкодера, мс
|
||||||
|
#define EB_DEB 50 // дебаунс кнопки, мс
|
||||||
|
#define EB_CLICK 400 // таймаут накликивания кнопки, мс
|
||||||
|
#include "EncButton2.h"
|
||||||
|
|
||||||
|
|
||||||
|
class Encoder : public IoTItem {
|
||||||
|
private:
|
||||||
|
float step = 1;
|
||||||
|
float stepOnPress = 5;
|
||||||
|
EncButton2<EB_ENCBTN> enc1;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Encoder(String parameters) : IoTItem(parameters) {
|
||||||
|
String pins;
|
||||||
|
jsonRead(parameters, "pins", pins);
|
||||||
|
int CLK = selectFromMarkerToMarker(pins, ",", 0).toInt();
|
||||||
|
int DT = selectFromMarkerToMarker(pins, ",", 1).toInt();
|
||||||
|
int SW = selectFromMarkerToMarker(pins, ",", 2).toInt();
|
||||||
|
|
||||||
|
jsonRead(parameters, "step", step);
|
||||||
|
jsonRead(parameters, "stepOnPress", stepOnPress);
|
||||||
|
|
||||||
|
enc1.setPins(INPUT, CLK, DT, SW);
|
||||||
|
enc1.setEncReverse(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (enc1.tick() != 0) {
|
||||||
|
if (enc1.left()) {
|
||||||
|
value.valD = value.valD - step;
|
||||||
|
regEvent(value.valD, "Encoder_left");
|
||||||
|
} else if (enc1.right()) {
|
||||||
|
value.valD = value.valD + step;
|
||||||
|
regEvent(value.valD, "Encoder_right");
|
||||||
|
} else if (stepOnPress) {
|
||||||
|
if (enc1.leftH()) {
|
||||||
|
value.valD = value.valD - stepOnPress;
|
||||||
|
regEvent(value.valD, "Encoder_leftH");
|
||||||
|
} else if (enc1.rightH()) {
|
||||||
|
value.valD = value.valD + stepOnPress;
|
||||||
|
regEvent(value.valD, "Encoder_rightH");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// в конце лучше вызвать resetState(), чтобы сбросить необработанные флаги!
|
||||||
|
enc1.resetState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~Encoder() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
void* getAPI_Encoder(String subtype, String param) {
|
||||||
|
if (subtype == F("Encoder")) {
|
||||||
|
return new Encoder(param);
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
66
src/modules/exec/Enconder/modinfo.json
Normal file
66
src/modules/exec/Enconder/modinfo.json
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"menuSection": "Исполнительные устройства",
|
||||||
|
"configItem": [
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "Энкодер",
|
||||||
|
"type": "Writing",
|
||||||
|
"subtype": "Encoder",
|
||||||
|
"id": "enc",
|
||||||
|
"widget": "inputDgt",
|
||||||
|
"page": "Энкодер",
|
||||||
|
"descr": "Громкость",
|
||||||
|
"needSave": 0,
|
||||||
|
"val": "0",
|
||||||
|
"round" : 0,
|
||||||
|
|
||||||
|
"step": 1,
|
||||||
|
"stepOnPress": 5,
|
||||||
|
"pins": "4,5,2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"about": {
|
||||||
|
"authorName": "Sergei Yakovlev",
|
||||||
|
"authorContact": "",
|
||||||
|
"authorGit": "",
|
||||||
|
"specialThanks": "",
|
||||||
|
"moduleName": "Encoder",
|
||||||
|
"moduleVersion": "1.5",
|
||||||
|
"usedRam": {
|
||||||
|
"esp32_4mb": 15,
|
||||||
|
"esp8266_4mb": 15
|
||||||
|
},
|
||||||
|
"subTypes": [
|
||||||
|
"Encoder"
|
||||||
|
],
|
||||||
|
"title": "Энкодер",
|
||||||
|
"moduleDesc": "модуль для работы с Энкодером. Кнопочный вариант совместим с модулями Multitouch и ButtonIn",
|
||||||
|
"retInfo": "Значение счетчика",
|
||||||
|
"propInfo": {
|
||||||
|
"step" : "Размер шага Энкодера, может принимать значение 0.0001 или 1000",
|
||||||
|
"stepOnPress": "Размер шага Энкодера при нажатой кнопке, 0 - отключает учет",
|
||||||
|
"pins": "Подключеные пины (CLK, DT, SW)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defActive": true,
|
||||||
|
"usedLibs": {
|
||||||
|
"esp32_4mb": [
|
||||||
|
"gyverlibs/EncButton @ ^2.0"
|
||||||
|
],
|
||||||
|
"esp8266_4mb": [
|
||||||
|
"gyverlibs/EncButton @ ^2.0"
|
||||||
|
],
|
||||||
|
"esp8266_1mb": [
|
||||||
|
"gyverlibs/EncButton @ ^2.0"
|
||||||
|
],
|
||||||
|
"esp8266_1mb_ota": [
|
||||||
|
"gyverlibs/EncButton @ ^2.0"
|
||||||
|
],
|
||||||
|
"esp8285_1mb": [
|
||||||
|
"gyverlibs/EncButton @ ^2.0"
|
||||||
|
],
|
||||||
|
"esp8285_1mb_ota": [
|
||||||
|
"gyverlibs/EncButton @ ^2.0"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,63 +1,66 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "classes/IoTItem.h"
|
#include "classes/IoTItem.h"
|
||||||
|
#include "NTP.h"
|
||||||
|
|
||||||
#include "esp_camera.h"
|
#include "esp_camera.h"
|
||||||
#include "soc/soc.h" // Disable brownour problems
|
#include "soc/soc.h" // Disable brownour problems
|
||||||
#include "soc/rtc_cntl_reg.h" // Disable brownour problems
|
#include "soc/rtc_cntl_reg.h" // Disable brownour problems
|
||||||
|
|
||||||
|
#include "FS.h" // SD Card ESP32
|
||||||
|
#include "SD_MMC.h" // SD Card ESP32
|
||||||
|
|
||||||
// Pin definition for CAMERA_MODEL_AI_THINKER
|
void handleGetPic();
|
||||||
#define PWDN_GPIO_NUM 32
|
|
||||||
#define RESET_GPIO_NUM -1
|
|
||||||
#define XCLK_GPIO_NUM 0
|
|
||||||
#define SIOD_GPIO_NUM 26
|
|
||||||
#define SIOC_GPIO_NUM 27
|
|
||||||
|
|
||||||
#define Y9_GPIO_NUM 35
|
// ===================
|
||||||
#define Y8_GPIO_NUM 34
|
// Select camera model
|
||||||
#define Y7_GPIO_NUM 39
|
// ===================
|
||||||
#define Y6_GPIO_NUM 36
|
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
|
||||||
#define Y5_GPIO_NUM 21
|
//#define CAMERA_MODEL_ESP_EYE // Has PSRAM
|
||||||
#define Y4_GPIO_NUM 19
|
//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
|
||||||
#define Y3_GPIO_NUM 18
|
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
|
||||||
#define Y2_GPIO_NUM 5
|
//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
|
||||||
#define VSYNC_GPIO_NUM 25
|
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
|
||||||
#define HREF_GPIO_NUM 23
|
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
|
||||||
#define PCLK_GPIO_NUM 22
|
//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
|
||||||
|
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
|
||||||
|
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
|
||||||
|
//#define CAMERA_MODEL_XIAO_ESP32S3 // Has PSRAM
|
||||||
|
// ** Espressif Internal Boards **
|
||||||
|
//#define CAMERA_MODEL_ESP32_CAM_BOARD
|
||||||
|
//#define CAMERA_MODEL_ESP32S2_CAM_BOARD
|
||||||
|
//#define CAMERA_MODEL_ESP32S3_CAM_LCD
|
||||||
|
|
||||||
#define PICBUF_SIZE 50000
|
|
||||||
|
#define LED_LEDC_CHANNEL 2 //Using different ledc channel/timer than camera
|
||||||
|
#define CONFIG_LED_MAX_INTENSITY 255
|
||||||
|
|
||||||
|
#include "camera_pins.h"
|
||||||
|
|
||||||
|
|
||||||
IoTItem* globalItem = nullptr;
|
IoTItem* globalItem = nullptr;
|
||||||
bool webTicker = false;
|
|
||||||
|
|
||||||
void handleGetCam() {
|
|
||||||
//Serial.printf("try send pic by size=%d", lastPhotoBSize);
|
|
||||||
if (globalItem && globalItem->value.extBinInfoSize) {
|
|
||||||
//Serial.printf("try send pic by size=%d", globalItem->value.extBinInfoSize);
|
|
||||||
HTTP.send_P(200, "image/jpeg", (char*)globalItem->value.extBinInfo, globalItem->value.extBinInfoSize);
|
|
||||||
if (webTicker) globalItem->regEvent("webAsk", "EspCam");
|
|
||||||
} else HTTP.send(200, "text/json", "Item EspCam not prepared yet or camera hasn't taken a picture yet");
|
|
||||||
}
|
|
||||||
|
|
||||||
class EspCam : public IoTItem {
|
class EspCam : public IoTItem {
|
||||||
private:
|
private:
|
||||||
camera_fb_t * fb = NULL;
|
bool _useLed, _ticker, _webTicker, _initSD;
|
||||||
bool _useLed, _ticker, _webTicker;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool isUsedLed() { return _useLed; }
|
||||||
|
bool isWebTicker() { return _webTicker; }
|
||||||
|
|
||||||
EspCam(String parameters): IoTItem(parameters) {
|
EspCam(String parameters): IoTItem(parameters) {
|
||||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
||||||
|
|
||||||
jsonRead(parameters, "useLed", _useLed); // используем = 1 или нет = 0 подсветку (вспышку)
|
jsonRead(parameters, "useLed", _useLed); // используем = 1 или нет = 0 подсветку (вспышку)
|
||||||
|
if (_useLed) {
|
||||||
|
ledcSetup(LED_LEDC_CHANNEL, 5000, 8);
|
||||||
|
ledcAttachPin(LED_GPIO_NUM, LED_LEDC_CHANNEL);
|
||||||
|
}
|
||||||
|
|
||||||
jsonRead(parameters, "ticker", _ticker); // тикать = 1 - сообщаем всем, что сделали снимок и он готов
|
jsonRead(parameters, "ticker", _ticker); // тикать = 1 - сообщаем всем, что сделали снимок и он готов
|
||||||
jsonRead(parameters, "webTicker", _webTicker); // сообщать всем, что через веб попросили отдать картинку с камеры
|
jsonRead(parameters, "webTicker", _webTicker); // сообщать всем, что через веб попросили отдать картинку с камеры
|
||||||
webTicker = _webTicker;
|
|
||||||
globalItem = this; // выносим адрес переменной экземпляра для доступа к данным из обработчика событий веб
|
globalItem = this; // выносим адрес переменной экземпляра для доступа к данным из обработчика событий веб
|
||||||
|
|
||||||
pinMode(4, OUTPUT);
|
|
||||||
digitalWrite(4, LOW);
|
|
||||||
|
|
||||||
camera_config_t config;
|
camera_config_t config;
|
||||||
config.ledc_channel = LEDC_CHANNEL_0;
|
config.ledc_channel = LEDC_CHANNEL_0;
|
||||||
config.ledc_timer = LEDC_TIMER_0;
|
config.ledc_timer = LEDC_TIMER_0;
|
||||||
@@ -78,76 +81,190 @@ class EspCam : public IoTItem {
|
|||||||
config.pin_pwdn = PWDN_GPIO_NUM;
|
config.pin_pwdn = PWDN_GPIO_NUM;
|
||||||
config.pin_reset = RESET_GPIO_NUM;
|
config.pin_reset = RESET_GPIO_NUM;
|
||||||
config.xclk_freq_hz = 20000000;
|
config.xclk_freq_hz = 20000000;
|
||||||
config.pixel_format = PIXFORMAT_JPEG;
|
config.frame_size = FRAMESIZE_UXGA;
|
||||||
|
config.pixel_format = PIXFORMAT_JPEG; // for streaming
|
||||||
value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * PICBUF_SIZE);
|
//config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition
|
||||||
|
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
|
||||||
|
config.fb_location = CAMERA_FB_IN_PSRAM;
|
||||||
|
config.jpeg_quality = 12;
|
||||||
|
config.fb_count = 1;
|
||||||
|
|
||||||
|
// if PSRAM IC present, init with UXGA resolution and higher JPEG quality
|
||||||
|
// for larger pre-allocated frame buffer.
|
||||||
|
|
||||||
if(psramFound()){
|
if(psramFound()){
|
||||||
config.frame_size = FRAMESIZE_SVGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
|
config.jpeg_quality = 10;
|
||||||
config.jpeg_quality = 20; //0-63 lower number means higher quality
|
config.fb_count = 2;
|
||||||
config.fb_count = 1;
|
config.grab_mode = CAMERA_GRAB_LATEST;
|
||||||
Serial.printf("Camera psramFound\n");
|
|
||||||
} else {
|
} else {
|
||||||
|
// Limit the frame size when PSRAM is not available
|
||||||
config.frame_size = FRAMESIZE_SVGA;
|
config.frame_size = FRAMESIZE_SVGA;
|
||||||
config.jpeg_quality = 20;
|
config.fb_location = CAMERA_FB_IN_DRAM;
|
||||||
config.fb_count = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init Camera
|
#if defined(CAMERA_MODEL_ESP_EYE)
|
||||||
|
pinMode(13, INPUT_PULLUP);
|
||||||
|
pinMode(14, INPUT_PULLUP);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// camera init
|
||||||
esp_err_t err = esp_camera_init(&config);
|
esp_err_t err = esp_camera_init(&config);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
Serial.printf("Camera init failed with error 0x%x\n", err);
|
Serial.printf("Camera init failed with error 0x%x", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
|
// initial sensors are flipped vertically and colors are a bit saturated
|
||||||
|
if (s->id.PID == OV3660_PID) {
|
||||||
|
s->set_vflip(s, 1); // flip it back
|
||||||
|
s->set_brightness(s, 1); // up the brightness just a bit
|
||||||
|
s->set_saturation(s, -2); // lower the saturation
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
|
||||||
|
s->set_vflip(s, 1);
|
||||||
|
s->set_hmirror(s, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CAMERA_MODEL_ESP32S3_EYE)
|
||||||
|
s->set_vflip(s, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HTTP.on("/getpic", HTTP_GET, handleGetPic);
|
||||||
|
|
||||||
|
// Start Micro SD card
|
||||||
|
_initSD = true;
|
||||||
|
Serial.println("Starting SD Card");
|
||||||
|
if(!SD_MMC.begin("/sdcard", true)){
|
||||||
|
Serial.println("SD Card Mount Failed");
|
||||||
|
_initSD = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTP.on("/getcam", HTTP_GET, handleGetCam);
|
uint8_t cardType = SD_MMC.cardType();
|
||||||
|
if(cardType == CARD_NONE){
|
||||||
|
Serial.println("No SD Card attached");
|
||||||
|
_initSD = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::FS &fs = SD_MMC;
|
||||||
|
fs.mkdir("/photos/");
|
||||||
}
|
}
|
||||||
|
|
||||||
void take_picture() {
|
void save_picture(String path = "") {
|
||||||
if (_useLed) digitalWrite(4, HIGH); //Turn on the flash
|
// if (_useLed) digitalWrite(4, HIGH); //Turn on the flash
|
||||||
|
|
||||||
|
// // Take Picture with Camera
|
||||||
|
// fb = esp_camera_fb_get();
|
||||||
|
// if(!fb || fb->len >= PICBUF_SIZE) {
|
||||||
|
// if (fb) {
|
||||||
|
// Serial.printf("Camera capture failed size=%d\n", fb->len);
|
||||||
|
// esp_camera_fb_return(fb);
|
||||||
|
// } else Serial.printf("Camera capture failed\n");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // if (value.extBinInfoSize < fb->len) {
|
||||||
|
// // if (value.extBinInfo) free(value.extBinInfo);
|
||||||
|
// // value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * fb->len);
|
||||||
|
// // }
|
||||||
|
// memcpy(value.extBinInfo, fb->buf, fb->len);
|
||||||
|
// value.extBinInfoSize = fb->len;
|
||||||
|
|
||||||
|
// Serial.printf("try send pic by size=%d", fb->len);
|
||||||
|
|
||||||
|
// if (_useLed) digitalWrite(4, LOW);
|
||||||
|
// if (_ticker) regEvent("shot", "EspCam");
|
||||||
|
// esp_camera_fb_return(fb);
|
||||||
|
|
||||||
|
|
||||||
|
// Save picture to microSD card
|
||||||
|
fs::FS &fs = SD_MMC;
|
||||||
|
|
||||||
|
if (path == "") {
|
||||||
|
path = "/photos/";
|
||||||
|
path += getTodayDateDotFormated();
|
||||||
|
path += "/";
|
||||||
|
fs.mkdir(path.c_str());
|
||||||
|
|
||||||
|
char buf[32];
|
||||||
|
sprintf(buf, "%02d-%02d-%02d", _time_local.hour, _time_local.minute, _time_local.second);
|
||||||
|
path += buf;
|
||||||
|
path += ".jpg";
|
||||||
|
}
|
||||||
|
Serial.println(path);
|
||||||
|
|
||||||
// Take Picture with Camera
|
// Take Picture with Camera
|
||||||
fb = esp_camera_fb_get();
|
camera_fb_t * fb = esp_camera_fb_get();
|
||||||
if(!fb || fb->len >= PICBUF_SIZE) {
|
|
||||||
if (fb) {
|
if(!fb) {
|
||||||
Serial.printf("Camera capture failed size=%d\n", fb->len);
|
Serial.println("Camera capture failed");
|
||||||
esp_camera_fb_return(fb);
|
|
||||||
} else Serial.printf("Camera capture failed\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File file = fs.open(path.c_str(), FILE_WRITE);
|
||||||
|
if(!file){
|
||||||
|
Serial.println("Failed to open file in writing mode");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
file.write(fb->buf, fb->len); // payload (image), payload length
|
||||||
|
Serial.printf("Saved file to path: %s\n", path.c_str());
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
// if (value.extBinInfoSize < fb->len) {
|
//return the frame buffer back to the driver for reuse
|
||||||
// if (value.extBinInfo) free(value.extBinInfo);
|
|
||||||
// value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * fb->len);
|
|
||||||
// }
|
|
||||||
memcpy(value.extBinInfo, fb->buf, fb->len);
|
|
||||||
value.extBinInfoSize = fb->len;
|
|
||||||
|
|
||||||
Serial.printf("try send pic by size=%d", fb->len);
|
|
||||||
|
|
||||||
if (_useLed) digitalWrite(4, LOW);
|
|
||||||
if (_ticker) regEvent("shot", "EspCam");
|
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(fb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
take_picture();
|
//save_picture();
|
||||||
}
|
}
|
||||||
|
|
||||||
IoTValue execute(String command, std::vector<IoTValue> ¶m) {
|
IoTValue execute(String command, std::vector<IoTValue> ¶m) {
|
||||||
if (command == "shot") {
|
if (command == "save") {
|
||||||
take_picture();
|
if (param.size() == 1)
|
||||||
|
save_picture(param[0].valS);
|
||||||
|
else
|
||||||
|
save_picture();
|
||||||
|
} else if (command == "ledOn" && param.size() == 1) {
|
||||||
|
ledcSetup(LED_LEDC_CHANNEL, 5000, 8);
|
||||||
|
ledcAttachPin(LED_GPIO_NUM, LED_LEDC_CHANNEL);
|
||||||
|
ledcWrite(LED_LEDC_CHANNEL, param[0].valD);
|
||||||
|
} else if (command == "ledOff") {
|
||||||
|
ledcWrite(LED_LEDC_CHANNEL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
~EspCam() {
|
~EspCam() {
|
||||||
free(value.extBinInfo);
|
//free(value.extBinInfo);
|
||||||
//globalItem = nullptr;
|
globalItem = nullptr;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void handleGetPic() {
|
||||||
|
if (!globalItem) return;
|
||||||
|
|
||||||
|
if (((EspCam*)globalItem)->isUsedLed()) ledcWrite(LED_LEDC_CHANNEL, CONFIG_LED_MAX_INTENSITY); //Turn on the flash
|
||||||
|
|
||||||
|
camera_fb_t* fb = NULL;
|
||||||
|
fb = esp_camera_fb_get();
|
||||||
|
if (!fb) {
|
||||||
|
HTTP.send(200, "text/json", F("Item EspCam not prepared yet or camera hasn't taken a picture yet"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HTTP.send_P(200, "image/jpeg", (char *)fb->buf, fb->len);
|
||||||
|
|
||||||
|
if (((EspCam*)globalItem)->isUsedLed()) ledcWrite(LED_LEDC_CHANNEL, 0);
|
||||||
|
if (((EspCam*)globalItem)->isWebTicker()) globalItem->regEvent("webTakesPhoto", "EspCam");
|
||||||
|
esp_camera_fb_return(fb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void* getAPI_EspCam(String subtype, String param) {
|
void* getAPI_EspCam(String subtype, String param) {
|
||||||
if (subtype == F("EspCam")) {
|
if (subtype == F("EspCam")) {
|
||||||
return new EspCam(param);
|
return new EspCam(param);
|
||||||
|
|||||||
298
src/modules/exec/EspCam/camera_pins.h
Normal file
298
src/modules/exec/EspCam/camera_pins.h
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
|
||||||
|
#if defined(CAMERA_MODEL_WROVER_KIT)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM -1
|
||||||
|
#define XCLK_GPIO_NUM 21
|
||||||
|
#define SIOD_GPIO_NUM 26
|
||||||
|
#define SIOC_GPIO_NUM 27
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 35
|
||||||
|
#define Y8_GPIO_NUM 34
|
||||||
|
#define Y7_GPIO_NUM 39
|
||||||
|
#define Y6_GPIO_NUM 36
|
||||||
|
#define Y5_GPIO_NUM 19
|
||||||
|
#define Y4_GPIO_NUM 18
|
||||||
|
#define Y3_GPIO_NUM 5
|
||||||
|
#define Y2_GPIO_NUM 4
|
||||||
|
#define VSYNC_GPIO_NUM 25
|
||||||
|
#define HREF_GPIO_NUM 23
|
||||||
|
#define PCLK_GPIO_NUM 22
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_ESP_EYE)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM -1
|
||||||
|
#define XCLK_GPIO_NUM 4
|
||||||
|
#define SIOD_GPIO_NUM 18
|
||||||
|
#define SIOC_GPIO_NUM 23
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 36
|
||||||
|
#define Y8_GPIO_NUM 37
|
||||||
|
#define Y7_GPIO_NUM 38
|
||||||
|
#define Y6_GPIO_NUM 39
|
||||||
|
#define Y5_GPIO_NUM 35
|
||||||
|
#define Y4_GPIO_NUM 14
|
||||||
|
#define Y3_GPIO_NUM 13
|
||||||
|
#define Y2_GPIO_NUM 34
|
||||||
|
#define VSYNC_GPIO_NUM 5
|
||||||
|
#define HREF_GPIO_NUM 27
|
||||||
|
#define PCLK_GPIO_NUM 25
|
||||||
|
|
||||||
|
#define LED_GPIO_NUM 22
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_M5STACK_PSRAM)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM 15
|
||||||
|
#define XCLK_GPIO_NUM 27
|
||||||
|
#define SIOD_GPIO_NUM 25
|
||||||
|
#define SIOC_GPIO_NUM 23
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 19
|
||||||
|
#define Y8_GPIO_NUM 36
|
||||||
|
#define Y7_GPIO_NUM 18
|
||||||
|
#define Y6_GPIO_NUM 39
|
||||||
|
#define Y5_GPIO_NUM 5
|
||||||
|
#define Y4_GPIO_NUM 34
|
||||||
|
#define Y3_GPIO_NUM 35
|
||||||
|
#define Y2_GPIO_NUM 32
|
||||||
|
#define VSYNC_GPIO_NUM 22
|
||||||
|
#define HREF_GPIO_NUM 26
|
||||||
|
#define PCLK_GPIO_NUM 21
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_M5STACK_V2_PSRAM)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM 15
|
||||||
|
#define XCLK_GPIO_NUM 27
|
||||||
|
#define SIOD_GPIO_NUM 22
|
||||||
|
#define SIOC_GPIO_NUM 23
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 19
|
||||||
|
#define Y8_GPIO_NUM 36
|
||||||
|
#define Y7_GPIO_NUM 18
|
||||||
|
#define Y6_GPIO_NUM 39
|
||||||
|
#define Y5_GPIO_NUM 5
|
||||||
|
#define Y4_GPIO_NUM 34
|
||||||
|
#define Y3_GPIO_NUM 35
|
||||||
|
#define Y2_GPIO_NUM 32
|
||||||
|
#define VSYNC_GPIO_NUM 25
|
||||||
|
#define HREF_GPIO_NUM 26
|
||||||
|
#define PCLK_GPIO_NUM 21
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_M5STACK_WIDE)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM 15
|
||||||
|
#define XCLK_GPIO_NUM 27
|
||||||
|
#define SIOD_GPIO_NUM 22
|
||||||
|
#define SIOC_GPIO_NUM 23
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 19
|
||||||
|
#define Y8_GPIO_NUM 36
|
||||||
|
#define Y7_GPIO_NUM 18
|
||||||
|
#define Y6_GPIO_NUM 39
|
||||||
|
#define Y5_GPIO_NUM 5
|
||||||
|
#define Y4_GPIO_NUM 34
|
||||||
|
#define Y3_GPIO_NUM 35
|
||||||
|
#define Y2_GPIO_NUM 32
|
||||||
|
#define VSYNC_GPIO_NUM 25
|
||||||
|
#define HREF_GPIO_NUM 26
|
||||||
|
#define PCLK_GPIO_NUM 21
|
||||||
|
|
||||||
|
#define LED_GPIO_NUM 2
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_M5STACK_ESP32CAM)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM 15
|
||||||
|
#define XCLK_GPIO_NUM 27
|
||||||
|
#define SIOD_GPIO_NUM 25
|
||||||
|
#define SIOC_GPIO_NUM 23
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 19
|
||||||
|
#define Y8_GPIO_NUM 36
|
||||||
|
#define Y7_GPIO_NUM 18
|
||||||
|
#define Y6_GPIO_NUM 39
|
||||||
|
#define Y5_GPIO_NUM 5
|
||||||
|
#define Y4_GPIO_NUM 34
|
||||||
|
#define Y3_GPIO_NUM 35
|
||||||
|
#define Y2_GPIO_NUM 17
|
||||||
|
#define VSYNC_GPIO_NUM 22
|
||||||
|
#define HREF_GPIO_NUM 26
|
||||||
|
#define PCLK_GPIO_NUM 21
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_M5STACK_UNITCAM)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM 15
|
||||||
|
#define XCLK_GPIO_NUM 27
|
||||||
|
#define SIOD_GPIO_NUM 25
|
||||||
|
#define SIOC_GPIO_NUM 23
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 19
|
||||||
|
#define Y8_GPIO_NUM 36
|
||||||
|
#define Y7_GPIO_NUM 18
|
||||||
|
#define Y6_GPIO_NUM 39
|
||||||
|
#define Y5_GPIO_NUM 5
|
||||||
|
#define Y4_GPIO_NUM 34
|
||||||
|
#define Y3_GPIO_NUM 35
|
||||||
|
#define Y2_GPIO_NUM 32
|
||||||
|
#define VSYNC_GPIO_NUM 22
|
||||||
|
#define HREF_GPIO_NUM 26
|
||||||
|
#define PCLK_GPIO_NUM 21
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_AI_THINKER)
|
||||||
|
#define PWDN_GPIO_NUM 32
|
||||||
|
#define RESET_GPIO_NUM -1
|
||||||
|
#define XCLK_GPIO_NUM 0
|
||||||
|
#define SIOD_GPIO_NUM 26
|
||||||
|
#define SIOC_GPIO_NUM 27
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 35
|
||||||
|
#define Y8_GPIO_NUM 34
|
||||||
|
#define Y7_GPIO_NUM 39
|
||||||
|
#define Y6_GPIO_NUM 36
|
||||||
|
#define Y5_GPIO_NUM 21
|
||||||
|
#define Y4_GPIO_NUM 19
|
||||||
|
#define Y3_GPIO_NUM 18
|
||||||
|
#define Y2_GPIO_NUM 5
|
||||||
|
#define VSYNC_GPIO_NUM 25
|
||||||
|
#define HREF_GPIO_NUM 23
|
||||||
|
#define PCLK_GPIO_NUM 22
|
||||||
|
|
||||||
|
// 4 for flash led or 33 for normal led
|
||||||
|
#define LED_GPIO_NUM 4
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_TTGO_T_JOURNAL)
|
||||||
|
#define PWDN_GPIO_NUM 0
|
||||||
|
#define RESET_GPIO_NUM 15
|
||||||
|
#define XCLK_GPIO_NUM 27
|
||||||
|
#define SIOD_GPIO_NUM 25
|
||||||
|
#define SIOC_GPIO_NUM 23
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 19
|
||||||
|
#define Y8_GPIO_NUM 36
|
||||||
|
#define Y7_GPIO_NUM 18
|
||||||
|
#define Y6_GPIO_NUM 39
|
||||||
|
#define Y5_GPIO_NUM 5
|
||||||
|
#define Y4_GPIO_NUM 34
|
||||||
|
#define Y3_GPIO_NUM 35
|
||||||
|
#define Y2_GPIO_NUM 17
|
||||||
|
#define VSYNC_GPIO_NUM 22
|
||||||
|
#define HREF_GPIO_NUM 26
|
||||||
|
#define PCLK_GPIO_NUM 21
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_XIAO_ESP32S3)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM -1
|
||||||
|
#define XCLK_GPIO_NUM 10
|
||||||
|
#define SIOD_GPIO_NUM 40
|
||||||
|
#define SIOC_GPIO_NUM 39
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 48
|
||||||
|
#define Y8_GPIO_NUM 11
|
||||||
|
#define Y7_GPIO_NUM 12
|
||||||
|
#define Y6_GPIO_NUM 14
|
||||||
|
#define Y5_GPIO_NUM 16
|
||||||
|
#define Y4_GPIO_NUM 18
|
||||||
|
#define Y3_GPIO_NUM 17
|
||||||
|
#define Y2_GPIO_NUM 15
|
||||||
|
#define VSYNC_GPIO_NUM 38
|
||||||
|
#define HREF_GPIO_NUM 47
|
||||||
|
#define PCLK_GPIO_NUM 13
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_ESP32_CAM_BOARD)
|
||||||
|
// The 18 pin header on the board has Y5 and Y3 swapped
|
||||||
|
#define USE_BOARD_HEADER 0
|
||||||
|
#define PWDN_GPIO_NUM 32
|
||||||
|
#define RESET_GPIO_NUM 33
|
||||||
|
#define XCLK_GPIO_NUM 4
|
||||||
|
#define SIOD_GPIO_NUM 18
|
||||||
|
#define SIOC_GPIO_NUM 23
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 36
|
||||||
|
#define Y8_GPIO_NUM 19
|
||||||
|
#define Y7_GPIO_NUM 21
|
||||||
|
#define Y6_GPIO_NUM 39
|
||||||
|
#if USE_BOARD_HEADER
|
||||||
|
#define Y5_GPIO_NUM 13
|
||||||
|
#else
|
||||||
|
#define Y5_GPIO_NUM 35
|
||||||
|
#endif
|
||||||
|
#define Y4_GPIO_NUM 14
|
||||||
|
#if USE_BOARD_HEADER
|
||||||
|
#define Y3_GPIO_NUM 35
|
||||||
|
#else
|
||||||
|
#define Y3_GPIO_NUM 13
|
||||||
|
#endif
|
||||||
|
#define Y2_GPIO_NUM 34
|
||||||
|
#define VSYNC_GPIO_NUM 5
|
||||||
|
#define HREF_GPIO_NUM 27
|
||||||
|
#define PCLK_GPIO_NUM 25
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_ESP32S3_CAM_LCD)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM -1
|
||||||
|
#define XCLK_GPIO_NUM 40
|
||||||
|
#define SIOD_GPIO_NUM 17
|
||||||
|
#define SIOC_GPIO_NUM 18
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 39
|
||||||
|
#define Y8_GPIO_NUM 41
|
||||||
|
#define Y7_GPIO_NUM 42
|
||||||
|
#define Y6_GPIO_NUM 12
|
||||||
|
#define Y5_GPIO_NUM 3
|
||||||
|
#define Y4_GPIO_NUM 14
|
||||||
|
#define Y3_GPIO_NUM 47
|
||||||
|
#define Y2_GPIO_NUM 13
|
||||||
|
#define VSYNC_GPIO_NUM 21
|
||||||
|
#define HREF_GPIO_NUM 38
|
||||||
|
#define PCLK_GPIO_NUM 11
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_ESP32S2_CAM_BOARD)
|
||||||
|
// The 18 pin header on the board has Y5 and Y3 swapped
|
||||||
|
#define USE_BOARD_HEADER 0
|
||||||
|
#define PWDN_GPIO_NUM 1
|
||||||
|
#define RESET_GPIO_NUM 2
|
||||||
|
#define XCLK_GPIO_NUM 42
|
||||||
|
#define SIOD_GPIO_NUM 41
|
||||||
|
#define SIOC_GPIO_NUM 18
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 16
|
||||||
|
#define Y8_GPIO_NUM 39
|
||||||
|
#define Y7_GPIO_NUM 40
|
||||||
|
#define Y6_GPIO_NUM 15
|
||||||
|
#if USE_BOARD_HEADER
|
||||||
|
#define Y5_GPIO_NUM 12
|
||||||
|
#else
|
||||||
|
#define Y5_GPIO_NUM 13
|
||||||
|
#endif
|
||||||
|
#define Y4_GPIO_NUM 5
|
||||||
|
#if USE_BOARD_HEADER
|
||||||
|
#define Y3_GPIO_NUM 13
|
||||||
|
#else
|
||||||
|
#define Y3_GPIO_NUM 12
|
||||||
|
#endif
|
||||||
|
#define Y2_GPIO_NUM 14
|
||||||
|
#define VSYNC_GPIO_NUM 38
|
||||||
|
#define HREF_GPIO_NUM 4
|
||||||
|
#define PCLK_GPIO_NUM 3
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_ESP32S3_EYE)
|
||||||
|
#define PWDN_GPIO_NUM -1
|
||||||
|
#define RESET_GPIO_NUM -1
|
||||||
|
#define XCLK_GPIO_NUM 15
|
||||||
|
#define SIOD_GPIO_NUM 4
|
||||||
|
#define SIOC_GPIO_NUM 5
|
||||||
|
|
||||||
|
#define Y2_GPIO_NUM 11
|
||||||
|
#define Y3_GPIO_NUM 9
|
||||||
|
#define Y4_GPIO_NUM 8
|
||||||
|
#define Y5_GPIO_NUM 10
|
||||||
|
#define Y6_GPIO_NUM 12
|
||||||
|
#define Y7_GPIO_NUM 18
|
||||||
|
#define Y8_GPIO_NUM 17
|
||||||
|
#define Y9_GPIO_NUM 16
|
||||||
|
|
||||||
|
#define VSYNC_GPIO_NUM 6
|
||||||
|
#define HREF_GPIO_NUM 7
|
||||||
|
#define PCLK_GPIO_NUM 13
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Camera model not selected"
|
||||||
|
#endif
|
||||||
@@ -23,23 +23,33 @@
|
|||||||
"authorGit": "https://github.com/biveraxe",
|
"authorGit": "https://github.com/biveraxe",
|
||||||
"specialThanks": "",
|
"specialThanks": "",
|
||||||
"moduleName": "EspCam",
|
"moduleName": "EspCam",
|
||||||
"moduleVersion": "1.0",
|
"moduleVersion": "2.1",
|
||||||
"usedRam": {
|
"usedRam": {
|
||||||
"esp32_4mb": 15,
|
"esp32_4mb": 15,
|
||||||
"esp8266_4mb": 15
|
"esp8266_4mb": 15
|
||||||
},
|
},
|
||||||
"title": "Camera OV2640 (ESPcam)",
|
"title": "Camera OV2640 (ESPcam)",
|
||||||
"moduleDesc": "Предназначен для специальной платы esp32 со встроенной камерой. Добавляет в прошивку функцию создания фото и сохранения в оперативную память. Для сброса на флешкарту необходимо использовать парный модуль SDcard. Это экспериментальные модули и в будущем планируется пересобрать их.",
|
"moduleDesc": "Предназначен для специальной платы esp32 со встроенной камерой. Добавляет в прошивку функцию создания фото и сохранения на SD при наличии. По адресу /getpic можно получить текущее фото (работает в том числе без SD карты).",
|
||||||
"propInfo": {
|
"propInfo": {
|
||||||
"int": "Пауза в секундах во время постоянной съемки.",
|
"int": "Пауза в секундах во время постоянной фотосъемки.",
|
||||||
"useLed": "использовать диод подсветки при съемке.",
|
"useLed": "использовать диод подсветки при съемке.",
|
||||||
"ticker": "Генерировать(1) или нет(0) событие с интервалом int",
|
"ticker": "Генерировать(1) или нет(0) событие с интервалом int",
|
||||||
"webTicker": "Генерировать(1) или нет(0) событие при обращении через веб-страницу с текущим фото в памяти."
|
"webTicker": "Генерировать(1) или нет(0) событие при обращении через веб-страницу по адресу /getpic."
|
||||||
},
|
},
|
||||||
"funcInfo": [
|
"funcInfo": [
|
||||||
{
|
{
|
||||||
"name": "shot",
|
"name": "save",
|
||||||
"descr": "Сделать снимок",
|
"descr": "Сохранить снимок на SD",
|
||||||
|
"params": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ledOn",
|
||||||
|
"descr": "Включить подсветку",
|
||||||
|
"params": ["Яркость 0-255"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ledOff",
|
||||||
|
"descr": "Отключить подсветку",
|
||||||
"params": []
|
"params": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -28,18 +28,18 @@ class SDcard : public IoTItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void savePicture(String path, IoTValue srcValue) {
|
void savePicture(String path, IoTValue srcValue) {
|
||||||
if (srcValue.extBinInfoSize) {
|
// if (srcValue.extBinInfoSize) {
|
||||||
fs::FS &fs = SD_MMC;
|
// fs::FS &fs = SD_MMC;
|
||||||
File file = fs.open(path.c_str(), FILE_WRITE);
|
// File file = fs.open(path.c_str(), FILE_WRITE);
|
||||||
if(!file){
|
// if(!file){
|
||||||
Serial.println("Failed to open file in writing mode");
|
// Serial.println("Failed to open file in writing mode");
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
file.write(srcValue.extBinInfo, srcValue.extBinInfoSize); // payload (image), payload length
|
// file.write(srcValue.extBinInfo, srcValue.extBinInfoSize); // payload (image), payload length
|
||||||
Serial.printf("Picture file name: %s | bufsize: %d\n", path.c_str(), srcValue.extBinInfoSize);
|
// Serial.printf("Picture file name: %s | bufsize: %d\n", path.c_str(), srcValue.extBinInfoSize);
|
||||||
}
|
// }
|
||||||
file.close();
|
// file.close();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
},
|
},
|
||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
95
src/modules/sensors/S8/S8.cpp
Normal file
95
src/modules/sensors/S8/S8.cpp
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
#include "Classes/IoTItem.h"
|
||||||
|
|
||||||
|
#include <SoftwareSerial.h>
|
||||||
|
|
||||||
|
#define R_LEN 7
|
||||||
|
#define C_LEN 8
|
||||||
|
|
||||||
|
byte cmd_s8[8] = {0xFE, 0x04, 0x00, 0x03, 0x00, 0x01, 0xD5, 0xC5};
|
||||||
|
//byte abc_s8[8] = {0xFE, 0x03, 0x00, 0x1F, 0x00, 0x01, 0xA1, 0xC3};
|
||||||
|
|
||||||
|
|
||||||
|
class S8co : public IoTItem {
|
||||||
|
private:
|
||||||
|
SoftwareSerial* s8Serial;
|
||||||
|
|
||||||
|
unsigned int _s8_co2;
|
||||||
|
int _s8_co2_mean = 0;
|
||||||
|
int _s8_co2_mean2 = 0;
|
||||||
|
|
||||||
|
float smoothing_factor = 0.5;
|
||||||
|
float smoothing_factor2 = 0.15;
|
||||||
|
|
||||||
|
byte _response_s8[7] = {0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
void s8Request(byte cmd[]) {
|
||||||
|
while(!s8Serial->available()) {
|
||||||
|
s8Serial->write(cmd, C_LEN);
|
||||||
|
delay(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
int timeout=0;
|
||||||
|
while(s8Serial->available() < R_LEN) {
|
||||||
|
timeout++;
|
||||||
|
if(timeout > 10) {
|
||||||
|
while(s8Serial->available()) {
|
||||||
|
s8Serial->read();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delay(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i < R_LEN; i++) {
|
||||||
|
_response_s8[i] = s8Serial->read();
|
||||||
|
}
|
||||||
|
|
||||||
|
s8Serial->end();
|
||||||
|
}
|
||||||
|
|
||||||
|
void co2_measure() {
|
||||||
|
s8Request(cmd_s8); // запрашиваем значение загрязнения
|
||||||
|
_s8_co2 = _response_s8[3] * 256 + _response_s8[4]; // полученный недобайт-ответ преобразуем в значение загрязнения
|
||||||
|
|
||||||
|
if (!_s8_co2_mean) _s8_co2_mean = _s8_co2;
|
||||||
|
_s8_co2_mean = _s8_co2_mean - smoothing_factor*(_s8_co2_mean - _s8_co2);
|
||||||
|
|
||||||
|
if (!_s8_co2_mean2) _s8_co2_mean2 = _s8_co2;
|
||||||
|
_s8_co2_mean2 = _s8_co2_mean2 - smoothing_factor2*(_s8_co2_mean2 - _s8_co2);
|
||||||
|
|
||||||
|
Serial.printf("CO2 value: %d, M1Value: %d, M2Value: %d\n", _s8_co2, _s8_co2_mean, _s8_co2_mean2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
S8co(String parameters): IoTItem(parameters) {
|
||||||
|
int S8_RX_PIN, S8_TX_PIN;
|
||||||
|
jsonRead(parameters, "rxPin", S8_RX_PIN);
|
||||||
|
jsonRead(parameters, "txPin", S8_TX_PIN);
|
||||||
|
|
||||||
|
s8Serial = new SoftwareSerial(S8_RX_PIN, S8_TX_PIN);
|
||||||
|
if (!s8Serial) return;
|
||||||
|
s8Serial->begin(9600);
|
||||||
|
}
|
||||||
|
|
||||||
|
void doByInterval() {
|
||||||
|
co2_measure();
|
||||||
|
value.valD = _s8_co2;
|
||||||
|
if (value.valD < 15000)
|
||||||
|
regEvent(value.valD, "S8co");
|
||||||
|
else
|
||||||
|
SerialPrint("E", "Sensor S8_uart", "Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
~S8co() {
|
||||||
|
if (s8Serial) delete s8Serial;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
void* getAPI_S8(String subtype, String param) {
|
||||||
|
if (subtype == F("S8co")) {
|
||||||
|
return new S8co(param);
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
43
src/modules/sensors/S8/modinfo.json
Normal file
43
src/modules/sensors/S8/modinfo.json
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"menuSection": "Сенсоры",
|
||||||
|
"configItem": [
|
||||||
|
{
|
||||||
|
"name": "(S8) Cенсор качества воздуха",
|
||||||
|
"num": 3,
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "S8co",
|
||||||
|
"id": "s8co",
|
||||||
|
"widget": "anydataPpm",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "S8_CO2",
|
||||||
|
"int": 15,
|
||||||
|
"round": 1,
|
||||||
|
"rxPin": 13,
|
||||||
|
"txPin": 15
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"about": {
|
||||||
|
"authorName": "Serghei Crasnicov",
|
||||||
|
"authorContact": "https://t.me/Serghei63",
|
||||||
|
"authorGit": "https://github.com/Serghei63",
|
||||||
|
"specialThanks": "",
|
||||||
|
"moduleName": "S8",
|
||||||
|
"moduleVersion": "2.1",
|
||||||
|
"usedRam": 15,
|
||||||
|
"subTypes": [
|
||||||
|
"S8co"
|
||||||
|
],
|
||||||
|
"title": "Датчик углекислого газа S8",
|
||||||
|
"moduleDesc": "Измеряет параметвы воздуха.",
|
||||||
|
"propInfo": {
|
||||||
|
"int": "Количество секунд между опросами датчика."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defActive": true,
|
||||||
|
"usedLibs": {
|
||||||
|
"esp32_4mb": [
|
||||||
|
],
|
||||||
|
"esp8266_4mb": [
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,7 +82,12 @@
|
|||||||
],
|
],
|
||||||
"esp8266_2mb_ota": [
|
"esp8266_2mb_ota": [
|
||||||
"plerup/EspSoftwareSerial"
|
"plerup/EspSoftwareSerial"
|
||||||
|
],
|
||||||
|
"esp8285_1mb": [
|
||||||
|
"plerup/EspSoftwareSerial"
|
||||||
|
],
|
||||||
|
"esp8285_1mb_ota": [
|
||||||
|
"plerup/EspSoftwareSerial"
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
543
src/modules/sensors/UART/utf.cpp.new
Normal file
543
src/modules/sensors/UART/utf.cpp.new
Normal file
@@ -0,0 +1,543 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2004 Unicode, Inc.
|
||||||
|
*
|
||||||
|
* Disclaimer
|
||||||
|
*
|
||||||
|
* This source code is provided as is by Unicode, Inc. No claims are
|
||||||
|
* made as to fitness for any particular purpose. No warranties of any
|
||||||
|
* kind are expressed or implied. The recipient agrees to determine
|
||||||
|
* applicability of information provided. If this file has been
|
||||||
|
* purchased on magnetic or optical media from Unicode, Inc., the
|
||||||
|
* sole remedy for any claim will be exchange of defective media
|
||||||
|
* within 90 days of receipt.
|
||||||
|
*
|
||||||
|
* Limitations on Rights to Redistribute This Code
|
||||||
|
*
|
||||||
|
* Unicode, Inc. hereby grants the right to freely use the information
|
||||||
|
* supplied in this file in the creation of products supporting the
|
||||||
|
* Unicode Standard, and to make copies of this file in any form
|
||||||
|
* for internal or external distribution as long as this notice
|
||||||
|
* remains attached.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
Conversions between UTF32, UTF-16, and UTF-8. Source code file.
|
||||||
|
Author: Mark E. Davis, 1994.
|
||||||
|
Rev History: Rick McGowan, fixes & updates May 2001.
|
||||||
|
Sept 2001: fixed const & error conditions per
|
||||||
|
mods suggested by S. Parent & A. Lillich.
|
||||||
|
June 2002: Tim Dodd added detection and handling of incomplete
|
||||||
|
source sequences, enhanced error detection, added casts
|
||||||
|
to eliminate compiler warnings.
|
||||||
|
July 2003: slight mods to back out aggressive FFFE detection.
|
||||||
|
Jan 2004: updated switches in from-UTF8 conversions.
|
||||||
|
Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions.
|
||||||
|
|
||||||
|
See the header file "ConvertUTF.h" for complete documentation.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
|
#include "utf.h"
|
||||||
|
#ifdef CVTUTF_DEBUG
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const int halfShift = 10; /* used for shifting by 10 bits */
|
||||||
|
|
||||||
|
static const UTF32 halfBase = 0x0010000UL;
|
||||||
|
static const UTF32 halfMask = 0x3FFUL;
|
||||||
|
|
||||||
|
#define UNI_SUR_HIGH_START (UTF32)0xD800
|
||||||
|
#define UNI_SUR_HIGH_END (UTF32)0xDBFF
|
||||||
|
#define UNI_SUR_LOW_START (UTF32)0xDC00
|
||||||
|
#define UNI_SUR_LOW_END (UTF32)0xDFFF
|
||||||
|
#define false 0
|
||||||
|
#define true 1
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF32toUTF16 (
|
||||||
|
const UTF32** sourceStart, const UTF32* sourceEnd,
|
||||||
|
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
|
||||||
|
ConversionResult result = conversionOK;
|
||||||
|
const UTF32* source = *sourceStart;
|
||||||
|
UTF16* target = *targetStart;
|
||||||
|
while (source < sourceEnd) {
|
||||||
|
UTF32 ch;
|
||||||
|
if (target >= targetEnd) {
|
||||||
|
result = targetExhausted; break;
|
||||||
|
}
|
||||||
|
ch = *source++;
|
||||||
|
if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
|
||||||
|
/* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */
|
||||||
|
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
|
||||||
|
if (flags == strictConversion) {
|
||||||
|
--source; /* return to the illegal value itself */
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
*target++ = UNI_REPLACEMENT_CHAR;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*target++ = (UTF16)ch; /* normal case */
|
||||||
|
}
|
||||||
|
} else if (ch > UNI_MAX_LEGAL_UTF32) {
|
||||||
|
if (flags == strictConversion) {
|
||||||
|
result = sourceIllegal;
|
||||||
|
} else {
|
||||||
|
*target++ = UNI_REPLACEMENT_CHAR;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* target is a character in range 0xFFFF - 0x10FFFF. */
|
||||||
|
if (target + 1 >= targetEnd) {
|
||||||
|
--source; /* Back up source pointer! */
|
||||||
|
result = targetExhausted; break;
|
||||||
|
}
|
||||||
|
ch -= halfBase;
|
||||||
|
*target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
|
||||||
|
*target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*sourceStart = source;
|
||||||
|
*targetStart = target;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF16toUTF32 (
|
||||||
|
const UTF16** sourceStart, const UTF16* sourceEnd,
|
||||||
|
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
|
||||||
|
ConversionResult result = conversionOK;
|
||||||
|
const UTF16* source = *sourceStart;
|
||||||
|
UTF32* target = *targetStart;
|
||||||
|
UTF32 ch, ch2;
|
||||||
|
while (source < sourceEnd) {
|
||||||
|
const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
|
||||||
|
ch = *source++;
|
||||||
|
/* If we have a surrogate pair, convert to UTF32 first. */
|
||||||
|
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
|
||||||
|
/* If the 16 bits following the high surrogate are in the source buffer... */
|
||||||
|
if (source < sourceEnd) {
|
||||||
|
ch2 = *source;
|
||||||
|
/* If it's a low surrogate, convert to UTF32. */
|
||||||
|
if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
|
||||||
|
ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
|
||||||
|
+ (ch2 - UNI_SUR_LOW_START) + halfBase;
|
||||||
|
++source;
|
||||||
|
} else if (flags == strictConversion) { /* it's an unpaired high surrogate */
|
||||||
|
--source; /* return to the illegal value itself */
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else { /* We don't have the 16 bits following the high surrogate. */
|
||||||
|
--source; /* return to the high surrogate */
|
||||||
|
result = sourceExhausted;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (flags == strictConversion) {
|
||||||
|
/* UTF-16 surrogate values are illegal in UTF-32 */
|
||||||
|
if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
|
||||||
|
--source; /* return to the illegal value itself */
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target >= targetEnd) {
|
||||||
|
source = oldSource; /* Back up source pointer! */
|
||||||
|
result = targetExhausted; break;
|
||||||
|
}
|
||||||
|
*target++ = ch;
|
||||||
|
}
|
||||||
|
*sourceStart = source;
|
||||||
|
*targetStart = target;
|
||||||
|
#ifdef CVTUTF_DEBUG
|
||||||
|
if (result == sourceIllegal) {
|
||||||
|
fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2);
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Index into the table below with the first byte of a UTF-8 sequence to
|
||||||
|
* get the number of trailing bytes that are supposed to follow it.
|
||||||
|
* Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
|
||||||
|
* left as-is for anyone who may want to do such conversion, which was
|
||||||
|
* allowed in earlier algorithms.
|
||||||
|
*/
|
||||||
|
static const char trailingBytesForUTF8[256] = {
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Magic values subtracted from a buffer value during UTF8 conversion.
|
||||||
|
* This table contains as many values as there might be trailing bytes
|
||||||
|
* in a UTF-8 sequence.
|
||||||
|
*/
|
||||||
|
static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
|
||||||
|
0x03C82080UL, 0xFA082080UL, 0x82082080UL };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
|
||||||
|
* into the first byte, depending on how many bytes follow. There are
|
||||||
|
* as many entries in this table as there are UTF-8 sequence types.
|
||||||
|
* (I.e., one byte sequence, two byte... etc.). Remember that sequencs
|
||||||
|
* for *legal* UTF-8 will be 4 or fewer bytes total.
|
||||||
|
*/
|
||||||
|
static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* The interface converts a whole buffer to avoid function-call overhead.
|
||||||
|
* Constants have been gathered. Loops & conditionals have been removed as
|
||||||
|
* much as possible for efficiency, in favor of drop-through switches.
|
||||||
|
* (See "Note A" at the bottom of the file for equivalent code.)
|
||||||
|
* If your compiler supports it, the "isLegalUTF8" call can be turned
|
||||||
|
* into an inline function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF16toUTF8 (
|
||||||
|
const UTF16** sourceStart, const UTF16* sourceEnd,
|
||||||
|
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
|
||||||
|
ConversionResult result = conversionOK;
|
||||||
|
const UTF16* source = *sourceStart;
|
||||||
|
UTF8* target = *targetStart;
|
||||||
|
while (source < sourceEnd) {
|
||||||
|
UTF32 ch;
|
||||||
|
unsigned short bytesToWrite = 0;
|
||||||
|
const UTF32 byteMask = 0xBF;
|
||||||
|
const UTF32 byteMark = 0x80;
|
||||||
|
const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
|
||||||
|
ch = *source++;
|
||||||
|
/* If we have a surrogate pair, convert to UTF32 first. */
|
||||||
|
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
|
||||||
|
/* If the 16 bits following the high surrogate are in the source buffer... */
|
||||||
|
if (source < sourceEnd) {
|
||||||
|
UTF32 ch2 = *source;
|
||||||
|
/* If it's a low surrogate, convert to UTF32. */
|
||||||
|
if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
|
||||||
|
ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
|
||||||
|
+ (ch2 - UNI_SUR_LOW_START) + halfBase;
|
||||||
|
++source;
|
||||||
|
} else if (flags == strictConversion) { /* it's an unpaired high surrogate */
|
||||||
|
--source; /* return to the illegal value itself */
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else { /* We don't have the 16 bits following the high surrogate. */
|
||||||
|
--source; /* return to the high surrogate */
|
||||||
|
result = sourceExhausted;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (flags == strictConversion) {
|
||||||
|
/* UTF-16 surrogate values are illegal in UTF-32 */
|
||||||
|
if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
|
||||||
|
--source; /* return to the illegal value itself */
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Figure out how many bytes the result will require */
|
||||||
|
if (ch < (UTF32)0x80) { bytesToWrite = 1;
|
||||||
|
} else if (ch < (UTF32)0x800) { bytesToWrite = 2;
|
||||||
|
} else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
|
||||||
|
} else if (ch < (UTF32)0x110000) { bytesToWrite = 4;
|
||||||
|
} else { bytesToWrite = 3;
|
||||||
|
ch = UNI_REPLACEMENT_CHAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
target += bytesToWrite;
|
||||||
|
if (target > targetEnd) {
|
||||||
|
source = oldSource; /* Back up source pointer! */
|
||||||
|
target -= bytesToWrite; result = targetExhausted; break;
|
||||||
|
}
|
||||||
|
switch (bytesToWrite) { /* note: everything falls through. */
|
||||||
|
case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
|
||||||
|
case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
|
||||||
|
case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
|
||||||
|
case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
|
||||||
|
}
|
||||||
|
target += bytesToWrite;
|
||||||
|
}
|
||||||
|
*sourceStart = source;
|
||||||
|
*targetStart = target;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Utility routine to tell whether a sequence of bytes is legal UTF-8.
|
||||||
|
* This must be called with the length pre-determined by the first byte.
|
||||||
|
* If not calling this from ConvertUTF8to*, then the length can be set by:
|
||||||
|
* length = trailingBytesForUTF8[*source]+1;
|
||||||
|
* and the sequence is illegal right away if there aren't that many bytes
|
||||||
|
* available.
|
||||||
|
* If presented with a length > 4, this returns false. The Unicode
|
||||||
|
* definition of UTF-8 goes up to 4-byte sequences.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static Boolean isLegalUTF8(const UTF8 *source, int length) {
|
||||||
|
UTF8 a;
|
||||||
|
const UTF8 *srcptr = source+length;
|
||||||
|
switch (length) {
|
||||||
|
default: return false;
|
||||||
|
/* Everything else falls through when "true"... */
|
||||||
|
case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
|
||||||
|
case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
|
||||||
|
case 2: if ((a = (*--srcptr)) > 0xBF) return false;
|
||||||
|
|
||||||
|
switch (*source) {
|
||||||
|
/* no fall-through in this inner switch */
|
||||||
|
case 0xE0: if (a < 0xA0) return false; break;
|
||||||
|
case 0xED: if (a > 0x9F) return false; break;
|
||||||
|
case 0xF0: if (a < 0x90) return false; break;
|
||||||
|
case 0xF4: if (a > 0x8F) return false; break;
|
||||||
|
default: if (a < 0x80) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1: if (*source >= 0x80 && *source < 0xC2) return false;
|
||||||
|
}
|
||||||
|
if (*source > 0xF4) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exported function to return whether a UTF-8 sequence is legal or not.
|
||||||
|
* This is not used here; it's just exported.
|
||||||
|
*/
|
||||||
|
Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
|
||||||
|
int length = trailingBytesForUTF8[*source]+1;
|
||||||
|
if (source+length > sourceEnd) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return isLegalUTF8(source, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF8toUTF16 (
|
||||||
|
const UTF8** sourceStart, const UTF8* sourceEnd,
|
||||||
|
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
|
||||||
|
ConversionResult result = conversionOK;
|
||||||
|
const UTF8* source = *sourceStart;
|
||||||
|
UTF16* target = *targetStart;
|
||||||
|
while (source < sourceEnd) {
|
||||||
|
UTF32 ch = 0;
|
||||||
|
unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
|
||||||
|
if (source + extraBytesToRead >= sourceEnd) {
|
||||||
|
result = sourceExhausted; break;
|
||||||
|
}
|
||||||
|
/* Do this check whether lenient or strict */
|
||||||
|
if (! isLegalUTF8(source, extraBytesToRead+1)) {
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* The cases all fall through. See "Note A" below.
|
||||||
|
*/
|
||||||
|
switch (extraBytesToRead) {
|
||||||
|
case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
|
||||||
|
case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
|
||||||
|
case 3: ch += *source++; ch <<= 6;
|
||||||
|
case 2: ch += *source++; ch <<= 6;
|
||||||
|
case 1: ch += *source++; ch <<= 6;
|
||||||
|
case 0: ch += *source++;
|
||||||
|
}
|
||||||
|
ch -= offsetsFromUTF8[extraBytesToRead];
|
||||||
|
|
||||||
|
if (target >= targetEnd) {
|
||||||
|
source -= (extraBytesToRead+1); /* Back up source pointer! */
|
||||||
|
result = targetExhausted; break;
|
||||||
|
}
|
||||||
|
if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
|
||||||
|
/* UTF-16 surrogate values are illegal in UTF-32 */
|
||||||
|
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
|
||||||
|
if (flags == strictConversion) {
|
||||||
|
source -= (extraBytesToRead+1); /* return to the illegal value itself */
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
*target++ = UNI_REPLACEMENT_CHAR;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*target++ = (UTF16)ch; /* normal case */
|
||||||
|
}
|
||||||
|
} else if (ch > UNI_MAX_UTF16) {
|
||||||
|
if (flags == strictConversion) {
|
||||||
|
result = sourceIllegal;
|
||||||
|
source -= (extraBytesToRead+1); /* return to the start */
|
||||||
|
break; /* Bail out; shouldn't continue */
|
||||||
|
} else {
|
||||||
|
*target++ = UNI_REPLACEMENT_CHAR;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* target is a character in range 0xFFFF - 0x10FFFF. */
|
||||||
|
if (target + 1 >= targetEnd) {
|
||||||
|
source -= (extraBytesToRead+1); /* Back up source pointer! */
|
||||||
|
result = targetExhausted; break;
|
||||||
|
}
|
||||||
|
ch -= halfBase;
|
||||||
|
*target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
|
||||||
|
*target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*sourceStart = source;
|
||||||
|
*targetStart = target;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF32toUTF8 (
|
||||||
|
const UTF32** sourceStart, const UTF32* sourceEnd,
|
||||||
|
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
|
||||||
|
ConversionResult result = conversionOK;
|
||||||
|
const UTF32* source = *sourceStart;
|
||||||
|
UTF8* target = *targetStart;
|
||||||
|
while (source < sourceEnd) {
|
||||||
|
UTF32 ch;
|
||||||
|
unsigned short bytesToWrite = 0;
|
||||||
|
const UTF32 byteMask = 0xBF;
|
||||||
|
const UTF32 byteMark = 0x80;
|
||||||
|
ch = *source++;
|
||||||
|
if (flags == strictConversion ) {
|
||||||
|
/* UTF-16 surrogate values are illegal in UTF-32 */
|
||||||
|
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
|
||||||
|
--source; /* return to the illegal value itself */
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Figure out how many bytes the result will require. Turn any
|
||||||
|
* illegally large UTF32 things (> Plane 17) into replacement chars.
|
||||||
|
*/
|
||||||
|
if (ch < (UTF32)0x80) { bytesToWrite = 1;
|
||||||
|
} else if (ch < (UTF32)0x800) { bytesToWrite = 2;
|
||||||
|
} else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
|
||||||
|
} else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4;
|
||||||
|
} else { bytesToWrite = 3;
|
||||||
|
ch = UNI_REPLACEMENT_CHAR;
|
||||||
|
result = sourceIllegal;
|
||||||
|
}
|
||||||
|
|
||||||
|
target += bytesToWrite;
|
||||||
|
if (target > targetEnd) {
|
||||||
|
--source; /* Back up source pointer! */
|
||||||
|
target -= bytesToWrite; result = targetExhausted; break;
|
||||||
|
}
|
||||||
|
switch (bytesToWrite) { /* note: everything falls through. */
|
||||||
|
case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
|
||||||
|
case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
|
||||||
|
case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
|
||||||
|
case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]);
|
||||||
|
}
|
||||||
|
target += bytesToWrite;
|
||||||
|
}
|
||||||
|
*sourceStart = source;
|
||||||
|
*targetStart = target;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
ConversionResult
|
||||||
|
ConvertUTF8toUTF32 (
|
||||||
|
const UTF8** sourceStart, const UTF8* sourceEnd,
|
||||||
|
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags)
|
||||||
|
{
|
||||||
|
ConversionResult result = conversionOK;
|
||||||
|
const UTF8* source = *sourceStart;
|
||||||
|
UTF32 * target = *targetStart;
|
||||||
|
|
||||||
|
while (source < sourceEnd)
|
||||||
|
{
|
||||||
|
UTF32 ch = 0;
|
||||||
|
unsigned short extraBytesToRead = trailingBytesForUTF8 [*source];
|
||||||
|
|
||||||
|
if (source + extraBytesToRead >= sourceEnd)
|
||||||
|
{
|
||||||
|
result = sourceExhausted; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do this check whether lenient or strict */
|
||||||
|
if (! isLegalUTF8(source, extraBytesToRead+1))
|
||||||
|
{
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The cases all fall through. See "Note A" below.
|
||||||
|
*/
|
||||||
|
switch (extraBytesToRead)
|
||||||
|
{
|
||||||
|
case 5: ch += *source++; ch <<= 6;
|
||||||
|
case 4: ch += *source++; ch <<= 6;
|
||||||
|
case 3: ch += *source++; ch <<= 6;
|
||||||
|
case 2: ch += *source++; ch <<= 6;
|
||||||
|
case 1: ch += *source++; ch <<= 6;
|
||||||
|
case 0: ch += *source++;
|
||||||
|
}
|
||||||
|
|
||||||
|
ch -= offsetsFromUTF8 [extraBytesToRead];
|
||||||
|
|
||||||
|
if (target >= targetEnd)
|
||||||
|
{
|
||||||
|
source -= (extraBytesToRead + 1); /* Back up the source pointer! */
|
||||||
|
result = targetExhausted; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch <= UNI_MAX_LEGAL_UTF32)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* UTF-16 surrogate values are illegal in UTF-32, and anything
|
||||||
|
* over Plane 17 (> 0x10FFFF) is illegal.
|
||||||
|
*/
|
||||||
|
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END)
|
||||||
|
{
|
||||||
|
if (flags == strictConversion)
|
||||||
|
{
|
||||||
|
source -= (extraBytesToRead+1); /* return to the illegal value itself */
|
||||||
|
result = sourceIllegal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*target++ = UNI_REPLACEMENT_CHAR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*target++ = ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* i.e., ch > UNI_MAX_LEGAL_UTF32 */
|
||||||
|
result = sourceIllegal;
|
||||||
|
*target++ = UNI_REPLACEMENT_CHAR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*sourceStart = source;
|
||||||
|
*targetStart = target;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
149
src/modules/sensors/UART/utf.h.new
Normal file
149
src/modules/sensors/UART/utf.h.new
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2001-2004 Unicode, Inc.
|
||||||
|
*
|
||||||
|
* Disclaimer
|
||||||
|
*
|
||||||
|
* This source code is provided as is by Unicode, Inc. No claims are
|
||||||
|
* made as to fitness for any particular purpose. No warranties of any
|
||||||
|
* kind are expressed or implied. The recipient agrees to determine
|
||||||
|
* applicability of information provided. If this file has been
|
||||||
|
* purchased on magnetic or optical media from Unicode, Inc., the
|
||||||
|
* sole remedy for any claim will be exchange of defective media
|
||||||
|
* within 90 days of receipt.
|
||||||
|
*
|
||||||
|
* Limitations on Rights to Redistribute This Code
|
||||||
|
*
|
||||||
|
* Unicode, Inc. hereby grants the right to freely use the information
|
||||||
|
* supplied in this file in the creation of products supporting the
|
||||||
|
* Unicode Standard, and to make copies of this file in any form
|
||||||
|
* for internal or external distribution as long as this notice
|
||||||
|
* remains attached.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
Conversions between UTF32, UTF-16, and UTF-8. Header file.
|
||||||
|
|
||||||
|
Several funtions are included here, forming a complete set of
|
||||||
|
conversions between the three formats. UTF-7 is not included
|
||||||
|
here, but is handled in a separate source file.
|
||||||
|
|
||||||
|
Each of these routines takes pointers to input buffers and output
|
||||||
|
buffers. The input buffers are const.
|
||||||
|
|
||||||
|
Each routine converts the text between *sourceStart and sourceEnd,
|
||||||
|
putting the result into the buffer between *targetStart and
|
||||||
|
targetEnd. Note: the end pointers are *after* the last item: e.g.
|
||||||
|
*(sourceEnd - 1) is the last item.
|
||||||
|
|
||||||
|
The return result indicates whether the conversion was successful,
|
||||||
|
and if not, whether the problem was in the source or target buffers.
|
||||||
|
(Only the first encountered problem is indicated.)
|
||||||
|
|
||||||
|
After the conversion, *sourceStart and *targetStart are both
|
||||||
|
updated to point to the end of last text successfully converted in
|
||||||
|
the respective buffers.
|
||||||
|
|
||||||
|
Input parameters:
|
||||||
|
sourceStart - pointer to a pointer to the source buffer.
|
||||||
|
The contents of this are modified on return so that
|
||||||
|
it points at the next thing to be converted.
|
||||||
|
targetStart - similarly, pointer to pointer to the target buffer.
|
||||||
|
sourceEnd, targetEnd - respectively pointers to the ends of the
|
||||||
|
two buffers, for overflow checking only.
|
||||||
|
|
||||||
|
These conversion functions take a ConversionFlags argument. When this
|
||||||
|
flag is set to strict, both irregular sequences and isolated surrogates
|
||||||
|
will cause an error. When the flag is set to lenient, both irregular
|
||||||
|
sequences and isolated surrogates are converted.
|
||||||
|
|
||||||
|
Whether the flag is strict or lenient, all illegal sequences will cause
|
||||||
|
an error return. This includes sequences such as: <F4 90 80 80>, <C0 80>,
|
||||||
|
or <A0> in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code
|
||||||
|
must check for illegal sequences.
|
||||||
|
|
||||||
|
When the flag is set to lenient, characters over 0x10FFFF are converted
|
||||||
|
to the replacement character; otherwise (when the flag is set to strict)
|
||||||
|
they constitute an error.
|
||||||
|
|
||||||
|
Output parameters:
|
||||||
|
The value "sourceIllegal" is returned from some routines if the input
|
||||||
|
sequence is malformed. When "sourceIllegal" is returned, the source
|
||||||
|
value will point to the illegal value that caused the problem. E.g.,
|
||||||
|
in UTF-8 when a sequence is malformed, it points to the start of the
|
||||||
|
malformed sequence.
|
||||||
|
|
||||||
|
Author: Mark E. Davis, 1994.
|
||||||
|
Rev History: Rick McGowan, fixes & updates May 2001.
|
||||||
|
Fixes & updates, Sept 2001.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------
|
||||||
|
The following 4 definitions are compiler-specific.
|
||||||
|
The C standard does not guarantee that wchar_t has at least
|
||||||
|
16 bits, so wchar_t is no less portable than unsigned short!
|
||||||
|
All should be unsigned values to avoid sign extension during
|
||||||
|
bit mask & shift operations.
|
||||||
|
------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
typedef unsigned long UTF32; /* at least 32 bits */
|
||||||
|
typedef unsigned short UTF16; /* at least 16 bits */
|
||||||
|
typedef unsigned char UTF8; /* typically 8 bits */
|
||||||
|
typedef unsigned char Boolean; /* 0 or 1 */
|
||||||
|
|
||||||
|
/* Some fundamental constants */
|
||||||
|
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
|
||||||
|
#define UNI_MAX_BMP (UTF32)0x0000FFFF
|
||||||
|
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
|
||||||
|
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
|
||||||
|
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
conversionOK, /* conversion successful */
|
||||||
|
sourceExhausted, /* partial character in source, but hit end */
|
||||||
|
targetExhausted, /* insuff. room in target for conversion */
|
||||||
|
sourceIllegal /* source sequence is illegal/malformed */
|
||||||
|
} ConversionResult;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
strictConversion = 0,
|
||||||
|
lenientConversion
|
||||||
|
} ConversionFlags;
|
||||||
|
|
||||||
|
/* This is for C++ and does no harm in C */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF8toUTF16 (
|
||||||
|
const UTF8** sourceStart, const UTF8* sourceEnd,
|
||||||
|
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF16toUTF8 (
|
||||||
|
const UTF16** sourceStart, const UTF16* sourceEnd,
|
||||||
|
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF8toUTF32 (
|
||||||
|
const UTF8** sourceStart, const UTF8* sourceEnd,
|
||||||
|
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF32toUTF8 (
|
||||||
|
const UTF32** sourceStart, const UTF32* sourceEnd,
|
||||||
|
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF16toUTF32 (
|
||||||
|
const UTF16** sourceStart, const UTF16* sourceEnd,
|
||||||
|
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
ConversionResult ConvertUTF32toUTF16 (
|
||||||
|
const UTF32** sourceStart, const UTF32* sourceEnd,
|
||||||
|
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
Reference in New Issue
Block a user