Merge pull request #1320 from justcallmekoko/develop

Develop
This commit is contained in:
Just Call Me Koko
2026-06-17 12:46:12 -04:00
committed by GitHub
10 changed files with 294 additions and 164 deletions
+97 -71
View File
@@ -1,7 +1,10 @@
// #ifdef HAS_BATTERY
#include "BatteryInterface.h"
#include "lang_var.h"
BatteryInterface::BatteryInterface() {
}
void BatteryInterface::main(uint32_t currentTime) {
@@ -27,96 +30,119 @@ void BatteryInterface::RunSetup() {
#ifdef HAS_BATTERY
#ifdef BATTERY_ADC_PIN
analogReadResolution(12);
pinMode(BATTERY_ADC_PIN, INPUT);
this->has_adc_battery = true;
this->i2c_supported = true;
Serial.println(F("Battery: ADC mode"));
#elif !defined(HAS_AXP2101)
Wire.begin(I2C_SDA, I2C_SCL);
analogReadResolution(12);
pinMode(BATTERY_ADC_PIN, INPUT);
this->has_adc_battery = true;
// this->i2c_supported = true;
Serial.println(F("Battery: ADC mode"));
Wire.beginTransmission(IP5306_ADDR);
error = Wire.endTransmission();
#elif defined(HAS_AXP2101) && defined(I2C_SDA)
bool result = this->power.begin(Wire, AXP2101_SLAVE_ADDRESS, I2C_SDA, I2C_SCL);
if (!result)
return;
Serial.println(F("Detected AXP2101"));
if (error == 0) {
Serial.println(F("Detected IP5306"));
this->has_ip5306 = true;
this->i2c_supported = true;
}
this->has_axp2101 = true;
Wire.beginTransmission(MAX17048_ADDR);
error = Wire.endTransmission();
#elif defined(I2C_SDA) // other i2c (shared)
if (error == 0) {
if (maxlipo.begin()) {
Serial.println(F("Detected MAX17048"));
this->has_max17048 = true;
this->i2c_supported = true;
}
}
#else
bool result = this->power.begin(Wire, AXP2101_SLAVE_ADDRESS, I2C_SDA, I2C_SCL);
Wire.begin(I2C_SDA, I2C_SCL);
if (!result)
return;
#ifdef HAS_IP5306
Wire.beginTransmission(IP5306_ADDR);
error = Wire.endTransmission();
Serial.println(F("Detected AXP2101"));
if (error == 0) {
Serial.println(F("Detected IP5306"));
this->has_ip5306 = true;
this->i2c_supported = true;
}
#endif
this->i2c_supported = true;
this->has_axp2101 = true;
#endif
#ifdef HAS_AXP192
axp192_obj.begin();
#endif
#ifdef HAS_MAX1704X
Wire.beginTransmission(MAX17048_ADDR);
error = Wire.endTransmission();
if (error == 0) {
if (maxlipo.begin()) {
Serial.println(F("Detected MAX17048"));
this->has_max17048 = true;
this->i2c_supported = true;
}
}
#endif
#endif // other i2c
this->initTime = millis();
#endif
#endif // HAS_BATTERY
}
int8_t BatteryInterface::getBatteryLevel() {
#ifdef BATTERY_ADC_PIN
if (this->has_adc_battery) {
int voltage_mv = analogReadMilliVolts(BATTERY_ADC_PIN) * 2; // voltage divider ratio 2:1
if (voltage_mv <= 3300) return 0;
if (voltage_mv >= 4150) return 100;
return (int8_t)(((voltage_mv - 3300) * 100) / 850);
}
#endif
#ifdef HAS_BATTERY
if (this->has_ip5306) {
Wire.beginTransmission(IP5306_ADDR);
Wire.write(0x78);
if (Wire.endTransmission(false) == 0 &&
Wire.requestFrom(IP5306_ADDR, 1)) {
this->i2c_supported = true;
switch (Wire.read() & 0xF0) {
case 0xE0: return 25;
case 0xC0: return 50;
case 0x80: return 75;
case 0x00: return 100;
default: return 0;
#ifdef BATTERY_ADC_PIN
if (this->has_adc_battery) {
int voltage_mv = analogReadMilliVolts(BATTERY_ADC_PIN) * 2; // voltage divider ratio 2:1
if (voltage_mv <= 3300) return 0;
if (voltage_mv >= 4150) return 100;
return (int8_t)(((voltage_mv - 3300) * 100) / 850);
}
}
this->i2c_supported = false;
return -1;
}
#endif
#ifdef HAS_IP5306
if (this->has_ip5306) {
Wire.beginTransmission(IP5306_ADDR);
Wire.write(0x78);
if (Wire.endTransmission(false) == 0 &&
Wire.requestFrom(IP5306_ADDR, 1)) {
this->i2c_supported = true;
switch (Wire.read() & 0xF0) {
case 0xE0: return 25;
case 0xC0: return 50;
case 0x80: return 75;
case 0x00: return 100;
default: return 0;
}
}
this->i2c_supported = false;
return -1;
}
#endif
if (this->has_max17048) {
float percent = this->maxlipo.cellPercent();
#ifdef HAS_MAX1704X
if (this->has_max17048) {
float percent = this->maxlipo.cellPercent();
// Sometimes we dumb
if (percent >= 100)
return 100;
else if (percent <= 0)
return 0;
else
return percent;
}
// Sometimes we dumb
if (percent >= 100)
return 100;
else if (percent <= 0)
return 0;
else
return percent;
}
#endif
#ifdef HAS_AXP2101
if (this->has_axp2101) {
return this->power.getBatteryPercent();
}
#endif
#ifdef HAS_AXP2101
if (this->has_axp2101) {
return this->power.getBatteryPercent();
}
#endif
#endif // HAS_BATTERY
return -1;
}
// #endif // HAS_BATTERY
+22 -4
View File
@@ -1,19 +1,31 @@
#pragma once
// #ifdef HAS_BATTERY
#ifndef BatteryInterface_h
#define BatteryInterface_h
#include <Arduino.h>
#include "configs.h"
#include "Adafruit_MAX1704X.h"
#ifdef HAS_MAX1704X
#include "Adafruit_MAX1704X.h"
#endif
#ifdef HAS_AXP2101
#define XPOWERS_CHIP_AXP2101
#include "XPowersLib.h"
#endif
#include <Wire.h>
#ifdef HAS_AXP192
#include "AXP192.h"
AXP192 axp192_obj;
#endif
#ifndef BATTERY_ADC_PIN // not 12c
#include <Wire.h>
#endif
#define IP5306_ADDR 0x75
#define MAX17048_ADDR 0x36
@@ -21,7 +33,10 @@
class BatteryInterface {
private:
uint32_t initTime = 0;
Adafruit_MAX17048 maxlipo;
#ifdef HAS_MAX1704X
Adafruit_MAX17048 maxlipo;
#endif
#ifdef HAS_AXP2101
XPowersPMU power;
@@ -43,4 +58,7 @@ class BatteryInterface {
int8_t getBatteryLevel();
};
#endif
#endif // ifndef BatteryInterface_h
// #endif // HAS_BATTERY
+10 -4
View File
@@ -590,12 +590,18 @@ void Display::displayBuffer(bool do_clear)
}
}
void Display::showCenterText(String text, int y, bool small_pp)
void Display::showCenterText(const char* text, int y, bool small_pp)
{
if (!text)
text = "";
size_t len = strlen(text);
if (!small_pp)
tft.setCursor((SCREEN_WIDTH - (text.length() * (6 * BANNER_TEXT_SIZE))) / 2, y);
tft.setCursor((SCREEN_WIDTH - (len * (6 * BANNER_TEXT_SIZE))) / 2, y);
else
tft.setCursor((SCREEN_WIDTH - (text.length() * (6))) / 2, y);
tft.setCursor((SCREEN_WIDTH - (len * 6)) / 2, y);
tft.println(text);
}
@@ -619,7 +625,7 @@ void Display::buildBanner(String msg, int xpos)
this->tft.setFreeFont(NULL); // Font 4 selected
this->tft.setTextSize(BANNER_TEXT_SIZE); // Font size scaling is x1
this->tft.setTextColor(TFT_WHITE, TFT_BLACK); // Black text, no background colour
this->showCenterText(msg, banner_y);
this->showCenterText(msg.c_str(), banner_y);
}
#endif
+1 -1
View File
@@ -141,7 +141,7 @@ class Display
void getTouchWhileFunction(bool pressed);
void init();
void RunSetup();
void showCenterText(String text, int y, bool small_pp = false);
void showCenterText(const char* text, int y, bool small_pp = false);
void touchToExit();
void twoPartDisplay(String center_text);
void updateBanner(String msg);
+5 -1
View File
@@ -21,7 +21,7 @@ void GpsInterface::begin() {
uint32_t gps_baud = this->initGpsBaudAndForce115200();
if ((gps_baud != 9600) && (gps_baud != 115200))
if ((gps_baud != 9600) && (gps_baud != 38400) && (gps_baud != 115200))
Serial.println(F("Could not detect GPS baudrate"));
delay(1000);
@@ -113,6 +113,10 @@ uint32_t GpsInterface::initGpsBaudAndForce115200() {
return 9600;
}
if (probeBaud(38400)) {
return 38400;
}
probeBaud(9600);
return 0;
}
+72 -31
View File
@@ -10,12 +10,14 @@ void MenuFunctions::drawMiniMenuButton(int b, int x, bool selected) {
if (!current_menu || !current_menu->list || x < 0 || x >= current_menu->list->size())
return;
uint16_t color = this->getColor(current_menu->list->get(x).color);
MenuNode mini_node = current_menu->list->get(x);
bool is_setting_node = (mini_node.icon == SETTINGS && mini_node.color == TFTLIGHTGREY);
uint16_t color = is_setting_node ? (mini_node.selected ? TFT_GREEN : TFT_RED) : this->getColor(mini_node.color);
int16_t button_x = KEY_X - (KEY_W / 2);
int16_t button_y = (KEY_Y + (b * (KEY_H + KEY_SPACING_Y))) - (KEY_H / 2);
uint16_t background = selected ? color : TFT_BLACK;
uint16_t text_color = selected ? TFT_BLACK : color;
uint16_t background = selected ? (is_setting_node ? TFT_LIGHTGREY : color) : TFT_BLACK;
uint16_t text_color = (selected && !is_setting_node) ? TFT_BLACK : color;
display_obj.tft.setFreeFont(NULL);
display_obj.tft.setTextSize(1);
@@ -38,10 +40,12 @@ void MenuFunctions::buttonNotSelected(int b, int x) {
this->drawMiniMenuButton(b, x, false);
#endif
uint16_t color = this->getColor(current_menu->list->get(x).color);
uint16_t color = (current_menu->list->get(x).icon == SETTINGS && current_menu->list->get(x).color == TFTLIGHTGREY) ? (current_menu->list->get(x).selected ? TFT_GREEN : TFT_RED) : this->getColor(current_menu->list->get(x).color);
uint16_t icon_color = (current_menu->list->get(x).icon == SETTINGS && current_menu->list->get(x).color == TFTLIGHTGREY) ? TFT_LIGHTGREY : color;
#ifdef HAS_FULL_SCREEN
display_obj.tft.setFreeFont(MENU_FONT);
display_obj.key[b].initButton(&display_obj.tft, KEY_X, KEY_Y + b * (KEY_H + KEY_SPACING_Y), KEY_W, KEY_H, TFT_BLACK, TFT_BLACK, color, (char*)"", KEY_TEXTSIZE);
display_obj.key[b].drawButton(false, current_menu->list->get(x).name);
if ((current_menu->list->get(x).name != text09) && (current_menu->list->get(x).icon != 255))
display_obj.tft.drawXBitmap(0,
@@ -50,7 +54,7 @@ void MenuFunctions::buttonNotSelected(int b, int x) {
ICON_W,
ICON_H,
TFT_BLACK,
color);
icon_color);
display_obj.tft.setFreeFont(NULL);
#endif
}
@@ -70,15 +74,28 @@ void MenuFunctions::buttonSelected(int b, int x) {
#ifdef HAS_FULL_SCREEN
display_obj.tft.setFreeFont(MENU_FONT);
display_obj.key[b].drawButton(true, current_menu->list->get(x).name);
if ((current_menu->list->get(x).name != text09) && (current_menu->list->get(x).icon != 255))
display_obj.tft.drawXBitmap(0,
if (current_menu->list->get(x).icon == SETTINGS && current_menu->list->get(x).color == TFTLIGHTGREY) {
uint16_t setting_color = current_menu->list->get(x).selected ? TFT_GREEN : TFT_RED;
display_obj.key[b].initButton(&display_obj.tft, KEY_X, KEY_Y + b * (KEY_H + KEY_SPACING_Y), KEY_W, KEY_H, TFT_BLACK, TFT_LIGHTGREY, setting_color, (char*)"", KEY_TEXTSIZE);
display_obj.key[b].drawButton(false, current_menu->list->get(x).name);
display_obj.tft.drawXBitmap(0,
KEY_Y + (b * (KEY_H + KEY_SPACING_Y)) - (ICON_H / 2),
menu_icons[current_menu->list->get(x).icon],
ICON_W,
ICON_H,
TFT_BLACK,
color);
TFT_LIGHTGREY);
} else {
display_obj.key[b].drawButton(true, current_menu->list->get(x).name);
if ((current_menu->list->get(x).name != text09) && (current_menu->list->get(x).icon != 255))
display_obj.tft.drawXBitmap(0,
KEY_Y + (b * (KEY_H + KEY_SPACING_Y)) - (ICON_H / 2),
menu_icons[current_menu->list->get(x).icon],
ICON_W,
ICON_H,
TFT_BLACK,
color);
}
display_obj.tft.setFreeFont(NULL);
#endif
}
@@ -531,7 +548,7 @@ void MenuFunctions::main(uint32_t currentTime)
this->displayCurrentMenu(current_menu->selected);
}
this->buttonSelected(current_menu->selected - this->menu_start_index, current_menu->selected);
if (!current_menu->list->get(current_menu->selected + 1).selected)
if (!current_menu->list->get(current_menu->selected + 1).selected || (current_menu->list->get(current_menu->selected + 1).icon == SETTINGS && current_menu->list->get(current_menu->selected + 1).color == TFTLIGHTGREY))
this->buttonNotSelected(current_menu->selected + 1 - this->menu_start_index, current_menu->selected + 1);
}
// Loop to end
@@ -542,7 +559,7 @@ void MenuFunctions::main(uint32_t currentTime)
this->displayCurrentMenu(current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
}
this->buttonSelected(current_menu->selected, current_menu->selected);
if (!current_menu->list->get(0).selected)
if (!current_menu->list->get(0).selected || (current_menu->list->get(0).icon == SETTINGS && current_menu->list->get(0).color == TFTLIGHTGREY))
this->buttonNotSelected(0, this->menu_start_index);
}
}
@@ -596,7 +613,7 @@ void MenuFunctions::main(uint32_t currentTime)
}
else
this->buttonSelected(current_menu->selected - this->menu_start_index, current_menu->selected);
if (!current_menu->list->get(current_menu->selected - 1).selected)
if (!current_menu->list->get(current_menu->selected - 1).selected || (current_menu->list->get(current_menu->selected - 1).icon == SETTINGS && current_menu->list->get(current_menu->selected - 1).color == TFTLIGHTGREY))
this->buttonNotSelected(current_menu->selected - 1 - this->menu_start_index, current_menu->selected - 1);
}
// Loop to beginning
@@ -610,7 +627,7 @@ void MenuFunctions::main(uint32_t currentTime)
else {
current_menu->selected = 0;
this->buttonSelected(current_menu->selected);
if (!current_menu->list->get(current_menu->list->size() - 1).selected)
if (!current_menu->list->get(current_menu->list->size() - 1).selected || (current_menu->list->get(current_menu->list->size() - 1).icon == SETTINGS && current_menu->list->get(current_menu->list->size() - 1).color == TFTLIGHTGREY))
this->buttonNotSelected(current_menu->list->size() - 1);
}
}
@@ -688,7 +705,7 @@ void MenuFunctions::main(uint32_t currentTime)
this->displayCurrentMenu(current_menu->selected);
}
this->buttonSelected(current_menu->selected - this->menu_start_index, current_menu->selected);
if (!current_menu->list->get(current_menu->selected + 1).selected)
if (!current_menu->list->get(current_menu->selected + 1).selected || (current_menu->list->get(current_menu->selected + 1).icon == SETTINGS && current_menu->list->get(current_menu->selected + 1).color == TFTLIGHTGREY))
this->buttonNotSelected(current_menu->selected + 1 - this->menu_start_index, current_menu->selected + 1);
}
// Loop to end
@@ -699,7 +716,7 @@ void MenuFunctions::main(uint32_t currentTime)
this->displayCurrentMenu(current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
}
this->buttonSelected(current_menu->selected, current_menu->selected);
if (!current_menu->list->get(0).selected)
if (!current_menu->list->get(0).selected || (current_menu->list->get(0).icon == SETTINGS && current_menu->list->get(0).color == TFTLIGHTGREY))
this->buttonNotSelected(0, this->menu_start_index);
}
}
@@ -761,7 +778,7 @@ void MenuFunctions::main(uint32_t currentTime)
}
else
this->buttonSelected(current_menu->selected - this->menu_start_index, current_menu->selected);
if (!current_menu->list->get(current_menu->selected - 1).selected)
if (!current_menu->list->get(current_menu->selected - 1).selected || (current_menu->list->get(current_menu->selected - 1).icon == SETTINGS && current_menu->list->get(current_menu->selected - 1).color == TFTLIGHTGREY))
this->buttonNotSelected(current_menu->selected - 1 - this->menu_start_index, current_menu->selected - 1);
}
// Loop to beginning
@@ -775,7 +792,7 @@ void MenuFunctions::main(uint32_t currentTime)
else {
current_menu->selected = 0;
this->buttonSelected(current_menu->selected);
if (!current_menu->list->get(current_menu->list->size() - 1).selected)
if (!current_menu->list->get(current_menu->list->size() - 1).selected || (current_menu->list->get(current_menu->list->size() - 1).icon == SETTINGS && current_menu->list->get(current_menu->list->size() - 1).color == TFTLIGHTGREY))
this->buttonNotSelected(current_menu->list->size() - 1);
}
}
@@ -1495,7 +1512,9 @@ void MenuFunctions::RunSetup()
// Main menu stuff
wifiMenu.list = new LinkedList<MenuNode>(); // Get list in second menu ready
#ifdef HAS_BT
bluetoothMenu.list = new LinkedList<MenuNode>(); // Get list in third menu ready
#endif
deviceMenu.list = new LinkedList<MenuNode>();
#ifdef HAS_GPS
if (gps_obj.getGpsModuleStatus()) {
@@ -1616,9 +1635,11 @@ void MenuFunctions::RunSetup()
this->addNodes(&mainMenu, text_table1[7], TFTGREEN, NULL, WIFI, [this]() {
this->changeMenu(&wifiMenu, true);
});
this->addNodes(&mainMenu, text_table1[19], TFTCYAN, NULL, BLUETOOTH, [this]() {
this->changeMenu(&bluetoothMenu, true);
});
#ifdef HAS_BT
this->addNodes(&mainMenu, text_table1[19], TFTCYAN, NULL, BLUETOOTH, [this]() {
this->changeMenu(&bluetoothMenu, true);
});
#endif
#ifdef HAS_GPS
if (gps_obj.getGpsModuleStatus()) {
this->addNodes(&mainMenu, text1_66, TFTRED, NULL, GPS_MENU, [this]() {
@@ -2559,6 +2580,7 @@ void MenuFunctions::RunSetup()
this->changeMenu(clearAPsMenu.parentMenu, true);
});
#ifdef HAS_BT
// Build Bluetooth Menu
bluetoothMenu.parentMenu = &mainMenu; // Second Menu is third menu parent
this->addNodes(&bluetoothMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
@@ -2658,6 +2680,7 @@ void MenuFunctions::RunSetup()
this->drawStatusBar();
wifi_scan_obj.StartScan(BT_ATTACK_SPAM_ALL, TFT_MAGENTA);
});
#endif
//#ifndef HAS_ILI9341
#ifdef HAS_BT
@@ -3698,7 +3721,7 @@ void MenuFunctions::buildButtons(Menu *menu, int starting_index, const char* but
for (uint8_t i = 0; i < visible_buttons; i++) {
MenuNode node = menu->list->get(starting_index + i);
uint16_t color = this->getColor(node.color);
uint16_t color = (node.icon == SETTINGS && node.color == TFTLIGHTGREY) ? (node.selected ? TFT_GREEN : TFT_RED) : this->getColor(node.color);
char buf[64];
@@ -3771,26 +3794,44 @@ void MenuFunctions::displayCurrentMenu(int start_index)
continue;
uint16_t color = this->getColor(current_menu->list->get(i).color);
#ifdef HAS_FULL_SCREEN
if ((current_menu->list->get(i).selected) || (current_menu->selected == i)) {
display_obj.key[i - start_index].drawButton(true, current_menu->list->get(i).name);
}
else {
display_obj.key[i - start_index].drawButton(false, current_menu->list->get(i).name);
}
if ((current_menu->list->get(i).name != text09) && (current_menu->list->get(i).icon != 255))
bool is_setting_node = (current_menu->list->get(i).icon == SETTINGS && current_menu->list->get(i).color == TFTLIGHTGREY);
if (is_setting_node && current_menu->selected == i) {
uint16_t setting_color = current_menu->list->get(i).selected ? TFT_GREEN : TFT_RED;
display_obj.key[i - start_index].initButton(&display_obj.tft, KEY_X, KEY_Y + (i - start_index) * (KEY_H + KEY_SPACING_Y), KEY_W, KEY_H, TFT_BLACK, TFT_LIGHTGREY, setting_color, (char*)"", KEY_TEXTSIZE);
display_obj.key[i - start_index].drawButton(false, current_menu->list->get(i).name);
display_obj.tft.drawXBitmap(0,
KEY_Y + (i - start_index) * (KEY_H + KEY_SPACING_Y) - (ICON_H / 2),
menu_icons[current_menu->list->get(i).icon],
ICON_W,
ICON_H,
TFT_BLACK,
color);
TFT_LIGHTGREY);
} else if ((!is_setting_node && current_menu->list->get(i).selected) || (current_menu->selected == i)) {
display_obj.key[i - start_index].drawButton(true, current_menu->list->get(i).name);
if ((current_menu->list->get(i).name != text09) && (current_menu->list->get(i).icon != 255))
display_obj.tft.drawXBitmap(0,
KEY_Y + (i - start_index) * (KEY_H + KEY_SPACING_Y) - (ICON_H / 2),
menu_icons[current_menu->list->get(i).icon],
ICON_W,
ICON_H,
TFT_BLACK,
color);
} else {
display_obj.key[i - start_index].drawButton(false, current_menu->list->get(i).name);
if ((current_menu->list->get(i).name != text09) && (current_menu->list->get(i).icon != 255))
display_obj.tft.drawXBitmap(0,
KEY_Y + (i - start_index) * (KEY_H + KEY_SPACING_Y) - (ICON_H / 2),
menu_icons[current_menu->list->get(i).icon],
ICON_W,
ICON_H,
TFT_BLACK,
is_setting_node ? TFT_LIGHTGREY : color);
}
#endif
#ifdef HAS_MINI_SCREEN
if ((current_menu->selected == i) || (current_menu->list->get(i).selected))
if ((current_menu->selected == i) || ((current_menu->list->get(i).icon != SETTINGS || current_menu->list->get(i).color != TFTLIGHTGREY) && current_menu->list->get(i).selected))
this->drawMiniMenuButton(i - start_index, i, true);
else
this->drawMiniMenuButton(i - start_index, i, false);
+2
View File
@@ -43,7 +43,9 @@
extern WiFiScan wifi_scan_obj;
extern SDInterface sd_obj;
// #ifdef HAS_BATTERY
extern BatteryInterface battery_obj;
// #endif
extern Settings settings_obj;
#define FLASH_BUTTON 0
+25 -7
View File
@@ -2112,8 +2112,10 @@ void WiFiScan::displayTargetFilter() {
display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
for (int i = 0; i < access_points->size(); i++) {
AccessPoint access_point = access_points->get(i);
if (access_point.selected)
display_obj.showCenterText("CH: " + (String)access_point.channel + " " + access_point.essid, display_obj.tft.getCursorY(), true);
if (access_point.selected) {
String msg_str = "CH: " + (String)access_point.channel + " " + access_point.essid;
display_obj.showCenterText(msg_str.c_str(), display_obj.tft.getCursorY(), true);
}
}
} else {
display_obj.tft.setTextColor(TFT_RED, TFT_BLACK);
@@ -3945,7 +3947,7 @@ void WiFiScan::RunInfo() {
#endif
Serial.println(text_table4[34]);
}
#endif
#endif // HAS_BATTERY
if (this->wifi_connected)
showNetworkInfo();
@@ -4072,6 +4074,10 @@ void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color) {
esp_wifi_set_promiscuous(true);
esp_wifi_set_promiscuous_filter(&filt);
esp_wifi_set_promiscuous_rx_cb(&wifiSnifferCallback);*/
#ifdef HAS_DUAL_BAND
dual_band_channel_index = 0;
set_channel = dual_band_channels[0];
#endif
this->changeChannel(this->set_channel);
//esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
this->wifi_initialized = true;
@@ -8832,8 +8838,14 @@ bool WiFiScan::filterActive() {
// Channel - button pressed
else if (b == CHAN_MINUS_INDEX) {
#ifndef HAS_DUAL_BAND
if (set_channel > 1) {
set_channel--;
#else
if (dual_band_channel_index > 0) {
dual_band_channel_index--;
set_channel = dual_band_channels[dual_band_channel_index];
#endif
delay(70);
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
display_obj.tftDrawXScaleButtons(x_scale);
@@ -8847,8 +8859,14 @@ bool WiFiScan::filterActive() {
// Channel + button pressed
else if (b == CHAN_PLUS_INDEX) {
#ifndef HAS_DUAL_BAND
if (set_channel < MAX_CHANNEL) {
set_channel++;
#else
if (dual_band_channel_index < (DUAL_BAND_CHANNELS - 1)) {
dual_band_channel_index++;
set_channel = dual_band_channels[dual_band_channel_index];
#endif
delay(70);
display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
display_obj.tftDrawXScaleButtons(x_scale);
@@ -9833,8 +9851,8 @@ void WiFiScan::displayTransmitRate() {
displayString2.concat(" ");
#ifdef HAS_SCREEN
display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
display_obj.showCenterText(displayString2, TFT_HEIGHT / 2);
display_obj.showCenterText(displayString, TFT_HEIGHT / 2);
display_obj.showCenterText(displayString2.c_str(), TFT_HEIGHT / 2);
display_obj.showCenterText(displayString.c_str(), TFT_HEIGHT / 2);
#endif
}
@@ -10105,8 +10123,8 @@ void WiFiScan::main(uint32_t currentTime)
displayString2.concat(" ");
#ifdef HAS_SCREEN
display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
display_obj.showCenterText(displayString2, TFT_HEIGHT / 2);
display_obj.showCenterText(displayString, TFT_HEIGHT / 2);
display_obj.showCenterText(displayString2.c_str(), TFT_HEIGHT / 2);
display_obj.showCenterText(displayString.c_str(), TFT_HEIGHT / 2);
#endif
}
+59 -36
View File
@@ -124,6 +124,11 @@
//#define FLIPPER_ZERO_HAT
#define HAS_MINI_KB
#define HAS_BATTERY
#if defined(MARAUDER_M5STICKC)
#define HAS_AXP192
#else
#define HAS_TP4057
#endif
#define HAS_BT
#define HAS_BUTTONS
//#define HAS_NEOPIXEL_LED
@@ -237,6 +242,7 @@
#define HAS_TOUCH
//#define FLIPPER_ZERO_HAT
#define HAS_BATTERY
#define HAS_IP5306
#define HAS_BT
//#define HAS_BUTTONS
#define HAS_NEOPIXEL_LED
@@ -256,6 +262,7 @@
#define HAS_TOUCH
//#define FLIPPER_ZERO_HAT
#define HAS_BATTERY
#define HAS_IP5306
#define HAS_BT
#define HAS_BT_REMOTE
#define HAS_BUTTONS
@@ -554,7 +561,7 @@
//// POWER MANAGEMENT
#ifdef HAS_PWR_MGMT
#if defined(MARAUDER_M5STICKC) || defined(MARAUDER_M5STICKCP2)
#if defined(HAS_AXP192)
#include "AXP192.h"
#endif
@@ -2640,72 +2647,88 @@
//// BATTERY STUFF
#ifdef HAS_BATTERY
#ifdef MARAUDER_V4
#if defined(MARAUDER_M5STICKC) || defined(MARAUDER_M5STICKCP2)
#define I2C_SDA 33
#define I2C_SCL 22
#endif
#ifdef MARAUDER_V6
#elif defined(MARAUDER_V4) || defined(MARAUDER_V6) || defined(MARAUDER_V6_1) || defined(MARAUDER_KIT)
#define I2C_SDA 33
#define I2C_SCL 22
#endif
#define HAS_IP5306
#ifdef MARAUDER_V6_1
#define I2C_SDA 33
#define I2C_SCL 22
#endif
#ifdef MARAUDER_M5STICKC
#define I2C_SDA 33
#define I2C_SCL 22
#endif
#ifdef MARAUDER_KIT
#define I2C_SDA 33
#define I2C_SCL 22
#endif
#ifdef MARAUDER_MINI
#elif defined(MARAUDER_MINI)
#define I2C_SDA 33
#define I2C_SCL 26
#endif
#ifdef MARAUDER_V7
#elif defined(MARAUDER_V7)
#define I2C_SDA 33
#define I2C_SCL 16
#endif
#define HAS_IP5306
#ifdef MARAUDER_V7_1
#elif defined(MARAUDER_V7_1)
#define I2C_SDA 33
#define I2C_SCL 27
#endif
#ifdef MARAUDER_CYD_MICRO
#elif defined(MARAUDER_CYD_MICRO)
#define I2C_SDA 22
#define I2C_SCL 27
#endif
#ifdef MARAUDER_CYD_2USB
#elif defined(MARAUDER_CYD_2USB)
#define I2C_SDA 22
#define I2C_SCL 27
#endif
#ifdef MARAUDER_CYD_3_5_INCH
#elif defined(MARAUDER_CYD_3_5_INCH)
#define I2C_SDA 32
#define I2C_SCL 25
#endif
#ifdef MARAUDER_CYD_GUITION
#elif defined(MARAUDER_CYD_GUITION)
#define I2C_SDA 22
#define I2C_SCL 21
#endif
#ifdef MARAUDER_V8
#elif defined(MARAUDER_V8)
#define I2C_SCL 4
#define I2C_SDA 5
#elif defined(MARAUDER_REV_FEATHER)
#define I2C_SCL 4
#define I2C_SDA 3
#define HAS_MAX1704X
#undef HAS_AXP2101
#undef HAS_IP5306
#endif
#endif
// If we know what we have, we can delete what we're not using
#ifdef BATTERY_ADC_PIN
#undef HAS_AXP2101
#undef HAS_IP5306
#undef HAS_MAX1704X
#undef HAS_AXP192
// No driver for this LiPo charger
#elif defined(HAS_TP4057)
#undef HAS_AXP2101
#undef HAS_IP5306
#undef HAS_MAX1704X
#undef HAS_AXP192
#elif defined(HAS_AXP192)
#undef HAS_AXP2101
#undef HAS_IP5306
#undef HAS_MAX1704X
#elif defined(HAS_AXP2101)
#undef HAS_IP5306
#undef HAS_MAX1704X
#else // punt
// #define HAS_AXP2101
#define HAS_IP5306
#define HAS_MAX1704X
#define HAS_AXP192
#endif
#endif // HAS_BATTERY
//// MARAUDER TITLE STUFF
#ifdef MARAUDER_V4
+1 -9
View File
@@ -1,6 +1,6 @@
/* FLASH SETTINGS
Board: LOLIN D32
Flash Frequency: 80MHz
Frequency: 80MHz
Partition Scheme: Minimal SPIFFS
https://www.online-utility.org/image/convert/to/XBM
*/
@@ -92,10 +92,6 @@ CommandLine cli_obj;
SDInterface sd_obj;
#endif
#ifdef MARAUDER_M5STICKC
AXP192 axp192_obj;
#endif
#ifdef HAS_FLIPPER_LED
flipperLED flipper_led;
#elif defined(XIAO_ESP32_S3)
@@ -252,10 +248,6 @@ void setup()
delay(100);
#endif
#ifdef defined(MARAUDER_M5STICKC) && !defined(MARAUDER_M5STICKCP2)
axp192_obj.begin();
#endif
#if defined(MARAUDER_M5STICKCP2) // Prevent StickCP2 from turning off when disconnect USB cable
pinMode(POWER_HOLD_PIN, OUTPUT);
digitalWrite(POWER_HOLD_PIN, HIGH);