mirror of
https://github.com/BruceDevices/firmware.git
synced 2026-03-13 10:12:21 +08:00
C5 with ILI9341, fixed some things
This commit is contained in:
@@ -40,6 +40,8 @@ void _setup_gpio() {
|
||||
log_i("Touch IC not Started");
|
||||
} else log_i("Touch IC Started");
|
||||
#endif
|
||||
|
||||
bruceConfig.colorInverted = 0;
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
@@ -80,7 +82,7 @@ void _post_setup_gpio() {
|
||||
// Brightness control must be initialized after tft in this case @Pirata
|
||||
pinMode(TFT_BL, OUTPUT);
|
||||
ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
|
||||
ledcWrite(TFT_BRIGHT_CHANNEL, 255);
|
||||
ledcWrite(TFT_BL, 255);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
@@ -9,12 +9,19 @@
|
||||
| NRF24 | 6 | 2 | 7 | 9* | 8* |
|
||||
(*) CC1101, NRF24, W5500 use the same pinouts, need to add a switch on CS and CE/GDO0 to choose which to use.
|
||||
|
||||
If using Buttons, use thesee pinouts
|
||||
| Buttons | GPIO |
|
||||
| --- | :---: |
|
||||
| Prev | 0 |
|
||||
| Sel | 28 |
|
||||
| Next | 1 |
|
||||
|
||||
If using ILI9341 with XPT2046 fo touchscreen, in this case you have 2 GPIO available (0 and 28) to use on CC1101/NRF24
|
||||
| Device | SCK | MISO | MOSI | CS | IRQ |
|
||||
| --- | :---: | :---: | :---: | :---: | :---: |
|
||||
| Display | 6 | 2 | 7 | 23 | --- |
|
||||
| XPT2046 | 6 | 2 | 7 | 1 | --- |
|
||||
|
||||
|
||||
| Device | RX | TX | GPIO |
|
||||
| --- | :---: | :---: | :---: |
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "core/powerSave.h"
|
||||
#include "core/utils.h"
|
||||
#include <interface.h>
|
||||
|
||||
/***************************************************************************************
|
||||
@@ -20,10 +21,11 @@ void _setup_gpio() {
|
||||
pinMode(TFT_DC, OUTPUT);
|
||||
digitalWrite(TFT_DC, HIGH);
|
||||
|
||||
#ifdef HAS_3_BUTTONS
|
||||
pinMode(UP_BTN, INPUT_PULLUP); // Sets the power btn as an INPUT
|
||||
pinMode(SEL_BTN, INPUT_PULLUP);
|
||||
pinMode(DW_BTN, INPUT_PULLUP);
|
||||
|
||||
#endif
|
||||
pinMode(NRF24_SS_PIN, OUTPUT);
|
||||
pinMode(CC1101_SS_PIN, OUTPUT);
|
||||
pinMode(SDCARD_CS, OUTPUT);
|
||||
@@ -35,6 +37,44 @@ void _setup_gpio() {
|
||||
digitalWrite(SDCARD_CS, HIGH);
|
||||
digitalWrite(W5500_SS_PIN, HIGH);
|
||||
digitalWrite(TFT_CS, HIGH);
|
||||
#ifdef ILI9341_DRIVER
|
||||
bruceConfig.colorInverted = 0;
|
||||
#endif
|
||||
}
|
||||
/***************************************************************************************
|
||||
** Function name: _post_setup_gpio()
|
||||
** Location: main.cpp
|
||||
** Description: second stage gpio setup to make a few functions work
|
||||
***************************************************************************************/
|
||||
void _post_setup_gpio() {
|
||||
#ifdef HAS_TOUCH
|
||||
pinMode(TOUCH_CS, OUTPUT);
|
||||
uint16_t calData[5];
|
||||
File caldata = LittleFS.open("/calData", "r");
|
||||
|
||||
if (!caldata) {
|
||||
tft.setRotation(ROTATION);
|
||||
tft.calibrateTouch(calData, TFT_WHITE, TFT_BLACK, 10);
|
||||
|
||||
caldata = LittleFS.open("/calData", "w");
|
||||
if (caldata) {
|
||||
caldata.printf(
|
||||
"%d\n%d\n%d\n%d\n%d\n", calData[0], calData[1], calData[2], calData[3], calData[4]
|
||||
);
|
||||
caldata.close();
|
||||
}
|
||||
} else {
|
||||
Serial.print("\ntft Calibration data: ");
|
||||
for (int i = 0; i < 5; i++) {
|
||||
String line = caldata.readStringUntil('\n');
|
||||
calData[i] = line.toInt();
|
||||
Serial.printf("%d, ", calData[i]);
|
||||
}
|
||||
Serial.println();
|
||||
caldata.close();
|
||||
}
|
||||
tft.setTouch(calData);
|
||||
#endif
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
@@ -71,7 +111,53 @@ void _setBrightness(uint8_t brightval) {
|
||||
void InputHandler(void) {
|
||||
static unsigned long tm = 0;
|
||||
if (millis() - tm < 200 && !LongPress) return;
|
||||
#ifdef HAS_TOUCH
|
||||
TouchPoint t;
|
||||
checkPowerSaveTime();
|
||||
bool _IH_touched = tft.getTouch(&t.x, &t.y);
|
||||
if (_IH_touched) {
|
||||
NextPress = false;
|
||||
PrevPress = false;
|
||||
UpPress = false;
|
||||
DownPress = false;
|
||||
SelPress = false;
|
||||
EscPress = false;
|
||||
AnyKeyPress = false;
|
||||
NextPagePress = false;
|
||||
PrevPagePress = false;
|
||||
touchPoint.pressed = false;
|
||||
_IH_touched = false;
|
||||
Serial.printf("\nRAW: Touch Pressed on x=%d, y=%d", t.x, t.y);
|
||||
if (bruceConfig.rotation == 3) {
|
||||
t.y = (tftHeight + 20) - t.y;
|
||||
t.x = tftWidth - t.x;
|
||||
}
|
||||
if (bruceConfig.rotation == 0) {
|
||||
uint16_t tmp = t.x;
|
||||
t.x = map((tftHeight + 20) - t.y, 0, 320, 0, 240);
|
||||
t.y = map(tmp, 0, 240, 0, 320);
|
||||
}
|
||||
if (bruceConfig.rotation == 2) {
|
||||
uint16_t tmp = t.x;
|
||||
t.x = map(t.y, 0, 320, 0, 240);
|
||||
t.y = map(tftWidth - tmp, 0, 240, 0, 320);
|
||||
}
|
||||
|
||||
Serial.printf("\nROT: Touch Pressed on x=%d, y=%d, rot=%d\n", t.x, t.y, bruceConfig.rotation);
|
||||
|
||||
if (!wakeUpScreen()) AnyKeyPress = true;
|
||||
else return;
|
||||
|
||||
// Touch point global variable
|
||||
touchPoint.x = t.x;
|
||||
touchPoint.y = t.y;
|
||||
touchPoint.pressed = true;
|
||||
touchHeatMap(touchPoint);
|
||||
tm = millis();
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef HAS_3_BUTTONS
|
||||
bool upPressed = (digitalRead(UP_BTN) == LOW);
|
||||
bool selPressed = (digitalRead(SEL_BTN) == LOW);
|
||||
bool dwPressed = (digitalRead(DW_BTN) == LOW);
|
||||
@@ -85,6 +171,7 @@ void InputHandler(void) {
|
||||
EscPress = upPressed && dwPressed;
|
||||
NextPress = dwPressed;
|
||||
SelPress = selPressed;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
@@ -71,24 +71,30 @@ static const uint8_t LP_TX = 11;
|
||||
#define ROTATION 1
|
||||
#define MINBRIGHT (uint8_t)1
|
||||
#define USER_SETUP_LOADED 1
|
||||
|
||||
// Setup for ST7789 170x320
|
||||
#define ST7789_DRIVER 1
|
||||
#define TFT_RGB_ORDER 0
|
||||
#define TFT_WIDTH 170
|
||||
#define TFT_HEIGHT 320
|
||||
/* --------------------- */
|
||||
// Setup for ST7789 170x320
|
||||
|
||||
// #define ST7789_DRIVER 1
|
||||
// #define TFT_RGB_ORDER 0
|
||||
// #define TFT_WIDTH 170
|
||||
// #define TFT_HEIGHT 320
|
||||
|
||||
/* --------------------- */
|
||||
// Setup for ST7789 240x320
|
||||
|
||||
// #define ST7789_DRIVER=1
|
||||
// #define TFT_WIDTH=240
|
||||
// #define TFT_HEIGHT=320
|
||||
// // #define TFT_INVERSION_ON
|
||||
// #define TFT_RGB_ORDER=TFT_BGR
|
||||
|
||||
/* --------------------- */
|
||||
// Setup for ILI9341 320x240 (no touch)
|
||||
// #define ILI9341_DRIVER 1
|
||||
// #define TFT_HEIGHT 320
|
||||
// #define TFT_WIDTH 240
|
||||
|
||||
#define ILI9341_DRIVER 1
|
||||
#define TFT_HEIGHT 320
|
||||
#define TFT_WIDTH 240
|
||||
|
||||
/* --------------------- */
|
||||
// Common TFT definitions
|
||||
#define TFT_BACKLIGHT_ON 1
|
||||
@@ -99,7 +105,7 @@ static const uint8_t LP_TX = 11;
|
||||
#define TFT_MOSI 7
|
||||
#define TFT_SCLK 6
|
||||
#define TFT_CS 23
|
||||
#define TOUCH_CS -1
|
||||
#define TOUCH_CS 1
|
||||
#define SMOOTH_FONT 1
|
||||
#define SPI_FREQUENCY 20000000
|
||||
#define SPI_READ_FREQUENCY 20000000
|
||||
@@ -112,6 +118,17 @@ static const uint8_t LP_TX = 11;
|
||||
// GPS Bus
|
||||
#define GPS_SERIAL_TX 5
|
||||
#define GPS_SERIAL_RX 4
|
||||
|
||||
#ifdef ILI9341_DRIVER
|
||||
// Touch Screen
|
||||
#define USE_TFT_eSPI_TOUCH 1 // touchscreen uses same tft spi bus
|
||||
#define HAS_TOUCH 1
|
||||
#define TOUCH_INT -1
|
||||
#define TOUCH_CS 1
|
||||
#define BTN_ACT LOW
|
||||
#define DEEPSLEEP_WAKEUP_PIN 0
|
||||
|
||||
#else
|
||||
// Buttons
|
||||
#define HAS_3_BUTTONS
|
||||
#define SEL_BTN 28
|
||||
@@ -119,6 +136,8 @@ static const uint8_t LP_TX = 11;
|
||||
#define UP_BTN 0
|
||||
#define BTN_ACT LOW
|
||||
#define DEEPSLEEP_WAKEUP_PIN SEL_BTN
|
||||
#endif
|
||||
|
||||
// InfraRed
|
||||
#define RXLED 26
|
||||
#define LED 3
|
||||
|
||||
@@ -125,7 +125,7 @@ void _post_setup_gpio() {
|
||||
// Brightness control must be initialized after tft in this case @Pirata
|
||||
pinMode(TFT_BL, OUTPUT);
|
||||
ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
|
||||
ledcWrite(TFT_BRIGHT_CHANNEL, 255);
|
||||
ledcWrite(TFT_BL, 255);
|
||||
}
|
||||
/*********************************************************************
|
||||
** Function: setBrightness
|
||||
|
||||
@@ -156,7 +156,7 @@ build_flags =
|
||||
-DSPI_MISO_PIN=38
|
||||
-DSPI_SS_PIN=-1
|
||||
-DT_DECK_PLUS
|
||||
-DDEVICE_NAME='"Lilygo T-Deck Pro"'
|
||||
-DDEVICE_NAME='"Lilygo T-Deck Plus"'
|
||||
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
@@ -177,4 +177,9 @@ build_flags =
|
||||
-DDEVICE_NAME='"Lilygo T-Deck"'
|
||||
|
||||
build_unflags =
|
||||
-DIR_TX_PINS='{{"Unavailable", -1}}'
|
||||
-DIR_RX_PINS='{{"Unavailable", -1}}'
|
||||
-DRF_TX_PINS='{{"Unavailable", -1}}'
|
||||
-DRF_RX_PINS='{{"Unavailable", -1}}'
|
||||
-DDEVICE_NAME='"Lilygo T-Deck Plus"'
|
||||
-DT_DECK_PLUS
|
||||
|
||||
@@ -78,7 +78,7 @@ void _setup_gpio() {
|
||||
void _post_setup_gpio() {
|
||||
// PWM backlight setup
|
||||
ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
|
||||
ledcWrite(TFT_BRIGHT_CHANNEL, 255);
|
||||
ledcWrite(TFT_BL, 255);
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
|
||||
@@ -37,7 +37,7 @@ void _post_setup_gpio() {
|
||||
// Brightness control must be initialized after tft in this case @Pirata
|
||||
pinMode(TFT_BL, OUTPUT);
|
||||
ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
|
||||
ledcWrite(TFT_BRIGHT_CHANNEL, 255);
|
||||
ledcWrite(TFT_BL, 255);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
@@ -95,7 +95,7 @@ void _post_setup_gpio() {
|
||||
pinMode(TFT_BL, OUTPUT);
|
||||
digitalWrite(TFT_BL, HIGH);
|
||||
ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
|
||||
ledcWrite(TFT_BRIGHT_CHANNEL, 255);
|
||||
ledcWrite(TFT_BL, 255);
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
|
||||
@@ -36,7 +36,7 @@ void _post_setup_gpio() {
|
||||
// Brightness control must be initialized after tft in this case @Pirata
|
||||
pinMode(TFT_BL, OUTPUT);
|
||||
ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
|
||||
ledcWrite(TFT_BRIGHT_CHANNEL, 255);
|
||||
ledcWrite(TFT_BL, 255);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
121
sd_files/xFlipper.js
Normal file
121
sd_files/xFlipper.js
Normal file
@@ -0,0 +1,121 @@
|
||||
|
||||
let eventLoop = require("event_loop");
|
||||
let gui = require("gui");
|
||||
|
||||
let loadingView = require("gui/loading");
|
||||
let submenuView = require("gui/submenu");
|
||||
let emptyView = require("gui/empty_screen");
|
||||
let textInputView = require("gui/text_input");
|
||||
let byteInputView = require("gui/byte_input");
|
||||
let textBoxView = require("gui/text_box");
|
||||
let dialogView = require("gui/dialog");
|
||||
let filePicker = require("gui/file_picker");
|
||||
let icon = require("gui/icon");
|
||||
let flipper = require("flipper");
|
||||
|
||||
let press =0;
|
||||
let serial = require("serial");
|
||||
|
||||
serial.setup("usart", 115200);
|
||||
|
||||
|
||||
function SerialCMD(cmd) {
|
||||
serial.write(cmd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// declare view instances
|
||||
let views = {
|
||||
loading: loadingView.make(),
|
||||
empty: emptyView.make(),
|
||||
keyboard: textInputView.makeWith({
|
||||
header: "",
|
||||
minLength: 0,
|
||||
maxLength: 32,
|
||||
defaultText: flipper.getName(),
|
||||
defaultTextClear: true,
|
||||
}),
|
||||
helloDialog: dialogView.make(),
|
||||
bytekb: byteInputView.makeWith({
|
||||
}),
|
||||
longText: textBoxView.makeWith({
|
||||
text: "",
|
||||
}),
|
||||
xmenu: submenuView.makeWith({
|
||||
header: "xFlipper",
|
||||
items: [
|
||||
"Controller",
|
||||
"Terminal",
|
||||
"Send Command",
|
||||
"Exit app",
|
||||
],
|
||||
}),
|
||||
};
|
||||
|
||||
// Enable illegal filename symbols since we're not choosing filenames, gives more flexibility
|
||||
// Not available in all firmwares, good idea to check if it is supported
|
||||
if (doesSdkSupport(["gui-textinput-illegalsymbols"])) {
|
||||
views.keyboard.set("illegalSymbols", true);
|
||||
}
|
||||
|
||||
views.helloDialog.set("text", "hshax ");
|
||||
|
||||
views.helloDialog.set("left", "<<");
|
||||
views.helloDialog.set("center", "SELECT");
|
||||
views.helloDialog.set("right", ">>");
|
||||
|
||||
// selector
|
||||
eventLoop.subscribe(views.xmenu.chosen, function (_sub, index, gui, eventLoop, views) {
|
||||
if (index === 0) {
|
||||
gui.viewDispatcher.switchTo(views.helloDialog);
|
||||
} else if (index === 1) {
|
||||
gui.viewDispatcher.switchTo(views.empty);
|
||||
} else if (index === 2) {
|
||||
gui.viewDispatcher.switchTo(views.empty);
|
||||
} else if (index === 3) {
|
||||
eventLoop.stop();
|
||||
}
|
||||
}, gui, eventLoop, views);
|
||||
|
||||
|
||||
|
||||
// go back after the greeting dialog
|
||||
eventLoop.subscribe(views.helloDialog.input, function (_sub, button, gui, views) {
|
||||
|
||||
if (button === "left" && press === 0) {
|
||||
press =2;
|
||||
serial.write("nav prev\n");
|
||||
delay(100);
|
||||
} else if (button === "center" && press === 0) {
|
||||
press =2;
|
||||
serial.write("nav sel\n");
|
||||
delay(100);
|
||||
|
||||
} else if (button === "right" && press === 0) {
|
||||
press =2;
|
||||
serial.write("nav next\n");
|
||||
delay(100);
|
||||
} else {
|
||||
serial.write(button);
|
||||
serial.write("\n");
|
||||
delay(100);
|
||||
}
|
||||
|
||||
if (press === 2) { press=0; }
|
||||
|
||||
}, gui, views);
|
||||
|
||||
// when the back key is pressed
|
||||
eventLoop.subscribe(gui.viewDispatcher.navigation, function (_sub, _, gui, views, eventLoop) {
|
||||
if (gui.viewDispatcher.currentView === views.xmenu) {
|
||||
serial.end();
|
||||
eventLoop.stop();
|
||||
return;
|
||||
}
|
||||
gui.viewDispatcher.switchTo(views.xmenu);
|
||||
}, gui, views, eventLoop);
|
||||
|
||||
// run UI
|
||||
gui.viewDispatcher.switchTo(views.xmenu);
|
||||
eventLoop.run();
|
||||
Reference in New Issue
Block a user