diff options
author | Andrew Cady <d@jerkface.net> | 2022-10-21 01:33:22 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2022-10-21 01:33:22 -0400 |
commit | 55370844e691cfcf334eb7d79f07ac68e11b9240 (patch) | |
tree | 930974e0fbbc947ac17decaf1022ae3883dd5554 | |
parent | 4325763348135944fa0378144ccece16d523ee39 (diff) |
show entire 5/3/1 progression
-rwxr-xr-x | repgoal.hs | 55 |
1 files changed, 41 insertions, 14 deletions
@@ -134,11 +134,38 @@ makeLenses ''St | |||
134 | -- TODO: Event for inotify on edited text file (as input interface) | 134 | -- TODO: Event for inotify on edited text file (as input interface) |
135 | data CustomEvent = CustomEvent | 135 | data CustomEvent = CustomEvent |
136 | 136 | ||
137 | data SetScheme = SetScheme { ratioMax :: Rational, numberOfReps :: Integer } | ||
138 | |||
139 | setScheme :: Rational -> Integer -> SetScheme | ||
140 | setScheme percentage reps = SetScheme (percentage / 100) reps | ||
141 | |||
142 | data SetOption = Fresher | Heavier | ||
143 | |||
144 | warmup :: [SetScheme] | ||
145 | warmup = [setScheme 40 5, setScheme 50 5, setScheme 60 3] | ||
146 | |||
147 | liftScheme :: SetOption -> WeekSelection -> [SetScheme] | ||
148 | liftScheme Fresher Week1 = warmup ++ [setScheme 65 5, setScheme 75 5, setScheme 85 5] | ||
149 | liftScheme Heavier Week1 = warmup ++ [setScheme 75 5, setScheme 80 5, setScheme 85 5] | ||
150 | liftScheme Fresher Week2 = warmup ++ [setScheme 70 3, setScheme 80 3, setScheme 90 3] | ||
151 | liftScheme Heavier Week2 = warmup ++ [setScheme 80 3, setScheme 85 3, setScheme 90 3] | ||
152 | liftScheme _______ Week3 = warmup ++ [setScheme 75 5, setScheme 85 3, setScheme 95 1] | ||
153 | |||
154 | data ListPosition = FirstInList | LastInList | MiddleInList deriving (Eq) | ||
155 | |||
156 | annotatePosition :: [a] -> [(ListPosition, a)] | ||
157 | annotatePosition [] = undefined | ||
158 | annotatePosition [x] = [(LastInList, x)] | ||
159 | annotatePosition (x:xs) = (FirstInList, x) : annotateRest xs | ||
160 | where | ||
161 | annotateRest [] = undefined | ||
162 | annotateRest [x] = [(LastInList, x)] | ||
163 | annotateRest (x:xs) = (MiddleInList, x) : annotateRest xs | ||
164 | |||
137 | drawUI :: St -> [Widget ()] | 165 | drawUI :: St -> [Widget ()] |
138 | drawUI st = [vCenter $ vBox [hCenter oneRepMaxTable, withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]] | 166 | drawUI st = [vCenter $ vBox [hCenter oneRepMaxTable, withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]] |
139 | where | 167 | where |
140 | -- lastSetTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Week", "Last Set", "Goal", "Goal+1"] : concatMap toWeekRows (view lifts st) | 168 | lastSetTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Set", "Goal"] : concatMap (toLiftRows (view week st)) (view lifts st) |
141 | lastSetTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Week", "Last Set", "Goal", "Goal+1"] : map (toWeekRow (view week st)) (view lifts st) | ||
142 | oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow (view lifts st) | 169 | oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow (view lifts st) |
143 | toRow LiftRecord{..} = | 170 | toRow LiftRecord{..} = |
144 | let best@Achieved{..} = bestPerformance stats | 171 | let best@Achieved{..} = bestPerformance stats |
@@ -149,13 +176,12 @@ drawUI st = [vCenter $ vBox [hCenter oneRepMaxTable, withVScrollBarHandles $ wit | |||
149 | str $ printf "%d @ %d" achievedReps achievedWeight, | 176 | str $ printf "%d @ %d" achievedReps achievedWeight, |
150 | str $ showRational $ computeOneRepMax best | 177 | str $ showRational $ computeOneRepMax best |
151 | ] | 178 | ] |
152 | -- toWeekRows lift = (flip map) [1,2,3::Int] $ \week -> toWeekRow week lift | 179 | toLiftRows :: WeekSelection -> LiftRecord -> [[Widget n]] |
153 | toWeekRow :: WeekSelection -> LiftRecord -> [Widget n] | 180 | toLiftRows week lift = (flip map) (annotatePosition $ liftScheme Fresher week) $ toLiftRow week lift |
154 | toWeekRow week LiftRecord{..} = | 181 | toLiftRow :: WeekSelection -> LiftRecord -> (ListPosition, SetScheme) -> [Widget n] |
182 | toLiftRow week LiftRecord{..} (position, (SetScheme targetRatio targetReps)) = | ||
155 | let best = bestPerformance stats | 183 | let best = bestPerformance stats |
156 | targetReps = case week of Week1 -> 5; Week2 -> 3; Week3 -> 1 :: Int | 184 | computedTarget = targetRatio * (90 % 100) * computeOneRepMax best |
157 | targetPercentage = case week of Week1 -> 85; Week2 -> 90; Week3 -> 95 | ||
158 | computedTarget = (* (targetPercentage % 100)) $ (* (90 % 100)) $ computeOneRepMax best | ||
159 | targetWeight = ceilingN 5 computedTarget | 185 | targetWeight = ceilingN 5 computedTarget |
160 | repGoal = computeRepGoal targetWeight stats | 186 | repGoal = computeRepGoal targetWeight stats |
161 | goalTo1RM g = computeOneRepMax $ Achieved g targetWeight | 187 | goalTo1RM g = computeOneRepMax $ Achieved g targetWeight |
@@ -163,12 +189,13 @@ drawUI st = [vCenter $ vBox [hCenter oneRepMaxTable, withVScrollBarHandles $ wit | |||
163 | in | 189 | in |
164 | map (padLeftRight 2) | 190 | map (padLeftRight 2) |
165 | [ | 191 | [ |
166 | -- txt $ (if week == 1 then liftName else " "), | 192 | -- txt $ if position == FirstInList then liftName else " ", |
167 | txt $ liftName, | 193 | txt $ case position of FirstInList -> liftName; LastInList -> " \n "; _ -> " ", |
168 | txt $ case week of Week1 -> "1"; Week2 -> "2"; Week3 -> "3", | 194 | -- txt $ case week of Week1 -> "1"; Week2 -> "2"; Week3 -> "3", |
169 | str $ printf "%2d+ @ %d" targetReps targetWeight, | 195 | str $ printf "%2d%s @ %d%s" targetReps (if position == LastInList then "+" else "" :: Text) targetWeight (if position == LastInList then "\n " else "" :: String), |
170 | str $ showGoal repGoal, | 196 | str $ if position /= LastInList then " " else showGoal repGoal ++ "\n" ++ showGoal (repGoal + 1) |
171 | str $ showGoal (repGoal + 1) | 197 | -- str $ if position /= LastInList then " " else showGoal repGoal, |
198 | -- str $ if position /= LastInList then " " else showGoal (repGoal + 1) | ||
172 | ] | 199 | ] |
173 | 200 | ||
174 | ceilingN :: Integer -> Rational -> Integer | 201 | ceilingN :: Integer -> Rational -> Integer |