forked from Xinyuan-LilyGO/LilyGo-LoRa-Series
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
puppy
committed
Jan 16, 2024
1 parent
0b1a133
commit a61bb34
Showing
803 changed files
with
491,315 additions
and
411 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
examples/Display/GxEPD_U8G2_Fonts_Demo/GxEPD_U8G2_Fonts_Demo.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
LilyGo Ink Screen Series u8g2Fonts Test | ||
- Created by Lewis he | ||
*/ | ||
|
||
// According to the board, cancel the corresponding macro definition | ||
// #define LILYGO_T5_V213 | ||
// #define LILYGO_T5_V22 | ||
// #define LILYGO_T5_V24 | ||
// #define LILYGO_T5_V28 | ||
// #define LILYGO_T5_V266 | ||
// #define LILYGO_EPD_DISPLAY_102 | ||
// #define LILYGO_EPD_DISPLAY_154 | ||
#define LILYGO_T3_S3_E_PAPER_V_1_0 | ||
|
||
#include <GxEPD.h> | ||
|
||
#if defined(LILYGO_T5_V102) || defined(LILYGO_EPD_DISPLAY_102) | ||
#include <GxGDGDEW0102T4/GxGDGDEW0102T4.h> //1.02" b/w | ||
#elif defined(LILYGO_T5_V266) | ||
#include <GxDEPG0266BN/GxDEPG0266BN.h> // 2.66" b/w form DKE GROUP | ||
#elif defined(LILYGO_T5_V213) | ||
#include <GxDEPG0213BN/GxDEPG0213BN.h> // 2.13" b/w form DKE GROUP | ||
#elif defined(LILYGO_T3_S3_E_PAPER_V_1_0) | ||
#include <GxDEPG0213BN/GxDEPG0213BN.h> // 2.13" b/w form DKE GROUP | ||
#else | ||
// #include <GxDEPG0097BW/GxDEPG0097BW.h> // 0.97" b/w form DKE GROUP | ||
// #include <GxGDGDEW0102T4/GxGDGDEW0102T4.h> //1.02" b/w | ||
// #include <GxGDEW0154Z04/GxGDEW0154Z04.h> // 1.54" b/w/r 200x200 | ||
// #include <GxGDEW0154Z17/GxGDEW0154Z17.h> // 1.54" b/w/r 152x152 | ||
// #include <GxGDEH0154D67/GxGDEH0154D67.h> // 1.54" b/w | ||
// #include <GxDEPG0150BN/GxDEPG0150BN.h> // 1.51" b/w form DKE GROUP | ||
// #include <GxDEPG0266BN/GxDEPG0266BN.h> // 2.66" b/w form DKE GROUP | ||
// #include <GxDEPG0290R/GxDEPG0290R.h> // 2.9" b/w/r form DKE GROUP | ||
// #include <GxDEPG0290B/GxDEPG0290B.h> // 2.9" b/w form DKE GROUP | ||
// #include <GxGDEW029Z10/GxGDEW029Z10.h> // 2.9" b/w/r form GoodDisplay | ||
// #include <GxGDEW0213Z16/GxGDEW0213Z16.h> // 2.13" b/w/r form GoodDisplay | ||
// #include <GxGDE0213B1/GxGDE0213B1.h> // 2.13" b/w old panel , form GoodDisplay | ||
// #include <GxGDEH0213B72/GxGDEH0213B72.h> // 2.13" b/w old panel , form GoodDisplay | ||
// #include <GxGDEH0213B73/GxGDEH0213B73.h> // 2.13" b/w old panel , form GoodDisplay | ||
// #include <GxGDEM0213B74/GxGDEM0213B74.h> // 2.13" b/w form GoodDisplay 4-color | ||
// #include <GxGDEW0213M21/GxGDEW0213M21.h> // 2.13" b/w Ultra wide temperature , form GoodDisplay | ||
// #include <GxDEPG0213BN/GxDEPG0213BN.h> // 2.13" b/w form DKE GROUP | ||
// #include <GxGDEW027W3/GxGDEW027W3.h> // 2.7" b/w form GoodDisplay | ||
// #include <GxGDEW027C44/GxGDEW027C44.h> // 2.7" b/w/r form GoodDisplay | ||
// #include <GxGDEH029A1/GxGDEH029A1.h> // 2.9" b/w form GoodDisplay | ||
// #include <GxDEPG0750BN/GxDEPG0750BN.h> // 7.5" b/w form DKE GROUP | ||
#endif | ||
|
||
#include <U8g2_for_Adafruit_GFX.h> | ||
#include <GxIO/GxIO_SPI/GxIO_SPI.h> | ||
#include <GxIO/GxIO.h> | ||
#include <WiFi.h> | ||
|
||
#define EDP_BUSY_PIN 48 | ||
#define EDP_RSET_PIN 47 | ||
#define EDP_DC_PIN 16 | ||
#define EDP_CS_PIN 15 | ||
#define EDP_CLK_PIN 14 // CLK | ||
#define EDP_MOSI_PIN 11 // MOSI | ||
#define EDP_MISO_PIN -1 | ||
|
||
#define USING_SOFT_SPI //Uncomment this line to use software SPI | ||
|
||
#if defined(USING_SOFT_SPI) | ||
GxIO_Class io(EDP_CLK_PIN, EDP_MISO_PIN, EDP_MOSI_PIN, EDP_CS_PIN, EDP_DC_PIN, EDP_RSET_PIN); | ||
#else | ||
GxIO_Class io(SPI, EDP_CS_PIN, EDP_DC_PIN, EDP_RSET_PIN); | ||
#endif | ||
GxEPD_Class display(io, EDP_RSET_PIN, EDP_BUSY_PIN); | ||
U8G2_FOR_ADAFRUIT_GFX u8g2Fonts; | ||
|
||
|
||
void setup(void) | ||
{ | ||
Serial.begin(115200); | ||
Serial.println(); | ||
Serial.println("setup"); | ||
|
||
#if defined(LILYGO_EPD_DISPLAY_102) | ||
pinMode(EPD_POWER_ENABLE, OUTPUT); | ||
digitalWrite(EPD_POWER_ENABLE, HIGH); | ||
#endif /*LILYGO_EPD_DISPLAY_102*/ | ||
|
||
SPI.begin(EDP_CLK_PIN, EDP_MISO_PIN, EDP_MOSI_PIN,EDP_CS_PIN); | ||
|
||
display.init(); // enable diagnostic output on Serial | ||
u8g2Fonts.begin(display); | ||
} | ||
|
||
void loop() | ||
{ | ||
u8g2Fonts.setFontMode(1); // use u8g2 transparent mode (this is default) | ||
u8g2Fonts.setFontDirection(3); // left to right (this is default) | ||
u8g2Fonts.setForegroundColor(GxEPD_BLACK); // apply Adafruit GFX color | ||
u8g2Fonts.setBackgroundColor(GxEPD_WHITE); // apply Adafruit GFX color | ||
|
||
u8g2Fonts.setFont(u8g2_font_helvR14_tf); // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall | ||
|
||
uint16_t x = GxEPD_WIDTH / 2 ; | ||
uint16_t y = GxEPD_HEIGHT / 2; | ||
|
||
display.fillScreen(GxEPD_WHITE); | ||
|
||
u8g2Fonts.setCursor(x, y); // start writing at this position | ||
u8g2Fonts.print("Hello World!"); | ||
|
||
u8g2Fonts.setFont(u8g2_font_unifont_t_chinese2); // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall | ||
u8g2Fonts.setCursor(x + 25, y + 32); | ||
u8g2Fonts.print("Hello LilyGo"); | ||
|
||
display.update(); | ||
delay(10000); | ||
} |
154 changes: 154 additions & 0 deletions
154
examples/RadioLibExamples/SX1262/SX1262_C6_Receive_interrupt/SX1262_C6_Receive_interrupt.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* | ||
RadioLib SX126x Receive with Interrupts Example | ||
This example listens for LoRa transmissions and tries to | ||
receive them. Once a packet is received, an interrupt is | ||
triggered. To successfully receive data, the following | ||
settings have to be the same on both transmitter | ||
and receiver: | ||
- carrier frequency | ||
- bandwidth | ||
- spreading factor | ||
- coding rate | ||
- sync word | ||
Other modules from SX126x family can also be used. | ||
For default module settings, see the wiki page | ||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem | ||
For full API reference, see the GitHub Pages | ||
https://jgromes.github.io/RadioLib/ | ||
*/ | ||
|
||
// include the library | ||
#include <RadioLib.h> | ||
|
||
#define RADIO_SCLK_PIN 6 | ||
#define RADIO_MISO_PIN 1 | ||
#define RADIO_MOSI_PIN 0 | ||
#define RADIO_CS_PIN 7 | ||
#define RADIO_DIO1_PIN 2 | ||
#define RADIO_BUSY_PIN 3 | ||
#define RADIO_RST_PIN 4 | ||
|
||
// SX1262 has the following connections: | ||
// NSS pin: 10 | ||
// DIO1 pin: 2 | ||
// NRST pin: 3 | ||
// BUSY pin: 9 | ||
SX1262 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN); | ||
// or using RadioShield | ||
// https://github.com/jgromes/RadioShield | ||
//SX1262 radio = RadioShield.ModuleA; | ||
|
||
// or using CubeCell | ||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN); | ||
// SPI.begin(5, 3, 6); | ||
// initialize SX1262 with default settings | ||
Serial.print(F("[SX1262] Initializing ... ")); | ||
int state = radio.begin(868); | ||
if (state == RADIOLIB_ERR_NONE) { | ||
Serial.println(F("success!")); | ||
} else { | ||
Serial.print(F("failed, code ")); | ||
Serial.println(state); | ||
while (true); | ||
} | ||
|
||
// set the function that will be called | ||
// when new packet is received | ||
radio.setDio1Action(setFlag); | ||
|
||
// start listening for LoRa packets | ||
Serial.print(F("[SX1262] Starting to listen ... ")); | ||
state = radio.startReceive(); | ||
if (state == RADIOLIB_ERR_NONE) { | ||
Serial.println(F("success!")); | ||
} else { | ||
Serial.print(F("failed, code ")); | ||
Serial.println(state); | ||
while (true); | ||
} | ||
|
||
// if needed, 'listen' mode can be disabled by calling | ||
// any of the following methods: | ||
// | ||
// radio.standby() | ||
// radio.sleep() | ||
// radio.transmit(); | ||
// radio.receive(); | ||
// radio.scanChannel(); | ||
} | ||
|
||
// flag to indicate that a packet was received | ||
volatile bool receivedFlag = false; | ||
|
||
// this function is called when a complete packet | ||
// is received by the module | ||
// IMPORTANT: this function MUST be 'void' type | ||
// and MUST NOT have any arguments! | ||
#if defined(ESP8266) || defined(ESP32) | ||
ICACHE_RAM_ATTR | ||
#endif | ||
void setFlag(void) { | ||
// we got a packet, set the flag | ||
receivedFlag = true; | ||
} | ||
|
||
void loop() { | ||
// check if the flag is set | ||
if(receivedFlag) { | ||
// reset flag | ||
receivedFlag = false; | ||
|
||
// you can read received data as an Arduino String | ||
String str; | ||
int state = radio.readData(str); | ||
|
||
// you can also read received data as byte array | ||
/* | ||
byte byteArr[8]; | ||
int numBytes = radio.getPacketLength(); | ||
int state = radio.readData(byteArr, numBytes); | ||
*/ | ||
|
||
if (state == RADIOLIB_ERR_NONE) { | ||
// packet was successfully received | ||
Serial.println(F("[SX1262] Received packet!")); | ||
|
||
// print data of the packet | ||
Serial.print(F("[SX1262] Data:\t\t")); | ||
Serial.println(str); | ||
|
||
// print RSSI (Received Signal Strength Indicator) | ||
Serial.print(F("[SX1262] RSSI:\t\t")); | ||
Serial.print(radio.getRSSI()); | ||
Serial.println(F(" dBm")); | ||
|
||
// print SNR (Signal-to-Noise Ratio) | ||
Serial.print(F("[SX1262] SNR:\t\t")); | ||
Serial.print(radio.getSNR()); | ||
Serial.println(F(" dB")); | ||
|
||
// print frequency error | ||
Serial.print(F("[SX1262] Frequency error:\t")); | ||
Serial.print(radio.getFrequencyError()); | ||
Serial.println(F(" Hz")); | ||
|
||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) { | ||
// packet was received, but is malformed | ||
Serial.println(F("CRC error!")); | ||
|
||
} else { | ||
// some other error occurred | ||
Serial.print(F("failed, code ")); | ||
Serial.println(state); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.