diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 8aa39a17b0..c07f6b9ba3 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -1202,6 +1202,7 @@ + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 4f84103925..3c397cd957 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -3441,6 +3441,9 @@ save yourself some time, copy this for undocumented things: Sets the current for the Profile. + + Sets the display name of the profile to name. + Sets the goal to iCals calories. diff --git a/Docs/Themerdocs/calories.txt b/Docs/Themerdocs/calories.txt new file mode 100644 index 0000000000..bea235fdfb --- /dev/null +++ b/Docs/Themerdocs/calories.txt @@ -0,0 +1,50 @@ +SM5 has two systems for calculating the number of calories burned during a song. + +The first system simply uses the weight of the player and adds a small amount for every step. This does not require any specific support from the theme and is the default for new profiles. + + +The second system uses age, gender, weight, heart rate, and song duration to calculate the amount used during a song. This requires a theme to support it, and the relevant parts of Editable.ini to be set for the profile. + +Editable.ini fields: +BirthYear, -- defaults to 1995 +IgnoreStepCountCalories, -- Must be set to 1 to use the second system. +IsMale, -- Defaults to 1. Set to 0 for females. +Voomax, -- VO2max. Optional. Calorie calculation is more accurate if it is set, but it is not necessary. 0 means unset. http://www.shapesense.com/fitness-exercise/calculators/vo2max-calculator.aspx is a site for estimating V02max, and the source of the equations used. +WeightPounds -- Weight in pounds. + +Lua API functions: (names only, details are in Docs/Luadoc/Lua.xml) +GetWeightPounds() +SetWeightPounds() +GetVoomax() +SetVoomax() +GetAge() +GetBirthYear() +SetBirthYear() +GetIgnoreStepCountCalories() +SetIgnoreStepCountCalories() +GetIsMale() +SetIsMale() +AddCaloriesToDailyTotal() +CalculateCaloriesFromHeartRate() + +Intended usage: +A theme that supports heart rate calorie calculation should take the following steps: +1. Create a new screen that the player will be able to use to enter their heart rate. It shall be called "ScreenHeartEntry" in this list, though a theme can name it anything. +2. During ScreenGameplay, track the amount of time that the player is hitting steps for. This duration must be in seconds. +3. When proceeding from ScreenGameplay: +3a. Check whether GetIgnoreStepCountCalories returns true for either player's profile. +3b. If it returns true for either player, go to ScreenHeartEntry instead of ScreenEvaluationNormal. +3c. This means changing the NextScreen metric for ScreenGameplay to use a function that checks the profiles and returns the correct screen. +4. On ScreenHeartEntry: +4a. Provide a timer that the players can watch while measuring their pulse. +4b. Provide a way for the players to enter their heart rate in beats per minute. +4c. When a player enters their heart rate, use Profile:CalculateCaloriesFromHeartRate(). +4d. Do not add calories to a profile if Profile:IgnoreStepCountCalories() returns false for that profile. +4e. Pass the heart rate and the duration from ScreenGameplay to Profile:CalculateCaloriesFromHeartRate() and store its return value. +4f. Pass the return value of Profile:CalculateCaloriesFromHeartRate() to Profile:AddCaloriesToDailyTotal() to add them to the total for that player's profile. +4g. When all active players have finished entering their heart rate, proceed to ScreenEvaluationNormal. +5. This concludes the special steps required for theme support of heart rate calorie calculation. + +Side notes: +CalculateCaloriesFromHeartRate and AddCaloriesToDailyTotal are separate functions so that a theme can display or use the calorie amount in other ways easily. +If IgnoreStepCountCalories is true for a profile, but the theme in use does not provide support using the steps listed above, that profile will not accumulate calories. diff --git a/src/Profile.cpp b/src/Profile.cpp index 7d493e5b2a..c6f72606a2 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -2374,6 +2374,7 @@ public: { ADD_METHOD( AddScreenshot ); ADD_METHOD( GetDisplayName ); + ADD_METHOD( SetDisplayName ); ADD_METHOD( GetLastUsedHighScoreName ); ADD_METHOD( SetLastUsedHighScoreName ); ADD_METHOD( GetAllUsedHighScoreNames );