Subversion Repositories svn.mios32

Rev

Rev 604 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
603 wackazong 1
/////////////////////////////////////////////////////////////////////////////
2
// Include files
3
/////////////////////////////////////////////////////////////////////////////
4
 
5
#import <mios32.h>
6
#import <FreeRTOS.h>
7
#import <task.h>
8
#import <queue.h>
9
#import "externalheaders.h"
10
#import "display.h"
11
#import "control.h"
12
#import "sysex.h"
13
 
14
/////////////////////////////////////////////////////////////////////////////
15
// Static definitions
16
/////////////////////////////////////////////////////////////////////////////
17
 
18
/////////////////////////////////////////////////////////////////////////////
19
// Global Variables
20
/////////////////////////////////////////////////////////////////////////////
21
 
22
u8 display_call_blinkflashhandler; //flag for the timer process
23
u16 display_led_counter; //counter to go through all leds
24
u8 display_led_blink_counter; //blinking step counter
25
u8 display_led_blink_direction; //direction on the blink step counter
26
xTaskHandle LedTaskHandle;
27
 
28
/////////////////////////////////////////////////////////////////////////////
29
// Local declares
30
/////////////////////////////////////////////////////////////////////////////
31
void DISPLAY_LedHandler(void);
32
 
33
#import "display_config.c"
34
 
35
/////////////////////////////////////////////////////////////////////////////
36
// Local prototypes
37
/////////////////////////////////////////////////////////////////////////////
38
static void DISPLAY_LedTask(void *pvParameters);
39
u8 DISPLAY_Interpolate(u8 value1, u8 value2, u8 step, u8 steps);
40
 
41
/////////////////////////////////////////////////////////////////////////////
42
// The task that is responsible for blinking the LEDs
43
/////////////////////////////////////////////////////////////////////////////
44
static void DISPLAY_LedTask(void *pvParameters)
45
{
46
  portTickType xLastExecutionTime;
47
    u8 change;
48
    display_led_color_t color;
49
    control_t   control;
50
    u8 blinksteps, flashsteps, flashcounter, touchsteps, touchcounter;
51
 
52
  // Initialise the xLastExecutionTime variable on task entry
53
  xLastExecutionTime = xTaskGetTickCount();
54
 
55
  while( 1 ) {
56
    vTaskDelayUntil(&xLastExecutionTime, 10 / portTICK_RATE_MS);
57
 
58
        control = controls[display_led_counter];
59
        blinksteps = control.BlinkSteps;
60
        flashsteps = control.FlashSteps;
61
        flashcounter = control.FlashCounter;
62
        touchsteps = control.TouchSteps;
63
        touchcounter = control.TouchCounter;
64
 
65
        //set change flag to false
66
        change = 0;
67
 
68
        //get the current color
69
        color = control.ColorNow;
70
 
71
        //temp color
72
        if (control.setTempColor) {
73
            controls[display_led_counter].setTempColor = 0;
74
            change = 1;
75
            color = control.tempColor;
76
        }
77
 
78
        //get the color the led should be at now (in between the two blink colors)
79
        if( control.Blink == DISPLAY_BLINK_ON) {
80
            //the color has to be changed, set the flag
81
            change = 1;
82
            //check the control type
83
            if( controllers[display_led_counter] > controllerTypeSmallButton) { //encoder and FSR, only blink very briefly to show that we are notinpreset
84
                u8 reducedBlink = blinksteps - (blinksteps / 4);
85
                if (display_led_blink_counter > reducedBlink) { //are we in the last steps?
86
                    color.Red = DISPLAY_Interpolate(control.secondaryColor.Red, control.blinkColor.Red, display_led_blink_counter-reducedBlink, blinksteps/4);
87
                    color.Green = DISPLAY_Interpolate(control.secondaryColor.Green, control.blinkColor.Green, display_led_blink_counter-reducedBlink, blinksteps/4);
88
                    color.Blue = DISPLAY_Interpolate(control.secondaryColor.Blue, control.blinkColor.Blue, display_led_blink_counter-reducedBlink, blinksteps/4);
89
                } else {
90
                    color = control.secondaryColor;
91
                }
92
            } else if (controllers[display_led_counter] == controllerTypeSmallButton) { //momentary and on/off button
93
                if ( controls[display_led_counter].Value == CONTROL_BUTTON_OFF) { //button is off
94
                    color.Red = DISPLAY_Interpolate(control.mainColor.Red, control.blinkColor.Red, display_led_blink_counter, blinksteps);
95
                    color.Green = DISPLAY_Interpolate(control.mainColor.Green, control.blinkColor.Green, display_led_blink_counter, blinksteps);
96
                    color.Blue = DISPLAY_Interpolate(control.mainColor.Blue, control.blinkColor.Blue, display_led_blink_counter, blinksteps);
97
                } else { //button is on
98
                    color.Red = DISPLAY_Interpolate(control.secondaryColor.Red, control.blinkColor.Red, display_led_blink_counter, blinksteps);
99
                    color.Green = DISPLAY_Interpolate(control.secondaryColor.Green, control.blinkColor.Green, display_led_blink_counter, blinksteps);
100
                    color.Blue = DISPLAY_Interpolate(control.secondaryColor.Blue, control.blinkColor.Blue, display_led_blink_counter, blinksteps);
101
                }          
102
            }
103
            //The ColorNow is not affected by the flash color nor by changes or touches
104
            controls[display_led_counter].ColorNow  = color;       
105
        }
106
 
107
        //see if we are at the moment in a transition from noblink to blink, from one color to another in noblink, from blink to noblink or from blink to blink
108
        if( control.ChangeSteps != 0 ) { //we are in a change transition
109
            change = 1;
110
            controls[display_led_counter].ChangeSteps = 0;
111
            //fade from the saved color to the new one. 
112
            // color.Red = DISPLAY_Interpolate(color.Red, control.ColorFrom.Red, control.ChangeSteps-1, DISPLAY_CHANGE_STEPS); //-1 so that we reach zero already when changesteps is 1
113
            // color.Green = DISPLAY_Interpolate(color.Green, control.ColorFrom.Green, control.ChangeSteps-1, DISPLAY_CHANGE_STEPS);
114
            // color.Blue = DISPLAY_Interpolate(color.Blue, control.ColorFrom.Blue, control.ChangeSteps-1, DISPLAY_CHANGE_STEPS);
115
            // --controls[display_led_counter].ChangeSteps;
116
        }
117
 
118
        if( control.Flash == DISPLAY_FLASH_ON ) {
119
 
120
            //the color has to be changed, set the flag
121
            change = 1;
122
 
123
            //We just reuse the value in color, this way we do not need to save an extra color and the colorchange ist still integrated into the flash
124
            color.Red = DISPLAY_Interpolate(color.Red, control.flashColor.Red, flashcounter, flashsteps);
125
            color.Green = DISPLAY_Interpolate(color.Green, control.flashColor.Green, flashcounter, flashsteps);
126
            color.Blue = DISPLAY_Interpolate(color.Blue, control.flashColor.Blue, flashcounter, flashsteps);
127
            if( control.FlashCounter == 0 ) {
128
                controls[display_led_counter].Flash = DISPLAY_FLASH_OFF;
129
            } else {
130
                --controls[display_led_counter].FlashCounter;
131
            }
132
        }
133
 
134
        if( control.Touch == DISPLAY_TOUCH_ON ) {
135
 
136
            //the color has to be changed, set the flag
137
            change = 1;
138
 
139
            //We just reuse the value in color, this way we do not need to save an extra color and the colorchange ist still integrated into the flash
140
            color.Red = DISPLAY_Interpolate(color.Red, control.touchColor.Red, touchcounter, touchsteps);
141
            color.Green = DISPLAY_Interpolate(color.Green, control.touchColor.Green, touchcounter, touchsteps);
142
            color.Blue = DISPLAY_Interpolate(color.Blue, control.touchColor.Blue, touchcounter, touchsteps);
143
            if( control.TouchCounter == 0 ) {
144
                controls[display_led_counter].Touch = DISPLAY_TOUCH_OFF;
145
            } else {
146
                --controls[display_led_counter].TouchCounter;
147
            }
148
        }
149
 
150
        if( change == 1) {
151
            DISPLAY_SendColor(display_led_counter, color);
152
            //see if we have a slave
153
            if (controllers[display_led_counter] > controllerTypeSmallButton) { //we have a slave
154
                DISPLAY_SendColor(display_led_counter+1, color);
155
            }
156
        }
157
 
158
        //increase the counter for the next run of the routine
159
        ++display_led_counter;
160
 
161
        if( display_led_counter == DISPLAY_LED_NUMBER ) {
162
            //reset the counter
163
            display_led_counter = 0;
164
            //increase/decrease the blink counter
165
            if( display_led_blink_direction == 0 ) {
166
                ++display_led_blink_counter;
167
                if( display_led_blink_counter == DISPLAY_BLINK_STEPS ) {
168
                    display_led_blink_direction = 1;
169
                    --display_led_blink_counter;
170
                    --display_led_blink_counter;
171
                }
172
            } else {
173
                if( display_led_blink_counter == 0) {
174
                    display_led_blink_direction = 0;
175
                    ++display_led_blink_counter;
176
                } else {
177
                    --display_led_blink_counter;
178
                }
179
            }
180
        }
181
    }
182
}
183
 
184
 
185
/////////////////////////////////////////////////////////////////////////////
186
// this function inits the LED drivers (returns <0 on errors)
187
/////////////////////////////////////////////////////////////////////////////
188
s32 DISPLAY_Init(u8 mode)
189
{
190
    u8 i;
191
 
192
    // currently only mode 0 supported
193
  if( mode != 0 )
194
    return -1; // unsupported mode
195
 
196
    //reset the counters
197
    display_led_counter = 0;
198
    display_led_blink_counter = 0;
199
    display_led_blink_direction = 0;
200
    display_call_blinkflashhandler = 0;
201
 
202
    //Init IIC
203
  MIOS32_IIC_Init(0);
204
 
205
    //Init commands for PCA9635
206
    s32 status;
207
    u8 pca9635_init[3] = {0x06, 0xa5, 0x5a};            //Reset PCAs (this array can be passed as a pointer to a function!)
208
    u8 pca9635_wakeup[3] = {0xe0, 0x00, 0x01};      //wakeup the pcas using all call address
209
    u8 pca9635_allcall[3] = {0xe0, 0x1b, 0x02};     //set the ALLCALL Adress to 00000010 to get a uninterrupted address range for the rest of the I2C addresses
210
    u8 pca9635_enable0[3] = {0x02, 0x14, 0xFF};     //Enable LED Group 0, enable individual and group pwm
211
    u8 pca9635_enable1[3] = {0x02, 0x15, 0xFF};     //Enable LED Group 1, enable individual and group pwm 
212
    u8 pca9635_enable2[3] = {0x02, 0x16, 0xFF};     //Enable LED Group 2, enable individual and group pwm
213
    u8 pca9635_enable3[3] = {0x02, 0x17, 0xFF};     //Enable LED Group 3, enable individual and group pwm
214
 
215
  // currently only mode 0 supported
216
  if( mode != 0 )
217
    return -1; // unsupported mode
218
 
219
    if( (status=MIOS32_IIC_TransferBegin(0,IIC_Blocking)) < 0 )
220
    return status;
221
 
222
    if( (status = MIOS32_IIC_Transfer(0,IIC_Write, pca9635_init[0], &pca9635_init[1], 2)) < 0 )
223
        return status;
224
    MIOS32_IIC_TransferWait(0);
225
    MIOS32_DELAY_Wait_uS(500);
226
    if( (status = MIOS32_IIC_Transfer(0,IIC_Write, pca9635_wakeup[0], &pca9635_wakeup[1], 2)) < 0 )
227
        return status;
228
    MIOS32_IIC_TransferWait(0);
229
    if( (status = MIOS32_IIC_Transfer(0,IIC_Write, pca9635_allcall[0], &pca9635_allcall[1], 2)) < 0 )
230
        return status;
231
    MIOS32_IIC_TransferWait(0);
232
    if( (status = MIOS32_IIC_Transfer(0,IIC_Write, pca9635_enable0[0], &pca9635_enable0[1], 2)) < 0 )
233
        return status;
234
    MIOS32_IIC_TransferWait(0);
235
    if( (status = MIOS32_IIC_Transfer(0,IIC_Write, pca9635_enable1[0], &pca9635_enable1[1], 2)) < 0 )
236
        return status;
237
    MIOS32_IIC_TransferWait(0);
238
    if( (status = MIOS32_IIC_Transfer(0,IIC_Write, pca9635_enable2[0], &pca9635_enable2[1], 2)) < 0 )
239
        return status;
240
    MIOS32_IIC_TransferWait(0);
241
    if( (status = MIOS32_IIC_Transfer(0,IIC_Write, pca9635_enable3[0], &pca9635_enable3[1], 2)) < 0 )
242
        return status;
243
    MIOS32_IIC_TransferWait(0);
244
    MIOS32_IIC_TransferFinished(0);
245
 
246
    //init the task that handles the led changing
2425 tk 247
    xTaskCreate(DISPLAY_LedTask, "LedTask", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+3, &LedTaskHandle);
603 wackazong 248
 
249
#if DEBUG_VERBOSE_LEVEL == 4
250
    MIOS32_MIDI_SendDebugMessage("DISPLAY_Init: FINISHED");
251
#endif      
252
 
253
};
254
 
255
void DISPLAY_SuspendLedTask() {
256
    vTaskSuspend(LedTaskHandle);
257
}
258
 
259
void DISPLAY_ResumeLedTask() {
260
    vTaskResume(LedTaskHandle);
261
}
262
 
263
///////////////////////////////////////////////////////////////////////////
264
// Interpolate: Gives back an interpolated value between value1 and value2
265
///////////////////////////////////////////////////////////////////////////
266
u8 DISPLAY_Interpolate(u8 value1, u8 value2, u8 step, u8 steps)
267
{
268
    u8 swap, diff;
269
 
270
    //send out value2 if step is the max value
271
    if( step == steps-1 ) {
272
        return value2;
273
    }
274
    //send out value1 if step is 0
275
    if( step == 0 ) {
276
        return value1;
277
    }
278
 
279
    //invert the interpolation if value1 > value2
280
    if( value1 > value2 ) {
281
        //swap the values
282
        swap = value2;
283
        value2 = value1;
284
        value1 = swap;
285
        //++step because we are counting from 0 to steps
286
        ++step;
287
        //invert the step counter
288
        step = steps-step;
289
    }
290
 
291
    //get the difference
292
    diff = value2 - value1;
293
 
294
    //multiply steps with the diff
295
    //now divide by the total number of steps
296
    //add the lower value
297
    return value1 + (step * diff / (steps-1));
298
}
299
 
300
 
301
/////////////////////////////////////////////////////////////////////////////
302
// this function sets the color of one led
303
/////////////////////////////////////////////////////////////////////////////
304
void DISPLAY_SendColor(u8 number, display_led_color_t color)
305
{
306
    u8 message[2];
307
    s32 error;
308
    //MIOS32_MIDI_SendDebugMessage("SetColor: number: %d red %d green %d blue %d", number, color.Red, color.Green, color.Blue);
309
    error = MIOS32_IIC_TransferBegin(0,IIC_Blocking);
310
    if (error<0) {
311
        MIOS32_MIDI_SendDebugMessage("begin %d", error);
312
    } else {
313
 
314
        error = MIOS32_IIC_TransferWait(0);
315
        if (error<0) MIOS32_MIDI_SendDebugMessage("wait before red %d", error);
316
        message[0] = display_led_address_red[number].Led;
317
        message[1] = color.Red;
318
        error = MIOS32_IIC_Transfer(0,IIC_Write, display_led_address_red[number].Driver, message, 2);
319
        if (error<0) MIOS32_MIDI_SendDebugMessage("transfer red %d", error);
320
 
321
        error = MIOS32_IIC_TransferWait(0);
322
        if (error<0) MIOS32_MIDI_SendDebugMessage("wait before green %d", error);  
323
        message[0] = display_led_address_green[number].Led;
324
        message[1] = color.Green;
325
        MIOS32_IIC_Transfer(0,IIC_Write, display_led_address_green[number].Driver, message, 2);
326
        if (error<0) MIOS32_MIDI_SendDebugMessage("transfer green %d", error);
327
 
328
        error = MIOS32_IIC_TransferWait(0);
329
        if (error<0) MIOS32_MIDI_SendDebugMessage("wait before blue %d", error);   
330
        message[0] = display_led_address_blue[number].Led;
331
        message[1] = color.Blue;
332
        MIOS32_IIC_Transfer(0,IIC_Write, display_led_address_blue[number].Driver, message, 2);
333
        if (error<0) MIOS32_MIDI_SendDebugMessage("transfer blue %d", error);
334
 
335
        error = MIOS32_IIC_TransferWait(0);
336
        if (error<0) MIOS32_MIDI_SendDebugMessage("wait after blue %d", error);
337
        MIOS32_IIC_TransferFinished(0);
338
    }
339
};
340
 
341
///////////////////////////////////////////////////////////////////////////
342
// Send Config Array
343
///////////////////////////////////////////////////////////////////////////
344
void DISPLAY_SendConfig(void)
345
{  
346
#if DEBUG_VERBOSE_LEVEL >= 3
347
    MIOS32_MIDI_SendDebugMessage("DISPLAY_SendConfig: START");
348
#endif      
349
    u8 configArray[7]; //this buffer is filled repeatedly to send the data
350
    u16 configCounter = 0;   //counts through the config bytes
351
    u8 configArrayCounter = 0;  //counts through the config array
352
    u8 endOfConfig = 0;
353
 
354
    MIOS32_MIDI_SendSysEx(DEFAULT, (u8* const)ab_sysex_header, sizeof(ab_sysex_header));
355
    //the rest is scrambled, except for the footer
356
    while (!endOfConfig) {
357
        //copy bytes into the buffer, depending on position
358
        switch (configCounter) {
359
            case 0: //type
360
                configArray[configArrayCounter] = AB_CMD_SENDCONFIG;
361
                break;
362
            case 1: //device
363
                configArray[configArrayCounter] = MIOS32_MIDI_DeviceIDGet() & 0x3f; //the upper two bytes have to be zero
364
                break;
365
            case 2: //control
366
                configArray[configArrayCounter] = 0xff; //does not really matter                
367
                break;
368
            case 3: //columns
369
                configArray[configArrayCounter] = control_columns;
370
                break;
371
            case 4: //rows
372
                configArray[configArrayCounter] = control_rows;
373
                break;
374
            default:
375
                configArray[configArrayCounter] = controllers[configCounter-5];
376
                break;
377
        }
378
        configArrayCounter++;
379
        configCounter++;
380
        //check if we are at the end of the data
381
        if (configCounter == ((control_rows*control_columns)+5)) {
382
            endOfConfig = 1;
383
        }
384
        //check if the buffer is full
385
        if (configArrayCounter == 7 || endOfConfig) {      
386
            SYSEX_SendData(configArray, configArrayCounter);
387
            configArrayCounter = 0;
388
        }              
389
    }
390
    //send the footer
391
    MIOS32_MIDI_SendSysEx(DEFAULT, (u8* const)&ab_sysex_footer, 1);
392
#if DEBUG_VERBOSE_LEVEL >= 3
393
    MIOS32_MIDI_SendDebugMessage("DISPLAY_SendConfig: END");
394
#endif  
395
}
396
 
397
///////////////////////////////////////////////////////////////////////////
398
// Update Color
399
///////////////////////////////////////////////////////////////////////////
400
void DISPLAY_UpdateColor(u8 number)
401
{
402
    //update the current color of the control
403
    control_t control = controls[number];
404
    controls[number].ColorFrom = controls[number].ColorNow;
405
    //check the control type
406
    if( controllers[number] > controllerTypeSmallButton ) { //encoder and FSR
407
        //calculate the current color
408
        if (control.Value < 63) {
409
            //the secondary value saves the current color modified by the value for encoders and FSRs
410
            controls[number].secondaryColor.Red =   DISPLAY_Interpolate(control.minValueColor.Red, control.mainColor.Red, control.Value, 63);
411
            controls[number].secondaryColor.Green = DISPLAY_Interpolate(control.minValueColor.Green, control.mainColor.Green, control.Value, 63);
412
            controls[number].secondaryColor.Blue =  DISPLAY_Interpolate(control.minValueColor.Blue, control.mainColor.Blue, control.Value, 63);
413
        }
414
        else if (control.Value > 64) {
415
            controls[number].secondaryColor.Red =   DISPLAY_Interpolate(control.mainColor.Red, control.maxValueColor.Red, control.Value - 65, 63);
416
            controls[number].secondaryColor.Green = DISPLAY_Interpolate(control.mainColor.Green, control.maxValueColor.Green, control.Value - 65, 63);
417
            controls[number].secondaryColor.Blue =  DISPLAY_Interpolate(control.mainColor.Blue, control.maxValueColor.Blue, control.Value -65, 63);            
418
        }
419
        else {
420
            controls[number].secondaryColor = controls[number].mainColor;
421
        }
422
        controls[number].ColorNow = controls[number].secondaryColor;
423
    } else { //momentary and on/off button
424
        if ( control.Value == CONTROL_BUTTON_OFF) { //button is off
425
            controls[number].ColorNow = controls[number].mainColor;
426
        } else { //button is on
427
            controls[number].ColorNow = controls[number].secondaryColor;
428
        }          
429
    }
430
 
431
    //set the changesteps of this control to update it
432
    controls[number].ChangeSteps = DISPLAY_CHANGE_STEPS;
433
}
434
 
435
///////////////////////////////////////////////////////////////////////////
436
// set brightness
437
///////////////////////////////////////////////////////////////////////////
438
void DISPLAY_SetBrightness(u8 brightness)
439
{
440
    u8 message[2];
441
#if DEBUG_VERBOSE_LEVEL >= 3
442
    MIOS32_MIDI_SendDebugMessage("PCA9685_Brightness: %d", brightness);
443
#endif
444
    MIOS32_IIC_TransferBegin(0,IIC_Blocking);
445
    message[0] = 0x12; //group pwm register, no auto increment
446
    message[1] = brightness; //brightness
447
    MIOS32_IIC_Transfer(0,IIC_Write, DISPLAY_ALLCALL, message, 2);
448
    MIOS32_IIC_TransferWait(0);
449
    MIOS32_IIC_TransferFinished(0);
450
}
451
 
452
///////////////////////////////////////////////////////////////////////////
453
// Turn Blinking on/off for one control
454
///////////////////////////////////////////////////////////////////////////
455
void DISPLAY_SetBlink(u8 number, u8 state)
456
{
457
    //TODO: switch off handling of blinking and flashing while making new settings
458
    if( controls[number].Blink != state ) { //only change if we are actually changing state
459
        controls[number].Blink = state;
460
    }
461
    DISPLAY_UpdateColor(number);
462
}
463
 
464
///////////////////////////////////////////////////////////////////////////
465
// Flash one control
466
///////////////////////////////////////////////////////////////////////////
467
void DISPLAY_Flash(u8 number, display_led_color_t *color)
468
{
469
    controls[number].flashColor = *color;
470
    controls[number].Flash = DISPLAY_FLASH_ON;
471
    controls[number].FlashCounter = controls[number].FlashSteps-1;
472
}
473
 
474
///////////////////////////////////////////////////////////////////////////
475
// Check LEDs
476
///////////////////////////////////////////////////////////////////////////
477
void DISPLAY_LedCheck()
478
{
479
    u8 message[2];
480
    u8 i;
481
    MIOS32_MIDI_SendDebugMessage("flashing all");
482
    for (i=0;i<16;i++) {
483
        MIOS32_IIC_TransferBegin(0,IIC_Blocking);
484
        message[0] = 0x02 + i;
485
        message[1] = 0xff;
486
        MIOS32_IIC_Transfer(0,IIC_Write, DISPLAY_ALLCALL, message, 2);
487
        MIOS32_IIC_TransferWait(0);
488
        message[0] = 0x02 + i;
489
        message[1] = 0xff;
490
        MIOS32_IIC_Transfer(0,IIC_Write, DISPLAY_ALLCALL, message, 2);
491
        MIOS32_IIC_TransferWait(0);
492
        message[0] = 0x02 + i;
493
        message[1] = 0xff;
494
        MIOS32_IIC_Transfer(0,IIC_Write, DISPLAY_ALLCALL, message, 2);
495
        MIOS32_IIC_TransferWait(0);
496
        MIOS32_IIC_TransferFinished(0);
497
    }
498
    for (i=0;i<30;i++) {
499
        MIOS32_DELAY_Wait_uS(40000);
500
    }
501
    for (i=0;i<16;i++) {
502
        MIOS32_IIC_TransferBegin(0,IIC_Blocking);
503
        message[0] = 0x02 + i;
504
        message[1] = 0x00;
505
        MIOS32_IIC_Transfer(0,IIC_Write, DISPLAY_ALLCALL, message, 2);
506
        MIOS32_IIC_TransferWait(0);
507
        message[0] = 0x02 + i;
508
        message[1] = 0x00;
509
        MIOS32_IIC_Transfer(0,IIC_Write, DISPLAY_ALLCALL, message, 2);
510
        MIOS32_IIC_TransferWait(0);
511
        message[0] = 0x02 + i;
512
        message[1] = 0x00;
513
        MIOS32_IIC_Transfer(0,IIC_Write, DISPLAY_ALLCALL, message, 2);
514
        MIOS32_IIC_TransferWait(0);
515
        MIOS32_IIC_TransferFinished(0);
516
    }
517
}
518
 
519
///////////////////////////////////////////////////////////////////////////
520
// Touch one control
521
///////////////////////////////////////////////////////////////////////////
522
void DISPLAY_Touch(u8 number)
523
{
524
    controls[number].Touch = DISPLAY_TOUCH_ON;
525
    controls[number].TouchCounter = controls[number].TouchSteps-1;
526
}
527
 
528
///////////////////////////////////////////////////////////////////////////
529
// MeterFlash one control
530
///////////////////////////////////////////////////////////////////////////
531
void DISPLAY_MeterFlash(u8 number, display_led_color_t *color)
532
{
533
    controls[number].flashColor = *color;
534
    controls[number].Flash = DISPLAY_FLASH_ON;
535
    controls[number].FlashCounter = 3;
536
}
537
 
538
/////////////////////////////////////////////////////////////////////////////
539
// Set a temporary  color
540
/////////////////////////////////////////////////////////////////////////////
541
extern void DISPLAY_SetColor(u8 number, display_led_color_t *color)
542
{
543
    controls[number].tempColor = *color;
544
    controls[number].setTempColor = 1;
545
}