Skip to content

Commit

Permalink
fixed conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
rouing committed Dec 22, 2024
1 parent 6268c5f commit d1cf850
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 113 deletions.
168 changes: 95 additions & 73 deletions src/core/display.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/core/menu_items/ConfigMenu.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "ConfigMenu.h"
#include "core/utils.h"
#include "core/display.h"
#include "core/settings.h"
#include "core/i2c_finder.h"
#include "core/wifi_common.h"
#include "core/utils.h"

void ConfigMenu::optionsMenu() {
options = {
Expand Down
32 changes: 16 additions & 16 deletions src/core/scrollableTextArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ScrollableTextArea::ScrollableTextArea(const String& title) :
_fontSize(FP),
_startX(BORDER_PAD_X),
_startY(BORDER_PAD_Y),
_width(WIDTH - 2*BORDER_PAD_X),
_height(HEIGHT - BORDER_PAD_X - BORDER_PAD_Y)
_width(tftWidth - 2*BORDER_PAD_X),
_height(tftHeight - BORDER_PAD_X - BORDER_PAD_Y)
#ifdef HAS_SCREEN
,_scrollBuffer(&tft)
#endif
Expand All @@ -27,16 +27,16 @@ ScrollableTextArea::ScrollableTextArea(const String& title) :
ScrollableTextArea::ScrollableTextArea(
uint8_t fontSize, int16_t startX, int16_t startY, int32_t width, int32_t height
) : _startLine{0},
_redraw{true},
_redraw{true},
_title(""),
_fontSize(fontSize),
_startX(startX),
_startY(startY),
_width(width),
_height(height)
_fontSize(fontSize),
_startX(startX),
_startY(startY),
_width(width),
_height(height)
#ifdef HAS_SCREEN
,_scrollBuffer(&tft)
#endif
,_scrollBuffer(&tft)
#endif
{
drawMainBorder();
setup();
Expand All @@ -50,15 +50,15 @@ ScrollableTextArea::~ScrollableTextArea() {

void ScrollableTextArea::setup() {
#ifdef HAS_SCREEN
_scrollBuffer.createSprite(_width, _height);
_scrollBuffer.setTextColor(bruceConfig.priColor);
_scrollBuffer.setTextSize(_fontSize);
_scrollBuffer.createSprite(_width, _height);
_scrollBuffer.setTextColor(bruceConfig.priColor);
_scrollBuffer.setTextSize(_fontSize);
_scrollBuffer.fillSprite(bruceConfig.bgColor);

_maxCharsInLine = floor(_width / _scrollBuffer.textWidth("w", _fontSize));
_pxlsPerLine = _scrollBuffer.fontHeight() + 2;
_maxLinesInArea = floor(_height / _pxlsPerLine);
#endif
_pxlsPerLine = _scrollBuffer.fontHeight() + 2;
_maxLinesInArea = floor(_height / _pxlsPerLine);
#endif
}

void ScrollableTextArea::scrollUp() {
Expand Down
10 changes: 5 additions & 5 deletions src/core/scrollableTextArea.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "core/display.h"
#include "display.h"

class ScrollableTextArea {
public:
ScrollableTextArea(const String& title = "");

ScrollableTextArea(
uint8_t fontSize,
int16_t startX,
int16_t startY,
int32_t width,
uint8_t fontSize,
int16_t startX,
int16_t startY,
int32_t width,
int32_t height
);

Expand Down
28 changes: 14 additions & 14 deletions src/core/sd_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <regex>
#include "globals.h"
#include <globals.h>
#include "sd_functions.h"
#include "mykeyboard.h" // using keyboard when calling rename
#include "display.h" // using displayRedStripe as error msg
Expand Down Expand Up @@ -45,7 +45,7 @@ if(sdcardMounted) return true;
if (!SD.begin(SDCARD_CS, sdcardSPI))
#endif
{
#if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2)
#if defined(ARDUINO_M5STICK_C_PLUS) || defined(ARDUINO_M5STICK_C_PLUS2)
sdcardSPI.end(); // Closes SPI connections and release pin header.
#endif
sdcardMounted = false;
Expand All @@ -64,7 +64,7 @@ if(sdcardMounted) return true;
***************************************************************************************/
void closeSdCard() {
SD.end();
#if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2)
#if defined(ARDUINO_M5STICK_C_PLUS) || defined(ARDUINO_M5STICK_C_PLUS2)
sdcardSPI.end(); // Closes SPI connections and release pins.
#endif
//Serial.println("SD Card Unmounted...");
Expand Down Expand Up @@ -165,7 +165,7 @@ bool copyToFs(FS from, FS to, String path, bool draw) {
displayError("Not enought space", true);
return false;
}
//tft.drawRect(5,HEIGHT-12, (WIDTH-10), 9, bruceConfig.priColor);
//tft.drawRect(5,tftHeight-12, (tftWidth-10), 9, bruceConfig.priColor);
while ((bytesRead = source.read(buff, bufSize)) > 0) {
if (dest.write(buff, bytesRead) != bytesRead) {
//Serial.println("Falha ao escrever no arquivo de destino");
Expand All @@ -176,7 +176,7 @@ bool copyToFs(FS from, FS to, String path, bool draw) {
} else {
prog+=bytesRead;
float rad = 360*prog/tot;
if(draw) tft.drawArc(WIDTH/2,HEIGHT/2,HEIGHT/4,HEIGHT/5,0,int(rad),ALCOLOR,bruceConfig.bgColor,true);
if(draw) tft.drawArc(tftWidth/2,tftHeight/2,tftHeight/4,tftHeight/5,0,int(rad),ALCOLOR,bruceConfig.bgColor,true);
}
}
if(prog==tot) result = true;
Expand Down Expand Up @@ -231,7 +231,7 @@ bool pasteFile(FS fs, String path) {
size_t bytesRead;
int tot=sourceFile.size();
int prog=0;
//tft.drawRect(5,HEIGHT-12, (WIDTH-10), 9, bruceConfig.priColor);
//tft.drawRect(5,tftHeight-12, (tftWidth-10), 9, bruceConfig.priColor);
while ((bytesRead = sourceFile.read(buff, bufSize)) > 0) {
if (destFile.write(buff, bytesRead) != bytesRead) {
//Serial.println("Falha ao escrever no arquivo de destino");
Expand All @@ -241,8 +241,8 @@ bool pasteFile(FS fs, String path) {
} else {
prog+=bytesRead;
float rad = 360*prog/tot;
tft.drawArc(WIDTH/2,HEIGHT/2,HEIGHT/4,HEIGHT/5,0,int(rad),ALCOLOR,bruceConfig.bgColor,true);
//tft.fillRect(7,HEIGHT-10, (WIDTH-14)*prog/tot, 5, bruceConfig.priColor);
tft.drawArc(tftWidth/2,tftHeight/2,tftHeight/4,tftHeight/5,0,int(rad),ALCOLOR,bruceConfig.bgColor,true);
//tft.fillRect(7,tftHeight-10, (tftWidth-14)*prog/tot, 5, bruceConfig.priColor);
}
}

Expand Down Expand Up @@ -455,7 +455,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
String Folder = "/";
String PreFolder = "/";
tft.fillScreen(bruceConfig.bgColor);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
if(&fs==&SD) {
closeSdCard();
if(!setupSdCard()){
Expand All @@ -477,7 +477,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
if(strcmp(PreFolder.c_str(),Folder.c_str()) != 0 || reload){
index=0;
tft.fillScreen(bruceConfig.bgColor);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
Serial.println("reload to read: " + Folder);
readFs(fs, Folder, allowed_ext);
PreFolder = Folder;
Expand Down Expand Up @@ -579,7 +579,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
};
delay(200);
loopOptions(options);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
reload = true;
redraw = true;
} else if(fileList[index].folder==false && fileList[index].operation==false){
Expand All @@ -592,7 +592,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
options.push_back({"Main Menu", [&]() { exit = true; }});
delay(200);
loopOptions(options);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
reload = true;
redraw = true;
}
Expand Down Expand Up @@ -732,7 +732,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
result = filepath;
break;
}
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
reload = true;
redraw = true;
} else {
Expand Down Expand Up @@ -766,7 +766,7 @@ void viewFile(FS fs, String filepath) {
file.close();

area.show();
}
}

/*********************************************************************
** Function: checkLittleFsSize
Expand Down
6 changes: 5 additions & 1 deletion src/core/sd_functions.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef __SD_FUNCTIONS_H__
#define __SD_FUNCTIONS_H__

#include <FS.h>
#include <LittleFS.h>
#include <SD.h>
Expand Down Expand Up @@ -53,3 +55,5 @@ bool checkLittleFsSizeNM(); //Don't display msg
bool getFsStorage(FS *&fs);

void fileInfo(FS fs, String filepath);

#endif
30 changes: 28 additions & 2 deletions src/core/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#include "utils.h"
#include "globals.h"
#include <globals.h>
#include "scrollableTextArea.h"
/*********************************************************************
** Function: backToMenu
** sets the global var to be be used in the options second parameter
** and returnToMenu will be user do handle the breaks of all loops
when using loopfunctions with an option to "Back to Menu", use:
add this option:
options.push_back({"Main Menu", [=]() { backToMenu(); }});
while(1) {
if(returnToMenu) break; // stop this loop and return to the previous loop
...
loopOptions(options);
...
}
*/

void backToMenu() {
returnToMenu=true;
}

void updateClockTimezone(){
timeClient.begin();
Expand All @@ -17,6 +39,10 @@ void updateClockTimezone(){
#endif
}

void updateTimeStr(struct tm timeInfo) {
// Atualiza timeStr com a hora e minuto
snprintf(timeStr, sizeof(timeStr), "%02d:%02d:%02d", timeInfo.tm_hour, timeInfo.tm_min, timeInfo.tm_sec);
}

void showDeviceInfo() {
ScrollableTextArea area = ScrollableTextArea("DEVICE INFO");
Expand All @@ -42,4 +68,4 @@ void showDeviceInfo() {
area.addLine("SPI_SS_PIN: " + String(SPI_SS_PIN));

area.show();
}
}
7 changes: 6 additions & 1 deletion src/core/utils.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
void updateClockTimezone();
#ifndef __UTILS_H__
#define __UTILS_H__

void backToMenu();
void updateClockTimezone();
void updateTimeStr(struct tm timeInfo);
void showDeviceInfo();
#endif

0 comments on commit d1cf850

Please sign in to comment.