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

View File

@ -53,9 +53,17 @@ uint16_t expectedDeviceID=0xEF30;
SPIFlash flash(SS_FLASHMEM, expectedDeviceID); SPIFlash flash(SS_FLASHMEM, expectedDeviceID);
void setup(){ void setup(){
#ifdef SERIAL_BAUD
Serial.begin(SERIAL_BAUD); Serial.begin(SERIAL_BAUD);
while (!Serial) delay(100); //wait until Serial/monitor is opened
#endif
pinMode(LED_BUILTIN, OUTPUT);
Serial.print("Start..."); 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()) if (flash.initialize())
{ {
Serial.println("Init OK!"); Serial.println("Init OK!");
@ -134,14 +142,12 @@ void loop(){
if ((int)(millis()/500) > lastPeriod) if ((int)(millis()/500) > lastPeriod)
{ {
lastPeriod++; lastPeriod++;
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, lastPeriod%2); digitalWrite(LED_BUILTIN, lastPeriod%2);
} }
} }
void Blink(int DELAY_MS, byte loops) void Blink(int DELAY_MS, byte loops)
{ {
pinMode(LED_BUILTIN, OUTPUT);
while (loops--) while (loops--)
{ {
digitalWrite(LED_BUILTIN,HIGH); digitalWrite(LED_BUILTIN,HIGH);