kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
+configurable batt adc, revert screens1.txt
rodzic
aa315d545a
commit
c42204a579
|
@ -632,6 +632,7 @@ struct st_configitems config_list[] = {
|
|||
{"led_pout", "LED output port", 0, &sonde.config.led_pout},
|
||||
{"gps_rxd", "GPS RXD pin (-1 to disable)", 0, &sonde.config.gps_rxd},
|
||||
{"gps_txd", "GPS TXD pin (not really needed)", 0, &sonde.config.gps_txd},
|
||||
{"batt_adc", "Battery measurement pin", 0, &sonde.config.batt_adc},
|
||||
#if 1
|
||||
{"sx1278_ss", "SX1278 SS", 0, &sonde.config.sx1278_ss},
|
||||
{"sx1278_miso", "SX1278 MISO", 0, &sonde.config.sx1278_miso},
|
||||
|
@ -720,6 +721,7 @@ const char *createConfigForm() {
|
|||
HTMLBODY(ptr, "config.html");
|
||||
strcat(ptr, "<table><tr><th>Option</th><th>Value</th></tr>");
|
||||
for (int i = 0; i < N_CONFIG; i++) {
|
||||
Serial.printf("%d: %s -- %d\n", i, config_list[i].label, strlen(ptr));
|
||||
switch (config_list[i].type) {
|
||||
case -5: // Heading
|
||||
addConfigHeading(ptr, config_list[i].label);
|
||||
|
@ -1929,11 +1931,11 @@ void setup()
|
|||
axp.clearIRQ();
|
||||
}
|
||||
int ndevices = scanI2Cdevice();
|
||||
if (sonde.fingerprint == 31) { pinMode(35, INPUT); }
|
||||
if (sonde.fingerprint != 17 || ndevices > 0) break; // only retry for fingerprint 17 (startup problems of new t-beam with oled)
|
||||
delay(500);
|
||||
}
|
||||
}
|
||||
if (sonde.config.batt_adc>=0) { pinMode(sonde.config.batt_adc, INPUT); }
|
||||
if (sonde.config.power_pout >= 0) { // for a heltec v2, pull GPIO21 low for display power
|
||||
pinMode(sonde.config.power_pout & 127, OUTPUT);
|
||||
digitalWrite(sonde.config.power_pout & 127, sonde.config.power_pout & 128 ? 1 : 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const char *version_name = "rdzTTGOsonde";
|
||||
const char *version_id = "devel20210908";
|
||||
const char *version_id = "devel20210908b";
|
||||
const int SPIFFS_MAJOR=2;
|
||||
const int SPIFFS_MINOR=14;
|
||||
|
|
|
@ -1560,24 +1560,20 @@ void Display::drawGPS(DispEntry *de) {
|
|||
void Display::drawBatt(DispEntry *de) {
|
||||
float val;
|
||||
char buf[30];
|
||||
if(!axp192_found && sonde.fingerprint != 31) return;
|
||||
if (!axp192_found && sonde.fingerprint == 31)
|
||||
{
|
||||
xSemaphoreTake(axpSemaphore, portMAX_DELAY);
|
||||
if (!axp192_found) {
|
||||
if (sonde.config.batt_adc<0) return;
|
||||
switch (de->extra[0])
|
||||
{
|
||||
case 'V':
|
||||
val = (float)(analogRead(35)) / 4095 * 2 * 3.3 * 1.1;
|
||||
val = (float)(analogRead(sonde.config.batt_adc)) / 4095 * 2 * 3.3 * 1.1;
|
||||
snprintf(buf, 30, "%.2f%s", val, de->extra + 1);
|
||||
break;
|
||||
default:
|
||||
*buf = 0;
|
||||
}
|
||||
xSemaphoreGive(axpSemaphore);
|
||||
rdis->setFont(de->fmt);
|
||||
drawString(de, buf);
|
||||
} else {
|
||||
|
||||
xSemaphoreTake( axpSemaphore, portMAX_DELAY );
|
||||
switch(de->extra[0]) {
|
||||
case 'S':
|
||||
|
|
|
@ -89,6 +89,7 @@ void Sonde::defaultConfig() {
|
|||
// Seems like on startup, GPIO4 is 1 on v1 boards, 0 on v2.1 boards?
|
||||
config.gps_rxd = -1;
|
||||
config.gps_txd = -1;
|
||||
config.batt_adc = -1;
|
||||
config.sx1278_ss = SS; // default SS pin, on all TTGOs
|
||||
config.sx1278_miso = MISO;
|
||||
config.sx1278_mosi = MOSI;
|
||||
|
@ -202,9 +203,11 @@ void Sonde::defaultConfig() {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// Likely a TTGO V2.1_1.6
|
||||
config.button_pin = 2 + 128; // GPIO2 / T2
|
||||
config.button2_pin = 14 + 128; // GPIO14 / T6
|
||||
config.led_pout = 25;
|
||||
config.batt_adc = 35;
|
||||
}
|
||||
}
|
||||
//
|
||||
|
@ -307,6 +310,8 @@ void Sonde::setConfig(const char *cfg) {
|
|||
config.gps_rxd = atoi(val);
|
||||
} else if(strcmp(cfg,"gps_txd")==0) {
|
||||
config.gps_txd = atoi(val);
|
||||
} else if(strcmp(cfg,"batt_adc")==0) {
|
||||
config.batt_adc = atoi(val);
|
||||
} else if(strcmp(cfg,"sx1278_ss")==0) {
|
||||
config.sx1278_ss = atoi(val);
|
||||
} else if(strcmp(cfg,"sx1278_miso")==0) {
|
||||
|
|
|
@ -216,6 +216,7 @@ typedef struct st_rdzconfig {
|
|||
int tft_spifreq; // SPI transfer speed (default 40M is out of spec for some TFT)
|
||||
int gps_rxd; // GPS module RXD pin. We expect 9600 baud NMEA data.
|
||||
int gps_txd; // GPS module TXD pin
|
||||
int batt_adc; // Pin for ADC battery measurement (GPIO35 on TTGO V2.1_1.6)
|
||||
int sx1278_ss; // SPI slave select for sx1278
|
||||
int sx1278_miso; // SPI MISO for sx1278
|
||||
int sx1278_mosi; // SPI MOSI for sx1278
|
||||
|
|
Ładowanie…
Reference in New Issue