0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

概要

TunerStudioを、究める。
一から、iniファイルを作ってみる。
ダッシュボードのゲージが1個動く、プログラム。

image.png

ダッシュボードのゲージが一個動く、プログラム。

import time
import sys
import math
import struct

def get_simulated_rpm():
	t = time.ticks_ms()
	rpm = 3000 + int(math.sin(t * 0.63) * 2000)
	return max(0, rpm)

def send_tunerstudio_data():
	fmt = '<HfffffHHHHHHH'
	packet = struct.pack(fmt, engine_rpm, curr_tdc_pos, next_ign_timing, ign_dwell_time_ms, inj_start_angle, inj_duration_ms, air_flow_raw, clt_temp_raw, tps_raw, map_raw, batt_volt_raw, o2_sens_raw, status_flags)
	return packet

signature = 'MShift v0.01'
engine_rpm = 1500
curr_tdc_pos = 10.5
next_ign_timing = 15.0
ign_dwell_time_ms = 3.2
inj_start_angle = 350.0
inj_duration_ms = 2.5
air_flow_raw = 512
clt_temp_raw = 400
tps_raw = 120
map_raw = 300
batt_volt_raw = 850
o2_sens_raw = 200
status_flags = 65


while True:
	input_one = sys.stdin.read(1)
	if input_one == 'F':
		print(signature, end='')
	if input_one == 'C':
		print(signature, end='')
	if input_one == 'O':
		engine_rpm = get_simulated_rpm()
		data_block = send_tunerstudio_data()
		sys.stdout.buffer.write(data_block)

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?