<script type="text/javascript">
-function dgear(x, m) {
- if ( x > 0 ) return ( m ? '' : 'A' ) + x;
- if ( x < 0 ) return 'R' + Math.abs(x);
+function dgear(x, f, m) {
+ // We try to deduce the correct forward gear number to display from
+ // the number of gears available. This likely just plain nonsense!
+ if ( x > 0 )
+ return ( m ? '' : 'A' ) + ( f>12 ? ( x<3 ? 'C'+x : x-2 ) : x );
+ if ( x < 0 )
+ return 'R' + -x;
return 'N';
}
cctrl.innerHTML = Math.round(tele.cctrl * 3.6);
- gear.innerHTML = dgear(tele.gear_disp, tele.shifter);
+ gear.innerHTML = dgear(tele.gear_disp, tele.gear_fwdcnt, tele.shifter);
if ( tele.clutch_eff > 0 )
gear.classList.add("hilite");
else
write(fd, buf, sprintf( buf, " \"rpm\": %f,\n", telemetry->rpm ) );
write(fd, buf, sprintf( buf, " \"gear\": %d,\n", telemetry->gear ) );
write(fd, buf, sprintf( buf, " \"gear_disp\": %d,\n", telemetry->gear_disp ) );
+ write(fd, buf, sprintf( buf, " \"gear_fwdcnt\": %u,\n", telemetry->gear_fwdcnt ) );
write(fd, buf, sprintf( buf, " \"clutch_eff\": %f,\n", telemetry->clutch_eff ) );
write(fd, buf, sprintf( buf, " \"shifter\": %d,\n", telemetry->shifter ) );
printf( "rpm: %.0f /min\n", telemetry->rpm );
printf( "gear: %d\n", telemetry->gear );
printf( "gear d: %d\n", telemetry->gear_disp );
+ printf( "gear fwd cnt: %u\n", telemetry->gear_fwdcnt );
printf( "clutch eff: %.1f\n", telemetry->clutch_eff );
printf( "shifter: %s\n", telemetry->shifter ? "manual" : "automatic" );
float rpm; // engine rpm
int gear; // engine gear
int gear_disp; // displayed gear
+ unsigned gear_fwdcnt; // gearbox number of forward gears
float clutch_eff; // effective clutch
int shifter; // 0 = automatic, 1 = manual
{
const struct scs_telemetry_configuration_t *const info = static_cast<const scs_telemetry_configuration_t *>(event_info);
- if ( 0 == strcmp( info->id, SCS_TELEMETRY_CONFIG_controls ) ) {
+ if ( 0 == strcmp( info->id, SCS_TELEMETRY_CONFIG_truck ) ) {
+ for (const scs_named_value_t *current = info->attributes; current->name; ++current) {
+ if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_forward_gear_count ) ) {
+ telemetry->gear_fwdcnt = current->value.value_u32.value;
+ }
+ }
+ }
+ else if ( 0 == strcmp( info->id, SCS_TELEMETRY_CONFIG_controls ) ) {
for (const scs_named_value_t *current = info->attributes; current->name; ++current) {
if ( 0 == strcmp( current->name, SCS_TELEMETRY_CONFIG_ATTRIBUTE_shifter_type ) ) {
// SCS_SHIFTER_TYPE_arcade