Adding d8/d7 + serial pins on all versions

This commit is contained in:
Magnus 2022-11-20 19:46:50 +01:00
parent 60675ecf0f
commit d905aeafe9
10 changed files with 67 additions and 5 deletions

View File

@ -937,7 +937,7 @@
setButtonDisabled( true ); setButtonDisabled( true );
var url = "/api/config"; var url = "/api/config";
var url = "/test/config.json"; //var url = "/test/config.json";
$('#spinner').show(); $('#spinner').show();
$.getJSON(url, function (cfg) { $.getJSON(url, function (cfg) {
console.log( cfg ); console.log( cfg );

File diff suppressed because one or more lines are too long

View File

@ -117,6 +117,9 @@ build_flags =
#-DCORE_DEBUG_LEVEL=0 #-DCORE_DEBUG_LEVEL=0
${common_env_data.build_flags} ${common_env_data.build_flags}
-D LOG_LEVEL=5 -D LOG_LEVEL=5
-DESP32D1
-DCORE_DEBUG_LEVEL=0
#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
lib_deps = lib_deps =
${common_env_data.lib_deps} ${common_env_data.lib_deps}
${common_env_data.lib_deps32} ${common_env_data.lib_deps32}

View File

@ -250,8 +250,10 @@ SerialDebug::SerialDebug(const uint32_t serialSpeed) {
EspSerial.begin(115200L, SERIAL_8N1, 37, 39); EspSerial.begin(115200L, SERIAL_8N1, 37, 39);
#elif defined(ESP32S2) #elif defined(ESP32S2)
EspSerial.begin(115200L); EspSerial.begin(115200L);
#elif defined(USE_SERIAL_PINS) && defined(ESP32LITE)
EspSerial.begin(serialSpeed, SERIAL_8N1, 16, 17);
#elif defined(USE_SERIAL_PINS) && defined(ESP32) #elif defined(USE_SERIAL_PINS) && defined(ESP32)
EspSerial.begin(serialSpeed, SERIAL_8N1, 3, 1); EspSerial.begin(serialSpeed, SERIAL_8N1, 1, 3);
#elif defined(ESP32) #elif defined(ESP32)
EspSerial.begin(115200L); EspSerial.begin(115200L);
#endif #endif
@ -269,6 +271,21 @@ void printTimestamp(Print* _logOutput, int _logLevel) {
_logOutput->print(c); _logOutput->print(c);
} }
bool checkPinConnected() {
#if defined(ESP8266)
pinMode(PIN_CFG1, INPUT);
#else
pinMode(PIN_CFG1, INPUT_PULLDOWN);
#endif
pinMode(PIN_CFG2, OUTPUT);
delay(5);
digitalWrite(PIN_CFG2, 1);
delay(5);
int i = digitalRead(PIN_CFG1);
digitalWrite(PIN_CFG2, 0);
return i == LOW ? false : true;
}
BatteryVoltage::BatteryVoltage() { BatteryVoltage::BatteryVoltage() {
#if defined(ESP8266) #if defined(ESP8266)
pinMode(PIN_VOLT, INPUT); pinMode(PIN_VOLT, INPUT);

View File

@ -43,6 +43,9 @@ void checkResetReason();
// Sleep mode // Sleep mode
void deepSleep(int t); void deepSleep(int t);
// Force config mode
bool checkPinConnected();
// Show build options // Show build options
void printBuildOptions(); void printBuildOptions();

View File

@ -137,6 +137,7 @@ void setup() {
// Add a delay so that serial is started. // Add a delay so that serial is started.
// delay(3000); // delay(3000);
#endif #endif
delay(2000);
// Main startup // Main startup
#if defined(ESP8266) #if defined(ESP8266)
@ -163,6 +164,11 @@ void setup() {
myAdvancedConfig.loadFile(); myAdvancedConfig.loadFile();
LOG_PERF_STOP("main-config-load"); LOG_PERF_STOP("main-config-load");
sleepModeAlwaysSkip = checkPinConnected();
if (sleepModeAlwaysSkip) {
Log.notice(F("Main: Forcing config mode since D7/D8 are connected." CR));
}
// Setup watchdog // Setup watchdog
#if defined(ESP8266) #if defined(ESP8266)
ESP.wdtDisable(); ESP.wdtDisable();
@ -331,7 +337,7 @@ bool loopReadGravity() {
} }
return true; return true;
} else { } else {
Log.error(F("MAIN: No gyro value found, the device might be moving." CR)); // Log.error(F("MAIN: No gyro value found, the device might be moving." CR));
} }
return false; return false;
} }

View File

@ -44,6 +44,8 @@ extern RunMode runMode;
#define ESP_RESET ESP.reset #define ESP_RESET ESP.reset
#define PIN_SDA D3 #define PIN_SDA D3
#define PIN_SCL D4 #define PIN_SCL D4
#define PIN_CFG1 D8
#define PIN_CFG2 D7
#define PIN_DS D6 #define PIN_DS D6
#define PIN_LED 2 #define PIN_LED 2
#define PIN_VOLT PIN_A0 #define PIN_VOLT PIN_A0
@ -65,6 +67,8 @@ extern RunMode runMode;
#define PIN_SDA 7 #define PIN_SDA 7
#define PIN_SCL 6 #define PIN_SCL 6
#endif // JTAG_DEBUG #endif // JTAG_DEBUG
#define PIN_CFG1 A5
#define PIN_CFG2 A4
#define PIN_DS A3 #define PIN_DS A3
#define PIN_VOLT A0 #define PIN_VOLT A0
// This should be the LED_BUILTIN, but that is also connected SDA (Gyro) so we // This should be the LED_BUILTIN, but that is also connected SDA (Gyro) so we
@ -82,6 +86,8 @@ extern RunMode runMode;
#define ESP8266WebServer WebServer #define ESP8266WebServer WebServer
#define PIN_SDA A17 #define PIN_SDA A17
#define PIN_SCL A15 #define PIN_SCL A15
#define PIN_CFG1 A11
#define PIN_CFG2 A10
#define PIN_DS A8 #define PIN_DS A8
#define PIN_VOLT A2 #define PIN_VOLT A2
#define PIN_LED LED_BUILTIN #define PIN_LED LED_BUILTIN
@ -99,6 +105,8 @@ extern RunMode runMode;
#define PIN_SCL A19 #define PIN_SCL A19
#define PIN_DS A3 #define PIN_DS A3
#define PIN_VOLT A7 #define PIN_VOLT A7
#define PIN_CFG1 A14
#define PIN_CFG2 A13
#define PIN_VCC A5 #define PIN_VCC A5
#define PIN_GND A18 #define PIN_GND A18
#define PIN_LED LED_BUILTIN #define PIN_LED LED_BUILTIN
@ -115,11 +123,13 @@ extern RunMode runMode;
#define PIN_SDA D3 #define PIN_SDA D3
#define PIN_SCL D4 #define PIN_SCL D4
#define PIN_DS D6 #define PIN_DS D6
#define PIN_CFG1 D8
#define PIN_CFG2 D7
#define PIN_LED LED_BUILTIN #define PIN_LED LED_BUILTIN
#define PIN_VOLT PIN_A0 #define PIN_VOLT PIN_A0
#endif #endif
#if defined(USE_SERIAL_PINS) && defined(ESP32) #if defined(USE_SERIAL_PINS) && ( defined(ESP32C3) || defined(ESP32S2) )
// #define EspSerial Serial0 // We cant use Serial on newer boards since this is // #define EspSerial Serial0 // We cant use Serial on newer boards since this is
// using USBC port // using USBC port
#define EspSerial \ #define EspSerial \

View File

@ -20,6 +20,7 @@ Schema for esp8266 build
:width: 700 :width: 700
:alt: Schema esp8266 :alt: Schema esp8266
iSpindle based on esp32 iSpindle based on esp32
======================= =======================
@ -114,3 +115,25 @@ this hardware platform as well but there are a few limitations:
* Temperature is read from the GYRO and cannot be changed. This works fine when measuring gravity but when in configuration mode the temperature will increase since it shows the chip temperature. * Temperature is read from the GYRO and cannot be changed. This works fine when measuring gravity but when in configuration mode the temperature will increase since it shows the chip temperature.
* No possibility to measure battery level (can be added with additional hardware). * No possibility to measure battery level (can be added with additional hardware).
Hardware extensions
===================
GravityMon has implemented a few additions to the standard iSpindel hardware. It's possible to channel the serial console to the TX/RX pins on the chip (these position also applies to all the
ESP32 chips for iSpindel). You need a USB to TTL converter for this to work. This enables you to read the serial console even when on battery (newer chips dont have a diode to remove).
.. note::
You need to compile the software using the -DUSE_SERIAL_PINS option to enable this feature.
Its also possible to force the device into configuration mode by connecting D7/D8 on the board during the startup sequence. This will enable the feature "gravity mode enabled during float".
.. image:: images/8266_pins.jpg
:width: 500
:alt: iSpindel pins
For the floaty device pins 16/17 are used as TX/RX pins and the 13/15 pins are used to force the device into configuration mode. Pin 35 can also be connected to the battery voltage via an voltage divider to be able to read the battery voltage.
.. image:: images/32lite_pins.jpg
:width: 500
:alt: Floaty pins

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB