sdcard & rgbled fixes
This commit is contained in:
parent
ef68179b85
commit
8bb2c75338
@ -5,7 +5,9 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
// Time functions
|
||||
#ifdef HAS_RTC
|
||||
#include <RtcDateTime.h>
|
||||
#endif
|
||||
#include <Ticker.h>
|
||||
|
||||
// std::set for unified array functions
|
||||
|
@ -1,8 +1,9 @@
|
||||
#ifndef _LED_H
|
||||
#define _LED_H
|
||||
|
||||
#ifdef RGB_LED_COUNT
|
||||
#include <SmartLeds.h>
|
||||
#ifdef HAS_RGB_LED
|
||||
#include <FastLED.h>
|
||||
#include "libpax_helpers.h"
|
||||
#endif
|
||||
#ifdef HAS_LORA
|
||||
#include "lorawan.h"
|
||||
@ -12,39 +13,13 @@
|
||||
#define RGB_LED_COUNT 1
|
||||
#endif
|
||||
|
||||
// value for HSL color
|
||||
// see http://www.workwithcolor.com/blue-color-hue-range-01.htm
|
||||
#define COLOR_RED 0
|
||||
#define COLOR_ORANGE 30
|
||||
#define COLOR_ORANGE_YELLOW 45
|
||||
#define COLOR_YELLOW 60
|
||||
#define COLOR_YELLOW_GREEN 90
|
||||
#define COLOR_GREEN 120
|
||||
#define COLOR_GREEN_CYAN 165
|
||||
#define COLOR_CYAN 180
|
||||
#define COLOR_CYAN_BLUE 210
|
||||
#define COLOR_BLUE 240
|
||||
#define COLOR_BLUE_MAGENTA 275
|
||||
#define COLOR_MAGENTA 300
|
||||
#define COLOR_PINK 350
|
||||
#define COLOR_WHITE 360
|
||||
#define COLOR_NONE 999
|
||||
|
||||
struct RGBColor {
|
||||
uint8_t R;
|
||||
uint8_t G;
|
||||
uint8_t B;
|
||||
};
|
||||
|
||||
enum led_states { LED_OFF, LED_ON };
|
||||
|
||||
extern TaskHandle_t ledLoopTask;
|
||||
|
||||
// Exported Functions
|
||||
void rgb_set_color(uint16_t hue);
|
||||
void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
|
||||
void rgb_led_init(void);
|
||||
void led_sethue(uint8_t hue);
|
||||
void ledLoop(void *parameter);
|
||||
void switch_LED(uint8_t state);
|
||||
void switch_LED1(uint8_t state);
|
||||
void switch_LED(led_states state);
|
||||
void switch_LED1(led_states state);
|
||||
|
||||
#endif
|
@ -33,6 +33,10 @@
|
||||
#elif HAS_SDCARD == 2 // MMC interface
|
||||
#include "driver/sdmmc_host.h"
|
||||
|
||||
#ifndef SDCARD_SLOTCONFIG
|
||||
#define SDCARD_SLOTCONFIG SDMMC_SLOT_CONFIG_DEFAULT()
|
||||
#endif
|
||||
|
||||
#ifndef SDCARD_SLOTWIDTH
|
||||
#define SDCARD_SLOTWIDTH 1
|
||||
#endif
|
||||
|
@ -0,0 +1,62 @@
|
||||
[board]
|
||||
halfile = ttgotdongles3.h
|
||||
;halfile = ttgotdongledisplays3.h
|
||||
|
||||
[platformio]
|
||||
; upload firmware to board with usb cable
|
||||
default_envs = usb
|
||||
description = Paxcounter is a device for metering passenger flows in realtime. It counts how many mobile devices are around.
|
||||
|
||||
[common]
|
||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
||||
release_version = 3.3.2
|
||||
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
|
||||
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
|
||||
debug_level = 5
|
||||
extra_scripts = pre:build.py
|
||||
otakeyfile = ota.conf
|
||||
lorakeyfile = loraconf.h
|
||||
lmicconfigfile = lmic_config.h
|
||||
platform_espressif32 = espressif32@5.2.0
|
||||
monitor_speed = 115200
|
||||
upload_speed = 115200 ; set by build.py and taken from hal file
|
||||
lib_deps_all =
|
||||
bitbank2/BitBang_I2C@^2.2.1
|
||||
https://github.com/bitbank2/bb_spi_lcd.git
|
||||
;https://github.com/RoboticsBrno/SmartLeds.git
|
||||
;greyrook/libpax @ ^1.0.1
|
||||
https://github.com/cyberman54/libpax.git
|
||||
https://github.com/SukkoPera/Arduino-Rokkit-Hash.git
|
||||
bblanchon/ArduinoJson @ ^6
|
||||
spacehuhn/SimpleButton
|
||||
256dpi/MQTT @ ^2.5.0
|
||||
build_flags_basic =
|
||||
-include "src/hal/${board.halfile}"
|
||||
-include "src/paxcounter.conf"
|
||||
'-DCORE_DEBUG_LEVEL=${common.debug_level}'
|
||||
'-DLOG_LOCAL_LEVEL=${common.debug_level}'
|
||||
'-DPROGVERSION="${common.release_version}"'
|
||||
'-D LIBPAX_WIFI'
|
||||
'-D LIBPAX_BLE'
|
||||
'-D LIBPAX_ARDUINO'
|
||||
build_flags_all =
|
||||
${common.build_flags_basic}
|
||||
-mfix-esp32-psram-cache-issue
|
||||
|
||||
[env]
|
||||
framework = arduino
|
||||
board = ESP32-S3-DevKitC-1
|
||||
board_build.partitions = min_spiffs.csv
|
||||
build_type = release
|
||||
upload_speed = ${common.upload_speed}
|
||||
;upload_port = COM6
|
||||
platform = ${common.platform_espressif32}
|
||||
lib_deps = ${common.lib_deps_all}
|
||||
build_flags = ${common.build_flags_all}
|
||||
upload_protocol = ${common.upload_protocol}
|
||||
extra_scripts = ${common.extra_scripts}
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
monitor_filters = time, esp32_exception_decoder, default
|
||||
|
||||
[env:usb]
|
||||
upload_protocol = esptool
|
@ -1,24 +0,0 @@
|
||||
// clang-format off
|
||||
// upload_speed 1500000
|
||||
// board ESP32-S3-DevKitC-1
|
||||
|
||||
#ifndef _TTGOTDISPLAYS3_H
|
||||
#define _TTGOTDISPLAYS3_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define HAS_LED NOT_A_PIN
|
||||
#define HAS_BUTTON 14 // on board button (right side)
|
||||
|
||||
// power management settings
|
||||
//#define BAT_MEASURE_ADC ADC1_GPIO4_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_6
|
||||
//#define BAT_VOLTAGE_DIVIDER 2.605f // voltage divider
|
||||
|
||||
// Display Settings
|
||||
#define HAS_DISPLAY 2 // TFT-LCD parallel
|
||||
#define TFT_TYPE DISPLAY_T_DISPLAY_S3
|
||||
#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_WIDTH 172
|
||||
#define MY_DISPLAY_HEIGHT 320
|
||||
|
||||
#endif
|
31
src/hal/ttgotdongledisplays3.h
Normal file
31
src/hal/ttgotdongledisplays3.h
Normal file
@ -0,0 +1,31 @@
|
||||
// clang-format off
|
||||
// upload_speed 1500000
|
||||
// board ESP32-S3-DevKitC-1
|
||||
|
||||
// see https://github.com/Xinyuan-LilyGO/T-Dongle-S3
|
||||
|
||||
#ifndef _TTGOTDONGLES3_H
|
||||
#define _TTGOTDONGLES3_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define HAS_LED NOT_A_PIN
|
||||
#define HAS_BUTTON 0
|
||||
|
||||
#define HAS_SDCARD 2 // this board has a SD MMC card-reader/writer
|
||||
#define SDCARD_SLOTWIDTH 4 // 4-line interface
|
||||
|
||||
#define HAS_DISPLAY 2 // TFT-LCD
|
||||
#define TFT_TYPE DISPLAY_TDONGLE_S3
|
||||
#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_WIDTH 80
|
||||
#define MY_DISPLAY_HEIGHT 160
|
||||
|
||||
#define TFT_CS_PIN 4
|
||||
#define TFT_SDA_PIN 3
|
||||
#define TFT_SCL_PIN 5
|
||||
#define TFT_DC_PIN 2
|
||||
#define TFT_RES_PIN 1
|
||||
#define TFT_LEDA_PIN 38
|
||||
|
||||
#endif
|
21
src/hal/ttgotdongles3.h
Normal file
21
src/hal/ttgotdongles3.h
Normal file
@ -0,0 +1,21 @@
|
||||
// clang-format off
|
||||
// upload_speed 1500000
|
||||
// board ESP32-S3-DevKitC-1
|
||||
|
||||
// for pinouts see https://github.com/Xinyuan-LilyGO/T-Dongle-S3
|
||||
|
||||
#ifndef _TTGOTDONGLES3_H
|
||||
#define _TTGOTDONGLES3_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define HAS_LED NOT_A_PIN
|
||||
#define RGB_LED_COUNT 1
|
||||
#define HAS_RGB_LED FastLED.addLeds<APA102, 40, 39, BGR>(leds, RGB_LED_COUNT)
|
||||
#define FASTLED_INTERNAL
|
||||
#define HAS_BUTTON 0 // dongle button is on GPIO0
|
||||
#define HAS_SDCARD 2 // dongle has a SD MMC card-reader/writer
|
||||
#define SDCARD_SLOTWIDTH 4 // dongle has 4 line interface
|
||||
#define SDCARD_SLOTCONFIG { .clk = GPIO_NUM_12, .cmd = GPIO_NUM_16, .d0 = GPIO_NUM_14, .d1 = GPIO_NUM_17, .d2 = GPIO_NUM_21, .d3 = GPIO_NUM_18, .cd = SDMMC_SLOT_NO_CD, .wp = SDMMC_SLOT_NO_WP, .width = 4, .flags = 0, }
|
||||
|
||||
#endif
|
177
src/led.cpp
177
src/led.cpp
@ -2,94 +2,44 @@
|
||||
#include "globals.h"
|
||||
#include "led.h"
|
||||
|
||||
led_states LEDState = LED_OFF; // LED state global for state machine
|
||||
led_states previousLEDState =
|
||||
LED_ON; // This will force LED to be off at boot since State is OFF
|
||||
|
||||
static led_states LEDState = LED_OFF; // LED state global for state machine
|
||||
TaskHandle_t ledLoopTask;
|
||||
|
||||
uint16_t LEDColor = COLOR_NONE, LEDBlinkDuration = 0; // state machine variables
|
||||
unsigned long LEDBlinkStarted = 0; // When (in millis() led blink started)
|
||||
static uint16_t LEDBlinkDuration = 0; // state machine variables
|
||||
static unsigned long LEDBlinkStarted =
|
||||
0; // When (in millis() led blink started)
|
||||
|
||||
#ifdef HAS_RGB_LED
|
||||
|
||||
// RGB Led instance
|
||||
HAS_RGB_LED;
|
||||
|
||||
float rgb_CalcColor(float p, float q, float t) {
|
||||
if (t < 0.0f)
|
||||
t += 1.0f;
|
||||
if (t > 1.0f)
|
||||
t -= 1.0f;
|
||||
|
||||
if (t < 1.0f / 6.0f)
|
||||
return p + (q - p) * 6.0f * t;
|
||||
|
||||
if (t < 0.5f)
|
||||
return q;
|
||||
|
||||
if (t < 2.0f / 3.0f)
|
||||
return p + ((q - p) * (2.0f / 3.0f - t) * 6.0f);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Hue, Saturation, Lightness color members
|
||||
// HslColor using H, S, L values (0.0 - 1.0)
|
||||
// L should be limited to between (0.0 - 0.5)
|
||||
// ------------------------------------------------------------------------
|
||||
RGBColor rgb_hsl2rgb(float h, float s, float l) {
|
||||
RGBColor RGB_color;
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
|
||||
if (s == 0.0f || l == 0.0f) {
|
||||
r = g = b = l; // achromatic or black
|
||||
} else {
|
||||
float q = l < 0.5f ? l * (1.0f + s) : l + s - (l * s);
|
||||
float p = 2.0f * l - q;
|
||||
r = rgb_CalcColor(p, q, h + 1.0f / 3.0f);
|
||||
g = rgb_CalcColor(p, q, h);
|
||||
b = rgb_CalcColor(p, q, h - 1.0f / 3.0f);
|
||||
}
|
||||
|
||||
RGB_color.R = (uint8_t)(r * 255.0f);
|
||||
RGB_color.G = (uint8_t)(g * 255.0f);
|
||||
RGB_color.B = (uint8_t)(b * 255.0f);
|
||||
|
||||
return RGB_color;
|
||||
}
|
||||
|
||||
void rgb_set_color(uint16_t hue) {
|
||||
if (hue == COLOR_NONE) {
|
||||
// set Off
|
||||
for (int i = 0; i < RGB_LED_COUNT; i++)
|
||||
rgb_led[i] = Rgb(0, 0, 0);
|
||||
} else {
|
||||
// see http://www.workwithcolor.com/blue-color-hue-range-01.htm
|
||||
// H (is color from 0..360) should be between 0.0 and 1.0
|
||||
// S is saturation keep it to 1
|
||||
// L is brightness should be between 0.0 and 0.5
|
||||
// cfg.rgblum is between 0 and 100 (percent)
|
||||
RGBColor target = rgb_hsl2rgb(hue / 360.0f, 1.0f, 0.005f * cfg.rgblum);
|
||||
// uint32_t color = target.R<<16 | target.G<<8 | target.B;
|
||||
for (int i = 0; i < RGB_LED_COUNT; i++)
|
||||
rgb_led[i] = Rgb(target.R, target.G, target.B);
|
||||
}
|
||||
// Show
|
||||
rgb_led.show();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// No RGB LED empty functions
|
||||
void rgb_set_color(uint16_t hue) {}
|
||||
|
||||
CRGB leds[RGB_LED_COUNT];
|
||||
#endif
|
||||
|
||||
void switch_LED(uint8_t state) {
|
||||
void led_setcolor(CRGB color) {
|
||||
#ifdef HAS_RGB_LED
|
||||
for (int i = 0; i < RGB_LED_COUNT; i++)
|
||||
leds[i] = color;
|
||||
FastLED.show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void led_sethue(uint8_t hue) {
|
||||
#ifdef HAS_RGB_LED
|
||||
for (int i = 0; i < RGB_LED_COUNT; i++)
|
||||
leds[i] = CHSV(hue, 0XFF, 100);
|
||||
FastLED.show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void rgb_led_init(void) {
|
||||
#ifdef HAS_RGB_LED
|
||||
HAS_RGB_LED;
|
||||
led_setcolor(CRGB::Green);
|
||||
#endif
|
||||
}
|
||||
|
||||
void switch_LED(led_states state) {
|
||||
static led_states previousLEDState = LED_OFF;
|
||||
// led need to change state? avoid digitalWrite() for nothing
|
||||
if (state != previousLEDState) {
|
||||
previousLEDState = state;
|
||||
#if (HAS_LED != NOT_A_PIN)
|
||||
if (state == LED_ON) {
|
||||
// switch LED on
|
||||
@ -98,6 +48,7 @@ void switch_LED(uint8_t state) {
|
||||
#else
|
||||
digitalWrite(HAS_LED, HIGH);
|
||||
#endif
|
||||
led_setcolor(CRGB::White);
|
||||
} else if (state == LED_OFF) {
|
||||
// switch LED off
|
||||
#ifdef LED_ACTIVE_LOW
|
||||
@ -105,37 +56,35 @@ void switch_LED(uint8_t state) {
|
||||
#else
|
||||
digitalWrite(HAS_LED, LOW);
|
||||
#endif
|
||||
led_setcolor(CRGB::Black);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void switch_LED1(uint8_t state) {
|
||||
#ifdef HAS_TWO_LED
|
||||
void switch_LED1(led_states state) {
|
||||
static led_states previousLEDState = LED_OFF;
|
||||
// led need to change state? avoid digitalWrite() for nothing
|
||||
if (state != previousLEDState) {
|
||||
previousLEDState = state;
|
||||
#if (HAS_LED != NOT_A_PIN)
|
||||
if (state == LED_ON) {
|
||||
// switch LED on
|
||||
#ifdef LED1_ACTIVE_LOW
|
||||
#ifdef LED_ACTIVE_LOW
|
||||
digitalWrite(HAS_TWO_LED, LOW);
|
||||
#else
|
||||
digitalWrite(HAS_TWO_LED, HIGH);
|
||||
#endif
|
||||
} else if (state == LED_OFF) {
|
||||
// switch LED off
|
||||
#ifdef LED1_ACTIVE_LOW
|
||||
#ifdef LED_ACTIVE_LOW
|
||||
digitalWrite(HAS_TWO_LED, HIGH);
|
||||
#else
|
||||
digitalWrite(HAS_TWO_LED, LOW);
|
||||
#endif
|
||||
}
|
||||
#endif // HAS_TWO_LED
|
||||
}
|
||||
|
||||
void blink_LED(uint16_t set_color, uint16_t set_blinkduration) {
|
||||
#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
|
||||
LEDColor = set_color; // set color for RGB LED
|
||||
LEDBlinkDuration = set_blinkduration; // duration
|
||||
LEDBlinkStarted = millis(); // Time Start here
|
||||
LEDState = LED_ON; // Let main set LED on
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
|
||||
@ -151,7 +100,7 @@ void ledLoop(void *parameter) {
|
||||
LEDState = LED_OFF;
|
||||
LEDBlinkStarted = 0;
|
||||
LEDBlinkDuration = 0;
|
||||
LEDColor = COLOR_NONE;
|
||||
led_setcolor(CRGB::Black);
|
||||
} else {
|
||||
// In case of LoRaWAN led management blinked off
|
||||
LEDState = LED_ON;
|
||||
@ -161,7 +110,7 @@ void ledLoop(void *parameter) {
|
||||
#if (HAS_LORA)
|
||||
// LED indicators for viusalizing LoRaWAN state
|
||||
if (LMIC.opmode & (OP_JOINING | OP_REJOIN)) {
|
||||
LEDColor = COLOR_YELLOW;
|
||||
led_setcolor(CRGB::Yellow);
|
||||
// quick blink 20ms on each 1/5 second
|
||||
LEDState =
|
||||
((millis() % 200) < 20) ? LED_ON : LED_OFF; // TX data pending
|
||||
@ -169,13 +118,13 @@ void ledLoop(void *parameter) {
|
||||
// select color to blink by message port
|
||||
switch (LMIC.pendTxPort) {
|
||||
case STATUSPORT:
|
||||
LEDColor = COLOR_PINK;
|
||||
led_setcolor(CRGB::Pink);
|
||||
break;
|
||||
case CONFIGPORT:
|
||||
LEDColor = COLOR_CYAN;
|
||||
led_setcolor(CRGB::Cyan);
|
||||
break;
|
||||
default:
|
||||
LEDColor = COLOR_BLUE;
|
||||
led_setcolor(CRGB::Blue);
|
||||
break;
|
||||
}
|
||||
// small blink 10ms on each 1/2sec (not when joining)
|
||||
@ -183,33 +132,23 @@ void ledLoop(void *parameter) {
|
||||
// This should not happen so indicate a problem
|
||||
} else if (LMIC.opmode &
|
||||
((OP_TXDATA | OP_TXRXPEND | OP_JOINING | OP_REJOIN) == 0)) {
|
||||
LEDColor = COLOR_RED;
|
||||
led_setcolor(CRGB::Red);
|
||||
// heartbeat long blink 200ms on each 2 seconds
|
||||
LEDState = ((millis() % 2000) < 200) ? LED_ON : LED_OFF;
|
||||
} else
|
||||
#elif (defined(HAS_RGB_LED) && ((WIFICOUNTER) || (BLECOUNTER)))
|
||||
struct count_payload_t count;
|
||||
libpax_counter_count(&count);
|
||||
led_sethue(count.pax);
|
||||
#endif // HAS_LORA
|
||||
{
|
||||
// led off
|
||||
LEDColor = COLOR_NONE;
|
||||
LEDState = LED_OFF;
|
||||
}
|
||||
}
|
||||
// led need to change state? avoid digitalWrite() for nothing
|
||||
if (LEDState != previousLEDState) {
|
||||
if (LEDState == LED_ON) {
|
||||
rgb_set_color(LEDColor);
|
||||
// if we have only single LED we use it to blink for status
|
||||
#ifndef HAS_RGB_LED
|
||||
switch_LED(LED_ON);
|
||||
#endif
|
||||
} else {
|
||||
rgb_set_color(COLOR_NONE);
|
||||
#ifndef HAS_RGB_LED
|
||||
switch_LED(LED_OFF);
|
||||
#endif
|
||||
}
|
||||
previousLEDState = LEDState;
|
||||
}
|
||||
|
||||
switch_LED(LEDState);
|
||||
|
||||
// give yield to CPU
|
||||
delay(5);
|
||||
} // while(1)
|
||||
|
@ -1,88 +0,0 @@
|
||||
#ifndef __LORACONF_H__
|
||||
#define __LORACONF_H__
|
||||
|
||||
#if (HAS_LORA)
|
||||
|
||||
/************************************************************
|
||||
* LMIC LoRaWAN configuration
|
||||
*
|
||||
* Read the values from TTN console (or whatever applies), insert them here,
|
||||
* and rename this file to src/loraconf.h
|
||||
*
|
||||
* You can configure OTAA or ABP Activation. In order to use ABP, uncomment
|
||||
* (enable) the following line, but you should only do so, if you have good
|
||||
* reasons for not using OTAA.
|
||||
*
|
||||
*************************************************************/
|
||||
|
||||
//#define LORA_ABP
|
||||
|
||||
#ifndef LORA_ABP
|
||||
/************************************************************
|
||||
* OTAA configuration
|
||||
*
|
||||
* DEVEUI, APPEUI and APPKEY should all be specified in MSB format as
|
||||
* displayed in TTN console, so you can cut & paste from there. This is different
|
||||
* from standard LMIC-Arduino which expects DEVEUI and APPEUI in LSB format.
|
||||
* For TTN, APPEUI in MSB format always starts with 0x70, 0xB3, 0xD5.
|
||||
* Set your DEVEUI here, if your device has have a fixed one.
|
||||
* If you leave this untouched, then the DEVEUI will be derived from device's
|
||||
* MAC adress during startup and will be displayed on device's screen as well as
|
||||
* on serial console, if you set 'verbose 1' in paxcounter.conf and
|
||||
* 'debug_level 3' in platformio.ini.
|
||||
* If using a board with Microchip 24AA02E64 Uinique ID for deveui, the DEVEUI
|
||||
* will be overwritten by the one contained in the Microchip module.
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
static const u1_t DEVEUI[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
static const u1_t APPEUI[8] = {0x70, 0xB3, 0xD5, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
static const u1_t APPKEY[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef LORA_ABP
|
||||
/************************************************************
|
||||
* ABP configuration (for development)
|
||||
*
|
||||
* Get your
|
||||
* - Network Session Key (NWKSKEY)
|
||||
* - App Session Key and your (APPSKEY)
|
||||
* - Device Address (DEVADDR)
|
||||
* from e.g. TTN console and replace the example values below.
|
||||
*
|
||||
* NOTE: Use MSB format (as displayed in TTN console, so you can cut & paste
|
||||
* from there)
|
||||
*
|
||||
* NOTE: You may also need to adjust lorawan_abp.cpp in order to configure
|
||||
* different channels and data rate channels to match your country's regulations
|
||||
* and your network's settings.
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
// ID of LoRaAlliance assigned Network (for a list, see e.g. here
|
||||
// https://www.thethingsnetwork.org/docs/lorawan/prefix-assignments.html)
|
||||
static const u1_t NETID = 0x13; // TTN
|
||||
|
||||
static const u1_t NWKSKEY[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
static const u1_t APPSKEY[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
static const u4_t DEVADDR =
|
||||
0x00000000; // <-- Change this address for every node!
|
||||
|
||||
// set additional ABP parameters in loraconf_abp.cpp
|
||||
void setABPParameters();
|
||||
|
||||
#endif
|
||||
|
||||
#endif // HAS_LORA
|
||||
|
||||
#endif // __LORACONF_H__
|
12
src/main.cpp
12
src/main.cpp
@ -201,26 +201,26 @@ void setup() {
|
||||
#endif
|
||||
|
||||
// initialize leds
|
||||
#ifdef HAS_RGB_LED
|
||||
rgb_led_init();
|
||||
strcat_P(features, " RGB");
|
||||
#endif
|
||||
|
||||
#if (HAS_LED != NOT_A_PIN)
|
||||
pinMode(HAS_LED, OUTPUT);
|
||||
strcat_P(features, " LED");
|
||||
|
||||
#ifdef LED_POWER_SW
|
||||
pinMode(LED_POWER_SW, OUTPUT);
|
||||
digitalWrite(LED_POWER_SW, LED_POWER_ON);
|
||||
#endif
|
||||
|
||||
#ifdef HAS_TWO_LED
|
||||
pinMode(HAS_TWO_LED, OUTPUT);
|
||||
strcat_P(features, " LED2");
|
||||
#endif
|
||||
|
||||
// use LED for power display if we have additional RGB LED, else for status
|
||||
#ifdef HAS_RGB_LED
|
||||
// use simple LED for power display if we have additional RGB LED, else for status
|
||||
switch_LED(LED_ON);
|
||||
strcat_P(features, " RGB");
|
||||
#endif
|
||||
|
||||
#endif // HAS_LED
|
||||
|
||||
#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
|
||||
|
@ -132,7 +132,7 @@ bool sdcard_init(bool create) {
|
||||
// has these signals.
|
||||
// Default config for SDMMC_HOST_DEFAULT (4-bit bus width, slot 1)
|
||||
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/sdmmc_host.html
|
||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
||||
sdmmc_slot_config_t slot_config = SDCARD_SLOTCONFIG;
|
||||
|
||||
// Set 1-line or 4-line SD mode (default is 1-line)
|
||||
slot_config.width = SDCARD_SLOTWIDTH;
|
||||
|
Loading…
Reference in New Issue
Block a user