Skip to content

Commit d30c32d

Browse files
committed
More passing by references whenever possible in OpenFIREdisplay
1 parent 06743a6 commit d30c32d

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

OpenFIREmain/OpenFIREcommon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ void FW_Common::GetPosition()
767767
int rawX[4];
768768
int rawY[4];
769769
// RAW Output for viewing in processing sketch mapped to 1920x1080 screen resolution
770-
for (int i = 0; i < 4; i++) {
770+
for (int i = 0; i < 4; ++i) {
771771
if(OF_Prefs::profiles[OF_Prefs::currentProfile].irLayout) {
772772
rawX[i] = map(OpenFIREdiamond.X(i), 0, 1023 << 2, 1920, 0);
773773
rawY[i] = map(OpenFIREdiamond.Y(i), 0, 768 << 2, 0, 1080);

OpenFIREmain/OpenFIREdisplay.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void ExtDisplay::TopPanelUpdate(const char *textPrefix, const char *profText)
8080
}
8181
}
8282

83-
void ExtDisplay::ScreenModeChange(int8_t screenMode, bool isAnalog)
83+
void ExtDisplay::ScreenModeChange(const int &screenMode, const bool &isAnalog)
8484
{
8585
if(display != nullptr) {
8686
idleTimeStamp = millis();
@@ -236,11 +236,11 @@ void ExtDisplay::ShowTemp()
236236

237237
// Warning: SLOOOOW, should only be used in cali/where the mouse isn't being updated.
238238
// Use at your own discression.
239-
void ExtDisplay::DrawVisibleIR(int pointX[4], int pointY[4])
239+
void ExtDisplay::DrawVisibleIR(int *pointX, int *pointY)
240240
{
241241
if(display != nullptr) {
242242
display->fillRect(0, 16, 128, 48, BLACK);
243-
for(uint i = 0; i < 4; ++i) {
243+
for(int i = 0; i < 4; ++i) {
244244
pointX[i] = map(pointX[i], 0, 1920, 0, 128);
245245
pointY[i] = map(pointY[i], 0, 1080, 16, 64);
246246
pointY[i] = constrain(pointY[i], 16, 64);
@@ -250,10 +250,10 @@ void ExtDisplay::DrawVisibleIR(int pointX[4], int pointY[4])
250250
}
251251
}
252252

253-
void ExtDisplay::PauseScreenShow(uint8_t currentProf, char name1[16], char name2[16], char name3[16], char name4[16])
253+
void ExtDisplay::PauseScreenShow(const int &currentProf, const char* name1, const char* name2, const char* name3, const char* name4)
254254
{
255255
if(display != nullptr) {
256-
char* namesList[16] = { name1, name2, name3, name4 };
256+
const char* namesList[] = { name1, name2, name3, name4 };
257257
TopPanelUpdate("Using ", namesList[currentProf]); // names are placeholder
258258
display->fillRect(0, 16, 128, 48, BLACK);
259259
display->setTextSize(1);
@@ -273,7 +273,7 @@ void ExtDisplay::PauseScreenShow(uint8_t currentProf, char name1[16], char name2
273273
}
274274
}
275275

276-
void ExtDisplay::PauseListUpdate(uint8_t selection)
276+
void ExtDisplay::PauseListUpdate(const int &selection)
277277
{
278278
if(display != nullptr) {
279279
display->fillRect(0, 16, 128, 48, BLACK);
@@ -420,7 +420,7 @@ void ExtDisplay::PauseListUpdate(uint8_t selection)
420420
}
421421
}
422422

423-
void ExtDisplay::PauseProfileUpdate(uint8_t selection, char name1[16], char name2[16], char name3[16], char name4[16])
423+
void ExtDisplay::PauseProfileUpdate(const int &selection, const char* name1, const char* name2, const char* name3, const char* name4)
424424
{
425425
if(display != nullptr) {
426426
display->fillRect(0, 16, 128, 48, BLACK);
@@ -477,7 +477,7 @@ void ExtDisplay::PauseProfileUpdate(uint8_t selection, char name1[16], char name
477477
}
478478
}
479479

480-
void ExtDisplay::SaveScreen(uint8_t status)
480+
void ExtDisplay::SaveScreen(const int &status)
481481
{
482482
if(display != nullptr) {
483483
display->fillRect(0, 16, 128, 48, BLACK);
@@ -489,7 +489,7 @@ void ExtDisplay::SaveScreen(uint8_t status)
489489
}
490490
}
491491

492-
void ExtDisplay::PrintAmmo(uint8_t ammo)
492+
void ExtDisplay::PrintAmmo(const uint &ammo)
493493
{
494494
if(display != nullptr) {
495495
currentAmmo = ammo;
@@ -498,7 +498,7 @@ void ExtDisplay::PrintAmmo(uint8_t ammo)
498498
uint ammoLeft = ammo / 10;
499499
uint ammoRight = ammo - (ammoLeft * 10);
500500

501-
if(!ammo) { ammoEmpty = true; } else { ammoEmpty = false; }
501+
ammoEmpty = ammo ? false : true;
502502

503503
if(screenState == Screen_Mamehook_Single) {
504504
display->fillRect(40, 22, (NUMBER_GLYPH_WIDTH*2)+6, NUMBER_GLYPH_HEIGHT, BLACK);
@@ -514,11 +514,11 @@ void ExtDisplay::PrintAmmo(uint8_t ammo)
514514
}
515515
}
516516

517-
void ExtDisplay::PrintLife(uint8_t life)
517+
void ExtDisplay::PrintLife(const uint &life)
518518
{
519519
if(display != nullptr) {
520520
currentLife = life;
521-
if(!life) { lifeEmpty = true; } else { lifeEmpty = false; }
521+
lifeEmpty = life ? false : true;
522522
if(screenState == Screen_Mamehook_Single) {
523523
if(lifeBar) {
524524
display->fillRect(14, 37, 100, 9, BLACK);

OpenFIREmain/OpenFIREdisplay.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ExtDisplay {
3232
void TopPanelUpdate(const char *, const char * = nullptr);
3333

3434
/// @brief Clear screen for different gun modes
35-
void ScreenModeChange(int8_t screenMode, bool isAnalog = false);
35+
void ScreenModeChange(const int &screenMode, const bool &isAnalog = false);
3636

3737
/// @brief Perform maintenance operations (WIP)
3838
/// @details For when values aren't being updated, but still want to change something on the screen
@@ -41,25 +41,26 @@ class ExtDisplay {
4141

4242
/// @brief Draw seen points here
4343
/// @details Should ONLY be used in scenarios where the mouse isn't being updated, i.e. calibration.
44-
void DrawVisibleIR(int pointX[4], int pointY[4]);
44+
/// Arguments here point to the original arrays of seen coords [4]
45+
void DrawVisibleIR(int *pointX, int *pointY);
4546

4647
/// @brief Draw hotkey pause mode layout
47-
void PauseScreenShow(uint8_t currentProf, char name1[16], char name2[16], char name3[16], char name4[16]);
48+
void PauseScreenShow(const int &currentProf, const char* name1, const char* name2, const char* name3, const char* name4);
4849

4950
/// @brief Update simple pause mode list on screen
50-
void PauseListUpdate(uint8_t selection);
51+
void PauseListUpdate(const int &selection);
5152

5253
/// @brief Update simple pause mode profiles list on screen
53-
void PauseProfileUpdate(uint8_t selection, char name1[16], char name2[16], char name3[16], char name4[16]);
54+
void PauseProfileUpdate(const int &selection, const char* name1, const char* name2, const char* name3, const char* name4);
5455

5556
/// @brief Print save status message
56-
void SaveScreen(uint8_t status);
57+
void SaveScreen(const int &status);
5758

5859
/// @brief Update main screen ammo glyphs
59-
void PrintAmmo(uint8_t ammo);
60+
void PrintAmmo(const uint &ammo);
6061

6162
/// @brief Update main screen life glyphs
62-
void PrintLife(uint8_t life);
63+
void PrintLife(const uint &life);
6364

6465
enum ScreenMode_e {
6566
Screen_None = -1,
@@ -105,7 +106,7 @@ class ExtDisplay {
105106
bool mister = false;
106107

107108
private:
108-
int8_t screenState = Screen_None;
109+
int screenState = Screen_None;
109110

110111
bool ammoEmpty = false;
111112
bool lifeEmpty = false;

0 commit comments

Comments
 (0)