Skip to content
Draft
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
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
"stop_token": "cpp",
"text_encoding": "cpp",
"variant": "cpp",
"usb_serial_jtag.h": "c"
"usb_serial_jtag.h": "c",
"memguard.h": "c",
"noftypes.h": "c"
},
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
Expand Down
1 change: 1 addition & 0 deletions boards/m5stack-cplus2/m5stack-cplus2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ board_upload.maximum_size = 8388608
build_src_filter =${env.build_src_filter} +<../boards/m5stack-cplus2>
build_flags =
${env.build_flags}
${env_light.build_flags}
-Iboards/m5stack-cplus2
-DCORE_DEBUG_LEVEL=1

Expand Down
2 changes: 2 additions & 0 deletions boards/m5stack-cplus2/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#define HAS_3_BUTTONS
#define M5STICK

// #define LITE_VERSION 1

static const uint8_t TX = 1;
static const uint8_t RX = 3;

Expand Down
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ lib_deps =
bitbank2/PNGdec @ ^1.1.2
ESP32Async/ESPAsyncWebServer
fastled/FastLED @^3.10.3
https://github.com/Tawank/arduino-nofrendo.git

monitor_speed = 115200

Expand Down
2 changes: 2 additions & 0 deletions src/core/menu_items/OthersMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "core/utils.h"
#include "modules/badusb_ble/ducky_typer.h"
#include "modules/bjs_interpreter/interpreter.h"
#include "modules/nes/nes_emu.h"
#include "modules/others/clicker.h"
#include "modules/others/ibutton.h"
#include "modules/others/mic.h"
Expand All @@ -12,6 +13,7 @@

void OthersMenu::optionsMenu() {
options = {
{"NES Emulator", setup_nes },
{"QRCodes", qrcode_menu },
{"Megalodon", shark_setup },
#ifdef MIC_SPM1423
Expand Down
49 changes: 8 additions & 41 deletions src/modules/bjs_interpreter/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,9 @@ static duk_ret_t native_analogRead(duk_context *ctx) {
}

static duk_ret_t native_touchRead(duk_context *ctx) {
#if SOC_TOUCH_SENSOR_SUPPORTED
int val = touchRead(duk_to_int(ctx, 0));
duk_push_int(ctx, val);
return 1;
#else
return duk_error(ctx, DUK_ERR_TYPE_ERROR, "%s function not supported on this device", "gpio.touchRead()");
#endif
}

static duk_ret_t native_dacWrite(duk_context *ctx) {
Expand All @@ -123,22 +119,13 @@ static duk_ret_t native_dacWrite(duk_context *ctx) {
}

static duk_ret_t native_ledcSetup(duk_context *ctx) {
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
int val = ledcAttach(duk_get_int(ctx, 0), 50, duk_get_int(ctx, 1));
#else
int val = ledcSetup(duk_get_int(ctx, 0), duk_get_int(ctx, 1), duk_get_int(ctx, 2));
#endif
duk_push_int(ctx, val);

return 1;
// int val = ledcSetup(duk_get_int(ctx, 0), duk_get_int(ctx, 1), duk_get_int(ctx, 2));
// duk_push_int(ctx, val);
return 0;
}

static duk_ret_t native_ledcAttachPin(duk_context *ctx) {
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
ledcAttach(duk_get_int(ctx, 0), 50, duk_get_int(ctx, 1));
#else
ledcAttachPin(duk_get_int(ctx, 0), duk_get_int(ctx, 1));
#endif
ledcAttach(duk_get_int(ctx, 0), duk_get_int(ctx, 1), duk_get_int(ctx, 2));
return 0;
}

Expand Down Expand Up @@ -455,37 +442,17 @@ static duk_ret_t native_tone(duk_context *ctx) {
}

static duk_ret_t native_irTransmitFile(duk_context *ctx) {
// usage: irTransmitFile(filename : string, hideDefaultUI : boolean);
// usage: irTransmitFile(filename : string);
// returns: bool==true on success, false on any error

// Get the filename (required)
const char *filename = duk_to_string(ctx, 0);

// Default for the hideDefaultUI parameter
bool hideDefaultUI = false;

// Check if second argument exists and is boolean
if (duk_get_top(ctx) > 1 && duk_is_boolean(ctx, 1)) { hideDefaultUI = duk_to_boolean(ctx, 1); }

bool r = serialCli.parse("ir tx_from_file " + String(filename) + " " + String(hideDefaultUI));
bool r = serialCli.parse("ir tx_from_file " + String(duk_to_string(ctx, 0)));
duk_push_boolean(ctx, r);
return 1;
}

static duk_ret_t native_subghzTransmitFile(duk_context *ctx) {
// usage: subghzTransmitFile(filename : string, hideDefaultUI : boolean);
// usage: subghzTransmitFile(filename : string);
// returns: bool==true on success, false on any error

// Get the filename (required)
const char *filename = duk_to_string(ctx, 0);

// Default for the hideDefaultUI parameter
bool hideDefaultUI = false;

// Check if second argument exists and is boolean
if (duk_get_top(ctx) > 1 && duk_is_boolean(ctx, 1)) { hideDefaultUI = duk_to_boolean(ctx, 1); }

bool r = serialCli.parse("subghz tx_from_file " + String(filename) + " " + String(hideDefaultUI));
bool r = serialCli.parse("subghz tx_from_file " + String(duk_to_string(ctx, 0)));
duk_push_boolean(ctx, r);
return 1;
}
Expand Down
12 changes: 12 additions & 0 deletions src/modules/nes/hw_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _HW_CONFIG_H_
#define _HW_CONFIG_H_

// enable audio
// #define HW_AUDIO
#define HW_AUDIO_BUZZER
#define HW_AUDIO_BUZZER_PIN 2
#define HW_AUDIO_SAMPLERATE 22050

#define PAL

#endif /* _HW_CONFIG_H_ */
Loading