Update examples

This commit is contained in:
Felix Rusu 2021-01-19 12:48:53 -05:00
parent f3f394b7f9
commit 279282b51f
2 changed files with 13 additions and 8 deletions

View File

@ -3,7 +3,7 @@
#include <SPIFlash.h> //https://github.com/lowpowerlab/spiflash
#include <SPI.h>
#define SERIAL_ENABLE
#define SERIAL_BAUD 115200
#define BLINK_FAST_DELAY 50
#define BLINK_SLOW_DELAY 1000
@ -12,15 +12,14 @@ int LEDTIME = 500;
// the setup routine runs once when you press reset:
void setup() {
#ifdef SERIAL_ENABLE
Serial.begin(115200);
delay(2000); //wait a bit until SerialMonitor can be opened
#ifdef SERIAL_BAUD
Serial.begin(SERIAL_BAUD);
while (!Serial) delay(100); //wait until Serial/monitor is opened
#endif
pinMode(LED_BUILTIN, OUTPUT);
//ensure the radio module CS pin is pulled HIGH or it might interfere!
pinMode(SS, OUTPUT);
digitalWrite(SS, HIGH);
pinMode(SS, OUTPUT); digitalWrite(SS, HIGH);
//ensure FLASH chip is not sleep mode (unresponsive)
flash.wakeup();

View File

@ -53,9 +53,17 @@ uint16_t expectedDeviceID=0xEF30;
SPIFlash flash(SS_FLASHMEM, expectedDeviceID);
void setup(){
#ifdef SERIAL_BAUD
Serial.begin(SERIAL_BAUD);
while (!Serial) delay(100); //wait until Serial/monitor is opened
#endif
pinMode(LED_BUILTIN, OUTPUT);
Serial.print("Start...");
//ensure the radio module CS pin is pulled HIGH or it might interfere!
pinMode(SS, OUTPUT); digitalWrite(SS, HIGH);
if (flash.initialize())
{
Serial.println("Init OK!");
@ -134,14 +142,12 @@ void loop(){
if ((int)(millis()/500) > lastPeriod)
{
lastPeriod++;
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, lastPeriod%2);
}
}
void Blink(int DELAY_MS, byte loops)
{
pinMode(LED_BUILTIN, OUTPUT);
while (loops--)
{
digitalWrite(LED_BUILTIN,HIGH);