Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
[platformio]
default_envs =
m5stack-cardputer
;m5stack-sticks3
;m5stack-cplus2
m5stack-sticks3
m5stack-cplus2
;m5stack-cplus1_1
;LAUNCHER_m5stack-cplus1_1
;m5stack-core2
Expand Down Expand Up @@ -129,7 +129,7 @@ build_flags =
-DEEPROMSIZE=128
-DLH=8
-DLW=6
-flto
;-flto
-ffunction-sections
-fdata-sections
-Os
Expand Down Expand Up @@ -202,7 +202,7 @@ lib_deps =
bitbank2/AnimatedGIF
bitbank2/PNGdec @ ^1.1.2
ESP32Async/ESPAsyncWebServer
fastled/FastLED @^3.10.3
https://github.com/bmorcelli/FastLED
jgromes/RadioLib @ ^7.4.0
; Pinned to fixed commits so upstream changes never break our patches
; (applied by patch_library_conflicts.py): IRQ-less I2C polling for
Expand Down
18 changes: 5 additions & 13 deletions src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,19 +927,11 @@ void drawStatusBar() {
tft.drawLine(5, 25, tftWidth - 6, 25, bruceConfig.priColor);
}

if (clock_set) {
setTftDisplay(12, 12, bruceConfig.priColor, 1, bruceConfig.bgColor);
tft.fillRect(12, 12, 60, LH, bruceConfig.bgColor);
#if defined(HAS_RTC)
updateTimeStr(_rtc.getTimeStruct());
#else
updateTimeStr(rtc.getTimeStruct());
#endif
tft.print(timeStr);
} else {
setTftDisplay(12, 12, bruceConfig.priColor, 1, bruceConfig.bgColor);
tft.print("BRUCE " + String(BRUCE_VERSION));
}
// === УБРАЛИ ЧАСЫ ===
setTftDisplay(12, 12, bruceConfig.priColor, 1, bruceConfig.bgColor);
tft.fillRect(12, 12, 60, LH, bruceConfig.bgColor);
tft.print("BRUCE");
// ===================

int iconCount = 0;
bool showSD = sdcardMounted;
Expand Down
9 changes: 6 additions & 3 deletions src/core/menu_items/IRMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
#include "modules/ir/custom_ir.h"
#include "modules/ir/ir_jammer.h"
#include "modules/ir/ir_read.h"
#include "modules/ir/conditioners.h" // <--- ДОБАВЛЕНО ДЛЯ AC

void IRMenu::optionsMenu() {
#if defined(ARDUINO_M5STICK_S3)
bool prevPower = M5.Power.getExtOutput();
M5.Power.setExtOutput(true); // ENABLE 5V OUTPUT
#endif

options = {
{"TV-B-Gone", StartTvBGone },
{"Custom IR", otherIRcodes },
{"IR Read", [=]() { IrRead(); } },
{"TV-B-gone", StartTvBGone }, // Переименовано
{"Custom IR", otherIRcodes }, // Переименовано
{"Ir read", [=]() { IrRead(); } }, // Переименовано
{"AC", [=]() { conditionersMenu(); } }, // <--- НОВЫЙ ПУНКТ
#if !defined(LITE_VERSION)
{"IR Jammer", startIrJammer }, // Simple frequency-adjustable jammer
#endif
Expand Down
27 changes: 27 additions & 0 deletions src/modules/ir/conditioners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "conditioners.h"
#include "core/display.h"
#include "core/mykeyboard.h"
#include "custom_ir.h"
#include <globals.h>
#include <ir_Gree.h>

void sendGreeAC(bool power, int temp, int mode) {
IRGreeAC ac(bruceConfigPins.irTx);
ac.begin();
ac.setPower(power);
ac.setTemp(temp);
ac.setMode(mode); // 0=Auto, 1=Cool, 2=Dry, 3=Fan, 4=Heat
ac.setFan(0); // 0=Auto
ac.send();
delay(200);
}

void conditionersMenu() {
options = {
{"ON (Cool 22)", [=]() { displayRedStripe("Sending ON..."); sendGreeAC(true, 22, 1); displaySuccess("Done!"); }},
{"ON (Heat 24)", [=]() { displayRedStripe("Sending HEAT..."); sendGreeAC(true, 24, 4); displaySuccess("Done!"); }},
{"OFF", [=]() { displayRedStripe("Sending OFF..."); sendGreeAC(false, 22, 1); displaySuccess("Done!"); }},
{"Back", yield}
};
loopOptions(options);
}
8 changes: 8 additions & 0 deletions src/modules/ir/conditioners.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef __CONDITIONERS_H__
#define __CONDITIONERS_H__

#include <Arduino.h>

void conditionersMenu();

#endif
55 changes: 17 additions & 38 deletions src/modules/ir/ir_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,26 @@ static String getParsedProtocolName(const decode_results &r) {
}

void IrRead::setup() {
// === КАК В 1.11.1 ===
irrecv.enableIRIn();

#ifdef USE_BOOST
PPM.enableOTG();
#endif
// Проверяем, что пин приёмника есть в списке IR_RX_PINS
const std::vector<std::pair<String, int>> pins = IR_RX_PINS;
int count = 0;
for (auto pin : pins) {
if (pin.second == bruceConfigPins.irRx) count++;
}
if (count == 0) gsetIrRxPin(true);

setup_ir_pin(bruceConfigPins.irRx, INPUT);
// КАК В 1.11.1: обычный INPUT, без setup_ir_pin (он и был источником шума).
pinMode(bruceConfigPins.irRx, INPUT);

if (headless) return;
returnToMenu = true;

std::vector<Option> quickRemoteOptions = {
{"TV",
[&]() {
Expand Down Expand Up @@ -241,16 +246,11 @@ void IrRead::read_signal() {

_read_signal = true;

raw = (results.decode_type == decode_type_t::UNKNOWN) || hasACState(results.decode_type);
// КАК В 1.11.1: всегда пишем RAW, без разбора протокола.
raw = true;

display_banner();

if (!raw) {
String proto = getParsedProtocolName(results);
padprintln("Protocol: " + (proto.length() ? proto : "UNKNOWN"));
padprintln("Bits: " + String(results.bits));
}

padprint("RAW Data Captured:");
String raw_signal = parse_raw_signal();
_captured_raw_signal = raw_signal;
Expand All @@ -269,32 +269,15 @@ void IrRead::discard_signal() {
}

void IrRead::emulate_signal() {
// В 1.11.1 эмуляции не было. Здесь реализуем её только через RAW,
// потому что raw всегда = true (как в 1.11.1).
IRCode code;
if (raw) {
code.type = "raw";
code.frequency = IR_FREQUENCY;
code.data = _captured_raw_signal;
} else {
code.type = "parsed";
code.protocol = getParsedProtocolName(results);
code.address = uint32ToString(results.address);
code.command = (results.decode_type == decode_type_t::NEC)
? uint32ToString(necCommandWithInverse(results.command))
: uint32ToString(results.command);
code.bits = results.bits;
code.data = resultToHexidecimal(&results);
if (code.protocol == "") {
code.type = "raw";
code.frequency = IR_FREQUENCY;
code.data = _captured_raw_signal;
}
}
code.type = "raw";
code.frequency = IR_FREQUENCY;
code.data = _captured_raw_signal;

sendIRCommand(&code);
if (code.type == "parsed" &&
(code.protocol == "RC5" || code.protocol == "RC5X" || code.protocol == "RC6")) {
delay(35);
sendIRCommand(&code);
}

_emulate_mode = true;
display_banner();
tft.setTextSize(FP);
Expand Down Expand Up @@ -329,12 +312,10 @@ String IrRead::parse_state_signal() {
}

String IrRead::parse_raw_signal() {

rawcode = resultToRawArray(&results);
raw_data_len = getCorrectedRawLength(&results);

String signal_code = "";

for (uint16_t i = 0; i < raw_data_len; i++) { signal_code += String(rawcode[i]) + " "; }

delete[] rawcode;
Expand All @@ -353,6 +334,8 @@ void IrRead::append_to_file_str(const String &btn_name) {
strDeviceContent += "duty_cycle: " + String(DUTY_CYCLE) + "\n";
strDeviceContent += "data: " + parse_raw_signal() + "\n";
} else {
// Эта ветка в текущей логике недостижима (raw всегда true),
// но оставлена для совместимости с ir_read.h.
strDeviceContent += "type: parsed\n";
switch (results.decode_type) {
case decode_type_t::RC5: {
Expand Down Expand Up @@ -421,7 +404,6 @@ void IrRead::save_device() {
{"SD Card", [&]() { fs = &SD; } },
{"LittleFS", [&]() { fs = &LittleFS; }},
};

loopOptions(options);
} else if (sdCardAvailable) {
fs = &SD;
Expand All @@ -448,7 +430,6 @@ void IrRead::save_device() {
}

String IrRead::loop_headless(int max_loops) {

while (!irrecv.decode(&results)) {
max_loops -= 1;
if (max_loops <= 0) {
Expand Down Expand Up @@ -496,7 +477,6 @@ bool IrRead::write_file(String filename, FS *fs) {
{"Overwrite ", [&]() { ch = 2; }},
{"Change name", [&]() { ch = 3; }},
};

loopOptions(options);

switch (ch) {
Expand All @@ -515,7 +495,6 @@ bool IrRead::write_file(String filename, FS *fs) {
}

File file = (*fs).open("/BruceIR/" + filename + ".ir", FILE_WRITE);

if (!file) { return false; }

file.println("Filetype: Bruce IR File");
Expand Down