diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..a2b51c9 --- /dev/null +++ b/.clang-format @@ -0,0 +1,18 @@ +BasedOnStyle: Google +AlignConsecutiveAssignments: true +AlignTrailingComments: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: true +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false +ColumnLimit: 100 +DerivePointerAlignment: false +PointerAlignment: Right diff --git a/Example.png b/Example.png new file mode 100644 index 0000000..37acaba Binary files /dev/null and b/Example.png differ diff --git a/Field.png b/Field.png new file mode 100644 index 0000000..53db2fd Binary files /dev/null and b/Field.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f0808d7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Joseph Spencer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5188f29 --- /dev/null +++ b/README.md @@ -0,0 +1,81 @@ +ScreenLib +========= +ScreenLib is a PROS library that handles screen drawing functions, +primarily printing each game's field. It provides a powerful way to +draw any possible field without requiring experience with [lvgl](https://littlevgl.com/) + +![alt text](./Example.png "Example") + +Installing +========== +* Go over to [releases](https://github.com/SpencerJ21/screenlib/releases) and download the latest version +* Open a terminal wherever you downloaded it(try shift + right click in file explorer) +* run `prosv5 c fetch screenlib@VERSION.zip`, replacing VERSION with the version +* run `prosv5 c apply screenlib` in your project directory to install + +Version +======= +The first digit refers to the vex game: Tower Takeover will be version 1.X.X, while next year's game will be 2.X.X +The second digit refers to any new features that may be added. +The third digit refers to any bug fixes. + +License +======= +This software uses the MIT License. See [LICENSE](LICENSE) for more information. + +Usage +===== +Object drawing is mostly done through a `Field` object, by giving a position enum class and a bitfield of which cubes to print. +Most objects on the screen are referred to by `left`, `right`, `near`, and `far` (near refers to the bottom of the screen while far refers to the top) + +**Make sure screen::initializeStyles() is called during initialization** + +Unscored Cubes +-------------- +An example of this is: +`field.draw(screen::cubeGroup::right4, 0b01010);` + +Let's take a look at how the field is represented +![alt text](./Field.png "Labeled Field") +Each of the cube group names are in the enum class `screen::cubeGroup`, +each of the tower names are in the enum class `screen::tower`, and +each of the scoring zone names are in the enum class `screen::scoringZone` + +The numbers on the cube show the bit that represents them in their bitfield: +a 0 means it's looking at bit 0: `0b0000X` +a 1 means it's looking at bit 1: `0b000X0` +and so on. + +This is done so the presence of every cube in a group can be given by a number +say you want the cubes labeled 3, 1, and 0, the bitfield would be `0b01011` + +For the stacks near the middle, the cubes in the stack but not on top, are still represented by the bits that follow the top cube's bit (the 3 cubes under a cube on bit 3 are represented by bits 2, 1, and 0) + +Alternatively, macros can be used for more verbose code; here is the equivalent of the previous example: +`field.draw(screen::cubeGroup::right4, CUBE_HIGHEST + CUBE_2LOWEST);` + +`CUBE_HIGHEST` represents the highest cube in the stack, followed by `CUBE_2HIGHEST` (the 2nd highest), followed by `CUBE_2LOWEST` (the 2nd lowest), and finally `CUBE_LOWEST` +As the 4 cube stacks on the left and right are in the same order but slightly different positions, the corresponding cubes are represented the same (purple to purple, orange to orange, green to green) + +`CUBE_FAR` and `CUBE_NEAR` are for the cube sectors farLeft and farRight + +`CUBE_TOP_NEAR`, `CUBE_FAR_LEFT`, `CUBE_NEAR_LEFT`, `CUBE_FAR_RIGHT`, and `CUBE_NEAR_RIGHT` are used for the five cube stack on the near side + +and finally, all macros starting with `TOWER_CUBE_` refer to the cubes around a tower + +Scored Cubes +------------ +Scored cubes are drawn along with where they are, either in a tower or a scoring zone. In a tower the second parameter describes the color of the cube, +(`screen::color::`). In a scoring zone the second parameter does the same however, two colors can be placed in an array to denote two stacks. In addition, +a third parameter is used to display "stack height", a number printed on top to describe how many cubes are in the stack. +Note: use `screen::color::none` to abstain from printing a scored cube in that position + +Example +------- +This directory (specifically [opcontrol.cpp](./src/opcontrol.cpp)) is a usage example (it produces the image at the top of this page) + +Acknowledgements +================ +smallfont.c is converted version of the digits 0-9 from [Synchronizer NBP Font](https://www.fontspace.com/total-fontgeek-dtf-ltd/synchronizer-nbp) by total FontGeek DTF, Ltd. all credit regarding the font to them. + +Thanks to Hotel from the PROS team, Salmon from Okapilib, and Theo from 7842F, for giving some advice on improving the code here diff --git a/include/screen/field.hpp b/include/screen/field.hpp index 1a9105c..5d9f774 100644 --- a/include/screen/field.hpp +++ b/include/screen/field.hpp @@ -1,12 +1,74 @@ #ifndef SCREEN_FIELD_HPP_ #define SCREEN_FIELD_HPP_ -#include "screen/resources.hpp" #include +#include "screen/resources.hpp" -namespace screen{ - -class Field{ - public: +#define TOWER_CUBE_FAR 8 +#define TOWER_CUBE_RIGHT 4 +#define TOWER_CUBE_NEAR 2 +#define TOWER_CUBE_LEFT 1 + +#define CUBE_HIGHEST 8 +#define CUBE_2HIGHEST 4 +#define CUBE_2LOWEST 2 +#define CUBE_LOWEST 1 + +#define CUBE_FAR 2 +#define CUBE_NEAR 1 + +#define CUBE_TOP_NEAR 16 +#define CUBE_NEAR_RIGHT 8 +#define CUBE_FAR_RIGHT 4 +#define CUBE_NEAR_LEFT 2 +#define CUBE_FAR_LEFT 1 + +/** + * See Field.png on https://github.com/SpencerJ21/screenlib + * + * Each of the cube group names are in screen::cubeGroup, + * each of the tower names are in screen::tower, and + * each of the scoring zone names are in screen::scoringZone + * + * The numbers on the cube show the bit that represents them in their bitfield: + * a 0 means it's looking at bit 0: 0b0000X + * a 1 means it's looking at bit 1: 0b000X0 + * and so on. + * + * This is done so the presence of every cube in a group can be given by a number + * say you want the cubes labeled 3, 1, and 0, the bitfield would be 0b01011 + * + * For the stacks near the middle, the cubes in the stack but not on top, are still represented by + * the bits that follow the top cube's bit (the 3 cubes under a cube on bit 3 are represented by + * bits 2, 1, and 0) + * + * Alternatively, macros can be used for more verbose code; here is the equivalent of the previous + * example: field.draw(screen::cubeGroup::right4, CUBE_HIGHEST + CUBE_2LOWEST); + * + * CUBE_HIGHEST represents the highest cube in the stack, followed by CUBE_2HIGHEST (the 2nd + * highest), followed by CUBE_2LOWEST (the 2nd lowest), and finally CUBE_LOWEST As the 4 cube stacks + * on the left and right are in the same order but slightly different positions, the corresponding + * cubes are represented the same (purple to purple, orange to orange, green to green) + * + * CUBE_FAR and CUBE_NEAR are for the cube Groups farLeft and farRight + * + * CUBE_TOP_NEAR, CUBE_FAR_LEFT, CUBE_NEAR_LEFT, CUBE_FAR_RIGHT, and CUBE_NEAR_RIGHT are used for + * the five cube stack on the near side + * + * and finally, all macros starting with TOWER_CUBE_ refer to the cubes around a tower + * + * + * Scored cubes are drawn along with where they are, either in a tower or a scoring zone. In a tower + * the second parameter describes the color of the cube, (screen::color::). In a scoring zone the + * second parameter does the same however, two colors can be placed in an array to denote two + * stacks. In addition, a third parameter is used to display "stack height", a number printed on top + * to describe how many cubes are in the stack. Note: use `screen::color::none` to abstain from + * printing a scored cube in that position + */ + +namespace screen { + +class Field { + public: /** * Field generator for the screen * @@ -14,11 +76,11 @@ class Field{ * @param x x-value from 0-240 of the leftmost side of the field, default is centered * @param iautoInit print colored tiles / taped lines immediately, and after each clean */ - Field(lv_obj_t *parent, const uint8_t x = 120, const bool iautoInit = true); + Field(lv_obj_t *parent, uint8_t x = 120, bool iautoInit = true); ~Field(); /** - * Remove all objects from the field + * Remove all objects from the field, and reset to default */ void clean(); @@ -28,34 +90,36 @@ class Field{ * * @param x new x-value from 0-240 of the leftmost side of the field */ - void setX(const uint8_t x); + void setX(uint8_t x); /** * draw a group of cubes * * @param pos which group of cubes to print - see resources.hpp * @param presence a bitfield of present cubes. Starts at highest cube as the highest bit, - * or furthest, or leftmost, depending on which group + * or furthest, or leftmost, depending on which group. See the README for more information */ - void drawCubeGroup(const CubeSector pos, const uint8_t presence = UINT8_MAX); + void draw(cubeGroup pos, uint8_t presence = UINT8_MAX); /** * draw a tower and group of cubes around it * * @param pos which tower to print - see resources.hpp - * @param contents what color cube is inside, set Color::None for no cube + * @param contents what color cube is inside, set color::none for no cube * @param presence a bitfield of present cubes. Starts with furthest and moves clockwise + * See the README for more information */ - void drawTower(const TowerPos pos, const Color contents = Color::None, const uint8_t cubePresence = UINT8_MAX); + void draw(tower pos, color contents = color::none, uint8_t cubePresence = UINT8_MAX); /** * draw a scoring zone (and cubes inside) * * @param pos which zone to print - * @param contents what color cube is inside, set Color::None for no cube + * @param contents what color cube is inside, set color::none for no cube * @param stackHeight how many cubes are in the zone vertically (puts number on top) + * See the README for more information */ - void drawScoringZone(const ZonePos pos, const Color contents = Color::None, const uint8_t stackHeight = 0); + void draw(scoringZone pos, color contents = color::none, uint8_t stackHeight = 0); /** * draw a scoring zone (and cubes inside) @@ -63,25 +127,33 @@ class Field{ * @param pos which zone to print * @param contents what colors of cubes are inside, use other function for 0 or 1 cubes * @param stackHeight how many cubes are in the zone vertically (puts number on top) - * for both stacks + * for both stacks. See the README for more information */ - void drawScoringZone(const ZonePos pos, const std::pair contents, const std::pair stackHeight); + void draw(scoringZone pos, std::pair contents, + std::pair stackHeight); /** * draw the four colored tiles + * + * called automatically by default */ - void drawColoredTiles(); + void drawcoloredTiles(); /** * draw the zone lines + * + * called automatically by default */ void drawLines(); /** * re-print the perimeter to make it look nice * - * note: should be called after drawColoredTiles(), drawLines(), and drawScoringZone()s, - * but before drawtowers()s + * called automatically assuming you are drawing the whole field + * calling this manually is not advised + * + * note: should be called after drawcoloredTiles(), drawLines(), and draw()s, + * but before draw()s */ void reinforcePerimeter(); @@ -92,33 +164,40 @@ class Field{ * @param pos y-value of the midpoint of the robot * note: there are 40 pixels for each field tile */ - void drawRobot(const bool red, const uint8_t pos); + void drawRobot(bool red, uint8_t pos); /** * to be called after drawing all towers, cubes, and scoring zones * this will automatically print all other game elements + * + * this is the suggested way to finish the field, as it will ensure everything is drawn in the + * correct order */ void finishDrawing(); - private: - //Do not try and draw cubes youself, use the above functions - void drawCube(const std::pair pos, const Color color, const uint8_t stackHeight, const bool targeted); - static void drawCube(lv_obj_t *parent, const std::pair pos, const Color color, const uint8_t stackHeight, const bool targeted); + private: + // Cubes should be drawn automatically by the above functions + void drawCube(std::pair pos, color color, uint8_t stackHeight, bool targeted); + + static void drawCube(lv_obj_t *parent, std::pair pos, color color, + uint8_t stackHeight, bool targeted); void resetVectors(); - const uint numOfBits[16] = {0,1,1,2,1,2,2,3, - 1,2,2,3,2,3,3,4}; + const uint numOfBits[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; lv_obj_t *obj; bool autoInit; - std::vector cubesToDraw; - std::vector towersToDraw; - std::vector zonesToDraw; + bool wallDrawn; + std::pair allianceTowerContents; + + std::vector cubesToDraw; + std::vector towersToDraw; + std::vector zonesToDraw; }; -}//namespace screen +} // namespace screen #endif diff --git a/include/screen/resources.hpp b/include/screen/resources.hpp index 9c81877..8b5f77d 100644 --- a/include/screen/resources.hpp +++ b/include/screen/resources.hpp @@ -8,7 +8,7 @@ extern lv_font_t smallFont; -namespace screen{ +namespace screen { /** * These styles are used for the objects on the field, along with @@ -72,22 +72,27 @@ void initializeStyles(); * Various enums for more readable parameters */ -enum class Color{ - None, Orange, Green, Purple +enum class color { none, orange, green, purple }; + +enum class cubeGroup { + farLeft, + farRight, + farPurple, + left1, + left2, + left3, + left4, + right1, + right2, + right3, + right4, + near }; -enum class CubeSector{ - FarLeft, FarRight, FarPurple, Left1, Left2, Left3, Left4, Right1, Right2, Right3, Right4, Near -}; - -enum class TowerPos{ - Left, Right, Center, Far, Near, Red, Blue -}; +enum class tower { left, right, center, far, near, red, blue }; -enum class ZonePos{ - FarRed, FarBlue, NearRed, NearBlue -}; +enum class scoringZone { farRed, farBlue, nearRed, nearBlue }; -}//namespace screen +} // namespace screen #endif diff --git a/src/autonomous.cpp b/src/autonomous.cpp index db70252..a4ee293 100644 --- a/src/autonomous.cpp +++ b/src/autonomous.cpp @@ -1,14 +1,3 @@ #include "main.h" -/** - * Runs the user autonomous code. This function will be started in its own task - * with the default priority and stack size whenever the robot is enabled via - * the Field Management System or the VEX Competition Switch in the autonomous - * mode. Alternatively, this function may be called in initialize or opcontrol - * for non-competition testing purposes. - * - * If the robot is disabled or communications is lost, the autonomous task - * will be stopped. Re-enabling the robot will restart the task, not re-start it - * from where it left off. - */ void autonomous() {} diff --git a/src/initialize.cpp b/src/initialize.cpp index 0e64ece..9c88ca7 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -1,30 +1,12 @@ #include "main.h" #include "screen/resources.hpp" -/** - * Runs initialization code. This occurs as soon as the program is started. - * - * All other competition modes are blocked by initialize; it is recommended - * to keep execution time for this mode under a few seconds. - */ -void initialize() { - screen::initializeStyles(); +void initialize() +{ + // this is very important + screen::initializeStyles(); } -/** - * Runs while the robot is in the disabled state of Field Management System or - * the VEX Competition Switch, following either autonomous or opcontrol. When - * the robot is enabled, this task will exit. - */ void disabled() {} -/** - * Runs after initialize(), and before autonomous when connected to the Field - * Management System or the VEX Competition Switch. This is intended for - * competition-specific initialization routines, such as an autonomous selector - * on the LCD. - * - * This task will exit when the robot is enabled and autonomous or opcontrol - * starts. - */ void competition_initialize() {} diff --git a/src/opcontrol.cpp b/src/opcontrol.cpp index 66b1218..b8835a6 100644 --- a/src/opcontrol.cpp +++ b/src/opcontrol.cpp @@ -1,39 +1,62 @@ #include "screen/field.hpp" -void testScreen() { - //make sure initializeStyles() happens or nothing will work! +void opcontrol() +{ + // make sure initializeStyles() happens or nothing will work! + // in this example it is called in initialize() - lv_obj_t *scr = lv_obj_create(NULL, NULL); - lv_obj_set_style(scr, &screen::blankStyle); - lv_scr_load(scr); + // initialize and load a screen object + lv_obj_t *scr = lv_obj_create(NULL, NULL); + lv_scr_load(scr); - screen::Field field(scr); + screen::Field field(scr); - field.drawScoringZone(screen::ZonePos::FarRed, {screen::Color::Purple, screen::Color::Orange}, {1, 3}); //two stacks use an array of colors - field.drawScoringZone(screen::ZonePos::NearRed); - field.drawScoringZone(screen::ZonePos::NearRed, screen::Color::Green, 4); //one stack does not - field.drawScoringZone(screen::ZonePos::NearBlue); + // two stacks use an array of colors + // draw a purple stack with height 1 and an orange stack with height 3 in the far red zone + field.draw(screen::scoringZone::farRed, {screen::color::purple, screen::color::orange}, + {1, 3}); - field.drawCubeGroup(screen::CubeSector::Left1, 0b00000011); // leave only the bottom two cubes - field.drawCubeGroup(screen::CubeSector::Left3, 0b00001100); // take the two cubes not in the stack - field.drawCubeGroup(screen::CubeSector::Right4, 0b00001010);// take the rightmost and 3rd rightmost cube - field.drawCubeGroup(screen::CubeSector::Near, 0b00001111); // take the top purple cube + // one stack does not need to use an array + // draw a green stack with height 4 in the near red zone + field.draw(screen::scoringZone::nearRed, screen::color::green, 4); + // draw the 1st(furthest) left stack with only the bottom two cubes + field.draw(screen::cubeGroup::left1, 0b00011); - field.drawTower(screen::TowerPos::Left, screen::Color::None, 0); //take all the cubes - field.drawTower(screen::TowerPos::Center, screen::Color::Orange, 0b0001110); //put a cube in the tower and take the leftmost cube - field.drawTower(screen::TowerPos::Red, screen::Color::Green); //put a cube in the tower + // draw the 3rd(2nd closest) left stack, but not the cubes to the left of it + field.draw(screen::cubeGroup::left3, 0b01100); - field.drawRobot(true, 120); //draw robot centered on the field + // draw the first and 3rd cube in the row + // right4 is the closest row of cubes on the right + // it looks the same in binary and on the field + field.draw(screen::cubeGroup::right4, 0b01010); - field.finishDrawing(); + // alternatively, macros can be used - while(true){ - pros::delay(1000); - } -} + // draw the 3 cubes the macros describe + // (this is the 5 cube stack on the audience side) + field.draw(screen::cubeGroup::near, CUBE_NEAR_LEFT + CUBE_NEAR_RIGHT + CUBE_FAR_RIGHT); + + // draw the highest(rightmost), and the 2nd lowest(leftmost) cube of the 4th(closest) left cube group + field.draw(screen::cubeGroup::left4, CUBE_HIGHEST + CUBE_2LOWEST); + + // draw the left tower with no cubes in or around + field.draw(screen::tower::left, screen::color::none, 0); + + // draw an orange cube in the center tower, and draw all cubes around it except the left one + field.draw(screen::tower::center, screen::color::orange, 0b1110); + + // draw the far tower with no cube, and draw the cube past it and to the left of it + field.draw(screen::tower::far, screen::color::none, TOWER_CUBE_FAR + TOWER_CUBE_LEFT); + + // draw a "robot" on the red (denoted by true) side of the field with a center y-value of 160 + // (straddling the line between the 4th and 5th tiles from the top) + field.drawRobot(true, 160); + + // draw all objects not explicity defined here with their default settings + field.finishDrawing(); -void opcontrol(){ - pros::delay(1000); - testScreen(); + while (true) { + pros::delay(1000); + } } diff --git a/src/screen/field.cpp b/src/screen/field.cpp index 44f2849..f7b33ed 100644 --- a/src/screen/field.cpp +++ b/src/screen/field.cpp @@ -1,276 +1,304 @@ #include "screen/field.hpp" -namespace screen{ - -Field::Field(lv_obj_t *parent, const uint8_t x, const bool iautoInit): - autoInit(iautoInit){ +namespace screen { +Field::Field(lv_obj_t *parent, const uint8_t x, const bool iautoInit) + : autoInit(iautoInit), wallDrawn(false), allianceTowerContents(color::none, color::none) +{ obj = lv_obj_create(parent, NULL); lv_obj_set_style(obj, &fieldStyle); lv_obj_set_size(obj, 240, 240); lv_obj_set_pos(obj, x, 0); - this->resetVectors(); + resetVectors(); - if(autoInit){ - this->drawColoredTiles(); - this->drawLines(); + if (autoInit) { + drawcoloredTiles(); + drawLines(); } } -Field::~Field(){ +Field::~Field() +{ lv_obj_del(obj); } -void Field::clean(){ +void Field::clean() +{ lv_obj_clean(obj); - this->resetVectors(); + resetVectors(); + + wallDrawn = false; + allianceTowerContents = {color::none, color::none}; - if(autoInit){ - this->drawColoredTiles(); - this->drawLines(); + if (autoInit) { + drawcoloredTiles(); + drawLines(); } } -void Field::setX(uint8_t x){ +void Field::setX(uint8_t x) +{ lv_obj_set_x(obj, x); } -void Field::drawCubeGroup(const CubeSector pos, const uint8_t presence){ +void Field::draw(const cubeGroup pos, const uint8_t presence) +{ bool targeted = presence != UINT8_MAX; - for(int i = 0; i < cubesToDraw.size(); i++){ - if(cubesToDraw[i] == pos){ + for (int i = 0; i < cubesToDraw.size(); i++) { + if (cubesToDraw[i] == pos) { cubesToDraw.erase(cubesToDraw.begin() + i); break; } } - switch(pos){ - case CubeSector::FarLeft: - if(presence & 0b11100001){ - drawCube({40, 30}, Color::Orange, 1, targeted); + switch (pos) { + case cubeGroup::farLeft: + if (presence & 0b11100001) { + drawCube({40, 30}, color::orange, 1, targeted); } - if(presence & 0b11100010){ - drawCube({40, 70}, Color::Orange, 1, targeted); + if (presence & 0b11100010) { + drawCube({40, 70}, color::orange, 1, targeted); } break; - case CubeSector::FarRight: - if(presence & 0b11100001){ - drawCube({190, 30}, Color::Green, 1, targeted); + case cubeGroup::farRight: + if (presence & 0b11100001) { + drawCube({190, 30}, color::green, 1, targeted); } - if(presence & 0b11100010){ - drawCube({190, 70}, Color::Green, 1, targeted); + if (presence & 0b11100010) { + drawCube({190, 70}, color::green, 1, targeted); } break; - case CubeSector::FarPurple: - if(presence){ - drawCube({115, 3}, Color::Purple, 1, targeted); + case cubeGroup::farPurple: + if (presence) { + drawCube({115, 3}, color::purple, 1, targeted); } break; - case CubeSector::Left1: - if(presence){ - drawCube({80, 70}, (presence >= 8 ? Color::Orange : (presence >= 2 ? Color::Green : Color::Purple)), numOfBits[presence & 0b00001111], targeted); + case cubeGroup::left1: + if (presence) { + drawCube({80, 70}, + presence >= 8 ? color::orange : (presence >= 2 ? color::green : color::purple), + numOfBits[presence & 0b00001111], targeted); } break; - case CubeSector::Left2: - if(presence & 0b11101110){ - drawCube({80, 110}, (presence >= 8 ? Color::Orange : Color::Green), numOfBits[presence & 0b00001110], targeted); + case cubeGroup::left2: + if (presence & 0b11101110) { + drawCube({80, 110}, presence >= 8 ? color::orange : color::green, + numOfBits[presence & 0b00001110], targeted); } - if(presence & 0b11100001){ - drawCube({70, 110}, Color::Purple, 1, targeted); + if (presence & 0b11100001) { + drawCube({70, 110}, color::purple, 1, targeted); } break; - case CubeSector::Left3: - if(presence & 0b11101100){ - drawCube({80, 150}, (presence >= 8 ? Color::Orange : Color::Green), numOfBits[presence & 0b00001100], targeted); + case cubeGroup::left3: + if (presence & 0b11101100) { + drawCube({80, 150}, presence >= 8 ? color::orange : color::green, + numOfBits[presence & 0b00001100], targeted); } - if(presence & 0b11100010){ - drawCube({70, 150}, Color::Green, 1, targeted); + if (presence & 0b11100010) { + drawCube({70, 150}, color::green, 1, targeted); } - if(presence & 0b11100001){ - drawCube({60, 150}, Color::Purple, 1, targeted); + if (presence & 0b11100001) { + drawCube({60, 150}, color::purple, 1, targeted); } break; - case CubeSector::Left4: - if(presence & 0b11101000){ - drawCube({80, 190}, Color::Orange, 1, targeted); + case cubeGroup::left4: + if (presence & 0b11101000) { + drawCube({80, 190}, color::orange, 1, targeted); } - if(presence & 0b11100100){ - drawCube({70, 190}, Color::Green, 1, targeted); + if (presence & 0b11100100) { + drawCube({70, 190}, color::green, 1, targeted); } - if(presence & 0b11100010){ - drawCube({60, 190}, Color::Green, 1, targeted); + if (presence & 0b11100010) { + drawCube({60, 190}, color::green, 1, targeted); } - if(presence & 0b11100001){ - drawCube({50, 190}, Color::Purple, 1, targeted); + if (presence & 0b11100001) { + drawCube({50, 190}, color::purple, 1, targeted); } break; - case CubeSector::Right1: - if(presence){ - drawCube({150, 70}, (presence >= 8 ? Color::Green : (presence >= 2 ? Color::Orange : Color::Purple)), numOfBits[presence & 0b00001111], targeted); + case cubeGroup::right1: + if (presence) { + drawCube({150, 70}, + presence >= 8 ? color::green : (presence >= 2 ? color::orange : color::purple), + numOfBits[presence & 0b00001111], targeted); } break; - case CubeSector::Right2: - if(presence & 0b11101110){ - drawCube({150, 110}, (presence >= 8 ? Color::Green : Color::Orange), numOfBits[presence & 0b00001110], targeted); + case cubeGroup::right2: + if (presence & 0b11101110) { + drawCube({150, 110}, presence >= 8 ? color::green : color::orange, + numOfBits[presence & 0b00001110], targeted); } - if(presence & 0b11100001){ - drawCube({160, 110}, Color::Purple, 1, targeted); + if (presence & 0b11100001) { + drawCube({160, 110}, color::purple, 1, targeted); } break; - case CubeSector::Right3: - if(presence & 0b11101100){ - drawCube({150, 150}, (presence >= 8 ? Color::Green : Color::Orange), numOfBits[presence & 0b00001100], targeted); + case cubeGroup::right3: + if (presence & 0b11101100) { + drawCube({150, 150}, presence >= 8 ? color::green : color::orange, + numOfBits[presence & 0b00001100], targeted); } - if(presence & 0b11100010){ - drawCube({160, 150}, Color::Orange, 1, targeted); + if (presence & 0b11100010) { + drawCube({160, 150}, color::orange, 1, targeted); } - if(presence & 0b11100001){ - drawCube({170, 150}, Color::Purple, 1, targeted); + if (presence & 0b11100001) { + drawCube({170, 150}, color::purple, 1, targeted); } break; - case CubeSector::Right4: - if(presence & 0b11101000){ - drawCube({150, 190}, Color::Green, 1, targeted); + case cubeGroup::right4: + if (presence & 0b11101000) { + drawCube({150, 190}, color::green, 1, targeted); } - if(presence & 0b11100100){ - drawCube({160, 190}, Color::Orange, 1, targeted); + if (presence & 0b11100100) { + drawCube({160, 190}, color::orange, 1, targeted); } - if(presence & 0b11100010){ - drawCube({170, 190}, Color::Orange, 1, targeted); + if (presence & 0b11100010) { + drawCube({170, 190}, color::orange, 1, targeted); } - if(presence & 0b11100001){ - drawCube({180, 190}, Color::Purple, 1, targeted); + if (presence & 0b11100001) { + drawCube({180, 190}, color::purple, 1, targeted); } break; - case CubeSector::Near: - if(presence & 0b11100001){ - drawCube({110, 217}, Color::Green, 1, targeted); + case cubeGroup::near: + if (presence & 0b11101000) { + drawCube({120, 227}, color::orange, 1, targeted); } - if(presence & 0b11100010){ - drawCube({110, 227}, Color::Green, 1, targeted); + if (presence & 0b11100100) { + drawCube({120, 217}, color::orange, 1, targeted); } - if(presence & 0b11100100){ - drawCube({120, 217}, Color::Orange, 1, targeted); + if (presence & 0b11100010) { + drawCube({110, 227}, color::green, 1, targeted); } - if(presence & 0b11101000){ - drawCube({120, 227}, Color::Orange, 1, targeted); + if (presence & 0b11100001) { + drawCube({110, 217}, color::green, 1, targeted); } - if(presence & 0b11110000){ - drawCube({115, 222}, Color::Purple, 1, targeted); + if (presence & 0b11110000) { + drawCube({115, 222}, color::purple, 1, targeted); } break; } } -void Field::drawTower(const TowerPos pos, const Color contents, const uint8_t cubePresence){ +void Field::draw(const tower pos, const color contents, const uint8_t cubePresence) +{ bool targeted = cubePresence != UINT8_MAX; - for(int i = 0; i < towersToDraw.size(); i++){ - if(towersToDraw[i] == pos){ + for (int i = 0; i < towersToDraw.size(); i++) { + if (towersToDraw[i] == pos) { towersToDraw.erase(towersToDraw.begin() + i); break; } } - lv_obj_t* tower = lv_obj_create(obj, NULL); + // alliance towers shouldn't be drawn until after the border is drawn; + // store the value and print later unless the border is already drawn + if (!wallDrawn) { + if (pos == tower::red) { + allianceTowerContents.first = contents; + return; + } else if (pos == tower::blue) { + allianceTowerContents.second = contents; + return; + } + } + + lv_obj_t *tower = lv_obj_create(obj, NULL); lv_obj_set_size(tower, 16, 16); - switch(pos){ - case TowerPos::Left: + switch (pos) { + case tower::left: lv_obj_set_style(tower, &neutralTower); lv_obj_set_pos(tower, 32, 112); drawCube(tower, {3, 3}, contents, 1, true); - if(cubePresence & 0b11110100){ - drawCube({35, 101}, Color::Purple, 1, targeted); + if (cubePresence & 0b11111000) { + drawCube({35, 101}, color::purple, 1, targeted); } - if(cubePresence & 0b11110010){ - drawCube({35, 129}, Color::Purple, 1, targeted); + if (cubePresence & 0b11110010) { + drawCube({35, 129}, color::purple, 1, targeted); } - if(cubePresence & 0b11110001){ - drawCube({21, 115}, Color::Orange, 1, targeted); + if (cubePresence & 0b11110001) { + drawCube({21, 115}, color::orange, 1, targeted); } break; - case TowerPos::Right: + case tower::right: lv_obj_set_style(tower, &neutralTower); lv_obj_set_pos(tower, 192, 112); drawCube(tower, {3, 3}, contents, 1, true); - if(cubePresence & 0b11110100){ - drawCube({195, 101}, Color::Purple, 1, targeted); + if (cubePresence & 0b11111000) { + drawCube({195, 101}, color::purple, 1, targeted); } - if(cubePresence & 0b11110010){ - drawCube({209, 115}, Color::Green, 1, targeted); + if (cubePresence & 0b11110100) { + drawCube({209, 115}, color::green, 1, targeted); } - if(cubePresence & 0b11110001){ - drawCube({195, 129}, Color::Purple, 1, targeted); + if (cubePresence & 0b11110010) { + drawCube({195, 129}, color::purple, 1, targeted); } break; - case TowerPos::Center: + case tower::center: lv_obj_set_style(tower, &neutralTower); lv_obj_set_pos(tower, 112, 112); drawCube(tower, {3, 3}, contents, 1, true); - if(cubePresence & 0b11111000){ - drawCube({115, 101}, Color::Purple, 1, targeted); + if (cubePresence & 0b11111000) { + drawCube({115, 101}, color::purple, 1, targeted); } - if(cubePresence & 0b11110100){ - drawCube({129, 115}, Color::Green, 1, targeted); + if (cubePresence & 0b11110100) { + drawCube({129, 115}, color::green, 1, targeted); } - if(cubePresence & 0b11110010){ - drawCube({115, 129}, Color::Purple, 1, targeted); + if (cubePresence & 0b11110010) { + drawCube({115, 129}, color::purple, 1, targeted); } - if(cubePresence & 0b11110001){ - drawCube({101, 115}, Color::Orange, 1, targeted); + if (cubePresence & 0b11110001) { + drawCube({101, 115}, color::orange, 1, targeted); } break; - case TowerPos::Far: + case tower::far: lv_obj_set_style(tower, &neutralTower); lv_obj_set_pos(tower, 112, 52); drawCube(tower, {3, 3}, contents, 1, true); - if(cubePresence & 0b11111000){ - drawCube({115, 41}, Color::Purple, 1, targeted); + if (cubePresence & 0b11111000) { + drawCube({115, 41}, color::purple, 1, targeted); } - if(cubePresence & 0b11110100){ - drawCube({129, 55}, Color::Green, 1, targeted); + if (cubePresence & 0b11110100) { + drawCube({129, 55}, color::green, 1, targeted); } - if(cubePresence & 0b11110010){ - drawCube({115, 69}, Color::Purple, 1, targeted); + if (cubePresence & 0b11110010) { + drawCube({115, 69}, color::purple, 1, targeted); } - if(cubePresence & 0b11110001){ - drawCube({101, 55}, Color::Orange, 1, targeted); + if (cubePresence & 0b11110001) { + drawCube({101, 55}, color::orange, 1, targeted); } break; - case TowerPos::Near: + case tower::near: lv_obj_set_style(tower, &neutralTower); lv_obj_set_pos(tower, 112, 172); drawCube(tower, {3, 3}, contents, 1, true); - if(cubePresence & 0b11111000){ - drawCube({115, 161}, Color::Purple, 1, targeted); + if (cubePresence & 0b11111000) { + drawCube({115, 161}, color::purple, 1, targeted); } - if(cubePresence & 0b11110100){ - drawCube({129, 175}, Color::Green, 1, targeted); + if (cubePresence & 0b11110100) { + drawCube({129, 175}, color::green, 1, targeted); } - if(cubePresence & 0b11110010){ - drawCube({115, 189}, Color::Purple, 1, targeted); + if (cubePresence & 0b11110010) { + drawCube({115, 189}, color::purple, 1, targeted); } - if(cubePresence & 0b11110001){ - drawCube({101, 175}, Color::Orange, 1, targeted); + if (cubePresence & 0b11110001) { + drawCube({101, 175}, color::orange, 1, targeted); } break; - case TowerPos::Red: + case tower::red: lv_obj_set_style(tower, &redTower); lv_obj_set_pos(tower, 54, 228); drawCube(tower, {3, 3}, contents, 1, true); break; - case TowerPos::Blue: + case tower::blue: lv_obj_set_style(tower, &blueTower); lv_obj_set_pos(tower, 174, 228); @@ -279,165 +307,194 @@ void Field::drawTower(const TowerPos pos, const Color contents, const uint8_t cu } } -void Field::drawScoringZone(const ZonePos pos, const Color contents, const uint8_t stackHeight){ - drawScoringZone(pos, {contents, Color::None}, {stackHeight, 0}); +void Field::draw(const scoringZone pos, const color contents, const uint8_t stackHeight) +{ + draw(pos, {contents, color::none}, {stackHeight, 0}); } -void Field::drawScoringZone(const ZonePos pos, const std::pair contents, const std::pair stackHeight){ - bool targeted = contents.first != Color::None; +void Field::draw(const scoringZone pos, const std::pair contents, + const std::pair stackHeight) +{ + bool targeted = contents.first != color::none; - for(int i = 0; i < zonesToDraw.size(); i++){ - if(zonesToDraw[i] == pos){ + for (int i = 0; i < zonesToDraw.size(); i++) { + if (zonesToDraw[i] == pos) { zonesToDraw.erase(zonesToDraw.begin() + i); break; } } - lv_obj_t* zone = lv_obj_create(obj, NULL); + lv_obj_t *zone = lv_obj_create(obj, NULL); - switch(pos){ - case ZonePos::FarRed: + switch (pos) { + case scoringZone::farRed: lv_obj_set_style(zone, targeted ? &redZoneHighlighted : &redZone); lv_obj_set_size(zone, 29, 20); lv_obj_set_pos(zone, 0, 0); - if(targeted){ + if (targeted) { drawCube(zone, {4, 5}, contents.first, stackHeight.first, false); drawCube(zone, {15, 5}, contents.second, stackHeight.second, false); } break; - case ZonePos::FarBlue: + case scoringZone::farBlue: lv_obj_set_style(zone, targeted ? &blueZoneHighlighted : &blueZone); lv_obj_set_size(zone, 29, 20); lv_obj_set_pos(zone, 211, 0); - if(targeted){ + if (targeted) { drawCube(zone, {15, 5}, contents.first, stackHeight.first, false); drawCube(zone, {4, 5}, contents.second, stackHeight.second, false); } break; - case ZonePos::NearRed: + case scoringZone::nearRed: lv_obj_set_style(zone, targeted ? &redZoneHighlighted : &redZone); lv_obj_set_size(zone, 20, 20); lv_obj_set_pos(zone, 0, 220); - if(targeted){ + if (targeted) { drawCube(zone, {5, 5}, contents.first, stackHeight.first, false); } break; - case ZonePos::NearBlue: + case scoringZone::nearBlue: lv_obj_set_style(zone, targeted ? &blueZoneHighlighted : &blueZone); lv_obj_set_size(zone, 20, 20); lv_obj_set_pos(zone, 220, 220); - if(targeted){ + if (targeted) { drawCube(zone, {5, 5}, contents.first, stackHeight.first, false); } break; } - if(!zonesToDraw.size()){ - this->reinforcePerimeter(); + if (!zonesToDraw.size()) { + reinforcePerimeter(); } } -void Field::drawColoredTiles(){ - lv_obj_t* redLeft1 = lv_obj_create(obj, NULL); +void Field::drawcoloredTiles() +{ + lv_obj_t *redLeft1 = lv_obj_create(obj, NULL); lv_obj_set_style(redLeft1, &redAlliance); lv_obj_set_size(redLeft1, 40, 40); lv_obj_set_pos(redLeft1, 0, 40); - lv_obj_t* redLeft2 = lv_obj_create(obj, redLeft1); + lv_obj_t *redLeft2 = lv_obj_create(obj, redLeft1); lv_obj_set_pos(redLeft2, 40, 0); - lv_obj_t* blueLeft1 = lv_obj_create(obj, redLeft1); + lv_obj_t *blueLeft1 = lv_obj_create(obj, redLeft1); lv_obj_set_style(blueLeft1, &blueAlliance); lv_obj_set_pos(blueLeft1, 200, 40); - lv_obj_t* blueLeft2 = lv_obj_create(obj, blueLeft1); + lv_obj_t *blueLeft2 = lv_obj_create(obj, blueLeft1); lv_obj_set_pos(blueLeft2, 160, 0); } -void Field::drawLines(){ - lv_obj_t* middleLine1 = lv_obj_create(obj, NULL); +void Field::drawLines() +{ + lv_obj_t *middleLine1 = lv_obj_create(obj, NULL); lv_obj_set_style(middleLine1, &lineStyle); lv_obj_set_pos(middleLine1, 117, 3); lv_obj_set_size(middleLine1, 2, 234); - lv_obj_t* middleLine2 = lv_obj_create(obj, middleLine1); + lv_obj_t *middleLine2 = lv_obj_create(obj, middleLine1); lv_obj_set_x(middleLine1, 121); - lv_obj_t* innerRedZone = lv_line_create(obj, NULL); + lv_obj_t *innerRedZone = lv_line_create(obj, NULL); lv_line_set_style(innerRedZone, &lineStyle); - static lv_point_t irzPts[3] = {{0,40}, {40,40}, {40,0}}; + static lv_point_t irzPts[3] = {{0, 40}, {40, 40}, {40, 0}}; lv_line_set_points(innerRedZone, irzPts, 3); - lv_obj_t* outerRedZone = lv_line_create(obj, innerRedZone); - static lv_point_t orzPts[4] = {{0,80}, {40,80}, {80,40}, {80,0}}; + lv_obj_t *outerRedZone = lv_line_create(obj, innerRedZone); + static lv_point_t orzPts[4] = {{0, 80}, {40, 80}, {80, 40}, {80, 0}}; lv_line_set_points(outerRedZone, orzPts, 4); - lv_obj_t* innerBlueZone = lv_line_create(obj, innerRedZone); - static lv_point_t ibzPts[3] = {{200,0}, {200,40}, {240,40}}; + lv_obj_t *innerBlueZone = lv_line_create(obj, innerRedZone); + static lv_point_t ibzPts[3] = {{200, 0}, {200, 40}, {240, 40}}; lv_line_set_points(innerBlueZone, ibzPts, 3); - lv_obj_t* outerBlueZone = lv_line_create(obj, innerRedZone); - static lv_point_t obzPts[4] = {{160,0}, {160,40}, {200,80}, {240,80}}; + lv_obj_t *outerBlueZone = lv_line_create(obj, innerRedZone); + static lv_point_t obzPts[4] = {{160, 0}, {160, 40}, {200, 80}, {240, 80}}; lv_line_set_points(outerBlueZone, obzPts, 4); } -void Field::reinforcePerimeter(){ - lv_obj_t* perimeter = lv_obj_create(obj, NULL); +void Field::reinforcePerimeter() +{ + lv_obj_t *perimeter = lv_obj_create(obj, NULL); lv_obj_set_style(perimeter, &perimeterStyle); lv_obj_set_size(perimeter, 240, 240); lv_obj_set_pos(perimeter, 0, 0); + + wallDrawn = true; + + if (allianceTowerContents.first != color::none) + draw(tower::red, allianceTowerContents.first); + if (allianceTowerContents.second != color::none) + draw(tower::blue, allianceTowerContents.second); } -void Field::drawRobot(const bool red, const uint8_t pos){ - lv_obj_t* robot = lv_obj_create(obj, NULL); +void Field::drawRobot(const bool red, const uint8_t pos) +{ + lv_obj_t *robot = lv_obj_create(obj, NULL); lv_obj_set_style(robot, red ? &redAllianceHighlighted : &blueAllianceHighlighted); lv_obj_set_size(robot, 30, 30); lv_obj_set_pos(robot, red ? 3 : 207, pos - 15); } -void Field::finishDrawing(){ - while(zonesToDraw.size()){ - drawScoringZone(zonesToDraw[0]); +void Field::finishDrawing() +{ + while (zonesToDraw.size()) { + draw(zonesToDraw[0]); } - while(cubesToDraw.size()){ - drawCubeGroup(cubesToDraw[0]); + while (cubesToDraw.size()) { + draw(cubesToDraw[0]); } - while(towersToDraw.size()){ - drawTower(towersToDraw[0]); + while (towersToDraw.size()) { + draw(towersToDraw[0]); } } -void Field::drawCube(const std::pair pos, const Color color, const uint8_t stackHeight, const bool targeted){ +void Field::drawCube(const std::pair pos, const color color, + const uint8_t stackHeight, const bool targeted) +{ drawCube(obj, pos, color, stackHeight, targeted); } -void Field::drawCube(lv_obj_t *parent, const std::pair pos, const Color color, const uint8_t stackHeight, const bool targeted){ - if(color == Color::None) return; - - lv_obj_t* cube = lv_obj_create(parent, NULL); - lv_obj_set_style(cube, (color == Color::Orange ? (targeted ? &orangeStyleHighlighted : &orangeStyle) : - color == Color::Green ? (targeted ? &greenStyleHighlighted : &greenStyle ) : - (targeted ? &purpleStyleHighlighted : &purpleStyle))); +void Field::drawCube(lv_obj_t *parent, const std::pair pos, const color color, + const uint8_t stackHeight, const bool targeted) +{ + if (color == color::none) + return; + + lv_obj_t *cube = lv_obj_create(parent, NULL); + lv_obj_set_style( + cube, (color == color::orange + ? (targeted ? &orangeStyleHighlighted : &orangeStyle) + : color == color::green ? (targeted ? &greenStyleHighlighted : &greenStyle) + : (targeted ? &purpleStyleHighlighted : &purpleStyle))); lv_obj_set_pos(cube, pos.first, pos.second); lv_obj_set_size(cube, 10, 10); - if(stackHeight > 1){ - lv_obj_t* cubeLabel = lv_label_create(cube, NULL); + if (stackHeight > 1) { + lv_obj_t *cubeLabel = lv_label_create(cube, NULL); lv_label_set_style(cubeLabel, &littleWhiteText); lv_obj_align(cubeLabel, NULL, LV_ALIGN_CENTER, -1, -1); lv_label_set_align(cubeLabel, LV_LABEL_ALIGN_CENTER); - lv_label_set_text(cubeLabel, (" "+std::to_string(stackHeight)).c_str()); + lv_label_set_text(cubeLabel, (" " + std::to_string(stackHeight)).c_str()); } } -void Field::resetVectors(){ - //fully occupy - cubesToDraw = {CubeSector::FarLeft, CubeSector::FarRight, CubeSector::FarPurple, CubeSector::Left1, CubeSector::Left2, CubeSector::Left3, CubeSector::Left4, CubeSector::Right1, CubeSector::Right2, CubeSector::Right3, CubeSector::Right4, CubeSector::Near}; - towersToDraw = {TowerPos::Left, TowerPos::Right, TowerPos::Center, TowerPos::Far, TowerPos::Near, TowerPos::Red, TowerPos::Blue}; - zonesToDraw = {ZonePos::FarRed, ZonePos::FarBlue, ZonePos::NearRed, ZonePos::NearBlue}; +void Field::resetVectors() +{ + // fully populate the vectors + cubesToDraw = {cubeGroup::farLeft, cubeGroup::farRight, cubeGroup::farPurple, + cubeGroup::left1, cubeGroup::left2, cubeGroup::left3, + cubeGroup::left4, cubeGroup::right1, cubeGroup::right2, + cubeGroup::right3, cubeGroup::right4, cubeGroup::near}; + + towersToDraw = {tower::left, tower::right, tower::center, tower::far, + tower::near, tower::red, tower::blue}; + + zonesToDraw = {scoringZone::farRed, scoringZone::farBlue, scoringZone::nearRed, scoringZone::nearBlue}; } -}//namespace screen +} // namespace screen diff --git a/src/screen/resources.cpp b/src/screen/resources.cpp index 7db24e0..9936521 100644 --- a/src/screen/resources.cpp +++ b/src/screen/resources.cpp @@ -1,6 +1,6 @@ #include "screen/resources.hpp" -namespace screen{ +namespace screen { lv_style_t blankStyle; lv_style_t listStyle; @@ -34,18 +34,18 @@ lv_style_t blueZone; lv_style_t redZoneHighlighted; lv_style_t blueZoneHighlighted; - -void initializeStyles(){ +void initializeStyles() +{ lv_style_copy(&blankStyle, &lv_style_plain); - blankStyle.body.main_color = LV_COLOR_GRAY; - blankStyle.body.grad_color = LV_COLOR_GRAY; + blankStyle.body.main_color = LV_COLOR_GRAY; + blankStyle.body.grad_color = LV_COLOR_GRAY; blankStyle.body.border.width = 0; lv_style_copy(&listStyle, &lv_style_plain); - listStyle.body.main_color = LV_COLOR_SILVER; - listStyle.body.grad_color = LV_COLOR_SILVER; + listStyle.body.main_color = LV_COLOR_SILVER; + listStyle.body.grad_color = LV_COLOR_SILVER; listStyle.body.border.width = 3; - listStyle.body.radius = 0; + listStyle.body.radius = 0; listStyle.body.border.color = LV_COLOR_BLACK; listStyle.body.border.width = 3; @@ -58,8 +58,8 @@ void initializeStyles(){ perimeterStyle.body.empty = true; lv_style_copy(&blueAlliance, &fieldStyle); - blueAlliance.body.main_color = LV_COLOR_BLUE; - blueAlliance.body.grad_color = LV_COLOR_BLUE; + blueAlliance.body.main_color = LV_COLOR_BLUE; + blueAlliance.body.grad_color = LV_COLOR_BLUE; blueAlliance.body.border.width = 0; lv_style_copy(&blueAllianceHighlighted, &blueAlliance); @@ -77,14 +77,14 @@ void initializeStyles(){ lv_style_copy(&lineStyle, &lv_style_plain); lineStyle.body.main_color = LV_COLOR_WHITE; lineStyle.body.grad_color = LV_COLOR_WHITE; - lineStyle.line.color = LV_COLOR_WHITE; - lineStyle.line.width = 3; + lineStyle.line.color = LV_COLOR_WHITE; + lineStyle.line.width = 3; lv_style_copy(&whiteText, &lv_style_plain); - whiteText.text.color = LV_COLOR_WHITE; - whiteText.text.font = &lv_font_dejavu_20; + whiteText.text.color = LV_COLOR_WHITE; + whiteText.text.font = &lv_font_dejavu_20; whiteText.text.letter_space = 2; - whiteText.text.line_space = 1; + whiteText.text.line_space = 1; lv_style_copy(&littleWhiteText, &whiteText); littleWhiteText.text.font = &::smallFont; @@ -104,9 +104,9 @@ void initializeStyles(){ pressedButton.body.grad_color = LV_COLOR_GRAY; lv_style_copy(&orangeStyle, &lv_style_plain); - orangeStyle.body.radius = 0; - orangeStyle.body.main_color = LV_COLOR_MAKE(0xFF, 0xA0, 0x00); - orangeStyle.body.grad_color = LV_COLOR_MAKE(0xFF, 0xA0, 0x00); + orangeStyle.body.radius = 0; + orangeStyle.body.main_color = LV_COLOR_MAKE(0xFF, 0x80, 0x00); + orangeStyle.body.grad_color = LV_COLOR_MAKE(0xFF, 0x80, 0x00); orangeStyle.body.border.color = LV_COLOR_WHITE; orangeStyle.body.border.width = 0; @@ -128,11 +128,11 @@ void initializeStyles(){ purpleStyleHighlighted.body.border.width = 1; lv_style_copy(&neutralTower, &lv_style_plain); - neutralTower.body.main_color = LV_COLOR_GRAY; - neutralTower.body.grad_color = LV_COLOR_GRAY; + neutralTower.body.main_color = LV_COLOR_GRAY; + neutralTower.body.grad_color = LV_COLOR_GRAY; neutralTower.body.border.color = LV_COLOR_BLACK; neutralTower.body.border.width = 2; - neutralTower.body.radius = LV_RADIUS_CIRCLE; + neutralTower.body.radius = LV_RADIUS_CIRCLE; lv_style_copy(&redTower, &neutralTower); redTower.body.main_color = LV_COLOR_RED; @@ -144,7 +144,7 @@ void initializeStyles(){ lv_style_copy(&redZone, &fieldStyle); redZone.body.border.width = 3; - redZone.body.radius = 3; + redZone.body.radius = 3; redZone.body.border.color = LV_COLOR_RED; lv_style_copy(&redZoneHighlighted, &redZone); @@ -159,4 +159,4 @@ void initializeStyles(){ blueZoneHighlighted.body.grad_color = LV_COLOR_WHITE; } -}//namespace screen +} // namespace screen diff --git a/src/screen/smallFont.c b/src/screen/smallFont.c index 036b358..80364be 100644 --- a/src/screen/smallFont.c +++ b/src/screen/smallFont.c @@ -4,6 +4,10 @@ /*********************************************************************************** * synchronizer_nbp.ttf 7 px Font in U+0030 (0) .. U+0039 (9) range with 1 bpp * Sparse font with only these characters: 0123456789 + * + * font by total FontGeek DTF, Ltd. - https://www.fontspace.com/total-fontgeek-dtf-ltd/synchronizer-nbp + * converted by the lvgl font converter - https://littlevgl.com/ttf-font-to-c-array + * all credit to them ***********************************************************************************/ /*Store the image of the letters (glyph)*/