Coder Social home page Coder Social logo

dvmarinoff / flux Goto Github PK

View Code? Open in Web Editor NEW
456.0 20.0 80.0 2.1 MB

Indoor Cycling App for Structured Training

Home Page: https://flux-web.vercel.app

License: GNU Affero General Public License v3.0

JavaScript 88.67% CSS 4.69% HTML 6.63%
web-bluetooth tacx cycling zwift garmin cycling-power ftms

flux's Introduction

dvmarinoff

user page

flux's People

Contributors

991jo avatar dvmarinoff avatar ihilt avatar mattdsteele avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flux's Issues

Enable larger fonts (13" laptop)

Enabling larger fonts for a 13" laptop screen (HiDpi) would be very nice for improved readability (at a distance).

As it is, right now (Windows 10, Microsoft Edge), with the browser in full-screen mode (F11), the text information is somewhat hard to read, IMHO.

Right now, the screen is also not overly full, either, lots blank space where information could be present.

workout import is broken

controllers.js:91 Uncaught TypeError: Cannot read property 'data' of undefined
    at controllers.js:91
    at HTMLDocument.<anonymous> (xf.js:12)
    at XF.dispatch (xf.js:26)
    at FileReader.reader.onload (file.js:13)

add a first time user setup story and multi-user settings

Case New User:
Page 1:
User starts at a page which asks for Name, FTP and weight.
If FTP is not known set a temporary one at sufficiently low value in the range of 90-200 depending on weight,
and suggest an FTP test.

Page 2:
Connect devices

  • display names of the devices in form of: s' (Rays' Tacx Flux)

Create a setup. That is a named combination of connected devices.
Like
'race':
Assioma Pedals for power and cadence,
Tacx Flux for controllable,
Polar HRM for heart rate.

'train':
Tacx Flux for power, cadence and controllable,
Fenix Watch for Heart rate

Page 3:
Choose between guided workout or guided recon session.

Case Existing User:
Pick from a list of existing Users.
Pick a setup.
Go to Home page.

add battery level to settings

  • add code to work with Battery Service

  • read battery level characteristic

  • file a bug report at bugs.chromium

NOTE: Web Bluetooth appears to have a bug when trying to recognize Battery Service.
Left a report, maybe I'll need to file a full bug report later. Waiting for response now

NOTE: added Issue 1155044

Add workout video view

On youtube there are workout videos for training, so we could add an option to play a youtube video inside the app.
For example exchange the workout graph with something like:

<iframe id="ytplayer" type="text/html" width="720" height="405"
src="https://www.youtube.com/embed/ZiGE3-L4vyg"
frameborder="0" allowfullscreen>

Perhaps adding big buttons to change watt/resistance/slope

Support for maps

Hi, First of all, this is absolutely jaw dropping... ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘

Have you thought of adding maps support, i.e. these use cases?

  • Draw a route in a map
  • Choose start / destination points
  • Mark slopes in the route using colors green to red (or violet)
  • Mark an estimated point were the user is pedaling at.
  • Calculate an ETA

Some of these features are currently supported in the official tacx training app. In order to be able to choose start / destination points, you have to export google maps directions to gpx, then reconvert the gpx file and upload it to the training app, only as a premium subscriber which is pretty annoying.

It's been a while since I last coded in nodejs, but if you need to I'm offering help to improve your tool.

Thanks in advance!

add support for Power Meters

outdoor power meters need to be connected over the Cycling Power Service (CPS)

  • add cps.js implementing the overall functionality for the service
  • add a power-meter.js to manage a device implementing the CPS
  • add a View in Settings with Power and Cadence
  • support cadence if available
  • support for dual side power meters (2 servers)
  • make it more robust

add device info to settings

  • add code to work with Device Information Service
  • device model string
  • device manufacturer
  • device firmware version

add support for Slope targets in workouts

Why?

  • recovery intervals, because ERG mode can be really tough on the legs
  • FTP tests with stable gradient and enough resistance for any gearing.
  • tabata style workouts in full slope mode might work much better than ERG mode especially at high power outputs where ERG
    often has trouble reaching the target. Jumping from 0 % to 10% and back. A bit like hitting a fly over in a CX race.

How?

add a custom attribute Slope="4.5" that takes slope as a number between 0 and say 30 or max 45 in increments of 0.1.
The attribute will be supported for <SteadyState />, <IntervalsT />.

  • <SteadyState Duration="60" Slope="4.5" />

will turn on slope mode and set target to 4.5 % grade simulation

  • <IntervalsT Repeat="2" OnDuration="60" OffDuration="30" OnSlope="9.0", OffSlope="0"/>

will turn on slope mode and set slope target to 9.0% for 60sec and 0.0% for 30sec, repeat for one more time (2 total)

  • <SteadyState Duration="60" Power="0.88" Slope="4.5" />

will set power target to 0.88 % of FTP, and slope target to 4.5%. The mode will be set to 1. the current active or 2. forced to slope mode. The User will be able to switch ERG and Slope mode with those predefined targets.

  • <SteadyState Duration="60" Power="230" Slope="4.5" />

power target is abs 250, slope target 4.5%

EDIT: it's just Slope now, not SlopeTarget

add Spin Down Support

[ ] - spin down UI
[ ] - spin down with FTMS
[ ] - persist status codes from spin down in settings

add support for ANT+ on the web

Supporting Ant+ on the web.

  • Research WebUSB
  • Research Serial API
  • figure out how ANT+ works
  • make a minimal example with heart rate data
  • figure out and design a clean and obvious UI that allows choosing between ANT+ and/or BLE
  • add ANT+ heart rate data
  • add ANT+ FE-C

WebBLE in Chrome on M1 Mac can sometimes drop the connection

m1 mac chrome is the first place I see this error, it needs to be handled properly so it is clear that the connection is dropped.
characteristic.writeValue: DOMException: GATT Service no longer exists.

The indicator kept being green, despite the service drop. Tacx Flux S and 2 have a tendency of sometimes dropping the connection when you stop to pedal, but it goes to red, and this test was run with the nRF Connect Simulator, which kept thinking it is properly connected just missed all the ERG mode commands.

Screenshot 2021-08-24 at 17 12 52

Add info on Firefox support

Opened the online version with Firefox, but could not figure out how to get started.
As Firefox support is not mentioned in the documentation, couldn't figure out whether it's a support issue, or PEBKAC.
Could Firefox support state be documented?

add support for outdoor use

  • recording gps data (from mobile device or gps watch)
  • routing and navigation with maps
  • outdoor velodrome and circuit auto laps
  • cycling speed and candence sensor support
  • pause just the workout not the recording option for outdoor workouts
  • custom segment timing
  • multi-sport recording (cycle + run)
  • research integration options with sports watches (garmin Extended Display ANT profile)

Geolocation Web API

geolocation (whatwebcando.today)
Using Geolocation Web API (MDN)

Extended Display

ANT+ Extended Display

add workout generator

It has to make a suggestion for a workout based on user defined constraints like time, intensity, energy system. A current physical condition and recent workout history can be used to narrow down and simplify the process for the user.
Heart rate data (like HRV) can be used to dial in intensity and energy system suggestions.
L-system or GA can be used for the generation.

Speed in ERG mode

The Fitness Machine Equipment Service (bluetooth spec) calculates the speed of the flywheel and sends this as a speed value.
In SIM mode this is fine, but in ERG mode this makes the speed values meaningless. In ERG mode you are setting a power target, which the trainer needs to meet regardless of gear combination or cadence, which results in power output having no effect on speed.
You can set the bike in 34/17 gear and doing 300 watts or 100 watts have no effect on speed, on the other hand changing cadence from 70 to 90 will give you about 6km/h more. This results in wrong distance calculation.

The problem:

  1. If avg speed is not that important, distance is. It is a major metric for comparing time blocks of training.
    Many people wouldn't like seeing their monthly distance graph sink in (especially on strava).
  2. For most trainers using the small ring results in much less noise. The mid tier trainers are basically silent at low flywheel speeds.

The solution:
Assuming flat terrain, the same way default SIM mode does, ERG speed can be calculated from power output.

The challenges:
This will require some assumptions to be made about:

  • Aero drag from rider position
  • Aero drag from equipment
  • Air pressure
  • Altitude
  • Temperature
  • Dew point
  • Wind Speed and direction
  • Surface rolling resistance
  • Tires rolling resistance
  • Bike weight
  • ...
  • (curvature of expanding spacetime =) )

The model could be simplified. At the end the resulting distance needs to match expectations (zwift, tr, ...) more than physics.

automatic reconnect to devices with already granted permission

The ability to auto connect to the devices used in the previous session would be a nice convenience.

The status of the chrome feature is tracked here:
chromium

This is a pattern to implement it:
getDevices

its based on navigator.bluetooth.getDevices() giving you a list of devices and device.watchAdvertisements({signal: abortController.signal}) to start listening for their availability.
Use this event to now that, and remember to abort the others once the needed device is there.
device.addEventListener('advertisementreceived', async (evt) => {})

persistence for user added workouts

The app will work with .zwo workout format only.

  • research IndexDB,
  • research Web Workers
  • figure out how to store and work with user added collections of workouts
  • research options for config files, user friendly way to create, edit and import them
  • implement the solution

PowerLow and PowerHigh on a .zwo Cooldown tag

In Zwift workout creator if I set PowerOne=40 and PowerTwo=75, on a Warmup tag it will be PowerLow=โ€œ0.40โ€ and PowerHigh=โ€œ0.75โ€. So far so good, but if I set them to PowerOne=75 and PowerTwo=40, on a Cooldown tag they will become PowerLow=โ€œ0.75โ€ and PowerHigh=โ€œ0.40โ€. This doesn't make any sense and there appears to be no official spec about it.

cooldown-attributes

high-low-created-with-zwift

Spotted in here

add display for avg power

  • avg power for current lap (maybe in the current power graph or over the current interval)
  • avg power for whole workout (maybe under the current power graph)
  • avg power of competed laps (maybe in the interval graph)

pausing just the workout

Add ability for the User to pause and resume just the workout in progress, but still continue the recording of data from devices and the overall timer running.

add support for absolute power targets

Why?

  • FTP tests with Ramps and the sort

How?

The power attribute must support absolute power targets like Power="250". If the value is Int and over 10 (1000% of FTP should be well beyond human capability) it should be treated as an absolute power target. The goal is to maintain compatibility with the existing standard.

  • <SteadyState Duration="60" Power="250"/>

  • <IntervalsT Repeat="2" OnDuration="60" OffDuration="30" OnPower="300" OffPower="140"/>

retry control messages over ANT+

Some control messages over ANT+ are returning fail result and they need to be send over again until success result or timeout.

log

slope mode resistance is getting 'soft' on sprints (BLE - FTMS)

110 rpm, 50/13 gear, and 7 % grade tops at about 600-700 watts, with a feeling of the resistance lowering down at the unit the harder you try to go.

  • try to reproduce it in resistance mode (BLE),
  • check if ERG mode can hold around its' advertised maximum (BLE),
  • test with ANT+ FEC for resistance mode and simulation mode

add a Race Recon mode

ability to control google maps street view through trainer input and recon a race course.

Pick a better name

Flux is the name of my trainer and was just a temp choice so I can start coding the app. But it is not a good name because it conflicts with way too many other projects that have the same name including popular frameworks for React and Julia.
The new name needs to be unique and googleable. Zwift is example for good name, Trainer Road not so much (hard to pronounce or make you remember it). I've looked at cycling words in French and English, historical names in my native language and others.
Tried a couple of online name generators, but couldn't find something I like.

I need to settle on a name so I can buy a domain and put the project on some real hosting.

read FTMS supported features

ability to read in advance what are the supported parts of FTMS on the Fitness Machine Control Point.

  • Fitness Machine Control Point (0x2ACC)
  • Supported Resistance Level Range (0x2AD6)
  • Supported Power Range (0x2AD8)
  • Fitness Machine Status (0x2AD9)

a better timer needed

timer is just a setInterval(fn, 1000) loop, which will drift with time. A self-adjusting timer will be a better solution.

set time on the x-axis of current workout graph

Setting time on x-axis just under the current workout graph would give a better overview
of the workout and the remaining time.

options:

  1. on the begging of each interval

This has more meaningful information, but could create some clutter on short intervals like 40/20s.

  1. calculate it on fixed (10 min) interval

less information, and also less clutter

Integrate 4iiii fliiiight trainer with missing 0x180A Device Information

Thanks for the great app for using smart trainers. Following topic with my trainer 4iiii fliiiight

The trainer is not reporting the uuid:

    deviceInformation: {
        uuid: '0000180a-0000-1000-8000-00805f9b34fb'

but instead reporting generic access:

4iiii

unfortunately due to this the actual app won't work because it misses device info.

I solved this by exchanging the uuids in services.js

    deviceInformation: {
//new        
		uuid: '00001800-0000-1000-8000-00805f9b34fb',
        manufacturerNameString: {uuid: '00002a00-0000-1000-8000-00805f9b34fb'},
        modelNumberString:      {uuid: '00002a00-0000-1000-8000-00805f9b34fb'},
        firmwareRevisionString: {uuid: '00002a00-0000-1000-8000-00805f9b34fb'}
	}
	
// old
//		uuid: '0000180a-0000-1000-8000-00805f9b34fb',	
//        manufacturerNameString: {uuid: '00002a29-0000-1000-8000-00805f9b34fb'},
//        modelNumberString:      {uuid: '00002a24-0000-1000-8000-00805f9b34fb'},
//        firmwareRevisionString: {uuid: '00002a26-0000-1000-8000-00805f9b34fb'}
//    }

i did not find any manufacturerNameString, modelNumberString, firmwareRevisionString inside my ble reportings yet, so i just linked them to the device name as well

i also changed sensor location:

		sensorLocation:           {uuid: '00002a5D-0000-1000-8000-00805f9b34fb'},
//        sensorLocation:           {uuid: '00002a5A-0000-1000-8000-00805f9b34fb'},

due to ble reportings of my device and uuid pdf

with these changes your app was working without problems for my trainer as well.

So could you please add a routine which checks for 0x180A Device Information and if it does not find it, then checks for 0x1800 Generic Access to receive the name. Or works as well if there is no name received in device info and reports it just as "unknown"

Thanks

pressing Arrow Down key does not work

Keyboard controls Arrow Up key is working, Down key not so much.
It should lower the target value of the current active mode (ERG, Resistance, Slope) by the configured increment value.

add Support for FE-C over BLE

This custom solution is often found on Tacx trainers and most notably the only present on their top trainer the NEO.
Uses a custom ble service 0xFEC1 to transmit ant messages covering the Fitness Machine profile.

  • read the tacx document
  • read the Ant+ documentation
  • develop a basic working example
  • integrate it into the ble controllable connection, maybe as a follow out case when FTMS service is not found

add Support for Wahoo trainer control

Wahoo uses Cycling Power Service as a trainer control. They are adding a custom characteristic: A026E005-0A7D-4AB3-97FA-F1500F9FEB8B. It supports setting of User weight, Simulation parameters, ERG target power, Load level and intensity. Doesn't have public documentation. The github projects SensorsSwiftTrainers and GoldenCheetah are the main sources.

list of known devices:

  • Wahoo Kickr Original / 2016 / 2017
  • Wahoo Kickr Snap
  • CycleOps Hammer H1,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.