├── img
├── 01.png
├── 02.png
├── location.png
└── location_cn.png
├── examples
├── SD
│ ├── SD.JPG
│ └── SD_Time
│ │ ├── SD_Time.ino
│ │ └── TestInfo.png
├── ESP32
│ ├── ESP32_Dual_Core
│ │ ├── resources
│ │ │ ├── Result.png
│ │ │ ├── MoveCore.png
│ │ │ ├── SpeedTest.png
│ │ │ ├── print_core.png
│ │ │ └── Task_Synchronization.png
│ │ ├── examples
│ │ │ ├── Showcore
│ │ │ │ └── Showcore.ino
│ │ │ ├── Movecore
│ │ │ │ └── Movecore.ino
│ │ │ └── SpeedTest
│ │ │ │ └── SpeedTest.ino
│ │ └── README.md
│ ├── ADC_Read_Voltage
│ │ ├── README.md
│ │ ├── ADC_Read_Accurate
│ │ │ └── ADC_Read_Accurate.ino
│ │ └── ADC_Read_Simple
│ │ │ └── ADC_Read_Simple.ino
│ ├── RTC_counter
│ │ └── RTC_counter.ino
│ ├── GetChipID
│ │ └── GetChipID.ino
│ ├── PSRAM_Test
│ │ └── PSRAM_Test.ino
│ ├── Serial2
│ │ └── Serial2.ino
│ ├── WiFiLoRa32_battery_read
│ │ └── WiFiLoRa32_battery_read.ino
│ ├── VextControl
│ │ └── VextControl.ino
│ ├── ULP
│ │ └── HoldPinStatus
│ │ │ └── HoldPinStatus.ino
│ ├── I2C_Scanner
│ │ └── I2C_Scanner.ino
│ └── ExternalWakeUp
│ │ └── ExternalWakeUp.ino
├── Wireless_paper
│ ├── Wireless_Paper_V1.0
│ │ ├── images.h
│ │ └── Wireless_Paper_V1.0.ino
│ ├── Wireless_Paper_V1.1
│ │ ├── images.h
│ │ ├── img
│ │ │ ├── image-1.png
│ │ │ ├── image-2.png
│ │ │ ├── image-3.png
│ │ │ ├── image-4.png
│ │ │ ├── image-5.png
│ │ │ └── image.png
│ │ ├── readme.md
│ │ └── Wireless_Paper_V1.1.ino
│ ├── Wireless_paper_1.2_manual_flasher
│ │ ├── img
│ │ │ ├── 01.jpg
│ │ │ └── 02.jpg
│ │ ├── readme.md
│ │ └── Wireless_paper_1.2_manual_flasher.ino
│ ├── Wireless_paper_1.1_manual_flasher
│ │ └── Wireless_paper_1.1_manual_flasher.ino
│ └── HT_E0213A367_test
│ │ └── images.h
├── LoRaBasic
│ ├── README.md
│ ├── TxPowerTest
│ │ └── TxPowerTest.ino
│ ├── LoRaReceiver
│ │ └── LoRaReceiver.ino
│ └── LoRaSender
│ │ └── LoRaSender.ino
├── VME213
│ ├── sensor_th
│ │ ├── img.h
│ │ └── sensor_th.ino
│ ├── LorawanEink
│ │ └── img.h
│ ├── Deepsleep
│ │ └── Deepsleep.ino
│ ├── Global_Simple
│ │ └── images.h
│ ├── HT_lCMEN2R13EFC1
│ │ └── images.h
│ ├── weather_station
│ │ └── readme.md
│ └── Part_Simple
│ │ ├── Part_Simple.ino
│ │ └── images.h
├── VME290
│ ├── lorawaneink_GHXTC
│ │ └── img.h
│ ├── deepsleep
│ │ └── deepsleep.ino
│ ├── DEPG0290BxS800FxX_BW
│ │ └── images.h
│ ├── GHXTC_Sensor_Display
│ │ ├── images.h
│ │ └── sensor_th.ino
│ └── weather_station
│ │ └── readme.md
├── Sensor
│ ├── BH1750_test
│ │ └── BH1750_test.ino
│ ├── GXHTC_read
│ │ └── GXHTC_read.ino
│ ├── da217_read_xyz
│ │ └── da217_read_xyz.ino
│ ├── bmp280
│ │ └── bmp280.ino
│ ├── Sensor_OLED
│ │ └── Sensor_OLED.ino
│ ├── BMP180basic
│ │ └── BMP180basic.ino
│ └── DHT11_LoRa_sender
│ │ └── DHT11_LoRa_sender.ino
├── LoRaWAN
│ ├── LoRaWanGPSTime
│ │ └── TTNDecoder.js
│ └── LoRaWanGPSLocation
│ │ └── TTNDecoder.js
├── GPS
│ ├── GPSToUart
│ │ └── GPSToUart.ino
│ └── GPSDisplayOnTFT
│ │ └── GPSDisplayOnTFT.ino
├── OLED
│ ├── OLED_rotate
│ │ └── OLED_rotate.ino
│ ├── SimpleDemo
│ │ └── images.h
│ └── UiDemo
│ │ └── images.h
├── Factory_Test
│ ├── Vision_Master_T190_FactoryTest
│ │ └── checklicense.cpp
│ ├── Vsion_Master_E213_FactoryTest
│ │ └── checklicense.cpp
│ ├── Vision_Master_E290_FactoryTest
│ │ └── checklicense.cpp
│ ├── Vsion_Master_E0213A367_FactoryTest
│ │ └── checklicense.cpp
│ ├── Vision_Master_E290V0.4.1_FactoryTest
│ │ └── checklicense.cpp
│ ├── Vision_Master_T190V1.4.1_FactoryTest
│ │ └── checklicense.cpp
│ └── Wireless_Paper_V1.1_FactoryTest
│ │ └── images.h
├── TFT
│ └── ST7735_SPI
│ │ └── ST7735_SPI.ino
└── eink
│ ├── e213_E0213A367_fase_mode
│ └── e213_E0213A367_fase_mode.ino
│ └── wireless_paper_E0213A367_fase_mode
│ └── wireless_paper_E0213A367_fase_mode.ino
├── src
├── esp32
│ └── liblorawan.a
├── esp32c3
│ ├── liblorawan.a
│ ├── liblorawan2.a
│ ├── liblorawan-espidf4.a
│ └── liblorawan-espidf5.a
├── esp32s3
│ └── liblorawan.a
├── ESP32_LoRaWan_102.h
├── HT_st7735_fonts.h
├── driver
│ ├── delay.c
│ ├── delay.h
│ ├── gpio.c
│ ├── gpio-board.c
│ ├── lorawan_spi.h
│ ├── gpio-board.h
│ ├── rtc-board.h
│ ├── board.h
│ ├── board-config.h
│ └── gpio.h
├── GXHTC.h
├── chsc6x.h
├── loramac
│ ├── Commissioning.h
│ ├── cmac.h
│ ├── LoRaMacTest.h
│ ├── LoRaMacClassBConfig.h
│ └── utilities.c
├── esp_clk_internal.h
├── GXHTC.cpp
├── BMP180.h
├── BH1750.h
├── heltec.h
├── ESP32_Mcu.h
├── chsc6x_platform.h
├── heltec.cpp
├── LoRaWan_APP.h
├── HT_lCMEN2R13EFC1_LUT.h
├── lora
│ └── LoRa.h
├── chsc6x.cpp
└── chsc6x_platform.cpp
├── library.json
├── library.properties
├── CMakeLists.txt
├── .gitignore
├── LICENSE
└── keywords.txt
/img/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/img/01.png
--------------------------------------------------------------------------------
/img/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/img/02.png
--------------------------------------------------------------------------------
/img/location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/img/location.png
--------------------------------------------------------------------------------
/examples/SD/SD.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/SD/SD.JPG
--------------------------------------------------------------------------------
/img/location_cn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/img/location_cn.png
--------------------------------------------------------------------------------
/src/esp32/liblorawan.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/src/esp32/liblorawan.a
--------------------------------------------------------------------------------
/src/esp32c3/liblorawan.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/src/esp32c3/liblorawan.a
--------------------------------------------------------------------------------
/src/esp32s3/liblorawan.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/src/esp32s3/liblorawan.a
--------------------------------------------------------------------------------
/src/esp32c3/liblorawan2.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/src/esp32c3/liblorawan2.a
--------------------------------------------------------------------------------
/examples/SD/SD_Time/SD_Time.ino:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/SD/SD_Time/SD_Time.ino
--------------------------------------------------------------------------------
/examples/SD/SD_Time/TestInfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/SD/SD_Time/TestInfo.png
--------------------------------------------------------------------------------
/src/esp32c3/liblorawan-espidf4.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/src/esp32c3/liblorawan-espidf4.a
--------------------------------------------------------------------------------
/src/esp32c3/liblorawan-espidf5.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/src/esp32c3/liblorawan-espidf5.a
--------------------------------------------------------------------------------
/examples/ESP32/ESP32_Dual_Core/resources/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/ESP32/ESP32_Dual_Core/resources/Result.png
--------------------------------------------------------------------------------
/examples/ESP32/ESP32_Dual_Core/resources/MoveCore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/ESP32/ESP32_Dual_Core/resources/MoveCore.png
--------------------------------------------------------------------------------
/examples/ESP32/ESP32_Dual_Core/resources/SpeedTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/ESP32/ESP32_Dual_Core/resources/SpeedTest.png
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.0/images.h:
--------------------------------------------------------------------------------
1 | #define WiFi_Logo_width 250
2 | #define WiFi_Logo_height 122
3 | uint8_t WiFi_Logo_bits[10000] PROGMEM = {
4 | };
5 |
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.1/images.h:
--------------------------------------------------------------------------------
1 | #define WiFi_Logo_width 250
2 | #define WiFi_Logo_height 122
3 | uint8_t WiFi_Logo_bits[10000] PROGMEM = {
4 | };
5 |
--------------------------------------------------------------------------------
/examples/ESP32/ESP32_Dual_Core/resources/print_core.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/ESP32/ESP32_Dual_Core/resources/print_core.png
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-1.png
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-2.png
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-3.png
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-4.png
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/Wireless_paper/Wireless_Paper_V1.1/img/image-5.png
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.1/img/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/Wireless_paper/Wireless_Paper_V1.1/img/image.png
--------------------------------------------------------------------------------
/examples/ESP32/ESP32_Dual_Core/resources/Task_Synchronization.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/ESP32/ESP32_Dual_Core/resources/Task_Synchronization.png
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_paper_1.2_manual_flasher/img/01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/Wireless_paper/Wireless_paper_1.2_manual_flasher/img/01.jpg
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_paper_1.2_manual_flasher/img/02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/HEAD/examples/Wireless_paper/Wireless_paper_1.2_manual_flasher/img/02.jpg
--------------------------------------------------------------------------------
/examples/LoRaBasic/README.md:
--------------------------------------------------------------------------------
1 | # LoRaBasic Folder
2 |
3 | All examples in this path, just directly call the SX1262 hardware layer to transmit LoRa signals, and do not include any operations with protocol layer.
--------------------------------------------------------------------------------
/examples/ESP32/ADC_Read_Voltage/README.md:
--------------------------------------------------------------------------------
1 | # ADC_Read_Voltage_Simple
2 | Basic ADC example read voltage.
3 |
4 | # ADC_Read_Voltage_Accurate
5 | A function that improves the defaulot ADC reading accuracy to within 1%
6 |
--------------------------------------------------------------------------------
/src/ESP32_LoRaWan_102.h:
--------------------------------------------------------------------------------
1 | #if !defined(HT_DE01)&&!defined(WIFI_Kit_32)&&!defined(WIFI_Kit_32_V3)
2 | #ifndef __LORAWAN_102_H__
3 | #define __LORAWAN_102_H__
4 |
5 | #include "loramac/LoRaMac.h"
6 | #include "loramac/Commissioning.h"
7 | #include "loramac/region/Region.h"
8 |
9 | #endif
10 |
11 | #endif
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_paper_1.2_manual_flasher/readme.md:
--------------------------------------------------------------------------------
1 | Set the image resolution to 250*122(consistent with the settings in **image.h**) and convert it to XBM.
2 |
3 | Open the XBM file with VSCode or Notepad, then copy the image code.
4 |
5 |
6 | Paste the code into image.h.
7 |
8 |
--------------------------------------------------------------------------------
/src/HT_st7735_fonts.h:
--------------------------------------------------------------------------------
1 | /* vim: set ai et ts=4 sw=4: */
2 | #ifndef __HT_ST7735_FONTS_H__
3 | #define __HT_ST7735_FONTS_H__
4 |
5 | #include
6 |
7 | typedef struct {
8 | const uint8_t width;
9 | uint8_t height;
10 | const uint16_t *data;
11 | } FontDef;
12 |
13 |
14 | extern FontDef Font_7x10;
15 | extern FontDef Font_11x18;
16 | extern FontDef Font_16x26;
17 |
18 | #endif // __HT_ST7735_FONTS_H__
19 |
--------------------------------------------------------------------------------
/examples/ESP32/ESP32_Dual_Core/examples/Showcore/Showcore.ino:
--------------------------------------------------------------------------------
1 | #define LED1 25
2 |
3 | void setup() {
4 | Serial.begin(115200);
5 | pinMode(LED1,OUTPUT);
6 | }
7 |
8 | void loop() {
9 | Serial.print("This loop Task run on Core: ");
10 | Serial.println(xPortGetCoreID()); /*print the current core*/
11 | digitalWrite(LED1,HIGH);
12 | delay(1000);
13 | digitalWrite(LED1,LOW);
14 | delay(1000);
15 | }
16 |
--------------------------------------------------------------------------------
/examples/VME213/sensor_th/img.h:
--------------------------------------------------------------------------------
1 | const uint8_t hum[] = {
2 | 0x20, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xFC, 0x01, 0xFC, 0x01,
3 | 0xFE, 0x03, 0xFE, 0x03, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
4 | 0xFF, 0x07, 0xFF, 0x07, 0xFE, 0x03, 0xFC, 0x01, };
5 | const uint8_t temp[] = {
6 | 0x78, 0x00, 0xFC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00,
7 | 0xCC, 0x00, 0xFC, 0x00, 0xFE, 0x01, 0xB7, 0x03, 0x33, 0x03, 0x7B, 0x03,
8 | 0x7B, 0x03, 0x03, 0x03, 0x87, 0x03, 0xFE, 0x01, 0xFC, 0x00, };
--------------------------------------------------------------------------------
/examples/VME213/LorawanEink/img.h:
--------------------------------------------------------------------------------
1 | const uint8_t hum[] = {
2 | 0x20, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xFC, 0x01, 0xFC, 0x01,
3 | 0xFE, 0x03, 0xFE, 0x03, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
4 | 0xFF, 0x07, 0xFF, 0x07, 0xFE, 0x03, 0xFC, 0x01, };
5 | const uint8_t temp[] = {
6 | 0x78, 0x00, 0xFC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00,
7 | 0xCC, 0x00, 0xFC, 0x00, 0xFE, 0x01, 0xB7, 0x03, 0x33, 0x03, 0x7B, 0x03,
8 | 0x7B, 0x03, 0x03, 0x03, 0x87, 0x03, 0xFE, 0x01, 0xFC, 0x00, };
--------------------------------------------------------------------------------
/examples/ESP32/RTC_counter/RTC_counter.ino:
--------------------------------------------------------------------------------
1 | #include "Arduino.h"
2 | #include "soc/rtc.h"
3 |
4 | /*rtc_time_get() return the RTC counters
5 | * the board using internal 150KHz RTC, but it's not accurate.
6 | */
7 | void setup() {
8 | // put your setup code here, to run once:
9 | Serial.begin(115200);
10 | }
11 |
12 | void loop() {
13 | uint64_t rtc_counter1 = rtc_time_get();
14 | delay(1000);
15 | uint64_t rtc_counter2 = rtc_time_get();
16 |
17 | Serial.println((uint32_t)(rtc_counter2-rtc_counter1));
18 | }
--------------------------------------------------------------------------------
/examples/VME290/lorawaneink_GHXTC/img.h:
--------------------------------------------------------------------------------
1 | const uint8_t hum[] = {
2 | 0x20, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xFC, 0x01, 0xFC, 0x01,
3 | 0xFE, 0x03, 0xFE, 0x03, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
4 | 0xFF, 0x07, 0xFF, 0x07, 0xFE, 0x03, 0xFC, 0x01, };
5 | const uint8_t temp[] = {
6 | 0x78, 0x00, 0xFC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00,
7 | 0xCC, 0x00, 0xFC, 0x00, 0xFE, 0x01, 0xB7, 0x03, 0x33, 0x03, 0x7B, 0x03,
8 | 0x7B, 0x03, 0x03, 0x03, 0x87, 0x03, 0xFE, 0x01, 0xFC, 0x00, };
--------------------------------------------------------------------------------
/library.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Heltec ESP32 Dev-Boards",
3 | "keywords": "heltec, esp32, lora, wifi kit, oled",
4 | "description": "A library for Heltec ESP32 (or ESP32+LoRa) based board",
5 | "repository":{
6 | "type": "git",
7 | "url": "https://github.com/HelTecAutomation/Heltec_ESP32.git"
8 | },
9 | "authors":{
10 | "name": "Heltec Automation(TM)",
11 | "email": "support@heltec.cn"
12 | },
13 | "version": "2.1.5",
14 | "frameworks": "arduino",
15 | "platforms": "espressif32"
16 | }
17 |
--------------------------------------------------------------------------------
/examples/ESP32/GetChipID/GetChipID.ino:
--------------------------------------------------------------------------------
1 | /* The true ESP32 chip ID is essentially its MAC address.*/
2 |
3 | uint64_t chipId = 0;
4 |
5 | void setup() {
6 | Serial.begin(115200);
7 | }
8 |
9 | void loop() {
10 | chipId=ESP.getEfuseMac();
11 | Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
12 | Serial.printf("This chip has %d cores\n", ESP.getChipCores());
13 | Serial.printf("ESP32ChipID=%04X",(uint16_t)(chipId>>32));//print High 2bytes
14 | Serial.printf("%08X\r\n",(uint32_t)chipId);//print Low 4bytes.
15 | delay(3000);
16 | }
17 |
--------------------------------------------------------------------------------
/src/driver/delay.c:
--------------------------------------------------------------------------------
1 | /*
2 | / _____) _ | |
3 | ( (____ _____ ____ _| |_ _____ ____| |__
4 | \____ \| ___ | (_ _) ___ |/ ___) _ \
5 | _____) ) ____| | | || |_| ____( (___| | | |
6 | (______/|_____)_|_|_| \__)_____)\____)_| |_|
7 | (C)2013 Semtech
8 |
9 | Description: Delay functions implementation
10 |
11 | License: Revised BSD License, see LICENSE.TXT file include in the project
12 |
13 | Maintainer: Miguel Luis and Gregory Cristian
14 | */
15 | #include "../driver/board.h"
16 | #include "Arduino.h"
17 |
18 | void DelayMs( uint32_t ms )
19 | {
20 | delay(ms);
21 | }
22 |
--------------------------------------------------------------------------------
/library.properties:
--------------------------------------------------------------------------------
1 | name=Heltec ESP32 Dev-Boards
2 | version=2.1.5
3 | author= Heltec Automation
4 | maintainer=HelTec
5 | sentence=Library for Heltec ESP32 (or ESP32+LoRa) based boards
6 | paragraph=Includes: WiFi Kit 32, WiFi LoRa 32, Wireless Stick Lite, Wireless Shell, Vision Master, HT-CT62, Wireless tracker,wireless paper, HT-VME213, HT-VME290, HT-VMT190 see more on http://heltec.cn
7 | category=Device Control
8 | url=https://github.com/HelTecAutomation/Heltec_ESP32.git
9 | architectures=esp32
10 | includes=heltec.h
11 | precompiled=true
12 | ldflags=-llorawan
13 | depends=Adafruit GFX Library, Adafruit BusIO, heltec-eink-modules
--------------------------------------------------------------------------------
/src/GXHTC.h:
--------------------------------------------------------------------------------
1 | #ifndef __GXHTC_H__
2 | #define __GXHTC_H__
3 | #include
4 |
5 |
6 | #define GXHTC_SDA (1)
7 | #define GXHTC_SCL (2)
8 | #define GXHTC_ADDRESS (0x70)
9 | #define GXHTC_AVERAGE_NUM (5)
10 | #define GXHTC_CHIP_ID (0x0887)
11 |
12 | class GXHTC {
13 | public:
14 | GXHTC();
15 | void begin(int sda =GXHTC_SDA,int scl =GXHTC_SCL ,uint8_t address=GXHTC_ADDRESS);
16 | void end();
17 | float g_temperature=0;
18 | float g_humidity=0;
19 | void read_data();
20 | uint16_t read_id(void);
21 |
22 | private:
23 | uint8_t _address;
24 | float findAverage(float arr[], int size);
25 | };
26 |
27 | #endif
28 |
29 |
--------------------------------------------------------------------------------
/examples/Sensor/BH1750_test/BH1750_test.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation BH1750 Sensors test example
2 | *
3 | * Function:
4 | * Light intensity
5 | *
6 | * HelTec AutoMation, Chengdu, China
7 | * www.heltec.org
8 | *
9 | * this project also realess in GitHub:
10 | * https://github.com/HelTecAutomation/Heltec_ESP32
11 | *
12 | */
13 | #include
14 | #include
15 |
16 | BH1750 lightMeter;
17 |
18 |
19 | void setup(){
20 |
21 | Serial.begin(115200);
22 |
23 | lightMeter.begin();
24 |
25 | Serial.println(F("BH1750 Test begin"));
26 |
27 | }
28 |
29 |
30 | void loop() {
31 |
32 | float lux = lightMeter.readLightLevel();
33 | Serial.print("Light: ");
34 | Serial.print(lux);
35 | Serial.println(" lx");
36 | delay(1000);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/examples/Sensor/GXHTC_read/GXHTC_read.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation GXHTC Sensors test example
2 | *
3 | * Function:
4 | * temperature and humidity sensor
5 | *
6 | * HelTec AutoMation, Chengdu, China
7 | * www.heltec.org
8 | *
9 | * this project also realess in GitHub:
10 | * https://github.com/HelTecAutomation/Heltec_ESP32
11 | *
12 | */
13 | #include "Wire.h"
14 | #include "GXHTC.h"
15 |
16 | GXHTC gxhtc;
17 | void setup() {
18 | Serial.begin(115200);
19 | gxhtc.begin(1,2);
20 | }
21 |
22 | void loop() {
23 | gxhtc.read_data();
24 | Serial.print("Temperature:");
25 | Serial.print(gxhtc.g_temperature);
26 | Serial.print(" Humidity:");
27 | Serial.println(gxhtc.g_humidity);
28 | Serial.printf("id = %X\r\n",gxhtc.read_id());
29 |
30 | delay(3000);
31 | }
--------------------------------------------------------------------------------
/examples/ESP32/PSRAM_Test/PSRAM_Test.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation ESP32 external PSRAM read/write example
2 | *
3 | * Must have external PSRAM connected.
4 | *
5 | * HelTec AutoMation, Chengdu, China
6 | * 成都惠利特自动化科技有限公司
7 | * https://heltec.org
8 | *
9 | * this project also realess in GitHub:
10 | * https://github.com/HelTecAutomation/Heltec_ESP32
11 | */
12 |
13 |
14 | #include
15 |
16 | void setup() {
17 | Serial.begin(115200);
18 |
19 | Serial.printf("Total heap: %d\r\n", ESP.getHeapSize());
20 | Serial.printf("Free heap: %d\r\n", ESP.getFreeHeap());
21 | Serial.printf("Total PSRAM: %d\r\n", ESP.getPsramSize());
22 | byte* psdRamBuffer = (byte*)ps_malloc(4000000);
23 | Serial.printf("Free PSRAM: %d\r\n", ESP.getFreePsram());
24 | }
25 |
26 | void loop() {}
27 |
--------------------------------------------------------------------------------
/examples/Sensor/da217_read_xyz/da217_read_xyz.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation da217 Sensors test example
2 | *
3 | * Function:
4 | * Three axis acceleration sensor
5 | *
6 | * HelTec AutoMation, Chengdu, China
7 | * www.heltec.org
8 | *
9 | * this project also realess in GitHub:
10 | * https://github.com/HelTecAutomation/Heltec_ESP32
11 | *
12 | */
13 |
14 | #include "Arduino.h"
15 | #include "da217.h"
16 |
17 | DA217 da217;
18 | uint16_t step_num;
19 | float x_data,y_data,z_data,sum_gravity;
20 | void setup()
21 | {
22 | Serial.begin(115200);
23 |
24 | da217.da217_gravity_init();
25 | }
26 |
27 | void loop()
28 | {
29 | da217.da217_get_xyz_gravity(&x_data,&y_data,&z_data);
30 | da217.da217_get_vector_sum_gravity(&sum_gravity);
31 | Serial.printf("x_data=%f y_data=%f z_data=%f %f\r\n",x_data,y_data,z_data,sum_gravity);
32 | delay(3000);
33 | }
--------------------------------------------------------------------------------
/src/driver/delay.h:
--------------------------------------------------------------------------------
1 | /*
2 | / _____) _ | |
3 | ( (____ _____ ____ _| |_ _____ ____| |__
4 | \____ \| ___ | (_ _) ___ |/ ___) _ \
5 | _____) ) ____| | | || |_| ____( (___| | | |
6 | (______/|_____)_|_|_| \__)_____)\____)_| |_|
7 | (C)2013 Semtech
8 |
9 | Description: Delay functions implementation
10 |
11 | License: Revised BSD License, see LICENSE.TXT file include in the project
12 |
13 | Maintainer: Miguel Luis and Gregory Cristian
14 | */
15 | #ifndef __DELAY_H__
16 | #define __DELAY_H__
17 |
18 | #ifdef __cplusplus
19 | extern "C"{
20 | #endif
21 | /*!
22 | * Blocking delay of "s" seconds
23 | */
24 | void Delay( float s );
25 |
26 | /*!
27 | * Blocking delay of "ms" milliseconds
28 | */
29 | void DelayMs( uint32_t ms );
30 |
31 | #ifdef __cplusplus
32 | } // extern "C"
33 | #endif
34 |
35 | #endif // __DELAY_H__
36 |
37 |
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.1/readme.md:
--------------------------------------------------------------------------------
1 | 1.Modifying the program
2 |
3 |
4 |
5 | Connect to WiFi.
6 |
7 | Compile and burn programs
8 |
9 | 2.After initialization is completed, access the wireless_paper IP address, which can be viewed on the serial port
10 |
11 | 
12 |
13 | 3.The following page appearsClick Select an image, and to ensure a refresh effect, it is best to choose a black and white BMP format image. The image size should be set to 250 x 122.
14 |
15 | The button will display the file address, as shown in the picture
16 |
17 | 4.Click the Get image data button to obtain image data, which will be displayed on the canvas. The effect is as follows:
18 | 5.Click the refresh button to refresh the image on the ink screen.
19 |
20 |
--------------------------------------------------------------------------------
/examples/LoRaWAN/LoRaWanGPSTime/TTNDecoder.js:
--------------------------------------------------------------------------------
1 | function bytesTouInt8(by) {
2 | f = by[0] | by[1]<<8 ;
3 | return f;
4 | }
5 |
6 | function bytesToFloat(by) {
7 | var bits = by[3]<<24 | by[2]<<16 | by[1]<<8 | by[0];
8 | var sign = (bits>>>31 === 0) ? 1.0 : -1.0;
9 | var e = bits>>>23 & 0xff;
10 | var m = (e === 0) ? (bits & 0x7fffff)<<1 : (bits & 0x7fffff) | 0x800000;
11 | var f = sign * m * Math.pow(2, e - 150);
12 | return f;
13 | }
14 |
15 | function Decoder(bytes, port) {
16 |
17 | var decoded = {};
18 | i = 0;
19 |
20 | decoded.hour = bytesToInt(bytes.slice(i,i+=2));
21 | decoded.minute = bytesToInt(bytes.slice(i,i+=2));
22 | decoded.second = bytesToFloat(bytes.slice(i,i+=2));
23 | decoded.centisecond = bytesToFloat(bytes.slice(i,i+=2));
24 |
25 |
26 | // decoded.battery = ((bytes[i++] << 8) | bytes[i++]);
27 |
28 | return decoded;
29 | }
--------------------------------------------------------------------------------
/examples/Sensor/bmp280/bmp280.ino:
--------------------------------------------------------------------------------
1 | #include "Arduino.h"
2 | #include
3 | #include
4 |
5 | BMP280 bmp;
6 |
7 | void setup() {
8 | Serial.begin(115200);
9 | delay(500);
10 | Wire.begin(42,41);
11 | bmp.begin();
12 | delay(500);
13 | bmp.setSampling(BMP280::MODE_NORMAL, /* Operating Mode. */
14 | BMP280::SAMPLING_X2, /* Temp. oversampling */
15 | BMP280::SAMPLING_X16, /* Pressure oversampling */
16 | BMP280::FILTER_X16, /* Filtering. */
17 | BMP280::STANDBY_MS_500); /* Standby time. */
18 | }
19 |
20 | void loop()
21 | {
22 | float temp = bmp.readTemperature();
23 | float Pressure = (float)bmp.readPressure() / 100.0;
24 | Serial.print("Temperature: ");
25 | Serial.print(temp);
26 | Serial.print(" C, Pressure: ");
27 | Serial.print(Pressure);
28 | Serial.println(" hPa");
29 | delay(1000);
30 | }
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(srcs
2 | src/BMP180.cpp
3 | src/heltec.cpp
4 | src/lora/LoRa.cpp
5 | src/HT_Display.cpp
6 | src/HT_DisplayUi.cpp
7 | )
8 |
9 | set(includedirs
10 | src
11 | src/lora
12 | )
13 |
14 | set(priv_includes )
15 | set(requires arduino)
16 | set(priv_requires )
17 |
18 | idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
19 |
20 | function(maybe_add_component component_name)
21 | idf_build_get_property(components BUILD_COMPONENTS)
22 | if (${component_name} IN_LIST components)
23 | idf_component_get_property(lib_name ${component_name} COMPONENT_LIB)
24 | target_link_libraries(${COMPONENT_LIB} PUBLIC ${lib_name})
25 | endif()
26 | endfunction()
27 |
28 | maybe_add_component(arduino)
29 |
30 | target_compile_options(${COMPONENT_TARGET} PUBLIC
31 | -DESP32)
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 | .vscode
11 |
12 | # Windows Installer files
13 | *.cab
14 | *.msi
15 | *.msm
16 | *.msp
17 |
18 | # Windows shortcuts
19 | *.lnk
20 |
21 | # Text editor backup files
22 | .*.swp
23 | .*.swo
24 | *~
25 |
26 | # CMake build folder
27 | /build
28 |
29 | # =========================
30 | # Operating System Files
31 | # =========================
32 |
33 | # OSX
34 | # =========================
35 |
36 | .DS_Store
37 | .AppleDouble
38 | .LSOverride
39 |
40 | # Thumbnails
41 | ._*
42 |
43 | # Files that might appear in the root of a volume
44 | .DocumentRevisions-V100
45 | .fseventsd
46 | .Spotlight-V100
47 | .TemporaryItems
48 | .Trashes
49 | .VolumeIcon.icns
50 |
51 | # Directories potentially created on remote AFP share
52 | .AppleDB
53 | .AppleDesktop
54 | Network Trash Folder
55 | Temporary Items
56 | .apdisk
57 |
--------------------------------------------------------------------------------
/examples/ESP32/ESP32_Dual_Core/examples/Movecore/Movecore.ino:
--------------------------------------------------------------------------------
1 | #define LED1 25
2 | TaskHandle_t Task1;
3 |
4 | void codeForTask1( void * parameter )
5 | {
6 | for(;;) {
7 | Serial.print("This Task run on Core: ");
8 | Serial.println(xPortGetCoreID());
9 |
10 | digitalWrite(LED1,HIGH);
11 | delay(1000);
12 | digitalWrite(LED1,LOW);
13 | delay(1000);
14 | }
15 | }
16 |
17 |
18 | void setup() {
19 | Serial.begin(115200);
20 | pinMode(LED1,OUTPUT);
21 |
22 | xTaskCreatePinnedToCore(
23 | codeForTask1, /*Task Function. */
24 | "Task_1", /*name of task. */
25 | 1000, /*Stack size of task. */
26 | NULL, /* parameter of the task. */
27 | 1, /* proiority of the task. */
28 | &Task1, /* Task handel to keep tra ck of created task. */
29 | 0); /* choose Core */
30 | }
31 |
32 | void loop() {
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/examples/LoRaWAN/LoRaWanGPSLocation/TTNDecoder.js:
--------------------------------------------------------------------------------
1 | function bytesToInt(by) {
2 | f = by[0] | by[1]<<8 | by[2]<<16 | by[3]<<24;
3 | return f;
4 | }
5 |
6 | function bytesToFloat(by) {
7 | var bits = by[3]<<24 | by[2]<<16 | by[1]<<8 | by[0];
8 | var sign = (bits>>>31 === 0) ? 1.0 : -1.0;
9 | var e = bits>>>23 & 0xff;
10 | var m = (e === 0) ? (bits & 0x7fffff)<<1 : (bits & 0x7fffff) | 0x800000;
11 | var f = sign * m * Math.pow(2, e - 150);
12 | return f;
13 | }
14 |
15 | function Decoder(bytes, port) {
16 |
17 | var decoded = {};
18 | i = 0;
19 |
20 | decoded.latitude = bytesToFloat(bytes.slice(i,i+=4));
21 | decoded.longitude = bytesToFloat(bytes.slice(i,i+=4));
22 | decoded.altitude = bytesToFloat(bytes.slice(i,i+=4));
23 | decoded.course = bytesToFloat(bytes.slice(i,i+=4));
24 | decoded.speed = bytesToFloat(bytes.slice(i,i+=4));
25 | decoded.hdop = bytesToFloat(bytes.slice(i,i+=4));
26 |
27 | decoded.battery = ((bytes[i++] << 8) | bytes[i++]);
28 |
29 | return decoded;
30 | }
--------------------------------------------------------------------------------
/examples/ESP32/Serial2/Serial2.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * Heltec Automation ESP32 Serial 1 & 2 example.
3 | * shows the usage of all 3 hardware uarts
4 | * work with ESP32's IO MUX
5 | *
6 | * to test the software and hardware
7 | * wire Rx1 to Tx1 and Rx2 to Tx2
8 | * type text in serial monitor
9 | * text will walk trough all 2 serials
10 | * result is echoed to serial (usb)
11 | */
12 |
13 |
14 | void setup() {
15 | Serial.begin(115200);
16 |
17 | // Serial1.begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert)
18 | // Serial2.begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert)
19 | // The txPin & rxPin can set to any output pin
20 |
21 | Serial1.begin(115200, SERIAL_8N1, 2, 17);
22 | Serial2.begin(115200, SERIAL_8N1, 22, 23);
23 | }
24 |
25 | void loop() {
26 |
27 | if(Serial.available()) {
28 | int ch = Serial.read();
29 | Serial1.write(ch);
30 | }
31 |
32 | if(Serial2.available()) {
33 | int ch = Serial2.read();
34 | Serial2.write(ch);
35 | }
36 |
37 | if(Serial2.available()) {
38 | int ch = Serial2.read();
39 | Serial.write(ch);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 Heltec Automation(TM)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 | See more at http://www.heltec.cn
24 |
--------------------------------------------------------------------------------
/examples/LoRaBasic/TxPowerTest/TxPowerTest.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation txpower test example
2 | *
3 | * Function:
4 | * 1. Lora transmission power test.
5 | *
6 | *
7 | * this project also realess in GitHub:
8 | * https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series
9 | * */
10 |
11 | #include "LoRaWan_APP.h"
12 | #include "Arduino.h"
13 |
14 | #define RF_FREQUENCY 868000000 // Hz
15 | #define TX_OUTPUT_POWER 10 // 20 dBm
16 | #define TX_TIMEOUT 10 // seconds (MAX value)
17 | static RadioEvents_t RadioEvents;
18 |
19 | void OnRadioTxTimeout( void )
20 | {
21 | // Restarts continuous wave transmission when timeout expires
22 | Radio.SetTxContinuousWave( RF_FREQUENCY, TX_OUTPUT_POWER, TX_TIMEOUT );
23 | }
24 | void setup() {
25 | // put your setup code here, to run once:
26 | Serial.begin(115200);
27 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);
28 | RadioEvents.TxTimeout = OnRadioTxTimeout;
29 | Radio.Init( &RadioEvents );
30 |
31 | Radio.SetTxContinuousWave( RF_FREQUENCY, TX_OUTPUT_POWER, TX_TIMEOUT );
32 | }
33 |
34 | void loop() {
35 | // put your main code here, to run repeatedly:
36 | Radio.IrqProcess( );
37 | }
--------------------------------------------------------------------------------
/examples/GPS/GPSToUart/GPSToUart.ino:
--------------------------------------------------------------------------------
1 | #include "Arduino.h"
2 | #include "HT_TinyGPS++.h"
3 |
4 |
5 | TinyGPSPlus GPS;
6 |
7 | #define VGNSS_CTRL 3
8 |
9 |
10 | void GPS_test(void)
11 | {
12 | pinMode(VGNSS_CTRL,OUTPUT);
13 | digitalWrite(VGNSS_CTRL,HIGH);
14 | Serial1.begin(115200,SERIAL_8N1,33,34);
15 | Serial.println("GPS_test");
16 |
17 | delay(100);
18 |
19 | while(1)
20 | {
21 | if(Serial1.available()>0)
22 | {
23 | if(Serial1.peek()!='\n')
24 | {
25 | GPS.encode(Serial1.read());
26 | }
27 | else
28 | {
29 | Serial1.read();
30 | if(GPS.time.second()==0)
31 | {
32 | continue;
33 | }
34 | Serial.printf(" %02d:%02d:%02d.%02d",GPS.time.hour(),GPS.time.minute(),GPS.time.second(),GPS.time.centisecond());
35 | Serial.print("LAT: ");
36 | Serial.print(GPS.location.lat(), 6);
37 | Serial.print(", LON: ");
38 | Serial.print(GPS.location.lng(), 6);
39 | Serial.println();
40 |
41 | delay(5000);
42 | while(Serial1.read()>0);
43 | }
44 | }
45 | }
46 | }
47 |
48 | void setup(){
49 | Serial.begin(115200);
50 | Serial.println("GPS_test");
51 | delay(1000);
52 | GPS_test();
53 | }
54 |
55 | void loop(){
56 | delay(100);
57 | }
58 |
--------------------------------------------------------------------------------
/examples/VME213/Deepsleep/Deepsleep.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation adc example
2 | *
3 | * Function:
4 | * 1.ESP32 deep sleep achieves low power consumption
5 | *
6 | * * Description:
7 | * 1.Pin states can be set to achieve stable deep sleep.
8 | *
9 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32
10 | * Support: support@heltec.cn
11 | *
12 | * HelTec AutoMation, Chengdu, China
13 | * 成都惠利特自动化科技有限公司
14 | * https://www.heltec.org
15 | *
16 | * */
17 |
18 | #include "Arduino.h"
19 | #include "LoRaWan_APP.h"
20 | #include "driver/rtc_io.h"
21 | #include
22 |
23 | #define wakeuptime 10 * 1000 * (uint64_t)1000 //Sleep time
24 |
25 | void intodeepsleep()
26 | {
27 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);
28 | pinMode(18,OUTPUT);
29 | digitalWrite(18, LOW);
30 | Radio.Sleep();
31 | SPI.end();
32 | pinMode(14,ANALOG);
33 | pinMode(8, OUTPUT);
34 | digitalWrite(8, HIGH);
35 | rtc_gpio_hold_en(gpio_num_t(8));
36 | pinMode(12,ANALOG);
37 | pinMode(13,ANALOG);
38 | pinMode(9,ANALOG);
39 | pinMode(11,ANALOG);
40 | pinMode(10,ANALOG);
41 | }
42 |
43 | void setup()
44 | {
45 | intodeepsleep();
46 | esp_sleep_enable_timer_wakeup(wakeuptime);
47 | delay(4000);
48 | esp_deep_sleep_start();
49 | }
50 | void loop()
51 | {
52 | }
--------------------------------------------------------------------------------
/src/chsc6x.h:
--------------------------------------------------------------------------------
1 | #ifndef __CHSC6X_MAIN_H__
2 | #define __CHSC6X_MAIN_H__
3 | #include
4 | #include "chsc6x_platform.h"
5 |
6 | typedef struct sm_touch_dev
7 | {
8 | int int_pin;
9 | int rst_pin;
10 | }sm_touch_dev, *psm_touch_dev;
11 |
12 | struct ts_event {
13 | uint16_t x; /*x coordinate */
14 | uint16_t y; /*y coordinate */
15 | int flag; /* touch event flag: 0 -- down; 4-- up; 8 -- contact */
16 | int id; /*touch ID */
17 | };
18 |
19 |
20 |
21 | class chsc6x :public chsc6x_platform{
22 | private:
23 | uint8_t real_suspend_flag = 1;
24 | #if CHSC6X_GESTURE
25 | uint8_t g_gesture_enable = 1;
26 | uint8_t g_gesture_status = 0;
27 | #endif
28 |
29 | public:
30 | chsc6x(TwoWire *wire = &Wire1, int sda_pin = -1, int scl_pin = -1, int int_pin = -1, int rst_pin = -1)
31 | : chsc6x_platform(wire, sda_pin, scl_pin, int_pin, rst_pin)
32 | {
33 | };
34 | ~chsc6x(){};
35 | void chsc6x_init(void);
36 | void chsc6x_suspend(void);
37 | void chsc6x_resume(void);
38 | int chsc6x_read_touch_info(uint16_t *touchX, uint16_t *touchY);
39 |
40 | #if CHSC6X_GESTURE
41 | void chsc6x_gesture_check(void);
42 | uint8_t chsc6x_get_gesture(void);
43 | #endif
44 |
45 | };
46 |
47 |
48 |
49 |
50 | #endif
51 |
52 |
53 |
--------------------------------------------------------------------------------
/src/loramac/Commissioning.h:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file Commissioning.h
3 | *
4 | * \brief End device commissioning parameters
5 | *
6 | * \copyright Revised BSD License, see section \ref LICENSE.
7 | *
8 | * \code
9 | * ______ _
10 | * / _____) _ | |
11 | * ( (____ _____ ____ _| |_ _____ ____| |__
12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
13 | * _____) ) ____| | | || |_| ____( (___| | | |
14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15 | * (C)2013-2017 Semtech
16 | *
17 | * \endcode
18 | *
19 | * \author Miguel Luis ( Semtech )
20 | *
21 | * \author Gregory Cristian ( Semtech )
22 | */
23 | #ifndef __LORA_COMMISSIONING_H__
24 | #define __LORA_COMMISSIONING_H__
25 |
26 | /*!
27 | * User application data buffer size
28 | */
29 |
30 | #define LORAWAN_APP_DATA_MAX_SIZE 255
31 |
32 | /*!
33 | * Indicates if the end-device is to be connected to a private or public network
34 | */
35 | #define LORAWAN_PUBLIC_NETWORK true
36 |
37 | /*!
38 | * Current network ID
39 | */
40 | #define LORAWAN_NETWORK_ID ( uint32_t )0
41 |
42 |
43 | #endif // __LORA_COMMISSIONING_H__
44 |
--------------------------------------------------------------------------------
/examples/ESP32/WiFiLoRa32_battery_read/WiFiLoRa32_battery_read.ino:
--------------------------------------------------------------------------------
1 | /*
2 | ADC read voltage via GPIO1 simple test.
3 | Base on Wi_Fi LoRa 32 V3.2
4 | by Aaron.Lee from HelTec AutoMation, ChengDu, China
5 | 成都惠利特自动化科技有限公司
6 | www.heltec.cn
7 | */
8 |
9 | void setup() {
10 | // Initialize serial communication at 115200 bits per second:
11 | Serial.begin(115200);
12 |
13 | // Set the resolution of the analog-to-digital converter (ADC) to 12 bits (0-4095):
14 | analogReadResolution(12);
15 |
16 | // Set pin 37 as an output pin (used for ADC control):
17 | pinMode(37, OUTPUT);
18 |
19 | // Set pin 37 to HIGH (enable ADC control):
20 | digitalWrite(37, HIGH);
21 | }
22 |
23 | void loop() {
24 | // Read the raw analog value from pin 1 (range: 0-4095 for 12-bit resolution):
25 | int analogValue = analogRead(1);
26 |
27 | // Read the analog voltage in millivolts from pin 1:
28 | int analogVolts = analogReadMilliVolts(1);
29 |
30 | // Print the scaled analog value (scaled by a factor of 490/100):
31 | Serial.printf("ADC analog value = %d\n", analogValue * 490 / 100);
32 |
33 | // Print the scaled millivolts value (scaled by a factor of 490/100):
34 | Serial.printf("ADC millivolts value = %d\n", analogVolts * 490 / 100);
35 |
36 | // Add a delay of 1 second between readings for clear serial output:
37 | delay(1000);
38 | }
39 |
40 |
41 |
--------------------------------------------------------------------------------
/examples/ESP32/VextControl/VextControl.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * HelTec Automation(TM) Vext control example.
3 | *
4 | * Function summary:
5 | *
6 | * - Vext connected to 3.3V via a MOS-FET, the gate pin connected to GPIO21;
7 | *
8 | * - OLED display and PE4259(RF switch) use Vext as power supply;
9 | *
10 | * - WIFI Kit series V1 don't have Vext control function;
11 | *
12 | * HelTec AutoMation, Chengdu, China.
13 | * 成都惠利特自动化科技有限公司
14 | * www.heltec.cn
15 | * support@heltec.cn
16 | *
17 | * this project also release in GitHub:
18 | * https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series
19 | */
20 |
21 | #include "Arduino.h"
22 | #include "heltec.h"
23 | void setup()
24 | {
25 | //WIFI Kit series V1 not support Vext control
26 | Heltec.begin(true /*DisplayEnable Enable*/, false /*LoRa Disable*/, true /*Serial Enable*/);
27 | //OLED use Vext power supply, Vext must be turn ON before OLED initialition.
28 | Heltec.display->init();
29 |
30 | Heltec.display->flipScreenVertically();
31 | Heltec.display->setFont(ArialMT_Plain_10);
32 | Heltec.display->drawString(0, 0, "Hello, I'm happy today");
33 | Heltec.display->display();
34 | delay(1000);
35 | }
36 |
37 | void loop()
38 | {
39 | Heltec.display->sleep();//OLED sleep
40 | Heltec.VextON();
41 | Serial.println("Turn OFF Vext");
42 | delay(5000);
43 |
44 | Heltec.VextOFF();
45 | Serial.println("Turn ON Vext");
46 | Heltec.display->wakeup();
47 | delay(5000);
48 | }
49 |
--------------------------------------------------------------------------------
/examples/ESP32/ADC_Read_Voltage/ADC_Read_Accurate/ADC_Read_Accurate.ino:
--------------------------------------------------------------------------------
1 | /*
2 | ADC read voltage via GPIO13 with 1% accuracy.
3 |
4 | by Aaron.Lee from HelTec AutoMation, ChengDu, China
5 | 成都惠利特自动化科技有限公司
6 | www.heltec.cn
7 | */
8 |
9 | void setup() {
10 | Serial.begin(115200);
11 | }
12 |
13 | void loop() {
14 | Serial.println(ReadVoltage(13),3);
15 | Serial.println(analogRead(13));
16 | delay(1000);
17 | }
18 |
19 | double ReadVoltage(byte pin){
20 | double reading = analogRead(pin); // Reference voltage is 3v3 so maximum reading is 3v3 = 4095 in range 0 to 4095
21 | if(reading < 1 || reading >= 4095)
22 | //return 0;
23 | // return -0.000000000009824 * pow(reading,3) + 0.000000016557283 * pow(reading,2) + 0.000854596860691 * reading + 0.065440348345433;
24 | return -0.000000000000016 * pow(reading,4) + 0.000000000118171 * pow(reading,3)- 0.000000301211691 * pow(reading,2)+ 0.001109019271794 * reading + 0.034143524634089;
25 | } // Added an improved polynomial, use either, comment out as required
26 |
27 | //See more APIs about ADC here: https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/esp32/cores/esp32/esp32-hal-adc.h
28 |
29 | /* ADC readings v voltage
30 | * y = -0.000000000009824x3 + 0.000000016557283x2 + 0.000854596860691x + 0.065440348345433
31 | // Polynomial curve match, based on raw data thus:
32 | * 464 0.5
33 | * 1088 1.0
34 | * 1707 1.5
35 | * 2331 2.0
36 | * 2951 2.5
37 | * 3775 3.0
38 | *
39 | */
40 |
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_paper_1.2_manual_flasher/Wireless_paper_1.2_manual_flasher.ino:
--------------------------------------------------------------------------------
1 | #include "HT_E0213A367.h"
2 | #include "images.h"
3 |
4 | // Initialize the display
5 | HT_E0213A367 display(6, 5, 4, 7, 3, 2, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency
6 |
7 | #define DIRECTION ANGLE_0_DEGREE
8 |
9 | int width, height;
10 |
11 | void setup() {
12 | Serial.begin(115200);
13 |
14 | // Set display dimensions based on rotation
15 | if (DIRECTION == ANGLE_0_DEGREE || DIRECTION == ANGLE_180_DEGREE) {
16 | width = display._width;
17 | height = display._height;
18 | } else {
19 | width = display._height;
20 | height = display._width;
21 | }
22 |
23 | VextON();
24 | delay(100);
25 |
26 | // Initialize the display
27 | display.init();
28 | display.screenRotate(DIRECTION);
29 | }
30 |
31 | void drawImageDemo() {
32 | display.clear();
33 | display.update(BLACK_BUFFER);
34 |
35 | display.clear();
36 | int x = width/2 - WiFi_Logo_width/2;
37 | int y = height/2 - WiFi_Logo_height/2;
38 | display.drawXbm(x, y, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);
39 | display.update(COLOR_BUFFER);
40 | display.display();
41 | }
42 |
43 | void VextON(void) {
44 | pinMode(Vext, OUTPUT);
45 | digitalWrite(Vext, LOW);
46 | }
47 |
48 | void VextOFF(void) {
49 | pinMode(Vext, OUTPUT);
50 | digitalWrite(Vext, HIGH);
51 | }
52 |
53 | void loop() {
54 | drawImageDemo();
55 | delay(15000); // Keep the logo displayed for 15 seconds
56 | }
57 |
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_paper_1.1_manual_flasher/Wireless_paper_1.1_manual_flasher.ino:
--------------------------------------------------------------------------------
1 | #include "HT_lCMEN2R13EFC1.h"
2 | #include "images.h"
3 |
4 | // Initialize the display
5 | HT_ICMEN2R13EFC1 display(6, 5, 4, 7, 3, 2, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency
6 |
7 | #define DIRECTION ANGLE_0_DEGREE
8 |
9 | int width, height;
10 |
11 | void setup() {
12 | Serial.begin(115200);
13 |
14 | // Set display dimensions based on rotation
15 | if (DIRECTION == ANGLE_0_DEGREE || DIRECTION == ANGLE_180_DEGREE) {
16 | width = display._width;
17 | height = display._height;
18 | } else {
19 | width = display._height;
20 | height = display._width;
21 | }
22 |
23 | VextON();
24 | delay(100);
25 |
26 | // Initialize the display
27 | display.init();
28 | display.screenRotate(DIRECTION);
29 | }
30 |
31 | void drawImageDemo() {
32 | display.clear();
33 | display.update(BLACK_BUFFER);
34 |
35 | display.clear();
36 | int x = width/2 - WiFi_Logo_width/2;
37 | int y = height/2 - WiFi_Logo_height/2;
38 | display.drawXbm(x, y, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);
39 | display.update(COLOR_BUFFER);
40 | display.display();
41 | }
42 |
43 | void VextON(void) {
44 | pinMode(Vext, OUTPUT);
45 | digitalWrite(Vext, LOW);
46 | }
47 |
48 | void VextOFF(void) {
49 | pinMode(Vext, OUTPUT);
50 | digitalWrite(Vext, HIGH);
51 | }
52 |
53 | void loop() {
54 | drawImageDemo();
55 | delay(15000); // Keep the logo displayed for 15 seconds
56 | }
57 |
--------------------------------------------------------------------------------
/src/esp_clk_internal.h:
--------------------------------------------------------------------------------
1 | #ifdef MCU_ESP32_S3
2 | // Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 |
16 | #pragma once
17 |
18 | /**
19 | * @file esp_clk_internal.h
20 | *
21 | * Private clock-related functions
22 | */
23 |
24 | /**
25 | * @brief Initialize clock-related settings
26 | *
27 | * Called from cpu_start.c, not intended to be called from other places.
28 | * This function configures the CPU clock, RTC slow and fast clocks, and
29 | * performs RTC slow clock calibration.
30 | */
31 | void esp_clk_init(void);
32 |
33 |
34 | /**
35 | * @brief Disables clock of some peripherals
36 | *
37 | * Called from cpu_start.c, not intended to be called from other places.
38 | * This function disables clock of useless peripherals when cpu starts.
39 | */
40 | void esp_perip_clk_init(void);
41 |
42 | /* Selects an external clock source (32 kHz) for RTC.
43 | * Only internal use in unit test.
44 | */
45 | //void rtc_clk_select_rtc_slow_clk(void);
46 | #endif
--------------------------------------------------------------------------------
/examples/VME290/deepsleep/deepsleep.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation adc example
2 | *
3 | * Function:
4 | * 1.ESP32 deep sleep achieves low power consumption
5 | *
6 | * * Description:
7 | * 1.Pin states can be set to achieve stable deep sleep.
8 | * 2.If equipped with Lora module, please use this low-power instance
9 | *
10 | * To reset the deepsleep on a Heltec Vision Master, you can press and
11 | * hold the Boot key, press RST once, and then release the Boot key.
12 | * Now you can upload next program.
13 | *
14 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32
15 | * Support: support@heltec.cn
16 | *
17 | * HelTec AutoMation, Chengdu, China
18 | * 成都惠利特自动化科技有限公司
19 | * https://www.heltec.org
20 | *
21 | * */
22 |
23 | #include "Arduino.h"
24 | #include "LoRaWan_APP.h"
25 | #include "driver/rtc_io.h"
26 | #include
27 |
28 | #define wakeuptime 10 * 1000 * (uint64_t)1000 //Sleep time
29 |
30 | void intodeepsleep()
31 | {
32 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);
33 | pinMode(18,OUTPUT);
34 | digitalWrite(18, LOW);
35 | Radio.Sleep();
36 | SPI.end();
37 | pinMode(14,ANALOG);
38 | pinMode(8, OUTPUT);
39 | digitalWrite(8, HIGH);
40 | rtc_gpio_hold_en(gpio_num_t(8));
41 | pinMode(12,ANALOG);
42 | pinMode(13,ANALOG);
43 | pinMode(9,ANALOG);
44 | pinMode(11,ANALOG);
45 | pinMode(10,ANALOG);
46 | }
47 |
48 | void setup()
49 | {
50 | intodeepsleep();
51 | esp_sleep_enable_timer_wakeup(wakeuptime);
52 | delay(4000);
53 | esp_deep_sleep_start();
54 | }
55 |
56 | void loop()
57 | {
58 | }
59 |
--------------------------------------------------------------------------------
/examples/GPS/GPSDisplayOnTFT/GPSDisplayOnTFT.ino:
--------------------------------------------------------------------------------
1 | #include "Arduino.h"
2 | #include "HT_st7735.h"
3 | #include "HT_TinyGPS++.h"
4 |
5 |
6 | TinyGPSPlus GPS;
7 | HT_st7735 st7735;
8 |
9 | #define VGNSS_CTRL 3
10 |
11 |
12 | void GPS_test(void)
13 | {
14 | pinMode(VGNSS_CTRL,OUTPUT);
15 | digitalWrite(VGNSS_CTRL,HIGH);
16 | Serial1.begin(115200,SERIAL_8N1,33,34);
17 | Serial.println("GPS_test");
18 | st7735.st7735_fill_screen(ST7735_BLACK);
19 | delay(100);
20 | st7735.st7735_write_str(0, 0, (String)"GPS_test");
21 |
22 | while(1)
23 | {
24 | if(Serial1.available()>0)
25 | {
26 | if(Serial1.peek()!='\n')
27 | {
28 | GPS.encode(Serial1.read());
29 | }
30 | else
31 | {
32 | Serial1.read();
33 | if(GPS.time.second()==0)
34 | {
35 | continue;
36 | }
37 | st7735.st7735_fill_screen(ST7735_BLACK);
38 | st7735.st7735_write_str(0, 0, (String)"GPS_test");
39 | String time_str = (String)GPS.time.hour() + ":" + (String)GPS.time.minute() + ":" + (String)GPS.time.second()+ ":"+(String)GPS.time.centisecond();
40 | st7735.st7735_write_str(0, 20, time_str);
41 | String latitude = "LAT: " + (String)GPS.location.lat();
42 | st7735.st7735_write_str(0, 40, latitude);
43 | String longitude = "LON: "+ (String)GPS.location.lng();
44 | st7735.st7735_write_str(0, 60, longitude);
45 |
46 |
47 | delay(5000);
48 | while(Serial1.read()>0);
49 | }
50 | }
51 | }
52 | }
53 |
54 | void setup(){
55 | delay(100);
56 | st7735.st7735_init();
57 | GPS_test();
58 | }
59 |
60 | void loop(){
61 | delay(100);
62 | }
63 |
--------------------------------------------------------------------------------
/examples/ESP32/ULP/HoldPinStatus/HoldPinStatus.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * Hold GPIO status in deep sleep mode, use ESP32's ULP (Ultra Low Power) coprocessor
3 | *
4 | * HelTec AutoMation, Chengdu, China.
5 | * 成都惠利特自动化科技有限公司
6 | * www.heltec.cn
7 | * support@heltec.cn
8 | *
9 | *this project also release in GitHub:
10 | *https://github.com/HelTecAutomation/ESP32_LoRaWAN
11 | */
12 | #include "soc/rtc_io_reg.h"
13 | #include "driver/rtc_io.h"
14 |
15 | #define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
16 | #define TIME_TO_SLEEP 5 /* Time ESP32 will go to sleep (in seconds) */
17 |
18 | RTC_DATA_ATTR int bootCount = 0;
19 |
20 | void setup(){
21 | rtc_gpio_hold_dis(GPIO_NUM_35);
22 | pinMode(35,OUTPUT);
23 | digitalWrite(35,LOW);//The on board LED will be OFF in wake up period
24 |
25 | Serial.begin(115200);
26 | delay(1000); //Take some time to open up the Serial Monitor
27 |
28 | //Increment boot number and print it every reboot
29 | ++bootCount;
30 | Serial.println("Boot number: " + String(bootCount));
31 | delay(2);
32 |
33 | esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
34 | Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +
35 | " Seconds");
36 | delay(10);
37 |
38 | Serial.println("Going to sleep now");
39 | delay(2);
40 |
41 | rtc_gpio_init(GPIO_NUM_35);
42 | pinMode(35,OUTPUT);
43 | digitalWrite(35,HIGH);//The on board LED will be ON in deep sleep period
44 | rtc_gpio_hold_en(GPIO_NUM_35);
45 |
46 | esp_deep_sleep_start();
47 | Serial.println("This will never be printed");
48 | }
49 |
50 | void loop(){
51 | //This is not going to be called
52 | }
--------------------------------------------------------------------------------
/examples/OLED/OLED_rotate/OLED_rotate.ino:
--------------------------------------------------------------------------------
1 |
2 | #include "HT_SSD1306Wire.h"
3 | #include "Arduino.h"
4 |
5 | //rotate only for GEOMETRY_128_64
6 | static SSD1306Wire display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); // addr , freq , i2c group , resolution , rst
7 |
8 | void VextON(void)
9 | {
10 | pinMode(Vext,OUTPUT);
11 | digitalWrite(Vext, LOW);
12 | }
13 |
14 | void VextOFF(void) //Vext default OFF
15 | {
16 | pinMode(Vext,OUTPUT);
17 | digitalWrite(Vext, HIGH);
18 | }
19 |
20 | void setup() {
21 |
22 | VextON();
23 | delay(100);
24 |
25 | display.init();
26 | display.clear();
27 | display.display();
28 |
29 | display.setContrast(255);
30 |
31 | display.setTextAlignment(TEXT_ALIGN_CENTER);
32 | display.clear();
33 | display.display();
34 | display.screenRotate(ANGLE_0_DEGREE);
35 | display.setFont(ArialMT_Plain_16);
36 | display.drawString(64, 32-16/2, "ROTATE_0");
37 | display.display();
38 | delay(2000);
39 |
40 | display.clear();
41 | display.display();
42 | display.screenRotate(ANGLE_90_DEGREE);
43 | display.setFont(ArialMT_Plain_10);
44 | display.drawString(32, 64-10/2, "ROTATE_90");
45 | display.display();
46 | delay(2000);
47 |
48 | display.clear();
49 | display.display();
50 | display.screenRotate(ANGLE_180_DEGREE);
51 | display.setFont(ArialMT_Plain_16);
52 | display.drawString(64, 32-16/2, "ROTATE_180");
53 | display.display();
54 | delay(2000);
55 |
56 | display.clear();
57 | display.display();
58 | display.screenRotate(ANGLE_270_DEGREE);
59 | display.setFont(ArialMT_Plain_10);
60 | display.drawString(32, 64-10/2, "ROTATE_270");
61 | display.display();
62 | delay(2000);
63 | }
64 |
65 | void loop() { }
--------------------------------------------------------------------------------
/src/driver/gpio.c:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file gpio.c
3 | *
4 | * \brief GPIO driver implementation
5 | *
6 | * \remark: Relies on the specific board GPIO implementation as well as on
7 | * IO expander driver implementation if one is available on the target
8 | * board.
9 | *
10 | * \copyright Revised BSD License, see section \ref LICENSE.
11 | *
12 | * \code
13 | * ______ _
14 | * / _____) _ | |
15 | * ( (____ _____ ____ _| |_ _____ ____| |__
16 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
17 | * _____) ) ____| | | || |_| ____( (___| | | |
18 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
19 | * (C)2013-2017 Semtech
20 | *
21 | * \endcode
22 | *
23 | * \author Miguel Luis ( Semtech )
24 | *
25 | * \author Gregory Cristian ( Semtech )
26 | */
27 |
28 | #include "../driver/gpio-board.h"
29 |
30 | void GpioInit( Gpio_t *obj, uint8_t pin, uint8_t mode, PinConfigs config, PinTypes type, uint32_t value )
31 | {
32 | GpioMcuInit( obj, pin, mode, config, type, value );
33 | }
34 |
35 | void GpioSetInterrupt( Gpio_t *obj, IrqModes irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler )
36 | {
37 | GpioMcuSetInterrupt( obj, irqMode, irqPriority, irqHandler );
38 | }
39 |
40 | void GpioRemoveInterrupt( Gpio_t *obj )
41 | {
42 | GpioMcuRemoveInterrupt( obj );
43 | }
44 |
45 | void GpioWrite( Gpio_t *obj, uint32_t value )
46 | {
47 | GpioMcuWrite( obj, value );
48 | }
49 |
50 | void GpioToggle( Gpio_t *obj )
51 | {
52 | GpioMcuToggle( obj );
53 | }
54 |
55 | uint32_t GpioRead( Gpio_t *obj )
56 | {
57 | return GpioMcuRead( obj );
58 | }
59 |
--------------------------------------------------------------------------------
/examples/Factory_Test/Vision_Master_T190_FactoryTest/checklicense.cpp:
--------------------------------------------------------------------------------
1 | #include "LoRaWan_APP.h"
2 |
3 |
4 | extern void getLicenseAddress(uint8_t board_type);
5 | RTC_DATA_ATTR static bool licenseok=false;
6 | extern void readlicense(uint8_t board_type);
7 | extern uint32_t storedlicense[4];
8 | extern void writelicense(uint32_t * license,uint8_t board_type);
9 | extern int calRTC(uint32_t * license);
10 | extern void check_input_license();
11 | extern uint32_t ex_32k_start_cnt;
12 |
13 | void checklicense()
14 | {
15 | if(licenseok==false)
16 | {
17 | getLicenseAddress(HELTEC_BOARD);
18 | readlicense(HELTEC_BOARD);
19 | if(calRTC(storedlicense)!=1)
20 | {
21 | uint64_t chipid=ESP.getEfuseMac();
22 | lora_printf("Please provide a correct license! For more information:\r\n");
23 | lora_printf("http://www.heltec.cn/search/\r\n");
24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
26 |
27 | //read cdkey from uart
28 | uint32_t print_timestart;
29 | print_timestart = millis();
30 |
31 | for(;;)
32 | {
33 | if(millis() -print_timestart > 3000 )
34 | {
35 | print_timestart = millis();
36 | lora_printf("Please provide a correct license! For more information:\r\n");
37 | lora_printf("http://www.heltec.cn/search/\r\n");
38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
40 | }
41 |
42 | check_input_license();
43 | if(calRTC(storedlicense)==1)
44 | {
45 | writelicense(storedlicense,HELTEC_BOARD);
46 | lora_printf("The board is actived\r\n");
47 | break;
48 | }
49 | }
50 | }
51 | else
52 | {
53 | licenseok=true;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/examples/Factory_Test/Vsion_Master_E213_FactoryTest/checklicense.cpp:
--------------------------------------------------------------------------------
1 | #include "LoRaWan_APP.h"
2 |
3 |
4 | extern void getLicenseAddress(uint8_t board_type);
5 | RTC_DATA_ATTR static bool licenseok=false;
6 | extern void readlicense(uint8_t board_type);
7 | extern uint32_t storedlicense[4];
8 | extern void writelicense(uint32_t * license,uint8_t board_type);
9 | extern int calRTC(uint32_t * license);
10 | extern void check_input_license();
11 | extern uint32_t ex_32k_start_cnt;
12 |
13 | void checklicense()
14 | {
15 | if(licenseok==false)
16 | {
17 | getLicenseAddress(HELTEC_BOARD);
18 | readlicense(HELTEC_BOARD);
19 | if(calRTC(storedlicense)!=1)
20 | {
21 | uint64_t chipid=ESP.getEfuseMac();
22 | lora_printf("Please provide a correct license! For more information:\r\n");
23 | lora_printf("http://www.heltec.cn/search/\r\n");
24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
26 |
27 | //read cdkey from uart
28 | uint32_t print_timestart;
29 | print_timestart = millis();
30 |
31 | for(;;)
32 | {
33 | if(millis() -print_timestart > 3000 )
34 | {
35 | print_timestart = millis();
36 | lora_printf("Please provide a correct license! For more information:\r\n");
37 | lora_printf("http://www.heltec.cn/search/\r\n");
38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
40 | }
41 |
42 | check_input_license();
43 | if(calRTC(storedlicense)==1)
44 | {
45 | writelicense(storedlicense,HELTEC_BOARD);
46 | lora_printf("The board is actived\r\n");
47 | break;
48 | }
49 | }
50 | }
51 | else
52 | {
53 | licenseok=true;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/examples/Factory_Test/Vision_Master_E290_FactoryTest/checklicense.cpp:
--------------------------------------------------------------------------------
1 | #include "LoRaWan_APP.h"
2 |
3 |
4 | extern void getLicenseAddress(uint8_t board_type);
5 | RTC_DATA_ATTR static bool licenseok=false;
6 | extern void readlicense(uint8_t board_type);
7 | extern uint32_t storedlicense[4];
8 | extern void writelicense(uint32_t * license,uint8_t board_type);
9 | extern int calRTC(uint32_t * license);
10 | extern void check_input_license();
11 | // extern uint32_t ex_32k_start_cnt;
12 |
13 | void checklicense()
14 | {
15 | if(licenseok==false)
16 | {
17 | getLicenseAddress(HELTEC_BOARD);
18 | readlicense(HELTEC_BOARD);
19 | if(calRTC(storedlicense)!=1)
20 | {
21 | uint64_t chipid=ESP.getEfuseMac();
22 | lora_printf("Please provide a correct license! For more information:\r\n");
23 | lora_printf("http://www.heltec.cn/search/\r\n");
24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
26 |
27 | //read cdkey from uart
28 | uint32_t print_timestart;
29 | print_timestart = millis();
30 |
31 | for(;;)
32 | {
33 | if(millis() -print_timestart > 3000 )
34 | {
35 | print_timestart = millis();
36 | lora_printf("Please provide a correct license! For more information:\r\n");
37 | lora_printf("http://www.heltec.cn/search/\r\n");
38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
40 | }
41 |
42 | check_input_license();
43 | if(calRTC(storedlicense)==1)
44 | {
45 | writelicense(storedlicense,HELTEC_BOARD);
46 | lora_printf("The board is actived\r\n");
47 | break;
48 | }
49 | }
50 | }
51 | else
52 | {
53 | licenseok=true;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/examples/Factory_Test/Vsion_Master_E0213A367_FactoryTest/checklicense.cpp:
--------------------------------------------------------------------------------
1 | #include "LoRaWan_APP.h"
2 |
3 |
4 | extern void getLicenseAddress(uint8_t board_type);
5 | RTC_DATA_ATTR static bool licenseok=false;
6 | extern void readlicense(uint8_t board_type);
7 | extern uint32_t storedlicense[4];
8 | extern void writelicense(uint32_t * license,uint8_t board_type);
9 | extern int calRTC(uint32_t * license);
10 | extern void check_input_license();
11 | extern uint32_t ex_32k_start_cnt;
12 |
13 | void checklicense()
14 | {
15 | if(licenseok==false)
16 | {
17 | getLicenseAddress(HELTEC_BOARD);
18 | readlicense(HELTEC_BOARD);
19 | if(calRTC(storedlicense)!=1)
20 | {
21 | uint64_t chipid=ESP.getEfuseMac();
22 | lora_printf("Please provide a correct license! For more information:\r\n");
23 | lora_printf("http://www.heltec.cn/search/\r\n");
24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
26 |
27 | //read cdkey from uart
28 | uint32_t print_timestart;
29 | print_timestart = millis();
30 |
31 | for(;;)
32 | {
33 | if(millis() -print_timestart > 3000 )
34 | {
35 | print_timestart = millis();
36 | lora_printf("Please provide a correct license! For more information:\r\n");
37 | lora_printf("http://www.heltec.cn/search/\r\n");
38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
40 | }
41 |
42 | check_input_license();
43 | if(calRTC(storedlicense)==1)
44 | {
45 | writelicense(storedlicense,HELTEC_BOARD);
46 | lora_printf("The board is actived\r\n");
47 | break;
48 | }
49 | }
50 | }
51 | else
52 | {
53 | licenseok=true;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/examples/Factory_Test/Vision_Master_E290V0.4.1_FactoryTest/checklicense.cpp:
--------------------------------------------------------------------------------
1 | #include "LoRaWan_APP.h"
2 |
3 |
4 | extern void getLicenseAddress(uint8_t board_type);
5 | RTC_DATA_ATTR static bool licenseok=false;
6 | extern void readlicense(uint8_t board_type);
7 | extern uint32_t storedlicense[4];
8 | extern void writelicense(uint32_t * license,uint8_t board_type);
9 | extern int calRTC(uint32_t * license);
10 | extern void check_input_license();
11 | // extern uint32_t ex_32k_start_cnt;
12 |
13 | void checklicense()
14 | {
15 | if(licenseok==false)
16 | {
17 | getLicenseAddress(HELTEC_BOARD);
18 | readlicense(HELTEC_BOARD);
19 | if(calRTC(storedlicense)!=1)
20 | {
21 | uint64_t chipid=ESP.getEfuseMac();
22 | lora_printf("Please provide a correct license! For more information:\r\n");
23 | lora_printf("http://www.heltec.cn/search/\r\n");
24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
26 |
27 | //read cdkey from uart
28 | uint32_t print_timestart;
29 | print_timestart = millis();
30 |
31 | for(;;)
32 | {
33 | if(millis() -print_timestart > 3000 )
34 | {
35 | print_timestart = millis();
36 | lora_printf("Please provide a correct license! For more information:\r\n");
37 | lora_printf("http://www.heltec.cn/search/\r\n");
38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
40 | }
41 |
42 | check_input_license();
43 | if(calRTC(storedlicense)==1)
44 | {
45 | writelicense(storedlicense,HELTEC_BOARD);
46 | lora_printf("The board is actived\r\n");
47 | break;
48 | }
49 | }
50 | }
51 | else
52 | {
53 | licenseok=true;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/examples/Factory_Test/Vision_Master_T190V1.4.1_FactoryTest/checklicense.cpp:
--------------------------------------------------------------------------------
1 | #include "LoRaWan_APP.h"
2 |
3 |
4 | extern void getLicenseAddress(uint8_t board_type);
5 | RTC_DATA_ATTR static bool licenseok=false;
6 | extern void readlicense(uint8_t board_type);
7 | extern uint32_t storedlicense[4];
8 | extern void writelicense(uint32_t * license,uint8_t board_type);
9 | extern int calRTC(uint32_t * license);
10 | extern void check_input_license();
11 | extern uint32_t ex_32k_start_cnt;
12 |
13 | void checklicense()
14 | {
15 | if(licenseok==false)
16 | {
17 | getLicenseAddress(HELTEC_BOARD);
18 | readlicense(HELTEC_BOARD);
19 | if(calRTC(storedlicense)!=1)
20 | {
21 | uint64_t chipid=ESP.getEfuseMac();
22 | lora_printf("Please provide a correct license! For more information:\r\n");
23 | lora_printf("http://www.heltec.cn/search/\r\n");
24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
26 |
27 | //read cdkey from uart
28 | uint32_t print_timestart;
29 | print_timestart = millis();
30 |
31 | for(;;)
32 | {
33 | if(millis() -print_timestart > 3000 )
34 | {
35 | print_timestart = millis();
36 | lora_printf("Please provide a correct license! For more information:\r\n");
37 | lora_printf("http://www.heltec.cn/search/\r\n");
38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes.
40 | }
41 |
42 | check_input_license();
43 | if(calRTC(storedlicense)==1)
44 | {
45 | writelicense(storedlicense,HELTEC_BOARD);
46 | lora_printf("The board is actived\r\n");
47 | break;
48 | }
49 | }
50 | }
51 | else
52 | {
53 | licenseok=true;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/examples/OLED/SimpleDemo/images.h:
--------------------------------------------------------------------------------
1 | #define WiFi_Logo_width 60
2 | #define WiFi_Logo_height 36
3 | const uint8_t WiFi_Logo_bits[] PROGMEM = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 | };
29 |
--------------------------------------------------------------------------------
/examples/VME213/Global_Simple/images.h:
--------------------------------------------------------------------------------
1 | #define WiFi_Logo_width 60
2 | #define WiFi_Logo_height 36
3 | const uint8_t WiFi_Logo_bits[] PROGMEM = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 | };
29 |
--------------------------------------------------------------------------------
/examples/VME213/HT_lCMEN2R13EFC1/images.h:
--------------------------------------------------------------------------------
1 | #define WiFi_Logo_width 60
2 | #define WiFi_Logo_height 36
3 | const uint8_t WiFi_Logo_bits[] PROGMEM = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 | };
29 |
--------------------------------------------------------------------------------
/examples/VME290/DEPG0290BxS800FxX_BW/images.h:
--------------------------------------------------------------------------------
1 | #define WiFi_Logo_width 60
2 | #define WiFi_Logo_height 36
3 | const uint8_t WiFi_Logo_bits[] PROGMEM = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 | };
29 |
--------------------------------------------------------------------------------
/examples/Wireless_paper/HT_E0213A367_test/images.h:
--------------------------------------------------------------------------------
1 | #define WiFi_Logo_width 60
2 | #define WiFi_Logo_height 36
3 | const uint8_t WiFi_Logo_bits[] PROGMEM = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 | };
29 |
--------------------------------------------------------------------------------
/src/driver/gpio-board.c:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file gpio-board.c
3 | *
4 | * \brief Target board GPIO driver implementation
5 | *
6 | * \copyright Revised BSD License, see section \ref LICENSE.
7 | *
8 | * \code
9 | * ______ _
10 | * / _____) _ | |
11 | * ( (____ _____ ____ _| |_ _____ ____| |__
12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
13 | * _____) ) ____| | | || |_| ____( (___| | | |
14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15 | * (C)2013-2017 Semtech
16 | *
17 | * \endcode
18 | *
19 | * \author Miguel Luis ( Semtech )
20 | *
21 | * \author Gregory Cristian ( Semtech )
22 | */
23 |
24 |
25 | #include "../loramac/utilities.h"
26 | #include "../driver/rtc-board.h"
27 | #include "../driver/gpio-board.h"
28 | #include "../driver/gpio-board.h"
29 | #include "board-config.h"
30 | #if !defined(HT_DE01)&&!defined(WIFI_Kit_32)&&!defined(WIFI_Kit_32_V3)
31 | static GpioIrqHandler *GpioIrq[16];
32 |
33 | void GpioMcuInit( Gpio_t *obj, uint8_t pin, uint8_t mode, PinConfigs config, PinTypes type, uint32_t value )
34 | {
35 | obj->pin = pin;
36 | pinMode(pin,mode);
37 | if( mode == OUTPUT )
38 | {
39 | GpioMcuWrite( obj, value );
40 | }
41 | }
42 |
43 | bool radio_nss_inited=false;
44 | void GpioMcuSetInterrupt( Gpio_t *obj, int irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler )
45 | {
46 | attachInterrupt(obj->pin,irqHandler,RISING);
47 | }
48 |
49 | void GpioMcuRemoveInterrupt( Gpio_t *obj )
50 | {
51 | detachInterrupt(obj->pin);
52 | }
53 |
54 | void GpioMcuWrite( Gpio_t *obj, uint32_t value )
55 | {
56 | if(obj->pin==RADIO_NSS && radio_nss_inited==false)
57 | {
58 | pinMode(obj->pin,OUTPUT);
59 | radio_nss_inited=true;
60 | }
61 | digitalWrite(obj->pin,value);
62 | }
63 |
64 | void GpioMcuToggle( Gpio_t *obj )
65 | {
66 |
67 | }
68 |
69 | uint32_t GpioMcuRead( Gpio_t *obj )
70 | {
71 | return digitalRead(obj->pin);
72 | }
73 |
74 | #endif
--------------------------------------------------------------------------------
/src/GXHTC.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "GXHTC.h"
3 |
4 |
5 | GXHTC::GXHTC()
6 | {
7 | }
8 |
9 | void GXHTC::begin(int sda,int scl,uint8_t address)
10 | {
11 | _address = address;
12 | Wire.begin(sda,scl);
13 | }
14 |
15 | void GXHTC::end()
16 | {
17 | Wire.end();
18 | }
19 |
20 | uint16_t GXHTC::read_id(void)
21 | {
22 | uint8_t buff[2];
23 | uint16_t chip_id;
24 | Wire.beginTransmission(_address);
25 | Wire.write(0xEF);
26 | Wire.write(0xC8);
27 | Wire.endTransmission();
28 |
29 | Wire.requestFrom(_address, (uint8_t)2);
30 | buff[0] = Wire.read();
31 | buff[1] = Wire.read();
32 |
33 | uint16_t tem,hum;
34 |
35 | chip_id = ((buff[0]<<8) | buff[1]);
36 | return chip_id;
37 | }
38 | void GXHTC::read_data()
39 | {
40 | uint8_t buff[6];
41 | Wire.beginTransmission(_address);
42 | Wire.write(0x35);
43 | Wire.write(0x17);
44 | Wire.endTransmission();
45 |
46 | Wire.beginTransmission(_address);
47 | Wire.write(0x7C);
48 | Wire.write(0xA2);
49 | Wire.endTransmission();
50 |
51 | Wire.requestFrom(_address, (uint8_t)6);
52 | buff[0] = Wire.read();
53 | buff[1] = Wire.read();
54 | buff[2] = Wire.read();
55 | buff[3] = Wire.read();
56 | buff[4] = Wire.read();
57 | buff[5] = Wire.read();
58 |
59 | uint16_t tem,hum;
60 |
61 | tem = ((buff[0]<<8) | buff[1]);//�¶�ƴ��
62 | hum = ((buff[3]<<8) | buff[4]);//ʪ��ƴ��
63 |
64 | g_temperature= (175.0*(float)tem/65535.0-45.0) ;// T = -45 + 175 * tem / (2^16-1)
65 | g_humidity= (100.0*(float)hum/65535.0);// RH = hum*100 / (2^16-1)
66 |
67 | Wire.beginTransmission(_address);
68 | Wire.write(0xb0);
69 | Wire.write(0x98);
70 | Wire.endTransmission();
71 | }
72 |
73 | float GXHTC::findAverage(float arr[], int size)
74 | {
75 | float max = arr[0];
76 | float min = arr[0];
77 | float sum = 0;
78 | int count = 0;
79 | for (int i = 0; i < size; i++) {
80 | if (arr[i] > max)
81 | max = arr[i];
82 | if (arr[i] < min)
83 | min = arr[i];
84 | sum += arr[i];
85 | count++;
86 | }
87 | count -= 2;
88 | sum = sum - max - min;
89 | float average = (float)sum / count;
90 |
91 | return average;
92 | }
93 |
--------------------------------------------------------------------------------
/examples/ESP32/I2C_Scanner/I2C_Scanner.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation I2C scanner example (also it's a basic example how to use I2C1)
2 | *
3 | * ESP32 have two I2C (I2C0 and I2C1) bus
4 | *
5 | * OLED is connected to I2C0, so if scan with Wire (I2C0), the return address should be 0x3C.
6 | *
7 | * If you need scan other device address in I2C1...
8 | * - Comment all Wire.***() codes;
9 | * - Uncomment all Wire1.***() codes;
10 | *
11 | * I2C scan example and I2C0
12 | *
13 | * HelTec AutoMation, Chengdu, China
14 | * 成都惠利特自动化科技有限公司
15 | * www.heltec.org
16 | *
17 | * this project also realess in GitHub:
18 | * https://github.com/HelTecAutomation/Heltec_ESP32
19 | * */
20 |
21 | #include "Arduino.h"
22 | #include "heltec.h"
23 |
24 | #if defined( WIRELESS_STICK_LITE )
25 | #include
26 | #include "oled/SSD1306Wire.h"
27 |
28 | static const uint8_t SCL_OLED = 15;
29 | static const uint8_t SDA_OLED = 4;
30 | #endif
31 |
32 | void setup()
33 | {
34 | Heltec.begin(true, false, true);
35 | Wire.begin(SDA_OLED, SCL_OLED); //Scan OLED's I2C address via I2C0
36 | //Wire1.begin(SDA, SCL); //If there have other device on I2C1, scan the device address via I2C1
37 | }
38 |
39 | void loop()
40 | {
41 | byte error, address;
42 | int nDevices;
43 |
44 | Serial.println("Scanning...");
45 |
46 | nDevices = 0;
47 | for(address = 1; address < 127; address++ )
48 | {
49 | Wire.beginTransmission(address);
50 | error = Wire.endTransmission();
51 |
52 | // Wire1.beginTransmission(address);
53 | // error = Wire1.endTransmission();
54 |
55 | if (error == 0)
56 | {
57 | Serial.print("I2C device found at address 0x");
58 | if (address<16)
59 | Serial.print("0");
60 | Serial.print(address,HEX);
61 | Serial.println(" !");
62 |
63 | nDevices++;
64 | }
65 | else if (error==4)
66 | {
67 | Serial.print("Unknown error at address 0x");
68 | if (address<16)
69 | Serial.print("0");
70 | Serial.println(address,HEX);
71 | }
72 | }
73 | if (nDevices == 0)
74 | Serial.println("No I2C devices found\n");
75 | else
76 | Serial.println("done\n");
77 |
78 | delay(5000);
79 | }
80 |
--------------------------------------------------------------------------------
/examples/ESP32/ESP32_Dual_Core/examples/SpeedTest/SpeedTest.ino:
--------------------------------------------------------------------------------
1 | #define LED1 25
2 | long loops1 = 1000;
3 | long loops2 = 1000;
4 | long qq;
5 | float t1;
6 | int t2,t3;
7 |
8 | TaskHandle_t Task1, Task2;
9 | SemaphoreHandle_t baton;
10 |
11 |
12 | void artificialLoad () {
13 | for ( long i = 0;i < loops1; i++){
14 | for ( long j = 1; j < loops2; j++) {
15 | qq++;
16 | t1 = 5000.0 * i;
17 | t2 = 150 * 1234 * i;
18 | t3 = j % 554 ;
19 | }
20 | }
21 | }
22 | void blink(){
23 | digitalWrite(LED1,HIGH);
24 | delay(1000);
25 | digitalWrite(LED1,LOW);
26 | delay(1000);
27 | }
28 |
29 | void codeForTask1( void * parameter )
30 | {
31 | for(;;){
32 | long start = millis();
33 | artificialLoad();
34 | Serial.print("Finish loop Task run on Core: ");
35 | Serial.print(xPortGetCoreID());
36 | Serial.print(" Time ");
37 | Serial.println(millis() - start);
38 | // blink();
39 | }
40 | }
41 |
42 |
43 | void codeForTask2( void * parameter )
44 | {
45 | for(;;){
46 | // long start = millis();
47 | // artificialLoad();
48 | // Serial.print(" Finish loop Task run on Core: ");
49 | // Serial.print(xPortGetCoreID());
50 | // Serial.print(" Time ");
51 | // Serial.println(millis() - start);
52 | delay(1000);
53 | }
54 | }
55 | void setup() {
56 | Serial.begin(115200);
57 | pinMode(LED1,OUTPUT);
58 | baton = xSemaphoreCreateMutex();
59 |
60 | xTaskCreatePinnedToCore(
61 | codeForTask1,
62 | "Task_1",
63 | 1000,
64 | NULL,
65 | 1,
66 | &Task1,
67 | 0);
68 |
69 | delay(500);
70 |
71 | xTaskCreatePinnedToCore(
72 | codeForTask2,
73 | "Task_2",
74 | 1000,
75 | NULL,
76 | 1,
77 | &Task2,
78 | 1);
79 | }
80 |
81 | void loop() {
82 | long start = millis();
83 | artificialLoad();
84 | Serial.print(" Finish loop Task run on Core: ");
85 | Serial.print(xPortGetCoreID());
86 | Serial.print(" Time ");
87 | Serial.println(millis() - start);
88 | delay(10);
89 | // delay(5000);
90 | }
91 |
--------------------------------------------------------------------------------
/src/BMP180.h:
--------------------------------------------------------------------------------
1 | #ifndef BMP180_H
2 | #define BMP180_H
3 |
4 | #include "Arduino.h"
5 | #include "Wire.h"
6 |
7 | #define BMP085_DEBUG 0
8 |
9 | #define BMP085_I2CADDR 0x77
10 |
11 | #define BMP085_ULTRALOWPOWER 0
12 | #define BMP085_STANDARD 1
13 | #define BMP085_HIGHRES 2
14 | #define BMP085_ULTRAHIGHRES 3
15 | #define BMP085_CAL_AC1 0xAA // R Calibration data (16 bits)
16 | #define BMP085_CAL_AC2 0xAC // R Calibration data (16 bits)
17 | #define BMP085_CAL_AC3 0xAE // R Calibration data (16 bits)
18 | #define BMP085_CAL_AC4 0xB0 // R Calibration data (16 bits)
19 | #define BMP085_CAL_AC5 0xB2 // R Calibration data (16 bits)
20 | #define BMP085_CAL_AC6 0xB4 // R Calibration data (16 bits)
21 | #define BMP085_CAL_B1 0xB6 // R Calibration data (16 bits)
22 | #define BMP085_CAL_B2 0xB8 // R Calibration data (16 bits)
23 | #define BMP085_CAL_MB 0xBA // R Calibration data (16 bits)
24 | #define BMP085_CAL_MC 0xBC // R Calibration data (16 bits)
25 | #define BMP085_CAL_MD 0xBE // R Calibration data (16 bits)
26 |
27 | #define BMP085_CONTROL 0xF4
28 | #define BMP085_TEMPDATA 0xF6
29 | #define BMP085_PRESSUREDATA 0xF6
30 | #define BMP085_READTEMPCMD 0x2E
31 | #define BMP085_READPRESSURECMD 0x34
32 |
33 |
34 | class BMP085 {
35 | public:
36 | BMP085();
37 | boolean begin(uint8_t mode = BMP085_ULTRAHIGHRES); // by default go highres
38 | float readTemperature(void);
39 | int32_t readPressure(void);
40 | int32_t readSealevelPressure(float altitude_meters = 0);
41 | float readAltitude(float sealevelPressure = 101325); // std atmosphere
42 | uint16_t readRawTemperature(void);
43 | uint32_t readRawPressure(void);
44 |
45 | private:
46 | int32_t computeB5(int32_t UT);
47 | uint8_t read8(uint8_t addr);
48 | uint16_t read16(uint8_t addr);
49 | void write8(uint8_t addr, uint8_t data);
50 |
51 | uint8_t oversampling;
52 |
53 | int16_t ac1, ac2, ac3, b1, b2, mb, mc, md;
54 | uint16_t ac4, ac5, ac6;
55 | };
56 |
57 |
58 | #endif // _BMP085_H
59 |
--------------------------------------------------------------------------------
/src/BH1750.h:
--------------------------------------------------------------------------------
1 | #ifndef __BH1750_H__
2 | #define __BH1750_H__
3 |
4 |
5 | #include
6 | #include "Wire.h"
7 |
8 |
9 | #define BH1750_SDA (1)
10 | #define BH1750_SCL (2)
11 | #define BH1750_RST (6)
12 | #define BH1750_AVERAGE_NUM (5)
13 |
14 | // Uncomment, to enable debug messages
15 | // #define BH1750_DEBUG
16 |
17 | // No active state
18 | #define BH1750_POWER_DOWN 0x00
19 |
20 | // Waiting for measurement command
21 | #define BH1750_POWER_ON 0x01
22 |
23 | // Reset data register value - not accepted in POWER_DOWN mode
24 | #define BH1750_RESET 0x07
25 |
26 | // Default MTreg value
27 | #define BH1750_DEFAULT_MTREG 69
28 |
29 | class BH1750 {
30 |
31 | public:
32 |
33 | enum Mode
34 | {
35 | UNCONFIGURED = 0,
36 | // Measurement at 1 lux resolution. Measurement time is approx 120ms.
37 | CONTINUOUS_HIGH_RES_MODE = 0x10,
38 | // Measurement at 0.5 lux resolution. Measurement time is approx 120ms.
39 | CONTINUOUS_HIGH_RES_MODE_2 = 0x11,
40 | // Measurement at 4 lux resolution. Measurement time is approx 16ms.
41 | CONTINUOUS_LOW_RES_MODE = 0x13,
42 | // Measurement at 1 lux resolution. Measurement time is approx 120ms.
43 | ONE_TIME_HIGH_RES_MODE = 0x20,
44 | // Measurement at 0.5 lux resolution. Measurement time is approx 120ms.
45 | ONE_TIME_HIGH_RES_MODE_2 = 0x21,
46 | // Measurement at 4 lux resolution. Measurement time is approx 16ms.
47 | ONE_TIME_LOW_RES_MODE = 0x23
48 | };
49 |
50 | BH1750(byte addr = 0x23);
51 | bool begin(int sda=BH1750_SDA, int scl=BH1750_SCL,int rst=BH1750_RST,Mode mode = CONTINUOUS_HIGH_RES_MODE);
52 | void end();
53 | bool configure(Mode mode);
54 | bool setMTreg(byte MTreg);
55 | float readLightLevel(bool maxWait = false);
56 |
57 | private:
58 | int _rst;
59 | byte BH1750_I2CADDR;
60 | byte BH1750_MTreg = (byte)BH1750_DEFAULT_MTREG;
61 | // Correction factor used to calculate lux. Typical value is 1.2 but can
62 | // range from 0.96 to 1.44. See the data sheet (p.2, Measurement Accuracy)
63 | // for more information.
64 | const float BH1750_CONV_FACTOR = 1.2;
65 | Mode BH1750_MODE = UNCONFIGURED;
66 | };
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/src/heltec.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ifndef _HELTEC_H_
4 | #define _HELTEC_H_
5 |
6 | #if defined(ESP32)
7 |
8 | #include
9 |
10 | /* Define board classes */
11 | #if defined( WIFI_Kit_32 ) || defined( WIFI_Kit_32_V3 )
12 | #define Class_Wifi_Kit
13 | #endif
14 |
15 | #if defined( WIFI_LORA_32 ) || defined( WIFI_LORA_32_V2 ) || defined( WIFI_LORA_32_V3 )|| defined( WIFI_LORA_32_V4 )
16 | #define Class_WIFI_LORA
17 | #endif
18 |
19 | #if defined( WIRELESS_STICK ) || defined( WIRELESS_STICK_LITE ) || defined( WIRELESS_STICK_V3 ) || defined( WIRELESS_STICK_LITE_V3 )
20 | #define Class_WIRELESS_STICK
21 | #endif
22 |
23 |
24 | /* Define board capabilities */
25 | #if defined( Class_Wifi_Kit ) || defined( Class_WIFI_LORA ) || defined( Class_WIRELESS_STICK ) || defined( WIRELESS_BRIDGE )
26 | #define Heltec_Wifi
27 | #endif
28 |
29 | #if defined( Class_WIFI_LORA ) || defined( Class_WIRELESS_STICK ) || defined( WIRELESS_BRIDGE )
30 | #define Heltec_LoRa
31 | #endif
32 |
33 | #if defined( Class_Wifi_Kit ) || defined( Class_WIFI_LORA ) || defined( WIRELESS_STICK )
34 | #define Heltec_Screen
35 | #endif
36 |
37 | /* wifi kit 32 and WiFi LoRa 32(V1) do not have vext */
38 | #if defined( WIFI_Kit_32_V3 ) || defined( WIFI_LORA_32_V2 ) || defined( WIFI_LORA_32_V3 )|| defined( WIFI_LORA_32_V4 ) || defined( Class_WIRELESS_STICK ) || defined( WIRELESS_BRIDGE )
39 | #define Heltec_Vext
40 | #endif
41 |
42 |
43 | #ifdef Heltec_Screen
44 | #include
45 | #include "HT_SSD1306Wire.h"
46 | #endif
47 |
48 | #ifdef Heltec_LoRa
49 | #include
50 | #include "lora/LoRa.h"
51 | #endif
52 |
53 |
54 | class Heltec_ESP32 {
55 |
56 | public:
57 | Heltec_ESP32();
58 | ~Heltec_ESP32();
59 |
60 | void begin(bool DisplayEnable=true, bool LoRaEnable=true, bool SerialEnable=true, bool PABOOST=true, long BAND=470E6);
61 | #ifdef Heltec_LoRa
62 | LoRaClass LoRa;
63 | #endif
64 |
65 | #ifdef Heltec_Screen
66 | SSD1306Wire *display;
67 | #endif
68 |
69 | /*wifi kit 32 and WiFi LoRa 32(V1) do not have vext*/
70 | #ifdef Heltec_Vext
71 | void VextON(void);
72 | void VextOFF(void);
73 | #endif
74 | };
75 |
76 | extern Heltec_ESP32 Heltec;
77 |
78 | #else
79 | #error "This library only supports boards with ESP32 processor."
80 | #endif
81 |
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/examples/Sensor/Sensor_OLED/Sensor_OLED.ino:
--------------------------------------------------------------------------------
1 | // Example of Dual I2C Interface Configuration
2 | // When using LoRa32 boards with built-in OLED displays (typically occupying I2C-0), connecting additional I2C sensors requires secondary interface initialization.
3 | #include // I2C communication
4 | #include // BMP280 sensor
5 | #include "HT_SSD1306Wire.h" // OLED display
6 |
7 | // I2C instance for BMP280
8 | TwoWire Wire2(1);
9 |
10 | // Sensor and display objects
11 | BMP280 bmp(&Wire2);
12 | static SSD1306Wire display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED);
13 |
14 | void setup() {
15 | Serial.begin(115200); // Start serial for debugging
16 | delay(500); // Stabilization delay
17 |
18 | Wire2.begin(42,41); // Initialize I2C on pins 42(SDA),41(SCL)
19 |
20 | if(!bmp.begin()) { // Initialize BMP280
21 | Serial.println("Sensor not found!");
22 | while(1); // Halt if failed
23 | }
24 |
25 | delay(500);
26 |
27 | // Configure BMP280 settings
28 | bmp.setSampling(
29 | BMP280::MODE_NORMAL, // Continuous measurement
30 | BMP280::SAMPLING_X2, // Temp oversampling x2
31 | BMP280::SAMPLING_X16, // Pressure oversampling x16
32 | BMP280::FILTER_X16, // Filter coefficient x16
33 | BMP280::STANDBY_MS_500 // 500ms standby
34 | );
35 |
36 | // OLED setup
37 | display.init();
38 | display.clear();
39 | display.display();
40 | display.setContrast(255);
41 | display.setFont(ArialMT_Plain_10);
42 | display.setTextAlignment(TEXT_ALIGN_LEFT);
43 | display.drawString(0, 0, "BMP280 Sensor Test");
44 | display.display();
45 | }
46 |
47 | void loop() {
48 | // Read sensor data
49 | float temp = bmp.readTemperature(); // Celsius
50 | float pressure = (float)bmp.readPressure() / 100.0; // hPa
51 |
52 | // Serial output
53 | Serial.print("Temperature: ");
54 | Serial.print(temp);
55 | Serial.print(" C, Pressure: ");
56 | Serial.print(pressure);
57 | Serial.println(" hPa");
58 |
59 | // OLED output
60 | display.clear();
61 | display.drawString(0, 20, "Temperature: " + String(temp) + " C");
62 | display.drawString(0, 40, "Pressure: " + String(pressure) + " hPa");
63 | display.display();
64 |
65 | delay(3000); // Update every 3 seconds
66 | }
--------------------------------------------------------------------------------
/keywords.txt:
--------------------------------------------------------------------------------
1 | #######################################
2 | # Syntax Coloring Map For Heltec_ESP32
3 | #######################################
4 |
5 | #######################################
6 | # Library (KEYWORD3)
7 | #######################################
8 |
9 | Heltec KEYWORD3
10 |
11 | #######################################
12 | # Datatypes (KEYWORD1)
13 | #######################################
14 |
15 | LoRa KEYWORD1
16 | display KEYWORD1
17 |
18 | #######################################
19 | # Methods and Functions (KEYWORD2)
20 | #######################################
21 |
22 | begin KEYWORD2
23 | end KEYWORD2
24 | write KEYWORD2
25 | sleep KEYWORD2
26 |
27 | beginPacket KEYWORD2
28 | endPacket KEYWORD2
29 | parsePacket KEYWORD2
30 | packetRssi KEYWORD2
31 | packetSnr KEYWORD2
32 | available KEYWORD2
33 | peek KEYWORD2
34 | flush KEYWORD2
35 | onReceive KEYWORD2
36 | receive KEYWORD2
37 | read KEYWORD2
38 | idle KEYWORD2
39 | setTxPower KEYWORD2
40 | setTxPowerMax KEYWORD2
41 | setFrequency KEYWORD2
42 | setSpreadingFactor KEYWORD2
43 | setSignalBandwidth KEYWORD2
44 | setCodingRate4 KEYWORD2
45 | setPreambleLength KEYWORD2
46 | setSyncWord KEYWORD2
47 | enableCrc KEYWORD2
48 | disableCrc KEYWORD2
49 | crc KEYWORD2
50 | noCrc KEYWORD2
51 | random KEYWORD2
52 | setpins KEYWORD2
53 | setSPIFrequency KEYWORD2
54 | dumpRegisters KEYWORD2
55 | enableLowDataRate KEYWORD2
56 | disableLowDataRate KEYWORD2
57 |
58 | drawString KEYWORD2
59 | display KEYWORD2
60 | wakeup KEYWORD2
61 | resetDisplay KEYWORD2
62 | setColor KEYWORD2
63 | getColor KEYWORD2
64 | setPixel KEYWORD2
65 | drawLine KEYWORD2
66 | drawRect KEYWORD2
67 | fillRect KEYWORD2
68 | drawCircle KEYWORD2
69 | drawCircleQuads KEYWORD2
70 | fillCircle KEYWORD2
71 | drawHorizontalLine KEYWORD2
72 | drawVerticalLine KEYWORD2
73 | drawProgressBar KEYWORD2
74 | drawFastImage KEYWORD2
75 | drawXbm KEYWORD2
76 | drawStringMaxWidth KEYWORD2
77 | getStringWidth KEYWORD2
78 | getStringWidth KEYWORD2
79 | setTextAlignment KEYWORD2
80 | setFont KEYWORD2
81 | setFontTableLookupFunction KEYWORD2
82 | displayOn KEYWORD2
83 | displayOff KEYWORD2
84 | invertDisplay KEYWORD2
85 | normalDisplay KEYWORD2
86 | setContrast KEYWORD2
87 | setBrightness KEYWORD2
88 | resetOrientation KEYWORD2
89 | flipScreenVertically KEYWORD2
90 | mirrorScreen KEYWORD2
91 | clear KEYWORD2
92 | setLogBuffer KEYWORD2
93 | drawLogBuffer KEYWORD2
94 | getWidth KEYWORD2
95 | getHeight KEYWORD2
96 |
97 |
--------------------------------------------------------------------------------
/examples/OLED/UiDemo/images.h:
--------------------------------------------------------------------------------
1 | #define WiFi_Logo_width 60
2 | #define WiFi_Logo_height 36
3 | const uint8_t WiFi_Logo_bits[] PROGMEM = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 | };
29 |
30 | const uint8_t activeSymbol[] PROGMEM = {
31 | 0B00000000,
32 | 0B00000000,
33 | 0B00011000,
34 | 0B00100100,
35 | 0B01000010,
36 | 0B01000010,
37 | 0B00100100,
38 | 0B00011000
39 | };
40 |
41 | const uint8_t inactiveSymbol[] PROGMEM = {
42 | 0B00000000,
43 | 0B00000000,
44 | 0B00000000,
45 | 0B00000000,
46 | 0B00011000,
47 | 0B00011000,
48 | 0B00000000,
49 | 0B00000000
50 | };
--------------------------------------------------------------------------------
/examples/Factory_Test/Wireless_Paper_V1.1_FactoryTest/images.h:
--------------------------------------------------------------------------------
1 | #ifndef IMAGES_H
2 | #define IMAGES_H
3 |
4 | #define logo_width 60
5 | #define logo_height 36
6 | const uint8_t logo_bits[] = {
7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
9 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
10 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
11 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
12 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
13 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
14 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
15 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
16 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
17 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
18 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
19 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
20 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
21 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
22 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
23 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
24 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
25 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
26 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
27 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
28 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
29 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 | };
32 |
33 | const char activeSymbol[] PROGMEM = {
34 | B00000000,
35 | B00000000,
36 | B00011000,
37 | B00100100,
38 | B01000010,
39 | B01000010,
40 | B00100100,
41 | B00011000
42 | };
43 |
44 | const char inactiveSymbol[] PROGMEM = {
45 | B00000000,
46 | B00000000,
47 | B00000000,
48 | B00000000,
49 | B00011000,
50 | B00011000,
51 | B00000000,
52 | B00000000
53 | };
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/examples/TFT/ST7735_SPI/ST7735_SPI.ino:
--------------------------------------------------------------------------------
1 | #include "HT_st7735.h"
2 | #include "Arduino.h"
3 | HT_st7735 st7735;
4 | void setup()
5 | {
6 | Serial.begin(115200);
7 | st7735.st7735_init();
8 | Serial.printf("Ready!\r\n");
9 | }
10 |
11 | void loop() {
12 | // Check border
13 | st7735.st7735_fill_screen(ST7735_BLACK);
14 |
15 | for(int x = 0; x < ST7735_WIDTH; x++) {
16 | st7735.st7735_draw_pixel(x, 0, ST7735_RED);
17 | st7735.st7735_draw_pixel(x, ST7735_HEIGHT-1, ST7735_RED);
18 | }
19 |
20 | for(int y = 0; y < ST7735_HEIGHT; y++) {
21 | st7735.st7735_draw_pixel(0, y, ST7735_RED);
22 | st7735.st7735_draw_pixel(ST7735_WIDTH-1, y, ST7735_RED);
23 | }
24 |
25 | delay(3000);
26 |
27 | // Check fonts
28 | st7735.st7735_fill_screen(ST7735_BLACK);
29 | st7735.st7735_write_str(0, 0, "Font_7x10, red on black, lorem ipsum dolor sit amet", Font_7x10, ST7735_RED, ST7735_BLACK);
30 | st7735.st7735_write_str(0, 3*10, "Font_11x18, green, lorem ipsum", Font_11x18, ST7735_GREEN, ST7735_BLACK);
31 | st7735.st7735_write_str(0, 3*10+3*18, "Font_16x26", Font_16x26, ST7735_BLUE, ST7735_BLACK);
32 | delay(2000);
33 |
34 | // Check colors
35 | st7735.st7735_fill_screen(ST7735_BLACK);
36 | st7735.st7735_write_str(0, 0, "BLACK", Font_11x18, ST7735_WHITE, ST7735_BLACK);
37 | delay(500);
38 |
39 | st7735.st7735_fill_screen(ST7735_BLUE);
40 | st7735.st7735_write_str(0, 0, "BLUE", Font_11x18, ST7735_BLACK, ST7735_BLUE);
41 | delay(500);
42 |
43 | st7735.st7735_fill_screen(ST7735_RED);
44 | st7735.st7735_write_str(0, 0, "RED", Font_11x18, ST7735_BLACK, ST7735_RED);
45 | delay(500);
46 |
47 | st7735.st7735_fill_screen(ST7735_GREEN);
48 | st7735.st7735_write_str(0, 0, "GREEN", Font_11x18, ST7735_BLACK, ST7735_GREEN);
49 | delay(500);
50 |
51 | st7735.st7735_fill_screen(ST7735_CYAN);
52 | st7735.st7735_write_str(0, 0, "CYAN", Font_11x18, ST7735_BLACK, ST7735_CYAN);
53 | delay(500);
54 |
55 | st7735.st7735_fill_screen(ST7735_MAGENTA);
56 | st7735.st7735_write_str(0, 0, "MAGENTA", Font_11x18, ST7735_BLACK, ST7735_MAGENTA);
57 | delay(500);
58 |
59 | st7735.st7735_fill_screen(ST7735_YELLOW);
60 | st7735.st7735_write_str(0, 0, "YELLOW", Font_11x18, ST7735_BLACK, ST7735_YELLOW);
61 | delay(500);
62 |
63 | st7735.st7735_fill_screen(ST7735_WHITE);
64 | st7735.st7735_write_str(0, 0, "WHITE", Font_11x18, ST7735_BLACK, ST7735_WHITE);
65 | delay(500);
66 | }
--------------------------------------------------------------------------------
/examples/VME290/GHXTC_Sensor_Display/images.h:
--------------------------------------------------------------------------------
1 | #define WiFi_Logo_width 60
2 | #define WiFi_Logo_height 36
3 | const uint8_t WiFi_Logo_bits[] PROGMEM = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 | };
29 | // w 10 h 17
30 | const uint8_t hum[] = {
31 | 0x20, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xFC, 0x01, 0xFC, 0x01,
32 | 0xFE, 0x03, 0xFE, 0x03, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
33 | 0xFF, 0x07, 0xFF, 0x07, 0xFE, 0x03, 0xFC, 0x01, };
34 | // w 11 h 16
35 | const uint8_t temp[] = {
36 | 0x78, 0x00, 0xFC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00,
37 | 0xCC, 0x00, 0xFC, 0x00, 0xFE, 0x01, 0xB7, 0x03, 0x33, 0x03, 0x7B, 0x03,
38 | 0x7B, 0x03, 0x03, 0x03, 0x87, 0x03, 0xFE, 0x01, 0xFC, 0x00,};
39 |
--------------------------------------------------------------------------------
/examples/eink/e213_E0213A367_fase_mode/e213_E0213A367_fase_mode.ino:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | EInkDisplay_VisionMasterE213V1_1 display;
4 | // "Loading icon" images
5 | // --------------------
6 | #include "hourglass_1.h"
7 | #include "hourglass_2.h"
8 | #include "hourglass_3.h"
9 | const unsigned char* hourglasses[] = {hourglass_1_bits, hourglass_2_bits, hourglass_3_bits};
10 |
11 |
12 | // Pre-calculate position for "loading icon"
13 |
14 | int ICON_L = display.centerX() - (hourglass_1_width / 2);
15 | int ICON_T = display.centerY() - (hourglass_1_height / 2) - 15; // Slightly towards screen top
16 |
17 |
18 | void setup() {
19 | // Make sure we're starting with a blank screen
20 | display.clear();
21 |
22 | // Bigger characters
23 | display.setTextSize(2);
24 |
25 | // Enable fastmode
26 | display.fastmodeOn();
27 |
28 | // Label text, screen bottom
29 | // -----------------------------------------
30 | DRAW (display) {
31 | display.setCursor(0, display.bottom() - 30);
32 | display.println("Fastmode:");
33 | display.println("On");
34 | }
35 |
36 | // Play loading animation, and countdown in corner
37 | // ------------------------------------------------
38 | display.setTextColor(WHITE);
39 | display.setWindow( display.left(), display.top(), display.width(), display.height() - 35 ); // Don't overwrite the bottom 35px
40 |
41 | for (int demo = 0; demo <= 5; demo++) { // Count up to 5
42 |
43 | DRAW (display) {
44 | // Draw the next "loading icon" in sequence, from hourglasses[]
45 | display.drawXBitmap(ICON_L, ICON_T, hourglasses[demo % 3], hourglass_1_width, hourglass_1_height, BLACK);
46 |
47 | // Draw a square in the corner with a digit
48 | display.fillRect(0, 0, 30, 30, BLACK);
49 | display.setCursor(10, 10);
50 | display.print(demo);
51 | }
52 |
53 | }
54 |
55 | // Pause here
56 | delay(4000);
57 |
58 | // Back to normal mode (full refresh)
59 | display.fastmodeOff();
60 |
61 | // Change the label text
62 | // ----------------------
63 | display.setTextColor(BLACK);
64 | display.setWindow ( display.left(), display.bottom() - 35, display.width(), 35 ); // Only write to the bottom 35px
65 |
66 | DRAW (display) {
67 | display.setCursor(0, display.bottom() - 30);
68 | display.println("Fastmode:");
69 | display.println("Off");
70 | }
71 |
72 | }
73 |
74 | void loop() {
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/src/driver/lorawan_spi.h:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file spi-board.h
3 | *
4 | * \brief SPI driver implementation
5 | *
6 | * \copyright Revised BSD License, see section \ref LICENSE.
7 | *
8 | * \code
9 | * ______ _
10 | * / _____) _ | |
11 | * ( (____ _____ ____ _| |_ _____ ____| |__
12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
13 | * _____) ) ____| | | || |_| ____( (___| | | |
14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15 | * (C)2013-2017 Semtech
16 | *
17 | * \endcode
18 | *
19 | * \author Miguel Luis ( Semtech )
20 | *
21 | * \author Gregory Cristian ( Semtech )
22 | */
23 | #ifndef __Lorawan_SPI_H__
24 | #define __Lorawan_SPI_H__
25 |
26 | #include "../driver/gpio.h"
27 |
28 | /*!
29 | * SPI peripheral ID
30 | */
31 | typedef enum
32 | {
33 | SPI_1,
34 | SPI_2,
35 | }SpiId_t;
36 |
37 | /*!
38 | * SPI object type definition
39 | */
40 | typedef struct Spi_s
41 | {
42 | SpiId_t SpiId;
43 | Gpio_t Mosi;
44 | Gpio_t Miso;
45 | Gpio_t Sclk;
46 | Gpio_t Nss;
47 | }Spi_t;
48 |
49 | /*!
50 | * \brief Initializes the SPI object and MCU peripheral
51 | *
52 | * \remark When NSS pin is software controlled set the pin name to NC otherwise
53 | * set the pin name to be used.
54 | *
55 | * \param [IN] obj SPI object
56 | * \param [IN] mosi SPI MOSI pin name to be used
57 | * \param [IN] miso SPI MISO pin name to be used
58 | * \param [IN] sclk SPI SCLK pin name to be used
59 | * \param [IN] nss SPI NSS pin name to be used
60 | */
61 | void SpiInit( Spi_t *obj, SpiId_t spiId, uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t nss );
62 |
63 | /*!
64 | * \brief De-initializes the SPI object and MCU peripheral
65 | *
66 | * \param [IN] obj SPI object
67 | */
68 | void SpiDeInit( Spi_t *obj );
69 |
70 | /*!
71 | * \brief Configures the SPI peripheral
72 | *
73 | * \remark Slave mode isn't currently handled
74 | *
75 | * \param [IN] obj SPI object
76 | * \param [IN] bits Number of bits to be used. [8 or 16]
77 | * \param [IN] cpol Clock polarity
78 | * \param [IN] cpha Clock phase
79 | * \param [IN] slave When set the peripheral acts in slave mode
80 | */
81 | void SpiFormat( Spi_t *obj, int8_t bits, int8_t cpol, int8_t cpha, int8_t slave );
82 |
83 | /*!
84 | * \brief Sets the SPI speed
85 | *
86 | * \param [IN] obj SPI object
87 | * \param [IN] hz SPI clock frequency in hz
88 | */
89 | void SpiFrequency( Spi_t *obj, uint32_t hz );
90 |
91 |
92 | #endif // __SPI_H__
93 |
--------------------------------------------------------------------------------
/src/ESP32_Mcu.h:
--------------------------------------------------------------------------------
1 |
2 | #if defined(HT_DE01)||defined(WIFI_Kit_32)||defined(WIFI_Kit_32_V3)
3 | #else
4 |
5 | #ifndef McuSet_H
6 | #define McuSet_H
7 |
8 | #include
9 | #include "SPI.h"
10 | #include "driver/rtc-board.h"
11 | #include "driver/board-config.h"
12 | #include "driver/lorawan_spi.h"
13 | #include "driver/sx126x.h"
14 |
15 | /* HELTEC_BOARD
16 | *
17 | * ESP32S3 CHIP
18 | * WIFI_LORA_32_V3 30
19 | * WIRELESS_STICK_V3 31
20 | * WIRELESS_STICK_LITE_V3 32
21 | * WIRELESS_SHELL_V3 33
22 | * WIRELESS_TRACKER 34
23 | * WIFI_KIT_32_V3 35
24 | * Vision_Master_E_213 36
25 | * Vision_Master_E290 37
26 | * Vision_Master_T190 38
27 | *
28 | * If value come to 49, next one should be 61
29 | * CAPSULE_SENSOR_V3 50
30 | * WIRELESS_PAPER 60
31 | *
32 | *
33 | * ESP32C3 CHIP
34 | * WIRELESS_MINI_SHELL 70
35 | *
36 | *
37 | * ESP32D0 CHIP
38 | *
39 | * WIFI_LORA_32_V2 0
40 | * WIFI_LORA_32 1
41 | * WIRELESS_STICK 2
42 | * WIRELESS_STICK_LITE //WIRELESS_SHELL 3
43 | * WIRELESS_BRIDGE 4
44 | * WIFI_KIT_32 5
45 | */
46 |
47 |
48 |
49 | #define LORA_DEFAULT_NSS_PIN 18
50 | #define LORA_DEFAULT_RESET_PIN 14
51 | #define LORA_DEFAULT_DIO0_PIN 26
52 | #define LORA_DEFAULT_DIO1_PIN 33
53 | #define Timer_DEFAULT_DIV 80
54 | extern uint8_t mcuStarted;
55 | class McuClass{
56 | public:
57 | McuClass();
58 | void setlicense(uint32_t * license,uint8_t board_type);
59 | int begin(uint8_t board_type,uint8_t ex_32k);
60 | void addwakeio(uint8_t gpio);
61 | void setSPIFrequency(uint32_t frequency);
62 | void timerhandler();
63 | void sleep(uint8_t classMode,uint8_t debugLevel,uint8_t board_type,uint8_t ex_32k);
64 | SPISettings _spiSettings;
65 | private:
66 |
67 | };
68 | extern TimerEvent_t TxNextPacketTimer;
69 |
70 | #ifdef __cplusplus
71 | extern "C" uint8_t SpiInOut(Spi_t *obj, uint8_t outData );
72 | extern "C" uint64_t timercheck();
73 | extern "C" uint64_t getID();
74 | extern "C" void SX126xIoInit( void );
75 | extern "C" void SX126xIoIrqInit( DioIrqHandler dioIrq );
76 | extern "C" void RadioOnDioIrq( void );
77 | extern "C" void SX126xIoInit( void );
78 | extern "C" void SX126xReset( void );
79 | extern "C" void sx126xSleep( void );
80 | extern "C" void calrtc();
81 | extern "C" void lora_printf(const char *format, ...);
82 | #ifdef RADIO_CHIP_SX127X
83 | extern "C" void SX1276IoInit( void );
84 | extern "C" void SX1276IoIrqInit( DioIrqHandler **irqHandlers );
85 | extern DioIrqHandler *DioIrq[];
86 | #endif
87 |
88 | #endif
89 |
90 | extern McuClass Mcu;
91 | #endif
92 | #endif
--------------------------------------------------------------------------------
/examples/VME213/weather_station/readme.md:
--------------------------------------------------------------------------------
1 | # WEATHER STATION
2 |
3 | This example demonstrates how to obtain weather, time, etc. from the internet and display them on an ink screen.
4 |
5 | # Supported Targets
6 |
7 | At present, this example only supports Vison Master Eink213, which uses the ESP32-S3 chip.
8 |
9 | ## How to Use Example
10 |
11 | Flash this example and observe the screen display.
12 |
13 | ### Configure the Project
14 |
15 | Change `SSID` and `password` to connect to your WiFi.
16 | Default values will allow you to use this example without any changes. If you want to use your own Weather server and you don't have one already follow these steps:
17 |
18 | * Create an account on [Weather server](https://www.seniverse.com/).
19 | * After logging in, click on the "immediate use" button to create a new product for your data. You can create a free or paid product, then obtain its private key and fill it in the 'privateKey' field.
20 | * This example uses a free API to obtain weather parameters for 3 days. The weather parameters for one week should have an interface. The author's city of residence does not have special weather conditions, and currently only supports three common weather conditions: sunny, rainy, and cloudy. Other weather interfaces are reserved.
21 | * This instance obtains the time from the [time server](ntp.aliyun.com), and you can modify 'ntpServe' to use a server that is convenient for you to use
22 |
23 | #### Config example:
24 |
25 | You can find the data to be changed at the top of the file:
26 |
27 | ```cpp
28 | const char *ntpServer = "ntp.aliyun.com";// time server
29 | const long gmtOffset_sec = 28800; // time offset,UTC/GMT +8
30 | const int daylightOffset_sec = 0;// Timing started in 1990
31 | const char *ssid = "Your Wi-Fi SSID";
32 | const char *password = "Your Wi-Fi password";
33 |
34 | const char *host = "api.seniverse.com";//Weather server
35 | const char *privateKey = "Sfv1t8EYrow1Zi-5o";//Product privateKey
36 | const char *city = "chengdu";//The city to be queried
37 | const char *language = "en";//language preference
38 | //The following is the API splicing method
39 | String getUrl = "/v3/weather/daily.json?key=";
40 | getUrl += privateKey;
41 | getUrl += "&location=";
42 | getUrl += city;
43 | getUrl += "&language=";
44 | getUrl += language;
45 | client.print(String("GET ") + getUrl + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
46 |
47 | #### Using Arduino IDE
48 |
49 | To get more information about the Espressif boards see [heltec.org](https://heltec.org).
50 |
51 | * Before Compile/Verify, select the correct board: `Tools -> Board`.
52 | * Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
53 |
54 |
--------------------------------------------------------------------------------
/examples/VME290/weather_station/readme.md:
--------------------------------------------------------------------------------
1 | # WEATHER STATION
2 |
3 | This example demonstrates how to obtain weather, time, etc. from the internet and display them on an ink screen.
4 |
5 | # Supported Targets
6 |
7 | At present, this example only supports Vison Master Eink213, which uses the ESP32-S3 chip.
8 |
9 | ## How to Use Example
10 |
11 | Flash this example and observe the screen display.
12 |
13 | ### Configure the Project
14 |
15 | Change `SSID` and `password` to connect to your WiFi.
16 | Default values will allow you to use this example without any changes. If you want to use your own Weather server and you don't have one already follow these steps:
17 |
18 | * Create an account on [Weather server](https://www.seniverse.com/).
19 | * After logging in, click on the "immediate use" button to create a new product for your data. You can create a free or paid product, then obtain its private key and fill it in the 'privateKey' field.
20 | * This example uses a free API to obtain weather parameters for 3 days. The weather parameters for one week should have an interface. The author's city of residence does not have special weather conditions, and currently only supports three common weather conditions: sunny, rainy, and cloudy. Other weather interfaces are reserved.
21 | * This instance obtains the time from the [time server](ntp.aliyun.com), and you can modify 'ntpServe' to use a server that is convenient for you to use
22 |
23 | #### Config example:
24 |
25 | You can find the data to be changed at the top of the file:
26 |
27 | ```cpp
28 | const char *ntpServer = "ntp.aliyun.com";// time server
29 | const long gmtOffset_sec = 28800; // time offset,UTC/GMT +8
30 | const int daylightOffset_sec = 0;// Timing started in 1990
31 | const char *ssid = "Your Wi-Fi SSID";
32 | const char *password = "Your Wi-Fi password";
33 |
34 | const char *host = "api.seniverse.com";//Weather server
35 | const char *privateKey = "Sfv1t8EYrow1Zi-5o";//Product privateKey
36 | const char *city = "chengdu";//The city to be queried
37 | const char *language = "en";//language preference
38 | //The following is the API splicing method
39 | String getUrl = "/v3/weather/daily.json?key=";
40 | getUrl += privateKey;
41 | getUrl += "&location=";
42 | getUrl += city;
43 | getUrl += "&language=";
44 | getUrl += language;
45 | client.print(String("GET ") + getUrl + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
46 |
47 | #### Using Arduino IDE
48 |
49 | To get more information about the Espressif boards see [heltec.org](https://heltec.org).
50 |
51 | * Before Compile/Verify, select the correct board: `Tools -> Board`.
52 | * Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
53 |
54 |
--------------------------------------------------------------------------------
/src/chsc6x_platform.h:
--------------------------------------------------------------------------------
1 | #ifndef __CHSC6X_PLATFORM_H__
2 | #define __CHSC6X_PLATFORM_H__
3 | //#include "printf.h"
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #define OS_OK (0)
11 | #define OS_ERROR (1)
12 | #define TP_RETRY_CNT (2)
13 | #define TP_RETRY_CNT2 (3)
14 | #define TP_RETRY_CNT3 (5)
15 |
16 | #if 0
17 | #define chsc6x_info Serial.printf
18 | #define chsc6x_err Serial.printf
19 | #else
20 | #define chsc6x_info
21 | #define chsc6x_err
22 | #endif
23 |
24 |
25 |
26 | #define CHSC6X_I2C_ID (0x2E) //8bit
27 |
28 | #define CHSC6X_MAX_POINTS_NUM (2)
29 |
30 | /*MACRO SWITCH for TP gesture function */
31 | #define CHSC6X_GESTURE (0)
32 |
33 | /*MACRO SWITCH for Proximity function */
34 | #define CHSC6X_PROXIMITY (0)
35 |
36 | /*MACRO SWITCH for esd check function */
37 | #define CHSC6X_ESD_CHECK (0)
38 |
39 | #define MAX_IIC_WR_LEN (32)
40 | #define MAX_IIC_RD_LEN (32)
41 |
42 | typedef enum
43 | {
44 | RESET_NONE,
45 | HW_CMD_RESET,
46 | HW_ACTIVE_RESET,
47 | RESET_MAX
48 | } chsc6x_reset_e;
49 | class chsc6x_platform
50 | {
51 | private:
52 | TwoWire *_wire;
53 | int _sda_pin;
54 | int _scl_pin;
55 | int _int_pin;
56 | int _rst_pin;
57 | public:
58 | uint8_t _i2c_addr;
59 | chsc6x_platform(TwoWire *wire = &Wire1,int sda_pin=-1,int scl_pin=-1,int int_pin=-1,int rst_pin=-1) {
60 | this->_wire = wire;
61 | this->_sda_pin = sda_pin;
62 | this->_scl_pin = scl_pin;
63 | this->_int_pin = int_pin;
64 | this->_rst_pin = rst_pin;
65 | this->_i2c_addr = CHSC6X_I2C_ID;
66 | };
67 | ~chsc6x_platform(){};
68 |
69 | /* fail : <0 */
70 | int i2cRead(uint8_t i2c_adr, uint16_t reg_adr, uint8_t *rxbuf, uint16_t lenth);
71 | int i2cSend(uint8_t i2c_adr, uint16_t reg_adr, uint8_t *txbuf, uint16_t lenth);
72 |
73 | /* RETURN:0->pass else->fail */
74 | int chsc6x_read_bytes_u8addr(uint8_t id, uint8_t adr, uint8_t *rxbuf, uint16_t lenth);
75 | /* RETURN:0->pass else->fail */
76 | int chsc6x_read_bytes_u16addr(uint8_t id, uint16_t adr, uint8_t *rxbuf, uint16_t lenth);
77 |
78 | /* RETURN:0->pass else->fail */
79 | int chsc6x_write_bytes_u16addr(uint8_t id, uint16_t addr, uint8_t *txbuf, uint16_t lenth);
80 | void chsc6x_tp_reset_delay(chsc6x_reset_e type);
81 |
82 | void chsc6x_msleep(int ms);
83 | int chsc6x_tp_reset(chsc6x_reset_e type);
84 | void semi_rst_pin_low(int pin);
85 | void semi_rst_pin_high(int pin);
86 | int semi_touch_get_int(void);
87 | int semi_touch_get_rst(void);
88 | // extern struct sm_touch_dev st_dev;
89 | int semi_touch_i2c_init(void);
90 | };
91 | #endif
92 |
--------------------------------------------------------------------------------
/examples/eink/wireless_paper_E0213A367_fase_mode/wireless_paper_E0213A367_fase_mode.ino:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | EInkDisplay_WirelessPaperV1_2 display;
4 | // DEMO: Fast Mode
5 | // ------------------
6 | // Some panels have the ability to perform a "fast update",
7 | // The technical term for this feature is "partial refresh".
8 | // If your panel supports this, you can select it with fastmodeOn()
9 |
10 |
11 | // "Loading icon" images
12 | // --------------------
13 | #include "hourglass_1.h"
14 | #include "hourglass_2.h"
15 | #include "hourglass_3.h"
16 | const unsigned char* hourglasses[] = {hourglass_1_bits, hourglass_2_bits, hourglass_3_bits};
17 |
18 |
19 | // Pre-calculate position for "loading icon"
20 |
21 | int ICON_L = display.centerX() - (hourglass_1_width / 2);
22 | int ICON_T = display.centerY() - (hourglass_1_height / 2) - 15; // Slightly towards screen top
23 |
24 |
25 | void setup() {
26 | // Make sure we're starting with a blank screen
27 | display.clear();
28 |
29 | // Bigger characters
30 | display.setTextSize(2);
31 |
32 | // Enable fastmode
33 | display.fastmodeOn();
34 |
35 | // Label text, screen bottom
36 | // -----------------------------------------
37 | DRAW (display) {
38 | display.setCursor(0, display.bottom() - 30);
39 | display.println("Fastmode:");
40 | display.println("On");
41 | }
42 |
43 | // Play loading animation, and countdown in corner
44 | // ------------------------------------------------
45 | display.setTextColor(WHITE);
46 | display.setWindow( display.left(), display.top(), display.width(), display.height() - 35 ); // Don't overwrite the bottom 35px
47 |
48 | for (int demo = 0; demo <= 5; demo++) { // Count up to 5
49 |
50 | DRAW (display) {
51 | // Draw the next "loading icon" in sequence, from hourglasses[]
52 | display.drawXBitmap(ICON_L, ICON_T, hourglasses[demo % 3], hourglass_1_width, hourglass_1_height, BLACK);
53 |
54 | // Draw a square in the corner with a digit
55 | display.fillRect(0, 0, 30, 30, BLACK);
56 | display.setCursor(10, 10);
57 | display.print(demo);
58 | }
59 |
60 | }
61 |
62 | // Pause here
63 | delay(4000);
64 |
65 | // Back to normal mode (full refresh)
66 | display.fastmodeOff();
67 |
68 | // Change the label text
69 | // ----------------------
70 | display.setTextColor(BLACK);
71 | display.setWindow ( display.left(), display.bottom() - 35, display.width(), 35 ); // Only write to the bottom 35px
72 |
73 | DRAW (display) {
74 | display.setCursor(0, display.bottom() - 30);
75 | display.println("Fastmode:");
76 | display.println("Off");
77 | }
78 |
79 | }
80 |
81 | void loop() {
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/loramac/cmac.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | Copyright (C) 2009 Lander Casado, Philippas Tsigas
3 |
4 | All rights reserved.
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining
7 | a copy of this software and associated documentation files
8 | (the "Software"), to deal with the Software without restriction, including
9 | without limitation the rights to use, copy, modify, merge, publish,
10 | distribute, sublicense, and/or sell copies of the Software, and to
11 | permit persons to whom the Software is furnished to do so, subject to
12 | the following conditions:
13 |
14 | Redistributions of source code must retain the above copyright notice,
15 | this list of conditions and the following disclaimers. Redistributions in
16 | binary form must reproduce the above copyright notice, this list of
17 | conditions and the following disclaimers in the documentation and/or
18 | other materials provided with the distribution.
19 |
20 | In no event shall the authors or copyright holders be liable for any special,
21 | incidental, indirect or consequential damages of any kind, or any damages
22 | whatsoever resulting from loss of use, data or profits, whether or not
23 | advised of the possibility of damage, and on any theory of liability,
24 | arising out of or in connection with the use or performance of this software.
25 |
26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 | DEALINGS WITH THE SOFTWARE
33 |
34 | *****************************************************************************/
35 |
36 | #ifndef _CMAC_H_
37 | #define _CMAC_H_
38 |
39 | #include "aes.h"
40 |
41 | #define AES_CMAC_KEY_LENGTH 16
42 | #define AES_CMAC_DIGEST_LENGTH 16
43 |
44 | typedef struct _AES_CMAC_CTX {
45 | aes_context rijndael;
46 | uint8_t X[16];
47 | uint8_t M_last[16];
48 | uint32_t M_n;
49 | } AES_CMAC_CTX;
50 |
51 | //#include
52 |
53 | //__BEGIN_DECLS
54 | void AES_CMAC_Init(AES_CMAC_CTX * ctx);
55 | void AES_CMAC_SetKey(AES_CMAC_CTX * ctx, const uint8_t key[AES_CMAC_KEY_LENGTH]);
56 | void AES_CMAC_Update(AES_CMAC_CTX * ctx, const uint8_t * data, uint32_t len);
57 | // __attribute__((__bounded__(__string__,2,3)));
58 | void AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX * ctx);
59 | // __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH)));
60 | //__END_DECLS
61 |
62 | #endif /* _CMAC_H_ */
63 |
64 |
--------------------------------------------------------------------------------
/src/driver/gpio-board.h:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file gpio-board.h
3 | *
4 | * \brief Target board GPIO driver implementation
5 | *
6 | * \copyright Revised BSD License, see section \ref LICENSE.
7 | *
8 | * \code
9 | * ______ _
10 | * / _____) _ | |
11 | * ( (____ _____ ____ _| |_ _____ ____| |__
12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
13 | * _____) ) ____| | | || |_| ____( (___| | | |
14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15 | * (C)2013-2017 Semtech
16 | *
17 | * \endcode
18 | *
19 | * \author Miguel Luis ( Semtech )
20 | *
21 | * \author Gregory Cristian ( Semtech )
22 | */
23 |
24 |
25 |
26 | #ifndef __GPIO_BOARD_H__
27 | #define __GPIO_BOARD_H__
28 |
29 | #include "gpio.h"
30 |
31 | /*!
32 | * \brief Initializes the given GPIO object
33 | *
34 | * \param [IN] obj Pointer to the GPIO object
35 | * \param [IN] pin Pin name ( please look in pinName-board.h file )
36 | * \param [IN] mode Pin mode [PIN_INPUT, PIN_OUTPUT,
37 | * PIN_ALTERNATE_FCT, PIN_ANALOGIC]
38 | * \param [IN] config Pin config [PIN_PUSH_PULL, PIN_OPEN_DRAIN]
39 | * \param [IN] type Pin type [PIN_NO_PULL, PIN_PULL_UP, PIN_PULL_DOWN]
40 | * \param [IN] value Default output value at initialization
41 | */
42 | void GpioMcuInit( Gpio_t *obj, uint8_t pin, uint8_t mode, PinConfigs config, PinTypes type, uint32_t value );
43 |
44 | /*!
45 | * \brief GPIO IRQ Initialization
46 | *
47 | * \param [IN] obj Pointer to the GPIO object
48 | * \param [IN] irqMode IRQ mode [NO_IRQ, IRQ_RISING_EDGE,
49 | * IRQ_FALLING_EDGE, IRQ_RISING_FALLING_EDGE]
50 | * \param [IN] irqPriority IRQ priority [IRQ_VERY_LOW_PRIORITY, IRQ_LOW_PRIORITY
51 | * IRQ_MEDIUM_PRIORITY, IRQ_HIGH_PRIORITY
52 | * IRQ_VERY_HIGH_PRIORITY]
53 | * \param [IN] irqHandler Callback function pointer
54 | */
55 | void GpioMcuSetInterrupt( Gpio_t *obj, int irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler );
56 |
57 | /*!
58 | * \brief Removes the interrupt from the object
59 | *
60 | * \param [IN] obj Pointer to the GPIO object
61 | */
62 | void GpioMcuRemoveInterrupt( Gpio_t *obj );
63 |
64 | /*!
65 | * \brief Writes the given value to the GPIO output
66 | *
67 | * \param [IN] obj Pointer to the GPIO object
68 | * \param [IN] value New GPIO output value
69 | */
70 | void GpioMcuWrite( Gpio_t *obj, uint32_t value );
71 |
72 | /*!
73 | * \brief Toggle the value to the GPIO output
74 | *
75 | * \param [IN] obj Pointer to the GPIO object
76 | */
77 | void GpioMcuToggle( Gpio_t *obj );
78 |
79 | /*!
80 | * \brief Reads the current GPIO input value
81 | *
82 | * \param [IN] obj Pointer to the GPIO object
83 | * \retval value Current GPIO input value
84 | */
85 | uint32_t GpioMcuRead( Gpio_t *obj );
86 |
87 | #endif //#
88 |
--------------------------------------------------------------------------------
/examples/ESP32/ExternalWakeUp/ExternalWakeUp.ino:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * *******************HelTec AutoMation WiFi_Kit_series Example******************
4 | Deep Sleep with External Wake Up
5 | =====================================
6 | This code displays how to use deep sleep with
7 | an external trigger as a wake up source and how
8 | to store data in RTC memory to use it over reboots
9 |
10 | This code is under Public Domain License.
11 |
12 | Hardware Connections
13 | ======================
14 | Push Button(PRG) to GPIO 0 pulled down with a 10K Ohm
15 | resistor
16 |
17 | NOTE:
18 | ======
19 | Only RTC IO can be used as a source for external wake
20 | source. They are pins: 0,2,4,12-15,25-27,32-39.
21 |
22 | Author:
23 | Pranav Cherukupalli
24 | */
25 |
26 | #include "driver/rtc_io.h"
27 | #define BUTTON_PIN_BITMASK 0x200000000 // 2^33 in hex
28 |
29 | RTC_DATA_ATTR int bootCount = 0;
30 |
31 | /*
32 | Method to print the reason by which ESP32
33 | has been awaken from sleep
34 | */
35 | void print_wakeup_reason(){
36 | esp_sleep_wakeup_cause_t wakeup_reason;
37 |
38 | wakeup_reason = esp_sleep_get_wakeup_cause();
39 |
40 | switch(wakeup_reason)
41 | {
42 | case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
43 | case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
44 | case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
45 | case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
46 | case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
47 | default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
48 | }
49 | }
50 |
51 | void setup(){
52 | rtc_gpio_deinit(GPIO_NUM_0);
53 | Serial.begin(115200);
54 | delay(1000); //Take some time to open up the Serial Monitor
55 |
56 | //Increment boot number and print it every reboot
57 | ++bootCount;
58 | Serial.println("Boot number: " + String(bootCount));
59 |
60 | //Print the wakeup reason for ESP32
61 | print_wakeup_reason();
62 |
63 | /*
64 | First we configure the wake up source
65 | We set our ESP32 to wake up for an external trigger.
66 | There are two types for ESP32, ext0 and ext1 .
67 | ext0 uses RTC_IO to wakeup thus requires RTC peripherals
68 | to be on while ext1 uses RTC Controller so doesnt need
69 | peripherals to be powered on.
70 | Note that using internal pullups/pulldowns also requires
71 | RTC peripherals to be turned on.
72 | */
73 | rtc_gpio_pulldown_en(GPIO_NUM_0);
74 | esp_sleep_enable_ext0_wakeup(GPIO_NUM_0,0); //1 = High, 0 = Low
75 |
76 | //If you were to use ext1, you would use it like
77 | //esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);
78 |
79 | //Go to sleep now
80 | Serial.println("Going to sleep now");
81 | esp_deep_sleep_start();
82 | Serial.println("This will never be printed");
83 | }
84 |
85 | void loop(){
86 | //This is not going to be called
87 | }
88 |
--------------------------------------------------------------------------------
/src/heltec.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Heltec Automation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | #include "heltec.h"
5 |
6 |
7 | Heltec_ESP32::Heltec_ESP32(){
8 |
9 | #if defined( Class_Wifi_Kit ) || defined( Class_Wifi_LoRa )
10 | display = new SSD1306Wire(0x3c, SDA_OLED, SCL_OLED, RST_OLED, GEOMETRY_128_64);
11 | #elif defined( WIRELESS_STICK )
12 | display = new SSD1306Wire(0x3c, SDA_OLED, SCL_OLED, RST_OLED, GEOMETRY_64_32);
13 | #endif
14 | }
15 |
16 | Heltec_ESP32::~Heltec_ESP32(){
17 | #ifdef Heltec_Screen
18 | delete display;
19 | #endif
20 | }
21 |
22 | void Heltec_ESP32::begin(bool DisplayEnable, bool LoRaEnable, bool SerialEnable, bool PABOOST, long BAND) {
23 |
24 | #ifdef Heltec_Vext
25 | VextON();
26 | #endif
27 |
28 | // UART
29 | if (SerialEnable) {
30 | Serial.begin(115200);
31 | Serial.flush();
32 | delay(50);
33 | Serial.print("Serial initial done\r\n");
34 | }
35 |
36 | // OLED
37 | if (DisplayEnable)
38 | {
39 | #ifndef Heltec_Screen
40 | if(SerialEnable)
41 | {
42 | Serial.print("Board does not have an on board display, Display option must be FALSE!!!\r\n");
43 | }
44 | #endif
45 |
46 | #ifdef Heltec_Screen
47 | display->init();
48 | //display->flipScreenVertically();
49 | display->setFont(ArialMT_Plain_10);
50 | display->drawString(0, 0, "OLED initial done!");
51 | display->display();
52 |
53 | if (SerialEnable){
54 | Serial.print("you can see OLED printed OLED initial done!\r\n");
55 | }
56 | #endif
57 | }
58 |
59 | // LoRa INIT
60 | if (LoRaEnable)
61 | {
62 | #ifndef Heltec_LoRa
63 | if (SerialEnable) {
64 | Serial.print("Board does not have LoRa function, LoRa option must be FALSE!!!\r\n");
65 | }
66 | #endif
67 |
68 |
69 | #ifdef Heltec_LoRa
70 | //LoRaClass LoRa;
71 |
72 | SPI.begin(SCK,MISO,MOSI,SS);
73 | LoRa.setPins(SS,RST_LoRa,DIO0);
74 | if (!LoRa.begin(BAND,PABOOST))
75 | {
76 | if (SerialEnable){
77 | Serial.print("Starting LoRa failed!\r\n");
78 | }
79 | #ifdef Heltec_Screen
80 | if(DisplayEnable){
81 | display->clear();
82 | display->drawString(0, 0, "Starting LoRa failed!");
83 | display->display();
84 | delay(300);
85 | }
86 | #endif
87 | while (1);
88 | }
89 | if (SerialEnable){
90 | Serial.print("LoRa Initial success!\r\n");
91 | }
92 | #ifdef Heltec_Screen
93 | if(DisplayEnable){
94 | display->clear();
95 | display->drawString(0, 0, "LoRa Initial success!");
96 | display->display();
97 | delay(300);
98 | }
99 | #endif
100 |
101 | #endif
102 | }
103 | #ifdef LED
104 | pinMode(LED,OUTPUT);
105 | #endif
106 | }
107 |
108 | #ifdef Heltec_Vext
109 | void Heltec_ESP32::VextON(void)
110 | {
111 | pinMode(Vext,OUTPUT);
112 | digitalWrite(Vext, LOW);
113 | }
114 |
115 | void Heltec_ESP32::VextOFF(void) //Vext default OFF
116 | {
117 | pinMode(Vext,OUTPUT);
118 | digitalWrite(Vext, HIGH);
119 | }
120 | #endif
121 |
122 | Heltec_ESP32 Heltec;
123 |
--------------------------------------------------------------------------------
/examples/Sensor/BMP180basic/BMP180basic.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation BMP180 Sensors test example
2 | *
3 | * Function:
4 | * Air pressure sensor
5 | *
6 | * HelTec AutoMation, Chengdu, China
7 | * www.heltec.org
8 | *
9 | * this project also realess in GitHub:
10 | * https://github.com/HelTecAutomation/Heltec_ESP32
11 | *
12 | */
13 | #include "Arduino.h"
14 | #include "heltec.h"
15 | #include
16 | #include
17 | #include "string.h"
18 |
19 | BMP085 bmp;
20 |
21 | uint8_t T[20] = {"Temperature"};
22 |
23 | void setup() {
24 | Serial.begin(115200);
25 | }
26 | void drawFontFaceDemo(double T,double P,double A,double R) {
27 | Heltec.begin(true /*DisplayEnable Enable*/, false /*LoRa Disable*/, true /*Serial Enable*/);
28 | // Heltec.display->flipScreenVertically();
29 | Heltec.display->clear();
30 | Heltec.display->setTextAlignment(TEXT_ALIGN_LEFT);
31 | Heltec.display->setFont(ArialMT_Plain_10);
32 | Heltec.display->drawString(0 , 0 , "Temperature =");
33 | Heltec.display->drawString(76 , 0 , (String)T);
34 | Heltec.display->drawString(106 , 0 , " *C");
35 | Heltec.display->drawString(0 , 16 , "Pressure =");
36 | Heltec.display->drawString(56 , 16 , (String)P);
37 | Heltec.display->drawString(100 , 16 , "Pa");
38 | Heltec.display->drawString(0 , 32 , "Altitude =");
39 | Heltec.display->drawString(56 , 32 , (String)A);
40 | Heltec.display->drawString(86 , 32 , " m");
41 | Heltec.display->drawString(0 , 48 , "Real altitude =");
42 | Heltec.display->drawString(76 , 48 , (String)R);
43 | Heltec.display->drawString(106 , 48 , " m");
44 | Heltec.display->display();
45 | }
46 | void loop() {
47 | if (!bmp.begin()) {
48 | Serial.println("Could not find a valid BMP085 sensor, check wiring!");
49 | while (1) {}
50 | }
51 | double T =bmp.readTemperature();
52 | Serial.print("Temperature = ");
53 | Serial.print(T);
54 | Serial.println(" *C");
55 |
56 | double P = bmp.readPressure();
57 | Serial.print("Pressure = ");
58 | Serial.print(bmp.readPressure());
59 | Serial.println(" Pa");
60 |
61 | double A = bmp.readAltitude();
62 | // Calculate altitude assuming 'standard' barometric
63 | // pressure of 1013.25 millibar = 101325 Pascal
64 | Serial.print("Altitude = ");
65 | Serial.print(bmp.readAltitude());
66 | Serial.println(" meters");
67 |
68 |
69 | Serial.print("Pressure at sealevel (calculated) = ");
70 | Serial.print(bmp.readSealevelPressure());
71 | Serial.println(" Pa");
72 |
73 | double R = bmp.readAltitude(101500);
74 | // you can get a more precise measurement of altitude
75 | // if you know the current sea level pressure which will
76 | // vary with weather and such. If it is 1015 millibars
77 | // that is equal to 101500 Pascals.
78 | Serial.print("Real altitude = ");
79 | Serial.print(bmp.readAltitude(101500));
80 | Serial.println(" meters");
81 |
82 | Serial.println();
83 | delay(500);
84 | drawFontFaceDemo(T, P, A, R) ;
85 | delay(5000);
86 | }
87 |
--------------------------------------------------------------------------------
/examples/Sensor/DHT11_LoRa_sender/DHT11_LoRa_sender.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include "LoRaWan_APP.h"
3 | #include "Arduino.h"
4 |
5 | // DHT11 Configuration
6 | #define DHT_PIN 1 // GPIO1 connected to DHT11 (avoid using GPIO1)
7 | DHTesp dht;
8 |
9 | // LoRa Configuration
10 | #define RF_FREQUENCY 915000000 // Hz (adjust according to your region)
11 | #define TX_OUTPUT_POWER 14 // dBm (increase power to extend transmission range)
12 | #define LORA_BANDWIDTH 0 // 125 kHz
13 | #define LORA_SPREADING_FACTOR 7 // SF7
14 | #define LORA_CODINGRATE 1 // 4/5
15 | #define LORA_PREAMBLE_LENGTH 8 // Preamble length
16 | #define LORA_FIX_LENGTH_PAYLOAD_ON false
17 | #define LORA_IQ_INVERSION_ON false
18 |
19 | #define BUFFER_SIZE 50 // Data buffer size
20 | char txpacket[BUFFER_SIZE]; // Transmission buffer
21 | bool lora_idle = true; // LoRa idle state flag
22 |
23 | // LoRa event callbacks
24 | static RadioEvents_t RadioEvents;
25 | void OnTxDone(void);
26 | void OnTxTimeout(void);
27 |
28 | void setup() {
29 | Serial.begin(115200);
30 |
31 | // Initialize DHT11
32 | dht.setup(DHT_PIN, DHTesp::DHT11);
33 | Serial.println("DHT11 Initialized");
34 |
35 | // Initialize LoRa
36 | Mcu.begin(HELTEC_BOARD, SLOW_CLK_TPYE); // Adjust parameters according to your board
37 | RadioEvents.TxDone = OnTxDone;
38 | RadioEvents.TxTimeout = OnTxTimeout;
39 |
40 | Radio.Init(&RadioEvents);
41 | Radio.SetChannel(RF_FREQUENCY);
42 | Radio.SetTxConfig(MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
43 | LORA_SPREADING_FACTOR, LORA_CODINGRATE,
44 | LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
45 | true, 0, 0, LORA_IQ_INVERSION_ON, 3000);
46 | }
47 |
48 | void loop() {
49 | if (lora_idle) {
50 | delay(2000); // DHT11 requires at least 1-second sampling interval
51 |
52 | // Read temperature and humidity data
53 | TempAndHumidity data = dht.getTempAndHumidity();
54 | if (dht.getStatus() != DHTesp::ERROR_NONE) {
55 | Serial.println("DHT11 read failed: " + String(dht.getStatusString()));
56 | return;
57 | }
58 |
59 | // Format data as JSON string (example: {"t":25.5,"h":50.0})
60 | snprintf(txpacket, BUFFER_SIZE,
61 | "{\"t\":%.1f,\"h\":%.1f}",
62 | data.temperature,
63 | data.humidity);
64 |
65 | Serial.printf("Sending data: %s\n", txpacket);
66 |
67 | // Transmit data via LoRa
68 | Radio.Send((uint8_t *)txpacket, strlen(txpacket));
69 | lora_idle = false;
70 | }
71 | Radio.IrqProcess(); // Process LoRa events
72 | }
73 |
74 | // LoRa transmission complete callback
75 | void OnTxDone(void) {
76 | Serial.println("LoRa transmission successful");
77 | lora_idle = true;
78 | }
79 |
80 | // LoRa transmission timeout callback
81 | void OnTxTimeout(void) {
82 | Radio.Sleep();
83 | Serial.println("LoRa transmission timeout");
84 | lora_idle = true;
85 | }
--------------------------------------------------------------------------------
/src/loramac/LoRaMacTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015-2017 Alibaba Group Holding Limited
3 | */
4 |
5 | /*!
6 | * \file LoRaMacTest.h
7 | *
8 | * \brief LoRa MAC layer test function implementation
9 | *
10 | * \copyright Revised BSD License, see section \ref LICENSE.
11 | *
12 | * \code
13 | * ______ _
14 | * / _____) _ | |
15 | * ( (____ _____ ____ _| |_ _____ ____| |__
16 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
17 | * _____) ) ____| | | || |_| ____( (___| | | |
18 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
19 | * (C)2013 Semtech
20 | *
21 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___
22 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
23 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
24 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
25 | * embedded.connectivity.solutions===============
26 | *
27 | * \endcode
28 | *
29 | * \author Miguel Luis ( Semtech )
30 | *
31 | * \author Gregory Cristian ( Semtech )
32 | *
33 | * \author Daniel Jaeckle ( STACKFORCE )
34 | *
35 | * \defgroup LORAMACTEST LoRa MAC layer test function implementation
36 | * This module specifies the API implementation of test function of the LoRaMAC layer.
37 | * The functions in this file are only for testing purposes only.
38 | * \{
39 | */
40 | #ifndef __LORAMACTEST_H__
41 | #define __LORAMACTEST_H__
42 |
43 | /*!
44 | * \brief Enabled or disables the reception windows
45 | *
46 | * \details This is a test function. It shall be used for testing purposes only.
47 | * Changing this attribute may lead to a non-conformance LoRaMac operation.
48 | *
49 | * \param [IN] enable - Enabled or disables the reception windows
50 | */
51 | void LoRaMacTestRxWindowsOn( bool enable );
52 |
53 | /*!
54 | * \brief Enables the MIC field test
55 | *
56 | * \details This is a test function. It shall be used for testing purposes only.
57 | * Changing this attribute may lead to a non-conformance LoRaMac operation.
58 | *
59 | * \param [IN] txPacketCounter - Fixed Tx packet counter value
60 | */
61 | void LoRaMacTestSetMic( uint16_t txPacketCounter );
62 |
63 | /*!
64 | * \brief Enabled or disables the duty cycle
65 | *
66 | * \details This is a test function. It shall be used for testing purposes only.
67 | * Changing this attribute may lead to a non-conformance LoRaMac operation.
68 | *
69 | * \param [IN] enable - Enabled or disables the duty cycle
70 | */
71 | void LoRaMacTestSetDutyCycleOn( bool enable );
72 |
73 | /*!
74 | * \brief Sets the channel index
75 | *
76 | * \details This is a test function. It shall be used for testing purposes only.
77 | * Changing this attribute may lead to a non-conformance LoRaMac operation.
78 | *
79 | * \param [IN] channel - Channel index
80 | */
81 | void LoRaMacTestSetChannel( uint8_t channel );
82 |
83 | /*! \} defgroup LORAMACTEST */
84 |
85 | #endif // __LORAMACTEST_H__
86 |
--------------------------------------------------------------------------------
/examples/ESP32/ADC_Read_Voltage/ADC_Read_Simple/ADC_Read_Simple.ino:
--------------------------------------------------------------------------------
1 | /*
2 | ADC read voltage via GPIO13 simple test.
3 |
4 | by Aaron.Lee from HelTec AutoMation, ChengDu, China
5 | 成都惠利特自动化科技有限公司
6 | www.heltec.cn
7 | */
8 |
9 | void setup() {
10 | Serial.begin(115200);
11 | /*
12 | analogReadResolution(12); // Sets the sample bits and read resolution, default is 12-bit (0 - 4095), range is 9 - 12 bits
13 | analogSetWidth(12); // Sets the sample bits and read resolution, default is 12-bit (0 - 4095), range is 9 - 12 bits
14 | // 9-bit gives an ADC range of 0-511
15 | // 10-bit gives an ADC range of 0-1023
16 | // 11-bit gives an ADC range of 0-2047
17 | // 12-bit gives an ADC range of 0-4095
18 | analogSetCycles(8); // Set number of cycles per sample, default is 8 and provides an optimal result, range is 1 - 255
19 | analogSetSamples(1); // Set number of samples in the range, default is 1, it has an effect on sensitivity has been multiplied
20 | analogSetClockDiv(1); // Set the divider for the ADC clock, default is 1, range is 1 - 255
21 | analogSetAttenuation(ADC_11db); // Sets the input attenuation for ALL ADC inputs, default is ADC_11db, range is ADC_0db, ADC_2_5db, ADC_6db, ADC_11db
22 | analogSetPinAttenuation(VP,ADC_11db); // Sets the input attenuation, default is ADC_11db, range is ADC_0db, ADC_2_5db, ADC_6db, ADC_11db
23 | // ADC_0db provides no attenuation so IN/OUT = 1 / 1 an input of 3 volts remains at 3 volts before ADC measurement
24 | // ADC_2_5db provides an attenuation so that IN/OUT = 1 / 1.34 an input of 3 volts is reduced to 2.238 volts before ADC measurement
25 | // ADC_6db provides an attenuation so that IN/OUT = 1 / 2 an input of 3 volts is reduced to 1.500 volts before ADC measurement
26 | // ADC_11db provides an attenuation so that IN/OUT = 1 / 3.6 an input of 3 volts is reduced to 0.833 volts before ADC measurement
27 | adcAttachPin(VP); // Attach a pin to ADC (also clears any other analog mode that could be on), returns TRUE/FALSE result
28 | adcStart(VP); // Starts an ADC conversion on attached pin's bus
29 | adcBusy(VP); // Check if conversion on the pin's ADC bus is currently running, returns TRUE/FALSE result
30 | adcEnd(VP); // Get the result of the conversion (will wait if it have not finished), returns 16-bit integer result
31 | */
32 | adcAttachPin(13);
33 | analogSetClockDiv(255); // 1338mS
34 | }
35 |
36 | void loop() {
37 | int timer = micros();
38 | Serial.print(analogRead(13));
39 | Serial.print(" ");
40 | Serial.println(micros() - timer);
41 | }
42 |
43 | //See more APIs about ADC here: https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/esp32/cores/esp32/esp32-hal-adc.h
44 |
45 |
--------------------------------------------------------------------------------
/examples/LoRaBasic/LoRaReceiver/LoRaReceiver.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation Receive communication test example
2 | *
3 | * Function:
4 | * 1. Receive the same frequency band lora signal program
5 | *
6 | * Description:
7 | *
8 | * HelTec AutoMation, Chengdu, China
9 | * 成都惠利特自动化科技有限公司
10 | * www.heltec.org
11 | *
12 | * this project also realess in GitHub:
13 | * https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series
14 | * */
15 |
16 | #include "LoRaWan_APP.h"
17 | #include "Arduino.h"
18 |
19 |
20 | #define RF_FREQUENCY 915000000 // Hz
21 |
22 | #define TX_OUTPUT_POWER 14 // dBm
23 |
24 | #define LORA_BANDWIDTH 0 // [0: 125 kHz,
25 | // 1: 250 kHz,
26 | // 2: 500 kHz,
27 | // 3: Reserved]
28 | #define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
29 | #define LORA_CODINGRATE 1 // [1: 4/5,
30 | // 2: 4/6,
31 | // 3: 4/7,
32 | // 4: 4/8]
33 | #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
34 | #define LORA_SYMBOL_TIMEOUT 0 // Symbols
35 | #define LORA_FIX_LENGTH_PAYLOAD_ON false
36 | #define LORA_IQ_INVERSION_ON false
37 |
38 |
39 | #define RX_TIMEOUT_VALUE 1000
40 | #define BUFFER_SIZE 30 // Define the payload size here
41 |
42 | char txpacket[BUFFER_SIZE];
43 | char rxpacket[BUFFER_SIZE];
44 |
45 | static RadioEvents_t RadioEvents;
46 |
47 | int16_t txNumber;
48 |
49 | int16_t rssi,rxSize;
50 |
51 | bool lora_idle = true;
52 |
53 | void setup() {
54 | Serial.begin(115200);
55 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);
56 |
57 | txNumber=0;
58 | rssi=0;
59 |
60 | RadioEvents.RxDone = OnRxDone;
61 | Radio.Init( &RadioEvents );
62 | Radio.SetChannel( RF_FREQUENCY );
63 | Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
64 | LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
65 | LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
66 | 0, true, 0, 0, LORA_IQ_INVERSION_ON, true );
67 | }
68 |
69 |
70 |
71 | void loop()
72 | {
73 | if(lora_idle)
74 | {
75 | lora_idle = false;
76 | Serial.println("into RX mode");
77 | Radio.Rx(0);
78 | }
79 | Radio.IrqProcess( );
80 | }
81 |
82 | void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
83 | {
84 | rssi=rssi;
85 | rxSize=size;
86 | memcpy(rxpacket, payload, size );
87 | rxpacket[size]='\0';
88 | Radio.Sleep( );
89 | Serial.printf("\r\nreceived packet \"%s\" with rssi %d , length %d\r\n",rxpacket,rssi,rxSize);
90 | lora_idle = true;
91 | }
--------------------------------------------------------------------------------
/examples/ESP32/ESP32_Dual_Core/README.md:
--------------------------------------------------------------------------------
1 | ## Contents
2 |
3 | - [The Overview](#the-overview)
4 | - [ShowCore](#showcore)
5 | - [MoveCore](#movecore)
6 | - [SpeedTest](#speedtest)
7 | - [Information](#information)
8 |
9 | # The Overview
10 |
11 | - The ESP32 chip has three cores.
12 | - Two cores are fast cores and one core is a low-power core.
13 | - Which is an example of ESP32 Dual Core on Arduino IDE including Data Passing and Task Synchronization.
14 |
15 |
16 | ## ShowCore
17 |
18 | In the first step, we need to know which core the current program is running on.
19 | We need a code to print the current core from the serial port.
20 |
21 | ```
22 | Serial.println(xPortGetCoreID());
23 | ```
24 |
25 | 
26 |
27 | We prepared an [example](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/tree/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/examples/Showcore) for you.
28 |
29 | ## MoveCore
30 |
31 | Run the program with the specified core.
32 | 
33 |
34 | - We use the following code to perform core switching
35 | ```
36 | xTaskCreatePinnedToCore(
37 | codeForTask1, /*Task Function. */
38 | "Task_1", /*name of task. */
39 | 1000, /*Stack size of task. */
40 | NULL, /* parameter of the task. */
41 | 1, /* proiority of the task. */
42 | &Task1, /* Task handel to keep tra ck of created task. */
43 | 0); /* choose Core */
44 | ```
45 |
46 | Check this [example](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/tree/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/examples/Movecore) to see how you can switch the core.
47 |
48 | ## SpeedTest
49 |
50 | Test the speed of the two cores under different conditions.
51 | 
52 |
53 | In this [example](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/tree/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/examples/SpeedTest) the program is running as follows:
54 |
55 | 
56 |
57 | The result of the operation is as follows:
58 | 
59 | At this time, 0 core and 1 core full speed synchronous processing independent tasks.
60 |
61 | ## Information
62 |
63 | 
64 |
65 | - [PinoutDiagram](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/PinoutDiagram/WIFI%20LoRa%2032(V2)%20.pdf)
66 | - node: [WIFI LoRa 32 V2](https://item.taobao.com/item.htm?spm=a1z10.1-c.w4004-17008247508.4.7bdf1d6f2XG3ID&id=575190433694)
67 | - Arduino 18.04
68 |
--------------------------------------------------------------------------------
/examples/VME213/Part_Simple/Part_Simple.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation Eink partial refresh example
2 | *
3 | * Function:
4 | * 1.Ink screen partial refresh demonstration.
5 | *
6 | * Description:
7 | * 1.Using an external Lut waveform file to achieve partial refresh
8 | *
9 | * Note:
10 | * This example is compatible with Wireless Paper and requires you to change the pin Settings in your code and change the order in which the VextCtrl pin HIGH and LOW.
11 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32
12 | * Support: support@heltec.cn
13 | *
14 | * HelTec AutoMation, Chengdu, China
15 | * 成都惠利特自动化科技有限公司
16 | * https://www.heltec.org
17 | * */
18 | #include "HT_lCMEN2R13EFC1.h"
19 | #include "images.h"
20 | // Initialize the display
21 | HT_ICMEN2R13EFC1 display(3, 2, 5, 1, 4, 6, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency
22 | uint8_t num = 0;
23 | typedef void (*Demo)(void);
24 |
25 | /* screen rotation
26 | * ANGLE_0_DEGREE
27 | * ANGLE_90_DEGREE
28 | * ANGLE_180_DEGREE
29 | * ANGLE_270_DEGREE
30 | */
31 | #define DIRECTION ANGLE_0_DEGREE
32 |
33 | int width, height;
34 | int demoMode = 0;
35 |
36 | void setup()
37 | {
38 | Serial.begin(115200);
39 | if (DIRECTION == ANGLE_0_DEGREE || DIRECTION == ANGLE_180_DEGREE)
40 | {
41 | width = display._width;
42 | height = display._height;
43 | }
44 | else
45 | {
46 | width = display._height;
47 | height = display._width;
48 | }
49 | VextON();
50 | delay(100);
51 | // Initialising the UI will init the display too.
52 | display.init();
53 | display.screenRotate(DIRECTION);
54 | display.setFont(ArialMT_Plain_10);
55 | }
56 |
57 | void part_ref(uint8_t _num)
58 | {
59 | switch (_num)
60 | {
61 | case 0:
62 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num0); // dis_img_Partial_Refresh(x,y,img_width,img_lenth)
63 | // The second parameter, the fourth parameter, takes an integer multiple of 8
64 | break;
65 | case 1:
66 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num1);
67 | break;
68 | case 2:
69 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num2);
70 | break;
71 | case 3:
72 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num3);
73 | break;
74 | case 4:
75 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num4);
76 | break;
77 | case 5:
78 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num5);
79 | break;
80 | case 6:
81 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num6);
82 | break;
83 | case 7:
84 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num7);
85 | break;
86 | case 8:
87 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num8);
88 | break;
89 | case 9:
90 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num9);
91 | break;
92 | default:
93 | break;
94 | }
95 | }
96 |
97 | void VextON(void)
98 | {
99 | pinMode(18, OUTPUT);
100 | digitalWrite(18, HIGH);
101 | }
102 |
103 | void VextOFF(void) // Vext default OFF
104 | {
105 | pinMode(18, OUTPUT);
106 | digitalWrite(18, LOW);
107 | }
108 |
109 | void loop()
110 | {
111 | part_ref(num++);
112 | }
113 |
--------------------------------------------------------------------------------
/src/LoRaWan_APP.h:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #ifndef LoRaWan_APP_H
5 | #define LoRaWan_APP_H
6 | #include "Arduino.h"
7 | #if !defined(HT_DE01)&&!defined(WIFI_Kit_32)&&!defined(WIFI_Kit_32_V3)
8 | #include "ESP32_Mcu.h"
9 | #include
10 | #include "loramac/LoRaMac.h"
11 | #include "loramac/utilities.h"
12 | #include "ESP32_LoRaWan_102.h"
13 | #include "HardwareSerial.h"
14 | #include "driver/board.h"
15 | #include "driver/debug.h"
16 |
17 | #if defined(__asr650x__)
18 | #include "board.h"
19 | #include "gpio.h"
20 | #include "hw.h"
21 | #include "low_power.h"
22 | #include "spi-board.h"
23 | #include "rtc-board.h"
24 | #include "asr_timer.h"
25 | #include "board-config.h"
26 | #include "hw_conf.h"
27 | #include
28 | #endif
29 |
30 | enum eDeviceState_LoraWan
31 | {
32 | DEVICE_STATE_INIT,
33 | DEVICE_STATE_JOIN,
34 | DEVICE_STATE_SEND,
35 | DEVICE_STATE_CYCLE,
36 | DEVICE_STATE_SLEEP
37 | };
38 |
39 | enum eDeviceState_Lora
40 | {
41 | LORA_INIT,
42 | LORA_SEND,
43 | LORA_RECEIVE,
44 | LORA_CAD,
45 | MCU_SLEEP,
46 | };
47 |
48 |
49 | extern uint8_t devEui[];
50 | extern uint8_t appEui[];
51 | extern uint8_t appKey[];
52 | extern uint8_t nwkSKey[];
53 | extern uint8_t appSKey[];
54 | extern uint32_t devAddr;
55 | extern uint8_t appData[LORAWAN_APP_DATA_MAX_SIZE];
56 | extern uint8_t appDataSize;
57 | extern uint8_t appPort;
58 | extern uint32_t txDutyCycleTime;
59 | extern bool overTheAirActivation;
60 | extern LoRaMacRegion_t loraWanRegion;
61 | extern bool loraWanAdr;
62 | extern bool isTxConfirmed;
63 | extern uint32_t appTxDutyCycle;
64 | extern DeviceClass_t loraWanClass;
65 | extern bool passthroughMode;
66 | extern uint8_t confirmedNbTrials;
67 | extern bool modeLoraWan;
68 | extern bool keepNet;
69 | extern uint16_t userChannelsMask[6];
70 |
71 | /*!
72 | * Defines a random delay for application data transmission duty cycle. 1s,
73 | * value in [ms].
74 | */
75 | #define APP_TX_DUTYCYCLE_RND 1000
76 |
77 | class LoRaWanClass{
78 | public:
79 | void init(DeviceClass_t lorawanClass,LoRaMacRegion_t region);
80 | void join();
81 | void send();
82 | void cycle(uint32_t dutyCycle);
83 | void sleep(DeviceClass_t classMode);
84 | void setDefaultDR(int8_t dataRate);
85 | void ifskipjoin();
86 | void generateDeveuiByChipID();
87 |
88 | #if defined(WIFI_LORA_32_V3)||defined(WIFI_LORA_32_V4)||defined(WIFI_LORA_32_V2)||defined(WIRELESS_STICK_V3)||defined( WIFI_LORA_32 )||defined(WIRELESS_STICK)
89 | void displayJoining();
90 | void displayJoined();
91 | void displaySending();
92 | void displayAck();
93 | void displayMcuInit();
94 | #endif
95 | };
96 |
97 | extern enum eDeviceState_LoraWan deviceState;
98 |
99 | extern "C" bool SendFrame( void );
100 | extern "C" void turnOnRGB(uint32_t color,uint32_t time);
101 | extern "C" void turnOffRGB(void);
102 | extern "C" bool checkUserAt(char * cmd, char * content);
103 | extern "C" void downLinkAckHandle();
104 | extern "C" void downLinkDataHandle(McpsIndication_t *mcpsIndication);
105 | extern "C" void lwan_dev_params_update( void );
106 | extern "C" void dev_time_updated( void );
107 | extern "C" void lora_printf(const char *format, ...);
108 |
109 | extern LoRaWanClass LoRaWAN;
110 |
111 | #endif
112 | #endif
--------------------------------------------------------------------------------
/examples/LoRaBasic/LoRaSender/LoRaSender.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation send communication test example
2 | *
3 | * Function:
4 | * 1. Send data from a esp32 device over hardware
5 | *
6 | * Description:
7 | *
8 | * HelTec AutoMation, Chengdu, China
9 | * 成都惠利特自动化科技有限公司
10 | * www.heltec.org
11 | *
12 | * this project also realess in GitHub:
13 | * https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series
14 | * */
15 |
16 | #include "LoRaWan_APP.h"
17 | #include "Arduino.h"
18 |
19 |
20 | #define RF_FREQUENCY 915000000 // Hz
21 |
22 | #define TX_OUTPUT_POWER 5 // dBm
23 |
24 | #define LORA_BANDWIDTH 0 // [0: 125 kHz,
25 | // 1: 250 kHz,
26 | // 2: 500 kHz,
27 | // 3: Reserved]
28 | #define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
29 | #define LORA_CODINGRATE 1 // [1: 4/5,
30 | // 2: 4/6,
31 | // 3: 4/7,
32 | // 4: 4/8]
33 | #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
34 | #define LORA_SYMBOL_TIMEOUT 0 // Symbols
35 | #define LORA_FIX_LENGTH_PAYLOAD_ON false
36 | #define LORA_IQ_INVERSION_ON false
37 |
38 |
39 | #define RX_TIMEOUT_VALUE 1000
40 | #define BUFFER_SIZE 30 // Define the payload size here
41 |
42 | char txpacket[BUFFER_SIZE];
43 | char rxpacket[BUFFER_SIZE];
44 |
45 | double txNumber;
46 |
47 | bool lora_idle=true;
48 |
49 | static RadioEvents_t RadioEvents;
50 | void OnTxDone( void );
51 | void OnTxTimeout( void );
52 |
53 | void setup() {
54 | Serial.begin(115200);
55 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);
56 |
57 | txNumber=0;
58 |
59 | RadioEvents.TxDone = OnTxDone;
60 | RadioEvents.TxTimeout = OnTxTimeout;
61 |
62 | Radio.Init( &RadioEvents );
63 | Radio.SetChannel( RF_FREQUENCY );
64 | Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
65 | LORA_SPREADING_FACTOR, LORA_CODINGRATE,
66 | LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
67 | true, 0, 0, LORA_IQ_INVERSION_ON, 3000 );
68 | }
69 |
70 |
71 |
72 | void loop()
73 | {
74 | if(lora_idle == true)
75 | {
76 | delay(1000);
77 | txNumber += 0.01;
78 | sprintf(txpacket,"Hello world number %0.2f",txNumber); //start a package
79 |
80 | Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket));
81 |
82 | Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out
83 | lora_idle = false;
84 | }
85 | Radio.IrqProcess( );
86 | }
87 |
88 | void OnTxDone( void )
89 | {
90 | Serial.println("TX done......");
91 | lora_idle = true;
92 | }
93 |
94 | void OnTxTimeout( void )
95 | {
96 | Radio.Sleep( );
97 | Serial.println("TX Timeout......");
98 | lora_idle = true;
99 | }
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.0/Wireless_Paper_V1.0.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation Wireless_Paper_V1.0 Sensors test example
2 | *
3 | * Function:
4 | * - Build a web page and refresh e-paper through Wi-Fi.
5 | * - With DHCP function.
6 | *
7 | * HelTec AutoMation, Chengdu, China
8 | * www.heltec.org
9 | *
10 | * Operation instance: Only work with Heltec Wireless Paper V1.0 hardware
11 | *
12 | * this project also realess in GitHub:
13 | * https://github.com/HelTecAutomation/Heltec_ESP32
14 | */
15 |
16 | #include
17 | #include
18 | #include "HT_QYEG0213RWS800_BWR.h"
19 | #include "images.h"
20 | #include "html.h"
21 | #include
22 |
23 | QYEG0213RWS800_BWR display(6, 5, 4, 7, 3, 2, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency
24 |
25 | uint8_t width, height;
26 | String HTTP_Payload;
27 |
28 | WebServer server(80); // Create WebServer object with port number 80
29 | // By using port number 80, you can directly enter the IP address for access, while using other ports requires entering the IP: port number for access
30 |
31 | const char *ssid = "your_ssid";
32 | const char *password = "your_password";
33 |
34 | // Distribute processing callback function
35 |
36 | void Config_Callback()
37 | {
38 |
39 | String Payload;
40 | const char *buff;
41 |
42 | Payload = server.arg("value"); // Obtain the data delivered
43 | buff = Payload.c_str();
44 |
45 | delay(100);
46 | int i = 0;
47 | char *token;
48 | token = strtok((char *)buff, ",");
49 |
50 | while (token != NULL)
51 | {
52 | int num = atoi(token);
53 | WiFi_Logo_bits[i] = num;
54 | token = strtok(NULL, ",");
55 | Serial.print(WiFi_Logo_bits[i]);
56 | i++;
57 | }
58 | drawImageDemo();
59 | Serial.println("dd");
60 | }
61 |
62 | void setup()
63 | {
64 |
65 | Serial.begin(115200);
66 | Serial.println();
67 |
68 | VextON();
69 | delay(100);
70 | display.init();
71 |
72 | WiFi.mode(WIFI_STA);
73 | WiFi.setSleep(false);
74 | WiFi.begin(ssid, password);
75 | while (WiFi.status() != WL_CONNECTED)
76 | {
77 | delay(500);
78 | Serial.print(".");
79 | }
80 | Serial.println("Connected");
81 | Serial.print("IP Address:");
82 | Serial.println(WiFi.localIP());
83 | server.on("/", []()
84 | { server.send(200, "text/html", index_html); });
85 |
86 | server.on("/set", HTTP_GET, Config_Callback); // Bind the handler that is configured to deliver the function
87 | server.begin();
88 | }
89 | void drawImageDemo()
90 | {
91 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html
92 | // on how to create xbm files
93 | display.clear();
94 | display.update(BLACK_BUFFER);
95 |
96 | display.clear();
97 | int x = width / 2 - WiFi_Logo_width / 2;
98 | int y = height / 2 - WiFi_Logo_height / 2;
99 | display.drawXbm(0, 0, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);
100 | display.update(BLACK_BUFFER);
101 | display.display();
102 | }
103 | void VextON(void)
104 | {
105 | pinMode(45, OUTPUT);
106 | digitalWrite(45, LOW);
107 | }
108 |
109 | void VextOFF(void) // Vext default OFF
110 | {
111 | pinMode(45, OUTPUT);
112 | digitalWrite(45, HIGH);
113 | }
114 | void loop()
115 | {
116 | server.handleClient(); // Handle requests from clients
117 | }
118 |
--------------------------------------------------------------------------------
/examples/Wireless_paper/Wireless_Paper_V1.1/Wireless_Paper_V1.1.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation Wireless_Paper_V1.0 Sensors test example
2 | *
3 | * Function:
4 | * - Build a web page and refresh e-paper through Wi-Fi.
5 | * - With DHCP function.
6 | *
7 | * HelTec AutoMation, Chengdu, China
8 | * www.heltec.org
9 | *
10 | * Operation instance: Only work with Heltec Wireless Paper V1.1 hardware
11 | *
12 | * this project also realess in GitHub:
13 | * https://github.com/HelTecAutomation/Heltec_ESP32
14 | */
15 |
16 | #include
17 | #include
18 | #include "HT_lCMEN2R13EFC1.h"
19 | #include "images.h"
20 | #include "html.h"
21 | #include
22 |
23 | HT_ICMEN2R13EFC1 display(6, 5, 4, 7, 3, 2, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency
24 |
25 | int width, height;
26 | String HTTP_Payload;
27 | WebServer server(80); // Create WebServer object with port number 80
28 | // By using port number 80, you can directly enter the IP address for access, while using other ports requires entering the IP: port number for access
29 |
30 | const char *ssid = "your-ssid";
31 | const char *password = "your-password";
32 |
33 | // Distribute processing callback function
34 | void Config_Callback()
35 | {
36 |
37 | String Payload;
38 | const char *buff;
39 |
40 | Payload = server.arg("value"); // Obtain the data delivered
41 | buff = Payload.c_str();
42 |
43 | delay(100);
44 | int i = 0;
45 | char *token;
46 | token = strtok((char *)buff, ",");
47 |
48 | while (token != NULL)
49 | {
50 | int num = atoi(token);
51 | WiFi_Logo_bits[i] = num;
52 | token = strtok(NULL, ",");
53 | Serial.print(WiFi_Logo_bits[i]);
54 | i++;
55 | }
56 | drawImageDemo();
57 | Serial.println("dd");
58 | }
59 |
60 | void setup()
61 | {
62 |
63 | Serial.begin(115200);
64 | Serial.println();
65 |
66 | VextON();
67 | delay(100);
68 | display.init();
69 |
70 | WiFi.mode(WIFI_STA);
71 | WiFi.setSleep(false);
72 | WiFi.begin(ssid, password);
73 | while (WiFi.status() != WL_CONNECTED)
74 | {
75 | delay(500);
76 | Serial.print(".");
77 | }
78 | Serial.println("Connected");
79 | Serial.print("IP Address:");
80 | Serial.println(WiFi.localIP());
81 | server.on("/", []()
82 | { server.send(200, "text/html", index_html); });
83 |
84 | server.on("/set", HTTP_GET, Config_Callback); // Bind the handler that is configured to deliver the function
85 | server.begin();
86 | }
87 | void drawImageDemo()
88 | {
89 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html
90 | // on how to create xbm files
91 | display.clear();
92 | display.update(BLACK_BUFFER);
93 |
94 | display.clear();
95 | int x = width / 2 - WiFi_Logo_width / 2;
96 | int y = height / 2 - WiFi_Logo_height / 2;
97 | display.drawXbm(0, 0, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);
98 | display.update(BLACK_BUFFER);
99 | display.display();
100 |
101 | }
102 | void VextON(void)
103 | {
104 | pinMode(45, OUTPUT); //For HT-VME213,choose "18, OUTPUT"
105 | digitalWrite(45, LOW); //For HT-VME213,choose "18, HIGH"
106 | }
107 |
108 | void VextOFF(void) // Vext default OFF
109 | {
110 | pinMode(45, OUTPUT); //For HT-VME213,choose "18, OUTPUT"
111 | digitalWrite(45, HIGH); //For HT-VME213,choose "18, LOW"
112 | }
113 | void loop()
114 | {
115 | server.handleClient(); // Handle requests from clients
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/loramac/LoRaMacClassBConfig.h:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file LoRaMacClassBConfig.h
3 | *
4 | * \brief LoRa MAC Class B configuration
5 | *
6 | * \copyright Revised BSD License, see section \ref LICENSE.
7 | *
8 | * \code
9 | * ______ _
10 | * / _____) _ | |
11 | * ( (____ _____ ____ _| |_ _____ ____| |__
12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
13 | * _____) ) ____| | | || |_| ____( (___| | | |
14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15 | * (C)2013 Semtech
16 | *
17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___
18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
21 | * embedded.connectivity.solutions===============
22 | *
23 | * \endcode
24 | *
25 | * \author Miguel Luis ( Semtech )
26 | *
27 | * \author Gregory Cristian ( Semtech )
28 | *
29 | * \author Daniel Jaeckle ( STACKFORCE )
30 | *
31 | * \defgroup LORAMACCLASSB LoRa MAC Class B configuration
32 | * This header file contains parameters to configure the class b operation.
33 | * By default, all parameters are set according to the specification.
34 | * \{
35 | */
36 | #ifndef __LORAMACCLASSBCONFIG_H__
37 | #define __LORAMACCLASSBCONFIG_H__
38 |
39 | /*!
40 | * Defines the beacon interval in ms
41 | */
42 | #define CLASSB_BEACON_INTERVAL 128000
43 |
44 | /*!
45 | * Beacon reserved time in ms
46 | */
47 | #define CLASSB_BEACON_RESERVED 2120
48 |
49 | /*!
50 | * Beacon guard time in ms
51 | */
52 | #define CLASSB_BEACON_GUARD 3000
53 |
54 | /*!
55 | * Beacon window time in ms
56 | */
57 | #define CLASSB_BEACON_WINDOW 122880
58 |
59 | /*!
60 | * Beacon window time in numer of slots
61 | */
62 | #define CLASSB_BEACON_WINDOW_SLOTS 4096
63 |
64 | /*!
65 | * Ping slot length time in ms
66 | */
67 | #define CLASSB_PING_SLOT_WINDOW 30
68 |
69 | /*!
70 | * Maximum allowed beacon less time in ms
71 | */
72 | #define CLASSB_MAX_BEACON_LESS_PERIOD 7200000
73 |
74 | /*!
75 | * Delay time for the BeaconTimingAns in ms
76 | */
77 | #define CLASSB_BEACON_DELAY_BEACON_TIMING_ANS 30
78 |
79 | /*!
80 | * Default symbol timeout for beacons and ping slot windows
81 | */
82 | #define CLASSB_BEACON_SYMBOL_TO_DEFAULT 8
83 |
84 | /*!
85 | * Maximum symbol timeout for beacons
86 | */
87 | #define CLASSB_BEACON_SYMBOL_TO_EXPANSION_MAX 255
88 |
89 | /*!
90 | * Maximum symbol timeout for ping slots
91 | */
92 | #define CLASSB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX 30
93 |
94 | /*!
95 | * Symbol expansion value for beacon windows in case of beacon
96 | * loss in symbols
97 | */
98 | #define CLASSB_BEACON_SYMBOL_TO_EXPANSION_FACTOR 2
99 |
100 | /*!
101 | * Defines the default window movement time
102 | */
103 | #define CLASSB_WINDOW_MOVE_DEFAULT 2
104 |
105 | /*!
106 | * Defines the maximum time for the beacon movement
107 | */
108 | #define CLASSB_WINDOW_MOVE_EXPANSION_MAX 256
109 |
110 | /*!
111 | * Defines the expansion factor for the beacon movement
112 | */
113 | #define CLASSB_WINDOW_MOVE_EXPANSION_FACTOR 2
114 |
115 | #endif // __LORAMACCLASSBCONFIG_H__
116 |
--------------------------------------------------------------------------------
/src/HT_lCMEN2R13EFC1_LUT.h:
--------------------------------------------------------------------------------
1 | const unsigned char LUT_VCOM[] = {
2 | 0x00,
3 | 0x00,
4 | 0x00,
5 | 0x00,
6 | 0x00,
7 | 0x00,
8 | 0x00,
9 | 0x00,
10 | 0x00,
11 | 0x00,
12 | 0x00,
13 | 0x00,
14 | 0x00,
15 | 0x00,
16 | 0x00,
17 | 0x00,
18 | 0x00,
19 | 0x00,
20 | 0x00,
21 | 0x00,
22 | 0x00,
23 | 0x01,
24 | 0x00,
25 | 0x00,
26 | 0x00,
27 | 0x00,
28 | 0x00,
29 | 0x00,
30 | 0x01,
31 | 0x83,
32 | 0x82,
33 | 0x43,
34 | 0x42,
35 | 0x01,
36 | 0x01,
37 | 0x01,
38 | 0x03,
39 | 0x03,
40 | 0x00,
41 | 0x00,
42 | 0x01,
43 | 0x01,
44 | };
45 | const unsigned char LUT_WW[] = {
46 | 0x00,
47 | 0x00,
48 | 0x00,
49 | 0x00,
50 | 0x00,
51 | 0x00,
52 | 0x00,
53 | 0x00,
54 | 0x00,
55 | 0x00,
56 | 0x00,
57 | 0x00,
58 | 0x00,
59 | 0x00,
60 | 0x00,
61 | 0x00,
62 | 0x00,
63 | 0x00,
64 | 0x00,
65 | 0x00,
66 | 0x00,
67 | 0x01,
68 | 0x00,
69 | 0x00,
70 | 0x00,
71 | 0x00,
72 | 0x00,
73 | 0x00,
74 | 0x01,
75 | 0x83,
76 | 0x82,
77 | 0x83,
78 | 0x82,
79 | 0x01,
80 | 0x01,
81 | 0x01,
82 | 0x03,
83 | 0x83,
84 | 0x00,
85 | 0x00,
86 | 0x01,
87 | 0x01,
88 | };
89 | const unsigned char LUT_BW[] = {
90 | 0x00,
91 | 0x00,
92 | 0x00,
93 | 0x00,
94 | 0x00,
95 | 0x00,
96 | 0x00,
97 | 0x00,
98 | 0x00,
99 | 0x00,
100 | 0x00,
101 | 0x00,
102 | 0x00,
103 | 0x00,
104 | 0x00,
105 | 0x00,
106 | 0x00,
107 | 0x00,
108 | 0x00,
109 | 0x00,
110 | 0x00,
111 | 0x01,
112 | 0x00,
113 | 0x00,
114 | 0x00,
115 | 0x00,
116 | 0x00,
117 | 0x00,
118 | 0x01,
119 | 0x83,
120 | 0x82,
121 | 0x83,
122 | 0x82,
123 | 0x01,
124 | 0x01,
125 | 0x01,
126 | 0x03,
127 | 0x83,
128 | 0x00,
129 | 0x00,
130 | 0x01,
131 | 0x01,
132 | };
133 | const unsigned char LUT_WB[] = {
134 | 0x00,
135 | 0x00,
136 | 0x00,
137 | 0x00,
138 | 0x00,
139 | 0x00,
140 | 0x00,
141 | 0x00,
142 | 0x00,
143 | 0x00,
144 | 0x00,
145 | 0x00,
146 | 0x00,
147 | 0x00,
148 | 0x00,
149 | 0x00,
150 | 0x00,
151 | 0x00,
152 | 0x00,
153 | 0x00,
154 | 0x00,
155 | 0x01,
156 | 0x00,
157 | 0x00,
158 | 0x00,
159 | 0x00,
160 | 0x00,
161 | 0x00,
162 | 0x01,
163 | 0x43,
164 | 0x42,
165 | 0x43,
166 | 0x42,
167 | 0x01,
168 | 0x01,
169 | 0x01,
170 | 0x43,
171 | 0x03,
172 | 0x00,
173 | 0x00,
174 | 0x01,
175 | 0x01,
176 | }; // 0.32
177 | const unsigned char LUT_BB[] = {
178 | 0x00,
179 | 0x00,
180 | 0x00,
181 | 0x00,
182 | 0x00,
183 | 0x00,
184 | 0x00,
185 | 0x00,
186 | 0x00,
187 | 0x00,
188 | 0x00,
189 | 0x00,
190 | 0x00,
191 | 0x00,
192 | 0x00,
193 | 0x00,
194 | 0x00,
195 | 0x00,
196 | 0x00,
197 | 0x00,
198 | 0x00,
199 | 0x01,
200 | 0x00,
201 | 0x00,
202 | 0x00,
203 | 0x00,
204 | 0x00,
205 | 0x00,
206 | 0x01,
207 | 0x43,
208 | 0x42,
209 | 0x43,
210 | 0x42,
211 | 0x01,
212 | 0x01,
213 | 0x01,
214 | 0x43,
215 | 0x03,
216 | 0x00,
217 | 0x00,
218 | 0x01,
219 | 0x01,
220 | };
221 | const unsigned char CMD_USER[] = {
222 | 0x00,
223 | 0x3F,
224 | 0x3F,
225 | 0x10,
226 | 0X09,
227 | 0x13,
228 | };
229 |
--------------------------------------------------------------------------------
/src/driver/rtc-board.h:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file rtc-board.h
3 | *
4 | * \brief Target board RTC timer and low power modes management
5 | *
6 | * \copyright Revised BSD License, see section \ref LICENSE.
7 | *
8 | * \code
9 | * ______ _
10 | * / _____) _ | |
11 | * ( (____ _____ ____ _| |_ _____ ____| |__
12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
13 | * _____) ) ____| | | || |_| ____( (___| | | |
14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15 | * (C)2013-2017 Semtech
16 | *
17 | * \endcode
18 | *
19 | * \author Miguel Luis ( Semtech )
20 | *
21 | * \author Gregory Cristian ( Semtech )
22 | */
23 | #ifndef __RTC_BOARD_H__
24 | #define __RTC_BOARD_H__
25 |
26 | #ifdef __cplusplus
27 | extern "C"{
28 | #endif
29 |
30 | #include
31 | #include
32 | #include "../driver/timer.h"
33 | #include "Arduino.h"
34 |
35 | extern uint64_t alarmTime;
36 |
37 | /*!
38 | * \brief Timer time variable definition
39 | */
40 | //#ifndef TimerTime_t
41 | //typedef uint64_t TimerTime_t;
42 | //#endif
43 |
44 | /*!
45 | * \brief Initializes the RTC timer
46 | *
47 | * \remark The timer is based on the RTC
48 | */
49 | void RtcInit( void );
50 |
51 | /*!
52 | * \brief Start the RTC timer
53 | *
54 | * \remark The timer is based on the RTC Alarm running at 32.768KHz
55 | *
56 | * \param[IN] timeout Duration of the Timer
57 | */
58 | void RtcSetTimeout( uint32_t timeout );
59 |
60 | void RtcStopTimeout( void );
61 |
62 | TimerTime_t RtcGetTimerContext( void );
63 |
64 | TimerTime_t RtcSetTimerContext( void );
65 |
66 | TimerTime_t RtcGetElapsedTime( void );
67 |
68 |
69 | /*!
70 | * \brief Adjust the value of the timeout to handle wakeup time from Alarm and GPIO irq
71 | *
72 | * \param[IN] timeout Duration of the Timer without compensation for wakeup time
73 | * \retval new value for the Timeout with compensations
74 | */
75 | TimerTime_t RtcGetAdjustedTimeoutValue( uint32_t timeout );
76 |
77 | /*!
78 | * \brief Get the RTC timer value
79 | *
80 | * \retval RTC Timer value
81 | */
82 | TimerTime_t RtcGetTimerValue( void );
83 |
84 | /*!
85 | * \brief Get the RTC timer elapsed time since the last Alarm was set
86 | *
87 | * \retval RTC Elapsed time since the last alarm
88 | */
89 | TimerTime_t RtcGetElapsedAlarmTime( void );
90 |
91 | /*!
92 | * \brief Compute the timeout time of a future event in time
93 | *
94 | * \param[IN] futureEventInTime Value in time
95 | * \retval time Time between now and the futureEventInTime
96 | */
97 | TimerTime_t RtcComputeFutureEventTime( TimerTime_t futureEventInTime );
98 |
99 | /*!
100 | * \brief Compute the elapsed time since a fix event in time
101 | *
102 | * \param[IN] eventInTime Value in time
103 | * \retval elapsed Time since the eventInTime
104 | */
105 | TimerTime_t RtcComputeElapsedTime( TimerTime_t eventInTime );
106 |
107 | /*!
108 | * \brief This function blocks the MCU from going into low power mode
109 | *
110 | * \param [IN] status [true: Enable, false: Disable
111 | */
112 | void BlockLowPowerDuringTask ( bool status );
113 |
114 | /*!
115 | * \brief Sets the MCU into low power STOP mode
116 | */
117 | void lowPowerHandler( void );
118 |
119 | /*!
120 | * \brief Restore the MCU to its normal operation mode
121 | */
122 | void RtcRecoverMcuStatus( void );
123 |
124 | /*!
125 | * \brief Processes pending timer events
126 | */
127 | void RtcProcess( void );
128 |
129 | #ifdef __cplusplus
130 | }
131 | #endif
132 |
133 | #endif // __RTC_BOARD_H__
134 |
--------------------------------------------------------------------------------
/src/lora/LoRa.h:
--------------------------------------------------------------------------------
1 | #ifndef LORA_H
2 | #define LORA_H
3 |
4 | #include
5 | #include
6 |
7 | #define LORA_DEFAULT_SS_PIN 18
8 | #define LORA_DEFAULT_RESET_PIN 14
9 | #define LORA_DEFAULT_DIO0_PIN 26
10 |
11 | #define PA_OUTPUT_PA_BOOST_PIN 1
12 | #define PA_OUTPUT_RFO_PIN 0
13 |
14 | /*!
15 | * RegPaConfig
16 | */
17 | #define RF_PACONFIG_PASELECT_MASK 0x7F
18 | #define RF_PACONFIG_PASELECT_PABOOST 0x80
19 | #define RF_PACONFIG_PASELECT_RFO 0x00 // Default
20 |
21 | #define RF_PACONFIG_MAX_POWER_MASK 0x8F
22 |
23 | #define RF_PACONFIG_OUTPUTPOWER_MASK 0xF0
24 |
25 | /*!
26 | * RegPaDac
27 | */
28 | #define RF_PADAC_20DBM_MASK 0xF8
29 | #define RF_PADAC_20DBM_ON 0x07
30 | #define RF_PADAC_20DBM_OFF 0x04 // Default
31 |
32 |
33 |
34 | #if defined (__STM32F1__)
35 | inline unsigned char digitalPinToInterrupt(unsigned char Interrupt_pin) { return Interrupt_pin; } //This isn't included in the stm32duino libs (yet)
36 | #define portOutputRegister(port) (volatile byte *)( &(port->regs->ODR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value
37 | #define portInputRegister(port) (volatile byte *)( &(port->regs->IDR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value
38 | #endif
39 |
40 | class LoRaClass : public Stream {
41 | public:
42 | LoRaClass();
43 |
44 | int begin(long frequency,bool PABOOST);
45 | void end();
46 |
47 | int beginPacket(int implicitHeader = false);
48 | int endPacket(bool async = false);
49 |
50 | int parsePacket(int size = 0);
51 | int packetRssi();
52 | float packetSnr();
53 |
54 | // from Print
55 | virtual size_t write(uint8_t byte);
56 | virtual size_t write(const uint8_t *buffer, size_t size);
57 |
58 | // from Stream
59 | virtual int available();
60 | virtual int read();
61 | virtual int peek();
62 | virtual void flush();
63 |
64 | void onReceive(void(*callback)(int));
65 |
66 | void receive(int size = 0);
67 | void idle();
68 | void sleep();
69 |
70 | void setTxPower(int8_t power, int8_t outputPin);
71 | void setTxPowerMax(int level);
72 | void setFrequency(long frequency);
73 | void setSpreadingFactor(int sf);
74 | void setSignalBandwidth(long sbw);
75 | void setCodingRate4(int denominator);
76 | void setPreambleLength(long length);
77 | void setSyncWord(int sw);
78 | void enableCrc();
79 | void disableCrc();
80 | void enableTxInvertIQ();
81 | void enableRxInvertIQ();
82 | void enableInvertIQ();
83 | void disableInvertIQ();
84 |
85 | // deprecated
86 | void crc() { enableCrc(); }
87 | void noCrc() { disableCrc(); }
88 |
89 | byte random();
90 |
91 | void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN);
92 | void setSPIFrequency(uint32_t frequency);
93 |
94 | void dumpRegisters(Stream& out);
95 |
96 | void enableLowDataRate();
97 | void disableLowDataRate();
98 |
99 | private:
100 | void explicitHeaderMode();
101 | void implicitHeaderMode();
102 |
103 | void handleDio0Rise();
104 |
105 | uint8_t readRegister(uint8_t address);
106 | void writeRegister(uint8_t address, uint8_t value);
107 | uint8_t singleTransfer(uint8_t address, uint8_t value);
108 |
109 | static void onDio0Rise();
110 |
111 | private:
112 | SPISettings _spiSettings;
113 | int _ss;
114 | int _reset;
115 | int _dio0;
116 | int _frequency;
117 | int _packetIndex;
118 | int _implicitHeaderMode;
119 | void (*_onReceive)(int);
120 | };
121 |
122 | extern LoRaClass LoRa;
123 |
124 | #endif
125 |
--------------------------------------------------------------------------------
/src/driver/board.h:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file board.h
3 | *
4 | * \brief Target board general functions implementation
5 | *
6 | * \copyright Revised BSD License, see section \ref LICENSE.
7 | *
8 | * \code
9 | * ______ _
10 | * / _____) _ | |
11 | * ( (____ _____ ____ _| |_ _____ ____| |__
12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
13 | * _____) ) ____| | | || |_| ____( (___| | | |
14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15 | * (C)2013-2017 Semtech
16 | *
17 | * \endcode
18 | *
19 | * \author Miguel Luis ( Semtech )
20 | *
21 | * \author Gregory Cristian ( Semtech )
22 | */
23 |
24 | #if !defined(HT_DE01)||defined(WIFI_Kit_32)||defined(WIFI_Kit_32_V3)
25 | #ifndef __BOARD_H__
26 | #define __BOARD_H__
27 |
28 | #include
29 | #include "../driver/timer.h"
30 |
31 | #ifdef __cplusplus
32 | extern "C"{
33 | #endif
34 |
35 | /*!
36 | * Possible power sources
37 | */
38 | enum BoardPowerSources
39 | {
40 | USB_POWER = 0,
41 | BATTERY_POWER,
42 | };
43 |
44 | /*!
45 | * Board Version
46 | */
47 | typedef union BoardVersion_u
48 | {
49 | struct BoardVersion_s
50 | {
51 | uint8_t Rfu;
52 | uint8_t Revision;
53 | uint8_t Minor;
54 | uint8_t Major;
55 | }Fields;
56 | uint32_t Value;
57 | }BoardVersion_t;
58 |
59 | /*!
60 | * \brief Disable interrupts
61 | *
62 | * \remark IRQ nesting is managed
63 | */
64 | void BoardDisableIrq( void );
65 |
66 | /*!
67 | * \brief Enable interrupts
68 | *
69 | * \remark IRQ nesting is managed
70 | */
71 | void BoardEnableIrq( void );
72 |
73 | /*!
74 | * \brief Initializes the mcu.
75 | */
76 | void BoardInitMcu( void );
77 |
78 | /*!
79 | * \brief Resets the mcu.
80 | */
81 | void BoardResetMcu( void );
82 |
83 | /*!
84 | * \brief Initializes the boards peripherals.
85 | */
86 | void BoardInitPeriph( void );
87 |
88 | /*!
89 | * \brief De-initializes the target board peripherals to decrease power
90 | * consumption.
91 | */
92 | void BoardDeInitMcu( void );
93 |
94 | /*!
95 | * \brief Gets the current potentiometer level value
96 | *
97 | * \retval value Potentiometer level ( value in percent )
98 | */
99 | uint8_t BoardGetPotiLevel( void );
100 |
101 | /*!
102 | * \brief Measure the Battery voltage
103 | *
104 | * \retval value battery voltage in volts
105 | */
106 | uint32_t BoardGetBatteryVoltage( void );
107 |
108 | /*!
109 | * \brief Get the current battery level
110 | *
111 | * \retval value battery level [ 0: USB,
112 | * 1: Min level,
113 | * x: level
114 | * 254: fully charged,
115 | * 255: Error]
116 | */
117 | uint8_t BoardGetBatteryLevel( void );
118 |
119 | /*!
120 | * Returns a pseudo random seed generated using the MCU Unique ID
121 | *
122 | * \retval seed Generated pseudo random seed
123 | */
124 | uint32_t BoardGetRandomSeed( void );
125 |
126 | /*!
127 | * \brief Gets the board 64 bits unique ID
128 | *
129 | * \param [IN] id Pointer to an array that will contain the Unique ID
130 | */
131 | void BoardGetUniqueId( uint8_t *id );
132 |
133 | /*!
134 | * \brief Get the board power source
135 | *
136 | * \retval value power source [0: USB_POWER, 1: BATTERY_POWER]
137 | */
138 | uint8_t GetBoardPowerSource( void );
139 |
140 | /*!
141 | * \brief Get the board version
142 | *
143 | * \retval value Version
144 | */
145 | BoardVersion_t BoardGetVersion( void );
146 |
147 |
148 | #ifdef __cplusplus
149 | } // extern "C"
150 | #endif
151 |
152 | #endif // __BOARD_H__
153 | #endif
--------------------------------------------------------------------------------
/src/loramac/utilities.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015-2017 Alibaba Group Holding Limited
3 | */
4 |
5 | /*
6 | / _____) _ | |
7 | ( (____ _____ ____ _| |_ _____ ____| |__
8 | \____ \| ___ | (_ _) ___ |/ ___) _ \
9 | _____) ) ____| | | || |_| ____( (___| | | |
10 | (______/|_____)_|_|_| \__)_____)\____)_| |_|
11 | (C)2013 Semtech
12 |
13 | Description: Helper functions implementation
14 |
15 | License: Revised BSD License, see LICENSE.TXT file include in the project
16 |
17 | Maintainer: Miguel Luis and Gregory Cristian
18 | */
19 | #if !defined(HT_DE01)||defined(WIFI_Kit_32)||defined(WIFI_Kit_32_V3)
20 | #include
21 | #include
22 | #include
23 | #include "../loramac/utilities.h"
24 | #include "esp_attr.h"
25 | #include "esp_sleep.h"
26 | /*!
27 | * Redefinition of rand() and srand() standard C functions.
28 | * These functions are redefined in order to get the same behavior across
29 | * different compiler toolchains implementations.
30 | */
31 | // Standard random functions redefinition start
32 | #define RAND_LOCAL_MAX 2147483647L
33 |
34 | RTC_DATA_ATTR static uint32_t next = 1;
35 |
36 | int32_t rand1( void )
37 | {
38 | return ( ( next = next * 1103515245L + 12345L ) % RAND_LOCAL_MAX );
39 | }
40 |
41 | void srand1( uint32_t seed )
42 | {
43 | next = seed;
44 | }
45 | // Standard random functions redefinition end
46 |
47 | int32_t randr( int32_t min, int32_t max )
48 | {
49 | return ( int32_t )rand1( ) % ( max - min + 1 ) + min;
50 | }
51 |
52 | void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size )
53 | {
54 | while( size-- )
55 | {
56 | *dst++ = *src++;
57 | }
58 | }
59 |
60 | void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size )
61 | {
62 | dst = dst + ( size - 1 );
63 | while( size-- )
64 | {
65 | *dst-- = *src++;
66 | }
67 | }
68 |
69 | void memset1( uint8_t *dst, uint8_t value, uint16_t size )
70 | {
71 | while( size-- )
72 | {
73 | *dst++ = value;
74 | }
75 | }
76 |
77 | int8_t Nibble2HexChar( uint8_t a )
78 | {
79 | if( a < 10 )
80 | {
81 | return '0' + a;
82 | }
83 | else if( a < 16 )
84 | {
85 | return 'A' + ( a - 10 );
86 | }
87 | else
88 | {
89 | return '?';
90 | }
91 | }
92 |
93 | uint32_t Crc32( uint8_t *buffer, uint16_t length )
94 | {
95 | // The CRC calculation follows CCITT - 0x04C11DB7
96 | const uint32_t reversedPolynom = 0xEDB88320;
97 |
98 | // CRC initial value
99 | uint32_t crc = 0xFFFFFFFF;
100 |
101 | if( buffer == NULL )
102 | {
103 | return 0;
104 | }
105 |
106 | for( uint16_t i = 0; i < length; ++i )
107 | {
108 | crc ^= ( uint32_t )buffer[i];
109 | for( uint16_t i = 0; i < 8; i++ )
110 | {
111 | crc = ( crc >> 1 ) ^ ( reversedPolynom & ~( ( crc & 0x01 ) - 1 ) );
112 | }
113 | }
114 |
115 | return ~crc;
116 | }
117 |
118 | uint32_t Crc32Init( void )
119 | {
120 | return 0xFFFFFFFF;
121 | }
122 |
123 | uint32_t Crc32Update( uint32_t crcInit, uint8_t *buffer, uint16_t length )
124 | {
125 | // The CRC calculation follows CCITT - 0x04C11DB7
126 | const uint32_t reversedPolynom = 0xEDB88320;
127 |
128 | // CRC initial value
129 | uint32_t crc = crcInit;
130 |
131 | if( buffer == NULL )
132 | {
133 | return 0;
134 | }
135 |
136 | for( uint16_t i = 0; i < length; ++i )
137 | {
138 | crc ^= ( uint32_t )buffer[i];
139 | for( uint16_t i = 0; i < 8; i++ )
140 | {
141 | crc = ( crc >> 1 ) ^ ( reversedPolynom & ~( ( crc & 0x01 ) - 1 ) );
142 | }
143 | }
144 | return crc;
145 | }
146 |
147 | uint32_t Crc32Finalize( uint32_t crc )
148 | {
149 | return ~crc;
150 | }
151 |
152 | #endif
--------------------------------------------------------------------------------
/src/driver/board-config.h:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file board-config.h
3 | *
4 | * \brief Board configuration
5 | *
6 | * \copyright Revised BSD License, see section \ref LICENSE.
7 | *
8 | * \code
9 | * ______ _
10 | * / _____) _ | |
11 | * ( (____ _____ ____ _| |_ _____ ____| |__
12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
13 | * _____) ) ____| | | || |_| ____( (___| | | |
14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15 | * (C)2013-2017 Semtech
16 | *
17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___
18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
21 | * embedded.connectivity.solutions===============
22 | *
23 | * \endcode
24 | *
25 | * \author Miguel Luis ( Semtech )
26 | *
27 | * \author Gregory Cristian ( Semtech )
28 | *
29 | * \author Daniel Jaeckle ( STACKFORCE )
30 | *
31 | * \author Johannes Bruder ( STACKFORCE )
32 | */
33 |
34 |
35 | #ifndef __BOARD_CONFIG_H__
36 | #define __BOARD_CONFIG_H__
37 |
38 | /*!
39 | * Defines the time required for the TCXO to wakeup [ms].
40 | */
41 |
42 | #define BOARD_TCXO_WAKEUP_TIME 5
43 |
44 | #if defined(WIFI_LORA_32_V3)||defined(WIFI_LORA_32_V4)||defined(WIRELESS_TRACKER)||defined(WIRELESS_TRACKER_V2)||defined(WIRELESS_STICK_V3)||defined(WIRELESS_STICK_LITE_V3)||defined(WIRELESS_PAPER)||defined(CAPSULE_SENSOR_V3)||defined(WIRELESS_SHELL_V3)||defined(Vision_Master_E_213)||defined(Vision_Master_E290)||defined(Vision_Master_T190)
45 |
46 | #define RADIO_DIO_1 14
47 | #define RADIO_NSS 8
48 | #define RADIO_RESET 12
49 | #define RADIO_BUSY 13
50 |
51 | #define LORA_CLK 9
52 | #define LORA_MISO 11
53 | #define LORA_MOSI 10
54 | #if defined(WIFI_LORA_32_V4)
55 | #define LORA_PA_POWER 7
56 | #define LORA_PA_EN 2
57 | #define LORA_PA_TX_EN 46
58 | #endif
59 | #if defined(WIRELESS_TRACKER_V2)
60 | #define LORA_PA_POWER 7
61 | #define LORA_PA_EN 4
62 | #define LORA_PA_TX_EN 46
63 | #endif
64 | #elif defined(WIFI_LORA_32_V2)||defined(WIRELESS_STICK)||defined(WIRELESS_STICK_LITE)||defined(WIRELESS_BRIDGE)
65 | #define RADIO_RESET 14
66 |
67 | #define LORA_MOSI 27
68 | #define LORA_MISO 19
69 | #define LORA_CLK 5
70 | #define RADIO_NSS 18
71 |
72 | #define RADIO_DIO_0 26
73 | #define RADIO_DIO_1 35 // GPIO35 -- SX127x's IRQ(Interrupt Request) V2
74 |
75 |
76 | #elif defined(WIFI_LORA_32_SX1262)
77 | #define RADIO_DIO_1 35
78 | #define RADIO_NSS 14
79 | #define RADIO_RESET 5
80 | #define RADIO_BUSY 34
81 |
82 | #define LORA_CLK 12
83 | #define LORA_MISO 15
84 | #define LORA_MOSI 13
85 |
86 | #elif defined(WIFI_LORA_32)
87 | #define RADIO_RESET 14
88 |
89 | #define LORA_MOSI 27
90 | #define LORA_MISO 19
91 | #define LORA_CLK 5
92 | #define RADIO_NSS 18
93 |
94 | #define RADIO_DIO_0 26
95 | #define RADIO_DIO_1 33 // GPIO35 -- SX127x's IRQ(Interrupt Request) V2
96 | #elif defined(WIRELESS_MINI_SHELL)
97 | #define RADIO_DIO_1 3
98 | #define RADIO_NSS 8
99 | #define RADIO_RESET 5
100 | #define RADIO_BUSY 4
101 |
102 | #define LORA_CLK 10
103 | #define LORA_MISO 6
104 | #define LORA_MOSI 7
105 | #endif
106 |
107 |
108 | #endif // __BOARD_CONFIG_H__
109 |
--------------------------------------------------------------------------------
/examples/VME290/GHXTC_Sensor_Display/sensor_th.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation GXHTC Sensors test example
2 | *
3 | * Function:
4 | * Read the temperature, humidity, and time displayed on the screen
5 | *
6 | * Description:
7 | * 1. This example use a quick link cable to connect gxhtv3 and read temperature and humidity through iic
8 | *
9 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32
10 | * Support: support@heltec.cn
11 | *
12 | * HelTec AutoMation, Chengdu, China
13 | * 成都惠利特自动化科技有限公司
14 | * https://www.heltec.org
15 | */
16 | #include "Wire.h"
17 | #include "GXHTC.h"
18 | #include "HT_DEPG0290BxS800FxX_BW.h"
19 | #include "images.h"
20 | #include
21 | #include "time.h"
22 | #include
23 |
24 | // Initialize the display
25 | DEPG0290BxS800FxX_BW display(5, 4, 3, 6, 2, 1, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency
26 | GXHTC gxhtc;
27 | char buffer[256];
28 | const char *ntpServer = "ntp.aliyun.com";
29 | const long gmtOffset_sec = 28800; // Time offset UTC+8
30 | const int daylightOffset_sec = 0;
31 | const char *ssid = "Your Wi-Fi SSID";
32 | const char *password = "Your Wi-Fi password";
33 |
34 | void setup() {
35 | Serial.begin(115200);
36 | pinMode(18, OUTPUT);
37 | digitalWrite(18, HIGH);
38 | gxhtc.begin(39, 38);
39 | display.init();
40 | display.clear();
41 | display.drawString(0, 0, "init >>> ");
42 | Serial.print("Connecting to ");
43 | display.drawString(0, 20, "Connecting to ... ");
44 | Serial.println(ssid);
45 | display.drawString(100, 20, ssid);
46 | WiFi.begin(ssid, password);
47 | uint8_t i = 0;
48 | while (WiFi.status() != WL_CONNECTED) {
49 | delay(500);
50 | Serial.print(".");
51 | display.drawString(i, 40, ".");
52 | i = i + 10;
53 | }
54 | Serial.println("");
55 | Serial.println("WiFi connected");
56 | display.drawString(0, 60, "WiFi connected");
57 | Serial.println("IP address: ");
58 | display.drawString(0, 90, "IP address: ");
59 | display.drawString(60, 90, WiFi.localIP().toString().c_str());
60 | Serial.println(WiFi.localIP());
61 | Serial.println("");
62 | Serial.println("WiFi Conected!");
63 | display.display();
64 | delay(1000);
65 | }
66 |
67 | void printLocalTime() {
68 | struct tm timeinfo;
69 | if (!getLocalTime(&timeinfo)) {
70 | Serial.println("Failed to obtain time");
71 | return;
72 | }
73 | display.setFont(ArialMT_Plain_10);
74 | char buffer[256];
75 | display.setFont(ArialMT_Plain_10);
76 | Serial.println(timeinfo.tm_hour);
77 | sprintf(buffer, "%d", timeinfo.tm_hour);
78 | display.drawString(10, 0, buffer);
79 | display.drawString(25, 0, ": ");
80 | sprintf(buffer, "%d", timeinfo.tm_min);
81 | Serial.println(timeinfo.tm_min);
82 | display.drawString(30, 0, buffer);
83 | Serial.println(timeinfo.tm_mon);
84 | display.setFont(ArialMT_Plain_16);
85 | sprintf(buffer, "%d", timeinfo.tm_year + 1900);
86 | display.drawString(190, 110, buffer);
87 | display.drawString(225, 110, "/");
88 | sprintf(buffer, "%d", timeinfo.tm_mon + 1);
89 | display.drawString(230, 110, buffer);
90 | display.drawString(240, 110, "/");
91 | sprintf(buffer, "%d", timeinfo.tm_mday);
92 | Serial.println(timeinfo.tm_mday);
93 | display.drawString(245, 110, buffer);
94 | Serial.println(timeinfo.tm_mday);
95 | }
96 |
97 | void GetNetTime() {
98 | configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
99 | printLocalTime();
100 | }
101 |
102 | void read_th() {
103 | gxhtc.read_data();
104 | Serial.print("Temperature:");
105 | Serial.print(gxhtc.g_temperature);
106 | display.setFont(ArialMT_Plain_24);
107 | sprintf(buffer, "%.2f", gxhtc.g_temperature);
108 | display.drawXbm(42, 55,10,17,temp);
109 | display.drawString(53, 50, buffer);
110 | Serial.print(" Humidity:");
111 | Serial.println(gxhtc.g_humidity);
112 | sprintf(buffer, "%.2f", gxhtc.g_humidity);
113 | display.drawXbm(151, 55,11,16,hum);
114 | display.drawString(167, 50, buffer);
115 | Serial.printf("id = %X\r\n", gxhtc.read_id());
116 | }
117 |
118 | void loop() {
119 | display.clear();
120 | display.drawLine(0, 15, 296, 15);
121 | read_th();
122 | GetNetTime();
123 | display.display();
124 | delay(30000);
125 | }
126 |
--------------------------------------------------------------------------------
/examples/VME213/Part_Simple/images.h:
--------------------------------------------------------------------------------
1 | //Image usage https://resource.heltec.cn/image-to-hex Conversion, open Mirror, Rotation angle 270
2 | //Try to have the length and width of the image as multiples of 8 as much as possible
3 | //Set the image height to be divided by 8, In this example, 32/8=4,由于旋转270°
4 |
5 | // width: 32, height: 14
6 | const unsigned char num0[] PROGMEM = {
7 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x3f, 0xfe, 0x3f, 0xff, 0x00, 0x00, 0x7f, 0xff, 0x80, 0x00, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff};
8 | // width: 32, height: 14
9 | const unsigned char num1[] PROGMEM = {
10 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0xcf, 0xff, 0x3f, 0xff, 0xcf, 0xff, 0x3f, 0xff, 0x80, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
11 | const unsigned char num2[] PROGMEM = {
12 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xfe, 0x3f, 0xff, 0x87, 0xfc, 0x3f, 0xff, 0x1f, 0xf8, 0x3f, 0xff, 0x3f, 0xf0, 0x3f, 0xfe, 0x3f, 0xe4, 0x3f, 0xfe, 0x3f, 0xcc, 0x3f, 0xfe, 0x1f, 0x1c, 0x3f, 0xfe, 0x00, 0x3c, 0x3f, 0xff, 0x00, 0x7c, 0x3f, 0xff, 0x80, 0xfc, 0x3f, 0xff, 0xc3, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
13 | // width: 32, height: 14
14 | const unsigned char num3[] PROGMEM = {
15 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0x8f, 0xfc, 0x7f, 0xff, 0x3f, 0xfc, 0x3f, 0xff, 0x3e, 0x7e, 0x3f, 0xfe, 0x3c, 0x7f, 0x3f, 0xfe, 0x38, 0x7f, 0x3f, 0xfe, 0x00, 0x3e, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xff, 0x06, 0x00, 0xff, 0xff, 0xde, 0x01, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
16 | // width: 32, height: 14
17 | const unsigned char num4[] PROGMEM = {
18 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0x87, 0xff, 0xff, 0xfe, 0x27, 0xff, 0xff, 0xfc, 0xe7, 0xff, 0xff, 0xf1, 0xe7, 0xff, 0xff, 0xe7, 0xe7, 0xff, 0xff, 0x80, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff};
19 | // width: 32, height: 14
20 | const unsigned char num5[] PROGMEM = {
21 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x00, 0x7c, 0x7f, 0xff, 0x00, 0x7c, 0x3f, 0xff, 0x1c, 0x7e, 0x3f, 0xff, 0x1c, 0x7f, 0x3f, 0xff, 0x1c, 0x7f, 0x3f, 0xff, 0x1c, 0x3f, 0x7f, 0xff, 0x1c, 0x00, 0x7f, 0xfe, 0x1c, 0x00, 0x7f, 0xfe, 0x3e, 0x00, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
22 | // width: 32, height: 14
23 | const unsigned char num6[] PROGMEM = {
24 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x03, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xe0, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x7f, 0xff, 0x80, 0xfe, 0x7f, 0xff, 0x0c, 0xff, 0x3f, 0xff, 0x1c, 0xff, 0x3f, 0xff, 0x3c, 0x7e, 0x3f, 0xfe, 0x7c, 0x00, 0x7f, 0xfe, 0x7e, 0x00, 0x7f, 0xff, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff};
25 | // width: 32, height: 14
26 | const unsigned char num7[] PROGMEM = {
27 | 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xfc, 0x3f, 0xfe, 0x1f, 0xf0, 0x3f, 0xfe, 0x1f, 0xc0, 0x7f, 0xfe, 0x1e, 0x01, 0xff, 0xfe, 0x18, 0x0f, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0xfe, 0x01, 0xff, 0xff, 0xfe, 0x0f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
28 | // width: 32, height: 14
29 | const unsigned char num8[] PROGMEM = {
30 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xe1, 0xff, 0xff, 0x81, 0xc0, 0xff, 0xff, 0x00, 0x80, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xfe, 0x78, 0x3f, 0x3f, 0xfe, 0xfc, 0x3f, 0x3f, 0xfe, 0x7c, 0x1f, 0x3f, 0xfe, 0x7c, 0x1f, 0x3f, 0xff, 0x00, 0x06, 0x7f, 0xff, 0x01, 0x00, 0x7f, 0xff, 0x83, 0x80, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff};
31 | // width: 32, height: 14
32 | const unsigned char num9[] PROGMEM = {
33 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0x80, 0x7f, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0xff, 0x00, 0x3f, 0x7f, 0xfe, 0x7f, 0x1e, 0x7f, 0xfe, 0xff, 0x9c, 0x7f, 0xfe, 0x7f, 0xb0, 0xff, 0xfe, 0x3f, 0x01, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff};
--------------------------------------------------------------------------------
/src/chsc6x.cpp:
--------------------------------------------------------------------------------
1 | #include "chsc6x.h"
2 |
3 |
4 |
5 |
6 | int chsc6x::chsc6x_read_touch_info(uint16_t *touchX, uint16_t *touchY)
7 | {
8 | int ret;
9 | uint8_t i, point_num;
10 | uint8_t rd_len = 16;
11 | uint8_t rd_buf[24] = { 0 };
12 | struct ts_event events[CHSC6X_MAX_POINTS_NUM];
13 | memset(&events, 0, sizeof(events));
14 |
15 | ret = chsc6x_read_bytes_u8addr(_i2c_addr, 0x0, rd_buf, rd_len);
16 | if( 0 != ret)
17 | {
18 | chsc6x_err("chsc6x: chsc6x_read_touch_info iic err! rd_len=%d, ret=%d \r\n", rd_len, ret);
19 | return -OS_ERROR;
20 | }
21 |
22 | point_num = rd_buf[2] & 0x07;
23 |
24 | if((0 == rd_buf[2] && 0 == rd_buf[3] && 0 == rd_buf[4] && 0 == rd_buf[6]) || \
25 | (0xff== rd_buf[2] && 0xff == rd_buf[3] && 0xff == rd_buf[4] && 0xff == rd_buf[6]))
26 | {
27 | return -OS_ERROR;
28 | }
29 |
30 | for (i = 0; i < CHSC6X_MAX_POINTS_NUM; i++)
31 | {
32 | if ((rd_buf[6 * i + 3] & 0xc0) == 0xc0)
33 | {
34 | continue;
35 | }
36 | events[i].x = (uint16_t) (rd_buf[6 * i + 3] & 0x0F) << 8 | (uint16_t) rd_buf[6 * i + 4];
37 | events[i].y= (uint16_t) (rd_buf[6 * i + 5] & 0x0F) << 8 | (uint16_t) rd_buf[6 * i + 6];
38 | events[i].flag = rd_buf[6 * i + 3] >> 4;
39 | events[i].id = rd_buf[6 * i + 5] >> 4;
40 | }
41 | if(point_num==0)
42 | {
43 | return -1;
44 | }
45 | *touchX = events[0].x;
46 | *touchY = events[0].y;
47 | static uint32_t num_n=0;
48 | // if(((num_n++)%100)==0)
49 | {
50 | chsc6x_info("chsc6x: point_num:%d, X1:%d, Y1:%d, flag1:%d, id1:%d; \r\n", \
51 | point_num, events[0].x, events[0].y, events[0].flag, events[0].id);
52 | chsc6x_info("chsc6x: point_num:%d, X2:%d, Y2:%d, flag2:%d, id2:%d; \r\n", \
53 | point_num, events[1].x, events[1].y, events[1].flag, events[1].id);
54 |
55 | if(0 == point_num)
56 | {
57 | chsc6x_info("chsc6x: all point up\r\n");
58 | }
59 | }
60 |
61 | return OS_OK;
62 | }
63 |
64 | #if CHSC6X_GESTURE
65 | void chsc6x::chsc6x_gesture_check(void)
66 | {
67 | uint8_t buft[1] = {0};
68 | chsc6x_tp_reset(HW_CMD_RESET);
69 | if(OS_OK == chsc6x_write_bytes_u16addr(CHSC6X_I2C_ID, 0xD001, buft, 0))//0xd000-disable
70 | {
71 | g_gesture_status = 1;
72 | real_suspend_flag = 1;
73 | chsc6x_info("chsc6x: enable gesture check succeed \r\n");
74 | }
75 | else
76 | {
77 | chsc6x_err("chsc6x: enable gesture check failed! \r\n");
78 | }
79 |
80 | }
81 | uint8_t chsc6x::chsc6x_get_gesture(void)
82 | {
83 | uint8_t rd_buf[24] = { 0 };
84 | if(g_gesture_enable && g_gesture_status)
85 | {
86 | chsc6x_read_bytes_u8addr(_i2c_addr, 0xd3, rd_buf, 4);
87 | chsc6x_info("chsc6x : gesture_id:%x; \r\n", rd_buf[0]);
88 | return rd_buf[0];
89 | }
90 | return 0;
91 | }
92 | #endif
93 |
94 |
95 |
96 |
97 |
98 | void chsc6x::chsc6x_resume(void) //Call when the display lights up
99 | {
100 | chsc6x_info("chsc6x_resume enter.\r\n");
101 |
102 | #if CHSC6X_GESTURE
103 | if(1 == g_gesture_enable)
104 | {
105 | g_gesture_status = 0;
106 | }
107 | #endif
108 | chsc6x_tp_reset(HW_CMD_RESET);
109 | real_suspend_flag = 0;
110 | }
111 |
112 | void chsc6x::chsc6x_suspend(void) //Call when the display is off
113 | {
114 | uint8_t buff[1] = {0};
115 |
116 | #if CHSC6X_GESTURE
117 | if(1 == g_gesture_enable)
118 | {
119 | chsc6x_gesture_check();
120 | return;
121 | }
122 | #endif
123 | chsc6x_tp_reset(HW_CMD_RESET);
124 | if(OS_OK == chsc6x_write_bytes_u16addr(CHSC6X_I2C_ID, 0xA503, buff, 0))
125 | {
126 | real_suspend_flag = 1;
127 | chsc6x_info("chsc6x: enter suspend succeed! \r\n");
128 | }else{
129 | chsc6x_err("chsc6x: enter suspend failed! \r\n");
130 | }
131 | }
132 |
133 | void chsc6x::chsc6x_init(void)
134 | {
135 | struct sm_touch_dev st_dev;
136 | memset(&st_dev, 0, sizeof(st_dev));
137 | st_dev.int_pin = semi_touch_get_int();
138 | st_dev.rst_pin = semi_touch_get_rst();
139 | semi_rst_pin_high(st_dev.rst_pin);
140 | semi_touch_i2c_init();
141 | chsc6x_msleep(60);
142 | chsc6x_tp_reset(HW_CMD_RESET);
143 | }
144 |
--------------------------------------------------------------------------------
/examples/VME213/sensor_th/sensor_th.ino:
--------------------------------------------------------------------------------
1 | /* Heltec Automation GXHTC Sensors test example
2 | *
3 | * Function:
4 | * Read the temperature, humidity, and time displayed on the screen
5 | *
6 | * Description:
7 | * 1. This example use a quick link cable to connect gxhtv3 and read temperature and humidity through iic
8 | *
9 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32
10 | * Support: support@heltec.cn
11 | *
12 | * HelTec AutoMation, Chengdu, China
13 | * 成都惠利特自动化科技有限公司
14 | * https://www.heltec.org
15 | */
16 | #include "Wire.h"
17 | #include "GXHTC.h"
18 | #include "HT_lCMEN2R13EFC1.h"
19 | #include "img.h"
20 | #include
21 | #include "time.h"
22 | #include
23 | // Initialize the display
24 | HT_ICMEN2R13EFC1 display(3, 2, 5, 1, 4, 6, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency
25 | GXHTC gxhtc;
26 |
27 | char buffer[256];
28 | const char *ntpServer = "ntp.aliyun.com";
29 | const long gmtOffset_sec = 28800; // time offset
30 | const int daylightOffset_sec = 0;
31 | const char *ssid = "Your Wi-Fi SSID";
32 | const char *password = "Your Wi-Fi password";
33 |
34 | void printLocalTime()
35 | {
36 | struct tm timeinfo;
37 | if (!getLocalTime(&timeinfo))
38 | {
39 | Serial.println("Failed to obtain time");
40 | return;
41 | }
42 | display.setFont(ArialMT_Plain_10);
43 | char buffer[256];
44 | display.setFont(ArialMT_Plain_10);
45 | Serial.println(timeinfo.tm_hour);
46 | sprintf(buffer, "%d", timeinfo.tm_hour);
47 | display.drawString(10, 0, buffer);
48 | display.drawString(25, 0, ": ");
49 | sprintf(buffer, "%d", timeinfo.tm_min);
50 | Serial.println(timeinfo.tm_min);
51 | display.drawString(30, 0, buffer);
52 | Serial.println(timeinfo.tm_mon);
53 | display.setFont(ArialMT_Plain_16);
54 | sprintf(buffer, "%d", timeinfo.tm_year + 1900);
55 | display.drawString(160, 100, buffer);
56 | display.drawString(195, 100, "/");
57 | sprintf(buffer, "%d", timeinfo.tm_mon + 1);
58 | display.drawString(200, 100, buffer);
59 | display.drawString(210, 100, "/");
60 | sprintf(buffer, "%d", timeinfo.tm_mday);
61 | Serial.println(timeinfo.tm_mday);
62 | display.drawString(215, 100, buffer);
63 | Serial.println(timeinfo.tm_mday);
64 | }
65 |
66 | void GetNetTime()
67 | {
68 | configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
69 | printLocalTime();
70 | }
71 |
72 | void read_th()
73 | {
74 | gxhtc.read_data();
75 | Serial.print("Temperature:");
76 | Serial.print(gxhtc.g_temperature);
77 | display.setFont(ArialMT_Plain_24);
78 | sprintf(buffer, "%.2f", gxhtc.g_temperature);
79 | display.drawXbm(18, 55, 10, 17, temp);
80 | display.drawString(30, 50, "28.2 C");
81 | Serial.print(" Humidity:");
82 | Serial.println(gxhtc.g_humidity);
83 | sprintf(buffer, "%.2f", gxhtc.g_humidity);
84 | display.drawXbm(128, 55, 11, 16, hum);
85 | display.drawString(142, 50, "69 %");
86 | Serial.printf("id = %X\r\n", gxhtc.read_id());
87 | }
88 |
89 | void setup()
90 | {
91 | Serial.begin(115200);
92 | pinMode(18, OUTPUT);
93 | digitalWrite(18, HIGH);
94 | gxhtc.begin(39, 38);
95 | display.init();
96 | display.clear();
97 | display.update(COLOR_BUFFER);
98 | display.drawString(0, 0, "init >>> ");
99 | Serial.print("Connecting to ");
100 | display.drawString(0, 20, "Connecting to ... ");
101 | Serial.println(ssid);
102 | display.drawString(100, 20, ssid);
103 | WiFi.begin(ssid, password);
104 | uint8_t i = 0;
105 | while (WiFi.status() != WL_CONNECTED)
106 | {
107 | delay(500);
108 | Serial.print(".");
109 | display.drawString(i, 40, ".");
110 | i = i + 10;
111 | }
112 | Serial.println("");
113 | Serial.println("WiFi connected");
114 | display.drawString(0, 60, "WiFi connected");
115 | Serial.println("IP address: ");
116 | display.drawString(0, 90, "IP address: ");
117 | display.drawString(60, 90, WiFi.localIP().toString().c_str());
118 | Serial.println(WiFi.localIP());
119 | Serial.println("");
120 | Serial.println("WiFi Conected!");
121 | display.update(COLOR_BUFFER);
122 | display.display();
123 | delay(1000);
124 | }
125 |
126 | void loop()
127 | {
128 | display.clear();
129 | display.drawLine(0, 15, 250, 15);
130 | read_th();
131 | GetNetTime();
132 | display.update(COLOR_BUFFER);
133 | display.display();
134 | delay(30000);
135 | }
136 |
--------------------------------------------------------------------------------
/src/driver/gpio.h:
--------------------------------------------------------------------------------
1 | /*!
2 | * \file gpio.h
3 | *
4 | * \brief GPIO driver implementation
5 | *
6 | * \remark: Relies on the specific board GPIO implementation as well as on
7 | * IO expander driver implementation if one is available on the target
8 | * board.
9 | *
10 | * \copyright Revised BSD License, see section \ref LICENSE.
11 | *
12 | * \code
13 | * ______ _
14 | * / _____) _ | |
15 | * ( (____ _____ ____ _| |_ _____ ____| |__
16 | * \____ \| ___ | (_ _) ___ |/ ___) _ \
17 | * _____) ) ____| | | || |_| ____( (___| | | |
18 | * (______/|_____)_|_|_| \__)_____)\____)_| |_|
19 | * (C)2013-2017 Semtech
20 | *
21 | * \endcode
22 | *
23 | * \author Miguel Luis ( Semtech )
24 | *
25 | * \author Gregory Cristian ( Semtech )
26 | */
27 |
28 | #ifndef __GPIO_H__
29 | #define __GPIO_H__
30 |
31 | #include
32 |
33 |
34 | /*!
35 | * Add a pull-up, a pull-down or nothing on the GPIO line
36 | */
37 | typedef enum
38 | {
39 | PIN_NO_PULL = 0,
40 | PIN_PULL_UP,
41 | PIN_PULL_DOWN
42 | }PinTypes;
43 |
44 | /*!
45 | * Define the GPIO as Push-pull type or Open Drain
46 | */
47 | typedef enum
48 | {
49 | PIN_PUSH_PULL = 0,
50 | PIN_OPEN_DRAIN
51 | }PinConfigs;
52 |
53 | /*!
54 | * Define the GPIO IRQ on a rising, falling or both edges
55 | */
56 | typedef enum
57 | {
58 | NO_IRQ = 0,
59 | IRQ_RISING_EDGE,
60 | IRQ_FALLING_EDGE,
61 | IRQ_RISING_FALLING_EDGE
62 | }IrqModes;
63 |
64 | /*!
65 | * Define the IRQ priority on the GPIO
66 | */
67 | typedef enum
68 | {
69 | IRQ_VERY_LOW_PRIORITY = 0,
70 | IRQ_LOW_PRIORITY,
71 | IRQ_MEDIUM_PRIORITY,
72 | IRQ_HIGH_PRIORITY,
73 | IRQ_VERY_HIGH_PRIORITY
74 | }IrqPriorities;
75 |
76 | /*!
77 | * Structure for the GPIO
78 | */
79 | typedef struct
80 | {
81 | uint8_t pin;
82 | uint16_t pinIndex;
83 | void *port;
84 | uint16_t portIndex;
85 | PinTypes pull;
86 | }Gpio_t;
87 |
88 | /*!
89 | * GPIO IRQ handler function prototype
90 | */
91 | typedef void( GpioIrqHandler )( void );
92 |
93 | /*!
94 | * GPIO Expander IRQ handler function prototype
95 | */
96 | typedef void( GpioIoeIrqHandler )( void );
97 |
98 | /*!
99 | * \brief Initializes the given GPIO object
100 | *
101 | * \param [IN] obj Pointer to the GPIO object
102 | * \param [IN] pin Pin name ( please look in pinName-board.h file )
103 | * \param [IN] mode Pin mode [PIN_INPUT, PIN_OUTPUT,
104 | * PIN_ALTERNATE_FCT, PIN_ANALOGIC]
105 | * \param [IN] config Pin config [PIN_PUSH_PULL, PIN_OPEN_DRAIN]
106 | * \param [IN] type Pin type [PIN_NO_PULL, PIN_PULL_UP, PIN_PULL_DOWN]
107 | * \param [IN] value Default output value at initialization
108 | */
109 | void GpioInit( Gpio_t *obj, uint8_t pin, uint8_t mode, PinConfigs config, PinTypes type, uint32_t value );
110 |
111 | /*!
112 | * \brief GPIO IRQ Initialization
113 | *
114 | * \param [IN] obj Pointer to the GPIO object
115 | * \param [IN] irqMode IRQ mode [NO_IRQ, IRQ_RISING_EDGE,
116 | * IRQ_FALLING_EDGE, IRQ_RISING_FALLING_EDGE]
117 | * \param [IN] irqPriority IRQ priority [IRQ_VERY_LOW_PRIORITY, IRQ_LOW_PRIORITY
118 | * IRQ_MEDIUM_PRIORITY, IRQ_HIGH_PRIORITY
119 | * IRQ_VERY_HIGH_PRIORITY]
120 | * \param [IN] irqHandler Callback function pointer
121 | */
122 | void GpioSetInterrupt( Gpio_t *obj, IrqModes irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler );
123 |
124 | /*!
125 | * \brief Removes the interrupt from the object
126 | *
127 | * \param [IN] obj Pointer to the GPIO object
128 | */
129 | void GpioRemoveInterrupt( Gpio_t *obj );
130 |
131 | /*!
132 | * \brief Writes the given value to the GPIO output
133 | *
134 | * \param [IN] obj Pointer to the GPIO object
135 | * \param [IN] value New GPIO output value
136 | */
137 | void GpioWrite( Gpio_t *obj, uint32_t value );
138 |
139 | /*!
140 | * \brief Toggle the value to the GPIO output
141 | *
142 | * \param [IN] obj Pointer to the GPIO object
143 | */
144 | void GpioToggle( Gpio_t *obj );
145 |
146 | /*!
147 | * \brief Reads the current GPIO input value
148 | *
149 | * \param [IN] obj Pointer to the GPIO object
150 | * \retval value Current GPIO input value
151 | */
152 | uint32_t GpioRead( Gpio_t *obj );
153 |
154 | #endif // __GPIO_H__
155 |
--------------------------------------------------------------------------------
/src/chsc6x_platform.cpp:
--------------------------------------------------------------------------------
1 | #include "chsc6x_platform.h"
2 |
3 | int chsc6x_platform::semi_touch_i2c_init(void)
4 | {
5 | //power on
6 | if((_sda_pin != -1) && (_scl_pin != -1))
7 | {
8 | _wire->begin(_sda_pin,_scl_pin,400000);
9 | }
10 | else
11 | {
12 | _wire->begin();
13 | }
14 | // _wire->begin(TOUCH_SDA_PIN,TOUCH_SCL_PIN,400000);
15 | return 0;
16 | }
17 |
18 | int chsc6x_platform::i2cRead(uint8_t i2c_adr, uint16_t reg_adr, uint8_t *rxbuf, uint16_t lenth)
19 | {
20 | uint8_t buf[2];
21 | uint8_t reg_adr_len,num = 0;
22 | if(rxbuf == NULL || lenth == 0)
23 | {
24 | return -OS_ERROR;
25 | }
26 | if(reg_adr > 0xFF )
27 | {
28 | buf[0] = (uint8_t) (reg_adr >> 8);
29 | buf[1] = (uint8_t) reg_adr ;
30 | reg_adr_len = 2;
31 | }
32 | else
33 | {
34 | buf[0] = (uint8_t) reg_adr ;
35 | reg_adr_len = 1;
36 | }
37 |
38 | _wire->beginTransmission(i2c_adr); // start transmission to device
39 | _wire->write(buf,reg_adr_len); // sends register address to read from
40 | _wire->endTransmission(0); // end transmission
41 |
42 | _wire->requestFrom(i2c_adr,lenth,true);// send data n-bytes read
43 | while(_wire->available() && (num < lenth))
44 | {
45 | rxbuf[num++] = _wire->read(); // receive DATA
46 | }
47 | return num;
48 | }
49 |
50 | int chsc6x_platform::i2cSend(uint8_t i2c_adr, uint16_t reg_adr, uint8_t *txbuf, uint16_t lenth)
51 | {
52 | uint8_t buffer[MAX_IIC_WR_LEN+2] = {0};
53 | if (NULL==txbuf|| lenth>MAX_IIC_WR_LEN)
54 | {
55 | return -OS_ERROR;
56 | }
57 | buffer[0] = reg_adr >> 8;
58 | buffer[1] = reg_adr;
59 | memcpy(&buffer[2], txbuf, lenth);
60 |
61 | _wire->beginTransmission(i2c_adr);
62 | _wire->write(buffer, lenth+2);
63 | _wire->endTransmission();
64 | return lenth+2;
65 | }
66 |
67 | int chsc6x_platform::chsc6x_read_bytes_u8addr(uint8_t id, uint8_t adr, uint8_t *rxbuf, uint16_t lenth)
68 | {
69 | int ret = i2cRead(id,adr,rxbuf,lenth);
70 | if(ret == lenth) {
71 | return OS_OK;
72 | }else{
73 | return -OS_ERROR;
74 | }
75 | }
76 |
77 | int chsc6x_platform::chsc6x_write_bytes_u16addr(uint8_t id, uint16_t adr, uint8_t *txbuf, uint16_t lenth)
78 | {
79 | int ret = i2cSend(id,adr,txbuf,lenth);
80 | if(ret == lenth+2) {
81 | return OS_OK;
82 | }else{
83 | return -OS_ERROR;
84 | }
85 | }
86 |
87 | int chsc6x_platform::chsc6x_read_bytes_u16addr(uint8_t id, uint16_t adr, uint8_t *rxbuf, uint16_t lenth)
88 | {
89 | int ret = i2cRead(id,adr,rxbuf,lenth);
90 | if(ret == lenth) {
91 | return OS_OK;
92 | }else{
93 | return -OS_ERROR;
94 | }
95 | }
96 |
97 | void chsc6x_platform::chsc6x_msleep(int ms)
98 | {
99 | delay(ms);
100 | }
101 |
102 | void chsc6x_platform::chsc6x_tp_reset_delay(chsc6x_reset_e type)
103 | {
104 | switch (type)
105 | {
106 | case HW_CMD_RESET:
107 | chsc6x_msleep(30);
108 | break;
109 |
110 | case HW_ACTIVE_RESET:
111 | chsc6x_msleep(2);
112 | break;
113 |
114 | default:
115 | break;
116 | }
117 |
118 | }
119 |
120 | int chsc6x_platform::chsc6x_tp_reset(chsc6x_reset_e type)
121 | {
122 | if (RESET_NONE >= type || RESET_MAX <= type)
123 | {
124 | return -OS_ERROR;
125 | }
126 | if(_rst_pin != -1) {
127 | semi_rst_pin_low(_rst_pin);
128 | chsc6x_msleep(20);
129 | semi_rst_pin_high(_rst_pin);
130 | chsc6x_tp_reset_delay(type);
131 | }
132 | return OS_OK;
133 | }
134 |
135 | bool Touch_state = false;
136 | void blink() {
137 | Touch_state = !Touch_state;
138 | }
139 | /* GPIO-INT*/
140 | int chsc6x_platform::semi_touch_get_int(void)
141 | {
142 | if(_int_pin != -1) {
143 | pinMode(_int_pin, INPUT_PULLUP);
144 | attachInterrupt(digitalPinToInterrupt(_int_pin), blink, RISING);
145 | }
146 | return _int_pin;
147 | }
148 |
149 | /* GPIO-RST*/
150 | int chsc6x_platform::semi_touch_get_rst(void)
151 | {
152 | if(_rst_pin != -1) {
153 | pinMode(_rst_pin,OUTPUT);
154 | digitalWrite(_rst_pin, HIGH);
155 | }
156 | return _rst_pin;
157 | }
158 |
159 | void chsc6x_platform::semi_rst_pin_low(int pin)
160 | {
161 | pinMode(pin,OUTPUT);
162 | digitalWrite(pin, LOW);
163 | }
164 |
165 | void chsc6x_platform::semi_rst_pin_high(int pin)
166 | {
167 | pinMode(pin,OUTPUT);
168 | digitalWrite(pin, HIGH);
169 | }
170 |
--------------------------------------------------------------------------------