Skip to content
This repository was archived by the owner on Oct 10, 2020. It is now read-only.

Commit 867949f

Browse files
author
Joseph Spencer
committed
added things that should have worked, may have exposed underlying issue
1 parent ab97496 commit 867949f

File tree

4 files changed

+130
-65
lines changed

4 files changed

+130
-65
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Version
1717
=======
1818
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
1919
The second digit refers to any new features that may be added.
20-
The third digit refers to any bug fixes.
20+
The third digit refers to any bug fixes or minor improvements to existing features.
2121

2222
License
2323
=======

include/screen/field.hpp

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ class Field {
7373
* Field generator for the screen
7474
*
7575
* @param parent LVGL object to place upon
76-
* @param x x-value from 0-240 of the leftmost side of the field, default is centered
76+
* @param ilength the side length of the field (in both directions)
7777
* @param iautoInit print colored tiles / taped lines immediately, and after each clean
7878
*/
79-
Field(lv_obj_t *parent, uint8_t x = 120, bool iautoInit = true);
79+
Field(lv_obj_t *parent, double ilength = 240, bool iautoInit = true);
8080
~Field();
8181

8282
/**
@@ -85,13 +85,43 @@ class Field {
8585
void clean();
8686

8787
/**
88-
* Set new x position on the screen
89-
* note: Y cannot be changed, as the field takes up the entire screen vertically
88+
* Set new x position of the field on the screen
9089
*
91-
* @param x new x-value from 0-240 of the leftmost side of the field
90+
* @param x new x-value of the distance from the leftmost side of the screen
91+
* (screen is 480 pixels wide)
9292
*/
9393
void setX(uint8_t x);
9494

95+
/**
96+
* Set new y position of the field on the screen
97+
*
98+
* @param y new y-value of the distance from the top side of the field
99+
* (screen is 240 pixels tall)
100+
*/
101+
void setY(uint8_t y);
102+
103+
/**
104+
* Set new position of the field on the screen
105+
*
106+
* note: the default(if this is never called) is 120,0 (centered)
107+
*
108+
* @param x new x-value of the distance from the leftmost side of the screen
109+
* (screen is 480 pixels wide)
110+
* @param y new y-value of the distance from the top side of the field
111+
* (screen is 240 pixels tall)
112+
*/
113+
void setPos(uint8_t x, uint8_t y);
114+
115+
/**
116+
* Set the new width and height of the field
117+
*
118+
* this will clean the screen and remove all existing objects
119+
*
120+
* note: you can make the field larger than the screen,
121+
* but you would then need a way to move the screen around in order to see it
122+
*/
123+
void setSideLength(uint ilength);
124+
95125
/**
96126
* draw a group of cubes
97127
*
@@ -137,7 +167,7 @@ class Field {
137167
*
138168
* called automatically by default
139169
*/
140-
void drawcoloredTiles();
170+
void drawColoredTiles();
141171

142172
/**
143173
* draw the zone lines
@@ -162,7 +192,7 @@ class Field {
162192
*
163193
* @param red true for red, false for blue
164194
* @param pos y-value of the midpoint of the robot
165-
* note: there are 40 pixels for each field tile
195+
* note: every 40 given to pos represents 1 field tile
166196
*/
167197
void drawRobot(bool red, uint8_t pos);
168198

@@ -179,16 +209,19 @@ class Field {
179209
// Cubes should be drawn automatically by the above functions
180210
void drawCube(std::pair<uint8_t, uint8_t> pos, color color, uint8_t stackHeight, bool targeted);
181211

182-
static void drawCube(lv_obj_t *parent, std::pair<uint8_t, uint8_t> pos, color color,
212+
static void drawCube(lv_obj_t *parent, std::pair<uint8_t, uint8_t> pos, double scalar, color color,
183213
uint8_t stackHeight, bool targeted);
184214

215+
int scale(int original);
216+
185217
void resetVectors();
186218

187219
const uint numOfBits[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
188220

189221
lv_obj_t *obj;
190222

191223
bool autoInit;
224+
double scalar;
192225

193226
bool wallDrawn;
194227
std::pair<color, color> allianceTowerContents;

src/opcontrol.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ void opcontrol()
1111

1212
screen::Field field(scr);
1313

14+
field.setSideLength(200);
15+
1416
// two stacks use an array of colors
1517
// draw a purple stack with height 1 and an orange stack with height 3 in the far red zone
1618
field.draw(screen::scoringZone::farRed, {screen::color::purple, screen::color::orange},

0 commit comments

Comments
 (0)