summaryrefslogtreecommitdiff
path: root/scripts/shiftlights.lua
blob: 5e7f907ff751025abb71dcad8d60fbe32c0fcf67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
-- SLIMax Mgr Lua Script v3
-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
-- this script builds all shiftlights methods
-- last change by Zappadoc - 2013-02

-- ==============================================================================
-- utilities functions and methods
-- ==============================================================================
-- SLI-M and SLI-PRO functions

-- shiftlights method from side to center
function SideToCenterSLI(rpm, redzone, p1, p2, p3, p4 ,p5 ,p6 ,p7)

	local rz = redzone / 100
	
	-- side to center custom
	if rpm > (rz*p1) then mRPMLedTable.RPM0 = 1 end -- G
	if rpm > (rz*p1) then mRPMLedTable.RPM12 = 1 end -- B

	if rpm > (rz*p2) then mRPMLedTable.RPM1 = 1 end -- G
	if rpm > (rz*p2) then mRPMLedTable.RPM11 = 1 end -- B

	if rpm > (rz*p3)	then mRPMLedTable.RPM2 = 1 end -- G
	if rpm > (rz*p3)	then mRPMLedTable.RPM10 = 1 end -- B

	if rpm > (rz*p4) then mRPMLedTable.RPM3 = 1 end -- G
	if rpm > (rz*p4) then mRPMLedTable.RPM9 = 1 end -- B

	if rpm > (rz*p5) then mRPMLedTable.RPM8 = 1 end -- R
	if rpm > (rz*p5) then mRPMLedTable.RPM4 = 1 end -- R

	if rpm > (rz*p6)	then mRPMLedTable.RPM5 = 1 end -- R
	if rpm > (rz*p6)	then mRPMLedTable.RPM7 = 1 end -- R

	if rpm > (rz*p7)	then mRPMLedTable.RPM6 = 1 end -- R

end

-- progressive method
function ProgressiveSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
	local rz = redzone / 13
	-- print("progessive")
	if rpm > (rz*p1) 	then mRPMLedTable.RPM0 = 1 end
	if rpm > (rz*p2) 	then mRPMLedTable.RPM1 = 1 end
	if rpm > (rz*p3)	then mRPMLedTable.RPM2 = 1 end
	if rpm > (rz*p4) 	then mRPMLedTable.RPM3 = 1 end

	if rpm > (rz*p5) 	then mRPMLedTable.RPM4 = 1 end
	if rpm > (rz*p6)  	then mRPMLedTable.RPM5 = 1 end
	if rpm > (rz*p7)	then mRPMLedTable.RPM6 = 1 end
	if rpm > (rz*p8) 	then mRPMLedTable.RPM7 = 1 end
	if rpm > (rz*p9)	then mRPMLedTable.RPM8 = 1 end

	if rpm > (rz*p10) 	then mRPMLedTable.RPM9 = 1 end
	if rpm > (rz*p11)	then mRPMLedTable.RPM10 = 1 end
	if rpm > (rz*p12)	then mRPMLedTable.RPM11 = 1 end
	if rpm > (rz*p13)	then mRPMLedTable.RPM12 = 1 end
end
	
-- alternate green, red and blue method
function AlternateSLI(rpm, redzone, step1, step2, step3)

	local rz = redzone / 13
	if rpm > (rz*step1)  then
		mRPMLedTable.RPM0 = 1	 -- G
		mRPMLedTable.RPM1 = 1	 -- G
		mRPMLedTable.RPM2 = 1	 -- G
		mRPMLedTable.RPM3 = 1	 -- G
	end
	if rpm > (rz*step2) then
		mRPMLedTable.RPM4 = 1	 -- R
		mRPMLedTable.RPM5 = 1	 -- R
		mRPMLedTable.RPM6 = 1	 -- R
		mRPMLedTable.RPM7 = 1	 -- R
		mRPMLedTable.RPM8 = 1	 -- R
	end
	if rpm > (rz*step3)  then
		mRPMLedTable.RPM9 = 1	 -- B
		mRPMLedTable.RPM10 = 1	 -- B
		mRPMLedTable.RPM11 = 1	 -- B
		mRPMLedTable.RPM12 = 1	 -- B
	end
end

function PercentageSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
	local onePercent = redzone / 100
	if p1>0 and rpm >= (p1*onePercent) then mRPMLedTable.RPM0 = 1 end -- G
	if p2>0 and rpm >= (p2*onePercent) then mRPMLedTable.RPM1 = 1	 end -- G
	if p3>0 and rpm >= (p3*onePercent) then mRPMLedTable.RPM2 = 1	 end -- G
	if p4>0 and rpm >= (p4*onePercent) then mRPMLedTable.RPM3 = 1	 end -- G
	if p5>0 and rpm >= (p5*onePercent) then mRPMLedTable.RPM4 = 1	 end -- R
	if p6>0 and rpm >= (p6*onePercent) then mRPMLedTable.RPM5 = 1	 end -- R
	if p7>0 and rpm >= (p7*onePercent) then mRPMLedTable.RPM6 = 1	 end -- R
	if p8>0 and rpm >= (p8*onePercent) then mRPMLedTable.RPM7 = 1	 end -- R
	if p9>0 and rpm >= (p9*onePercent) then mRPMLedTable.RPM8 = 1	 end -- R
	if p10>0 and rpm >= (p10*onePercent) then mRPMLedTable.RPM9 = 1	 end -- B
	if p11>0 and rpm >= (p11*onePercent) then mRPMLedTable.RPM10 = 1	 end -- B
	if p12>0 and rpm >= (p12*onePercent) then mRPMLedTable.RPM11 = 1	 end -- B
	if p13>0 and rpm >= (p13*onePercent) then mRPMLedTable.RPM12 = 1	 end -- B
end

-- fixed rpm method, set rpm for each led (NOT RECOMMENDED)
function RpmSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
	if p1>0 and rpm >= p1 then mRPMLedTable.RPM0 = 1	 end -- G
	if p2>0 and rpm >= p2 then mRPMLedTable.RPM1 = 1	 end -- G
	if p3>0 and rpm >= p3 then mRPMLedTable.RPM2 = 1	 end -- Y
	if p4>0 and rpm >= p4 then mRPMLedTable.RPM3 = 1	 end -- Y
	if p5>0 and rpm >= p5 then mRPMLedTable.RPM4 = 1	 end -- R
	if p6>0 and rpm >= p6 then mRPMLedTable.RPM5 = 1	 end -- R
	if p7>0 and rpm >= p7 then mRPMLedTable.RPM6 = 1	 end -- G
	if p8>0 and rpm >= p8 then mRPMLedTable.RPM7 = 1	 end -- G
	if p9>0 and rpm >= p9 then mRPMLedTable.RPM8 = 1	 end -- Y
	if p10>0 and rpm >= p10 then mRPMLedTable.RPM9 = 1	 end -- Y
	if p11>0 and rpm >= p11 then mRPMLedTable.RPM10 = 1	 end -- R
	if p12>0 and rpm >= p12 then mRPMLedTable.RPM11 = 1	 end -- R
	if p13>0 and rpm >= p13 then mRPMLedTable.RPM12 = 1	 end -- R
end

-- progressive method but with rpm value for eah led
function ProgressiveFixedSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)
	-- progressive method with thresholds as parameters
	if rpm > p1 	then mRPMLedTable.RPM0 = 1 end
	if rpm > p2 	then mRPMLedTable.RPM1 = 1 end
	if rpm > p3		then mRPMLedTable.RPM2 = 1 end
	if rpm > p4 	then mRPMLedTable.RPM3 = 1 end

	if rpm > p5 	then mRPMLedTable.RPM4 = 1 end
	if rpm > p6  	then mRPMLedTable.RPM5 = 1 end
	if rpm > p7		then mRPMLedTable.RPM6 = 1 end
	if rpm > p8 	then mRPMLedTable.RPM7 = 1 end
	if rpm > p9		then mRPMLedTable.RPM8 = 1 end

	if rpm > p10 	then mRPMLedTable.RPM9 = 1 end
	if rpm > p11	then mRPMLedTable.RPM10 = 1 end
	if rpm > p12	then mRPMLedTable.RPM11 = 1 end
	if rpm > p13	then mRPMLedTable.RPM12 = 1 end
end

-- --------------------------------------------
-- --------------------------------------------
-- BU0710 functions

-- progressive method for BU0710
function ProgressiveBU0710(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
	local rz = redzone / 10.0
	if rpm > (rz * p1) then mBU0710Leds = 0x1 end -- G
	if rpm > (rz * p2) then mBU0710Leds = 0x2 end -- G
	if rpm > (rz * p3) then mBU0710Leds = 0x3 end -- G
	if rpm > (rz * p4) then mBU0710Leds = 0x4 end -- Y
	if rpm > (rz * p5) then mBU0710Leds = 0x5 end -- Y
	if rpm > (rz * p6) then mBU0710Leds = 0x6 end -- Y
	if rpm > (rz * p7) then mBU0710Leds = 0x7 end -- R
	if rpm > (rz * p8) then mBU0710Leds = 0x8 end -- R
	if rpm > (rz * p9) then mBU0710Leds = 0x9 end -- R
	if rpm > (rz * p10) then mBU0710Leds = 0xA end -- R
	if rpm > (rz * p11) then mBU0710Leds = 0xB end -- RRRR
end

-- percentage method for BU0710
function PercentageBU0710(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
	local onePercent = redzone / 100
	if rpm > (p1 * onePercent) then mBU0710Leds = 0x1 end -- G
	if rpm > (p2 * onePercent) then mBU0710Leds = 0x2 end -- G
	if rpm > (p3 * onePercent) then mBU0710Leds = 0x3 end -- G
	if rpm > (p4 * onePercent) then mBU0710Leds = 0x4 end -- Y
	if rpm > (p5 * onePercent) then mBU0710Leds = 0x5 end -- Y
	if rpm > (p6 * onePercent) then mBU0710Leds = 0x6 end -- Y
	if rpm > (p7 * onePercent) then mBU0710Leds = 0x7 end -- R
	if rpm > (p8 * onePercent) then mBU0710Leds = 0x8 end -- R
	if rpm > (p9 * onePercent) then mBU0710Leds = 0x9 end -- R
	if rpm > (p10 * onePercent) then mBU0710Leds = 0xA end -- R
	if rpm > (p11 * onePercent) then mBU0710Leds = 0xB end -- RRRR
end

-- fixed rpm method for BU0710 (NOT RECOMMENDED)
function RpmBU0710(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
	if rpm > p1 then mBU0710Leds = 0x1 end -- G
	if rpm > p2 then mBU0710Leds = 0x2 end -- G
	if rpm > p3 then mBU0710Leds = 0x3 end -- G
	if rpm > p4 then mBU0710Leds = 0x4 end -- Y
	if rpm > p5 then mBU0710Leds = 0x5 end -- Y
	if rpm > p6 then mBU0710Leds = 0x6 end -- Y
	if rpm > p7 then mBU0710Leds = 0x7 end -- R
	if rpm > p8 then mBU0710Leds = 0x8 end -- R
	if rpm > p9 then mBU0710Leds = 0x9 end -- R
	if rpm > p10 then mBU0710Leds = 0xA end -- R
	if rpm > p11 then mBU0710Leds = 0xB end -- RRRR
end

-- --------------------------------------------
-- --------------------------------------------
-- G27 functions

-- progressive method for G27
function ProgressiveG27(rpm, redzone, p1, p2, p3, p4, p5)
	local rz = redzone / 5.0
	if rpm > (rz * p1) then mG27Leds = 0x1 end -- G
	if rpm > (rz * p2) then mG27Leds = 0x3 end -- G
	if rpm > (rz * p3) then mG27Leds = 0x7 end -- Y
	if rpm > (rz * p4) then mG27Leds = 0x0F end -- Y
	if rpm > (rz * p5) then mG27Leds = 0x1F end -- R
end

-- percentage method for G27
function PercentageG27(rpm, redzone, p1, p2, p3, p4, p5)
	local onePercent = redzone / 100
	if rpm > (p1 * onePercent) then mG27Leds = 0x1 end -- G
	if rpm > (p2 * onePercent) then mG27Leds = 0x3 end -- G
	if rpm > (p3 * onePercent) then mG27Leds = 0x7 end -- Y
	if rpm > (p4 * onePercent) then mG27Leds = 0x0F end -- Y
	if rpm > (p5 * onePercent) then mG27Leds = 0x1F end -- R
end

-- fixed rpm method for G27 (NOT RECOMMENDED)
function RpmG27(rpm, p1, p2, p3, p4, p5 )
	if rpm > p1 then mG27Leds = 0x1 end -- G
	if rpm > p2 then mG27Leds = 0x3 end -- G
	if rpm > p3 then mG27Leds = 0x7 end -- Y
	if rpm > p4 then mG27Leds = 0x0F end -- Y
	if rpm > p5 then mG27Leds = 0x1F end -- R
end

-- --------------------------------------------
-- --------------------------------------------
-- Fanatec functions

-- progressive method for Fanatec
function ProgressiveFanatec(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9)
	local rz = redzone / 9.0
	if rpm > (rz*p1) 	then mRPMLedTable.RPM0 = 1 end
	if rpm > (rz*p2) 	then mRPMLedTable.RPM1 = 1 end
	if rpm > (rz*p3)	then mRPMLedTable.RPM2 = 1 end
	if rpm > (rz*p4) 	then mRPMLedTable.RPM3 = 1 end

	if rpm > (rz*p5) 	then mRPMLedTable.RPM4 = 1 end
	if rpm > (rz*p6)  	then mRPMLedTable.RPM5 = 1 end
	if rpm > (rz*p7)	then mRPMLedTable.RPM6 = 1 end
	if rpm > (rz*p8) 	then mRPMLedTable.RPM7 = 1 end
	if rpm > (rz*p9)	then mRPMLedTable.RPM8 = 1 end
end

-- percentage method for Fanatec
function PercentageFanatec(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9)
	local onePercent = redzone / 100
	if p1>0 and rpm >= (p1*onePercent) then mRPMLedTable.RPM0 = 1    end -- y
	if p2>0 and rpm >= (p2*onePercent) then mRPMLedTable.RPM1 = 1	 end -- y
	if p3>0 and rpm >= (p3*onePercent) then mRPMLedTable.RPM2 = 1	 end -- y
	if p4>0 and rpm >= (p4*onePercent) then mRPMLedTable.RPM3 = 1	 end -- r
	if p5>0 and rpm >= (p5*onePercent) then mRPMLedTable.RPM4 = 1	 end -- r
	if p6>0 and rpm >= (p6*onePercent) then mRPMLedTable.RPM5 = 1	 end -- r
	if p7>0 and rpm >= (p7*onePercent) then mRPMLedTable.RPM6 = 1	 end -- b
	if p8>0 and rpm >= (p8*onePercent) then mRPMLedTable.RPM7 = 1	 end -- b
	if p9>0 and rpm >= (p9*onePercent) then mRPMLedTable.RPM8 = 1	 end -- b
end

-- fixed rpm method for Fanatec (NOT RECOMMENDED)
function RpmFanatec(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9 )
	if rpm > p1 	then mRPMLedTable.RPM0 = 1 end
	if rpm > p2 	then mRPMLedTable.RPM1 = 1 end
	if rpm > p3		then mRPMLedTable.RPM2 = 1 end
	if rpm > p4 	then mRPMLedTable.RPM3 = 1 end

	if rpm > p5 	then mRPMLedTable.RPM4 = 1 end
	if rpm > p6  	then mRPMLedTable.RPM5 = 1 end
	if rpm > p7		then mRPMLedTable.RPM6 = 1 end
	if rpm > p8 	then mRPMLedTable.RPM7 = 1 end
	if rpm > p9		then mRPMLedTable.RPM8 = 1 end
end

-- alternate yellow, red and blue method
function AlternateFanatec(rpm, redzone, step1, step2, step3)

	local rz = redzone / 9.0
	if rpm > (rz*step1)  then
		mRPMLedTable.RPM0 = 1	 -- y
		mRPMLedTable.RPM1 = 1	 -- y
		mRPMLedTable.RPM2 = 1	 -- y
	end
	if rpm > (rz*step2) then
		mRPMLedTable.RPM3 = 1	 -- r
		mRPMLedTable.RPM4 = 1	 -- r
		mRPMLedTable.RPM5 = 1	 -- r
	end
	if rpm > (rz*step3)  then
		mRPMLedTable.RPM6 = 1	 -- b
		mRPMLedTable.RPM7 = 1	 -- b
		mRPMLedTable.RPM8 = 1	 -- b
	end
end

-- shiftlights method from side to center
function SideToCenterFanatec(rpm, redzone, p1, p2, p3, p4 ,p5 )

	local rz = redzone / 100
	
	-- side to center custom
	if rpm > (rz*p1) then mRPMLedTable.RPM0 = 1 end -- y
	if rpm > (rz*p1) then mRPMLedTable.RPM8 = 1 end -- B

	if rpm > (rz*p2) then mRPMLedTable.RPM1 = 1 end -- y
	if rpm > (rz*p2) then mRPMLedTable.RPM7 = 1 end -- B

	if rpm > (rz*p3)	then mRPMLedTable.RPM2 = 1 end -- y
	if rpm > (rz*p3)	then mRPMLedTable.RPM6 = 1 end -- B

	if rpm > (rz*p4) then mRPMLedTable.RPM3 = 1 end -- r
	if rpm > (rz*p4) then mRPMLedTable.RPM5 = 1 end -- r

	if rpm > (rz*p5) then mRPMLedTable.RPM4 = 1 end -- R
end


-- ==============================================================================

 -- SLI-M, SLI-PRO ShiftLights Methods Event
function shiftLightsMethodEvent(idx)
	-- get red zone (red zone default value is initialized in gear.lua )
	if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end

	-- call custom script
	local result = custom_shiftLightsMethodEvent(idx)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue
	
	-- call global custom script
	result = global_custom_shiftLightsMethodEvent(idx)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue

	-- get rpm
	local rpm = 0
	rpm = GetCarInfo("rpm")
	if rpm == nil then rpm = 0 end
	
	-- init leds (see global.lua)
	initLedTable(mRPMLedTable, 0)
	
	if idx == 0 then
		-- progressive method 0
		ProgressiveSLI(rpm, gRedZone, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 12.8, 12.98 )
		
	elseif idx == 1 then
		-- alternate method 1
		AlternateSLI(rpm, gRedZone, 11.0, 12.0, 12.9)
		
	elseif idx == 2 then
		-- percentage method 2
		PercentageSLI(rpm, gRedZone, RPM_PERCENT_VALUES[1], RPM_PERCENT_VALUES[2], RPM_PERCENT_VALUES[3], RPM_PERCENT_VALUES[4], RPM_PERCENT_VALUES[5], RPM_PERCENT_VALUES[6], RPM_PERCENT_VALUES[7], RPM_PERCENT_VALUES[8], RPM_PERCENT_VALUES[9], RPM_PERCENT_VALUES[10], RPM_PERCENT_VALUES[11], RPM_PERCENT_VALUES[12], RPM_PERCENT_VALUES[13] )
		
    elseif idx == 3 then
		-- abs rpm method 3 (not recommended) 
		RpmSLI(rpm, RPM_ABSOLUTE_VALUES[1], RPM_ABSOLUTE_VALUES[2], RPM_ABSOLUTE_VALUES[3], RPM_ABSOLUTE_VALUES[4], RPM_ABSOLUTE_VALUES[5], RPM_ABSOLUTE_VALUES[6], RPM_ABSOLUTE_VALUES[7], RPM_ABSOLUTE_VALUES[8], RPM_ABSOLUTE_VALUES[9], RPM_ABSOLUTE_VALUES[10], RPM_ABSOLUTE_VALUES[11], RPM_ABSOLUTE_VALUES[12], RPM_ABSOLUTE_VALUES[13] )
		
	elseif idx == 4 then
		-- side to center method 4
		SideToCenterSLI(rpm, gRedZone, 94.5, 95, 96, 97 ,98 ,99 ,99.5 )
		
	elseif idx == 5 then
		-- KERS + RPM
		
		-- get kers value
		local k_percent = GetKersPercent()
		
		-- without first 4 green leds
		AlternateSLI(rpm, gRedZone, 100, 11.6, 12.9)
	
		-- KERS feedback on green leds
		-- print("KERS: " .. kers_level .. " - " .. k_percent .. "\n")
	
		if k_percent > 0   then mRPMLedTable.RPM0 = 1 end
		if k_percent >= 25 then mRPMLedTable.RPM1 = 1 end
		if k_percent >= 50 then mRPMLedTable.RPM2 = 1 end
		if k_percent >= 75 then mRPMLedTable.RPM3 = 1 end
		
	elseif idx == 6 then
		-- Revers KERS + RPM
		
		-- get kers value
		local k_percent = GetKersPercent()
	
		-- without first 4 green leds
		AlternateSLI(rpm, gRedZone, 0, 11.6, 12.9)
	
		-- KERS feedback on green leds
		-- print("KERS: " .. kers_level .. " - " .. k_percent .. "\n")
	
		if k_percent > 0   then mRPMLedTable.RPM3 = 0 end
		if k_percent >= 25 then mRPMLedTable.RPM2 = 0 end
		if k_percent >= 50 then mRPMLedTable.RPM1 = 0 end
		if k_percent >= 75 then mRPMLedTable.RPM0 = 0 end
		
   else
        return 1
	end

	local tName = "mRPMLedTable"
	SetRPMLed(tName)
	return 1
end

-- ==============================================================================

-- BU0710 ShiftLights Methods Event
function shiftLightsBU0710Event(idx)

	-- get red zone (red zone default value is initialized in gear.lua )
	if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end

	-- call custom script
	local result = custom_shiftLightsBU0710Event(idx)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue
	
	-- call global custom script
	result = global_custom_shiftLightsBU0710Event(idx)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue

	local rpm = GetCarInfo("rpm")
	if rpm == nil then rpm = 0 end
	
	-- init leds (see global.lua)
	mBU0710Leds = 0
	
	if (idx <= 1) or (idx >= 4) then
		-- progressive methods 1 or 4
		ProgressiveBU0710(rpm, gRedZone, 4.0, 6.0, 7.0, 7.5, 8.0, 8.5, 9.0, 9.3, 9.5, 9.7, 9.9 )

	elseif (idx == 2) then
		-- percentage method 2
		PercentageBU0710(rpm, gRedZone, 84, 88, 90, 92, 93, 94, 95, 96, 97, 98, 99 )

	elseif (idx == 3) then
		-- abs method 3 (not recommended)
		RpmBU0710(rpm, 15823, 16354, 16410, 16675, 17252, 17545, 17823, 18354, 18510, 18655, 18675 )

	else
		return 1
	end
	SetBU0710Led(mBU0710Leds)
	return 1
end

-- ==============================================================================

-- G27 ShiftLights Methods Event
function shiftLightsG27LedsMethodEvent(idx)
	-- get red zone (red zone default value is initialized in gear.lua )
		
	if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end

	-- call custom script
	local result = custom_shiftLightsG27LedsMethodEvent(idx)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue
	
	-- call global custom script
	result = global_custom_shiftLightsG27LedsMethodEvent(idx)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue

	local rpm = GetCarInfo("rpm")
	if rpm == nil then rpm = 0 end
	
	-- init leds (see global.lua)
	mG27Leds = 0

	if idx <= 0 or idx >= 3 then
		-- progressive methods 1
		ProgressiveG27(rpm, gRedZone, 2.0, 2.5, 3.5, 4.5, 4.9 )

	elseif idx == 1 then
		-- percentage method 2
		--PercentageG27(rpm, gRedZone, 88, 92, 95, 97, 99 )
		PercentageG27(rpm, gRedZone, RPM_PERCENT_VALUES[1], RPM_PERCENT_VALUES[2], RPM_PERCENT_VALUES[3], RPM_PERCENT_VALUES[4], RPM_PERCENT_VALUES[5] )

	elseif idx == 2 then
		-- abs method 3 (not recommended)
		RpmG27(rpm, RPM_ABSOLUTE_VALUES[1], RPM_ABSOLUTE_VALUES[2], RPM_ABSOLUTE_VALUES[3], RPM_ABSOLUTE_VALUES[4], RPM_ABSOLUTE_VALUES[5] )

	else
		return 1
	end
	SetG27Led(mG27Leds)
	return 1
end

-- ==============================================================================

-- Fanatec ShiftLights Methods Event
function shiftLightsFanatecMethodEvent(idx)
	-- get red zone (red zone default value is initialized in gear.lua )
		
	if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end

	-- call custom script
	local result = custom_shiftLightsFanatecMethodEvent(idx)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue
	
	-- call global custom script
	result = global_custom_shiftLightsFanatecMethodEvent(idx)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue

	local rpm = GetCarInfo("rpm")
	if rpm == nil then rpm = 0 end
	
	-- init leds (see global.lua)
	initLedTable(mRPMLedTable, 0)

	if (idx < 1) or (idx > 6) then
		-- progressive methods 0
		ProgressiveFanatec(rpm, gRedZone, 6.0, 6.5, 7.0, 7.5, 8.0, 8.3, 8.5, 8.7, 8.9  )
		
	elseif idx == 1 then
		-- alternate method 1
		AlternateFanatec(rpm, gRedZone, 7.0, 8.0, 8.9)
		
	elseif (idx == 2) then
		-- percentage method 2
		PercentageFanatec(rpm, gRedZone, RPM_PERCENT_VALUES[1], RPM_PERCENT_VALUES[2], RPM_PERCENT_VALUES[3], RPM_PERCENT_VALUES[4], RPM_PERCENT_VALUES[5], RPM_PERCENT_VALUES[6], RPM_PERCENT_VALUES[7], RPM_PERCENT_VALUES[8], RPM_PERCENT_VALUES[9] )

	elseif (idx == 3) then
		-- abs method 3 (not recommended)
		RpmFanatec(rpm, RPM_ABSOLUTE_VALUES[1], RPM_ABSOLUTE_VALUES[2], RPM_ABSOLUTE_VALUES[3], RPM_ABSOLUTE_VALUES[4], RPM_ABSOLUTE_VALUES[5], RPM_ABSOLUTE_VALUES[6], RPM_ABSOLUTE_VALUES[7], RPM_ABSOLUTE_VALUES[8], RPM_ABSOLUTE_VALUES[9] )

	elseif idx == 4 then
		-- side to center method 4
		SideToCenterFanatec(rpm, gRedZone, 96, 97 ,98 ,99 ,99.5 )
		
	elseif idx == 5 then
		-- KERS + RPM
		
		-- get kers value, see function in global.lua 
		local k_percent = GetKersPercent()
		
		-- without first 4 green leds
		local kers_level = GetCarInfo("kers")
		AlternateFanatec(rpm, gRedZone, 100, 7.6, 8.9)
	
		-- KERS feedback on yellow leds
		-- print("IDX: ".. idx.." KERS: " .. kers_level .. " - " .. k_percent .. "\n")
	
		if k_percent > 0   then mRPMLedTable.RPM0 = 1 end
		if k_percent >= 33 then mRPMLedTable.RPM1 = 1 end
		if k_percent >= 66 then mRPMLedTable.RPM2 = 1 end
		
	elseif idx == 6 then
		-- Revers KERS + RPM
		
		-- get kers value,  see function in global.lua 
		local k_percent = GetKersPercent()
	
		-- without first 4 green leds
		AlternateFanatec(rpm, gRedZone, 0, 7.6, 8.9)
	
		-- KERS feedback on yellow leds
		--local kers_level = GetCarInfo("kers")
		--print("IDX: ".. idx.." KERS: " .. kers_level .. " - " .. k_percent .. "\n")
	
	if k_percent > 0 then mRPMLedTable.RPM2 = 0 end
	if k_percent >= 33 then mRPMLedTable.RPM1 = 0 end
	if k_percent >= 66 then mRPMLedTable.RPM0 = 0 end
		
	else
		return 1
	end
	

	
	local tName = "mRPMLedTable"
	SetFanatecLed(tName)
	return 1
end