Summer Week #8 (7/3 – 7/9)

This past week was a little bit shorter with the Fourth of July holiday, but I feel that I was still able to make quite a bit of progress. I mainly worked on developing the squatting mode for our PhoneGap app, refreshing myself on CSS, updating the Arduino code to work with the squatting mode, and creating diagrams that help better illustrate how the MuscleMemory Bluetooth Application will work.

Squatting Mode

Katie had asked me this week to focus on creating a squatting mode for the PhoneGap application that would serve as our ambient display in place of the NeoPixels that were on the original MuscleMemory knee sleeve. The idea for the squatting mode is to have 2 circles for both starting and target squat positions that are filled red when the athlete has not yet set either position. When athletes set either the start or target position then the circle representing the position that has been set will fill in green to let athletes know they’ve set the position. The squatting mode will also display the number of remaining reps in an athlete’s workout and will also change its background color to let athletes know what stage of the squat they are in.

  • If an athlete has not yet attempted his or her squat then the background color of the squatting mode will be red.
  • If the athlete is attempting his or her squat but has not yet completed it then the background color of the squatting mode will change from red to yellow.
  • If the athlete fully completes a squat then the background color of the squatting mode will change from yellow to green.
  • If the athlete ends a squat without fully completing it (half-squat) then the background color of the squatting mode will change from yellow to purple.
  • When an athlete is ready to begin his or her next rep then the background color of the squatting mode will change from either purple or green back to red.

After spending quite a bit of time refreshing myself on CSS, which I had pretty little knowledge of, I was able to create a rough version of my app with the squatting mode. My current version of the squatting mode has the 2 circles for start and target position, has a number in the middle of the screen that displays how many reps are remaining, and just has a box at the bottom of the screen that changes its background color according to the stage of the squat that an athlete is in.

I would say that the majority of squatting mode is completed as when I tested it the box at the bottom was properly changing its background color based on the data sent. However, there are still a few problems with the squatting mode that need to be fixed.

  1. After being set, the start and target position circles should be filled in green rather than red, but currently these circles just flash green when the app receives data from the Arduino and then almost immediately the circles return to the color red.
  2. After receiving data from the Arduino the text that should display the number of reps remaining in the workout will flash a number on the screen (not the correct number of reps remaining but rather a number assuming there were only 17 reps instead of 20) and then display the number 0.
  3. After fully completing 17 reps out of the 20 in the assigned workout of 4 sets of 5 reps, the athlete’s table changes the 2 reps in the 4th set from green to gold even though the set has not been completed.

I suspect that I’m likely encountering these issues because the Arduino is only sending 20 characters of the workout string at a time and then delaying before sending the rest of the workout string. I noticed that this delay was happening earlier when I was testing what string the Flora was sending to update the table. I believe that the PhoneGap app probably is receiving the first 20 characters of the workout string from the Arduino (the first 3 being characters that determine the color of the start position, target position, and backgroundBox and the other 17 being the number of reps), taking off the first 3 characters to determine the colors of the start circle, target circle, and backgroundBox and then updating the table based off the other 17 characters. Then there is probably a delay and the PhoneGap app is then receiving the last 3 characters which were meant to have been included in “tableString” (line 185 of index.js) that was used to update the matrix. These 3 characters are then instead being set as the variables startSet (line 154), targetSet (line 163), and squatModeColor (line 171) and this is probably what is changing the start and target circles back to red.

I’m not entirely sure what the solution to this problem is, but I suspect that I’ll need to find a way that the Arduino can send more than 20 characters at a time to the app.

Arduino Code

This week I also had to make a couple of changes to the Arduino code so that it would be able to work with our app’s squatting mode. One of the main changes that I made in my new Arduino code was to change the string “workoutToSend” to include characters that told the app if the starting and target positions had been set and a character that told the app what color to display. I also updated the Arduino code so that it could work with the app’s squatting mode to provide real-time feedback by automatically sending data to the app after both the start and target positions had been set and also every time that the background box in the squat mode needed to change. This change freed a pin on the Flora board as we no longer need a switch to send data to the app and it also made sure that we would not have to worry about athletes forgetting to send their data after their workout.

While I was testing my Arduino code this week I did recognize a problem that I hadn’t before. The problem occurs directly after an athlete sets a target position and begins to come back up to his or her starting position. This should not be counted as a rep and the knee sleeve should wait for the athlete to return to his or her starting position before counting any reps but during testing that was not the case. I’m not entirely sure why my current solution to this problem is not working, but I’m sure that I will figure it out soon. After I fix this issue then there shouldn’t be too much more I’ll need to change in my Arduino code. I’ll simply need to include packet parsing and a reset function for when a new workout is beginning, possibly change the values for attemptedValue and restartingValue and probably shorten a few of my delays. After making all of those changes though I suspect the Arduino code will be complete and then we’ll just need to focus on the app and sew together the actual knee sleeve.

Diagrams 

This past week Katie asked me to make a couple of diagrams. The first diagram that I made was a diagram that helps show how all of the components of the project will be connected and how they will all work together. Here’s my diagram:

Diagram

This is not the prettiest diagram, but I feel that it does a good job in explaining how the instructor side of the app, database, athlete side of the app, and the knee sleeve all work together.

The other diagram that I made this week was a Fritzing diagram that shows all of the components that will all be on the MuscleMemory knee sleeve.

 

Bend Sensor Fritzing_bb

Plans for This Week

This week I’m planning to find a way to send more than 20 characters from the Flora to the PhoneGap app without a delay and to continue finishing up the app’s squatting mode. Additionally, I’m hoping to finish up the Arduino code by learning how to send and parse packets to set the number of sets and reps in the workout, fixing the issue of counting a rep after setting the target squat position, and including a reset function for when new workouts start. If I get farther than that I’ll try again to connect the PhoneGap app with the database.