IO spi

Committer:
bosko001
Date:
Sun Mar 21 22:20:23 2021 +0100
Revision:
9:a4360a7713f5
Parent:
7:4aa3dac73b66
IO_board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bosko001 7:4aa3dac73b66 1 #include "ledControl.h"
bosko001 7:4aa3dac73b66 2
bosko001 7:4aa3dac73b66 3
bosko001 7:4aa3dac73b66 4 const E_ledColor e_colorTemplateRed[NO_LED] = { ledRed, ledRed, ledRed, ledRed, ledRed, ledRed };
bosko001 7:4aa3dac73b66 5 const E_ledColor e_colorTemplateGreen[NO_LED] = { ledGreen, ledGreen, ledGreen, ledGreen, ledGreen, ledGreen };
bosko001 7:4aa3dac73b66 6 const E_ledColor e_colorTemplateYellow[NO_LED] = { ledYellow, ledYellow, ledYellow, ledYellow, ledYellow, ledYellow };
bosko001 7:4aa3dac73b66 7 const E_ledColor e_colorTemplateExample[NO_LED] = { ledRed, ledRed, ledYellow, ledGreen, ledRed, ledGreen };
bosko001 7:4aa3dac73b66 8
bosko001 7:4aa3dac73b66 9 void C_ledControl::set_colorTemplate_Red( void ) {apply_colorTemplate( e_colorTemplateRed);}
bosko001 7:4aa3dac73b66 10 void C_ledControl::set_colorTemplate_Green( void ) {apply_colorTemplate( e_colorTemplateGreen);}
bosko001 7:4aa3dac73b66 11 void C_ledControl::set_colorTemplate_Yellow( void ) {apply_colorTemplate( e_colorTemplateYellow);}
bosko001 7:4aa3dac73b66 12 void C_ledControl::set_colorTemplate_Example( void ) {apply_colorTemplate( e_colorTemplateExample);}
bosko001 7:4aa3dac73b66 13
bosko001 7:4aa3dac73b66 14 void C_ledControl::apply_colorTemplate( const E_ledColor *p_lcniz)
bosko001 7:4aa3dac73b66 15 {
bosko001 7:4aa3dac73b66 16 apply_ledColorTemplate(p_lcniz);
bosko001 7:4aa3dac73b66 17 }
bosko001 7:4aa3dac73b66 18 void C_ledControl::set_ledBlinker( char no, const E_blinkPatern bp )
bosko001 7:4aa3dac73b66 19 {
bosko001 7:4aa3dac73b66 20 switch( bp )
bosko001 7:4aa3dac73b66 21 {
bosko001 7:4aa3dac73b66 22 case offBlink: set_ledLightTickPatern(no, 0); break;
bosko001 7:4aa3dac73b66 23 case onBlink: set_ledLightTickPatern(no, 0xff); break;
bosko001 7:4aa3dac73b66 24 case faultBlink: set_ledLightTickPatern(no, 0x72); break;
bosko001 7:4aa3dac73b66 25 case mouseBlink: set_ledLightTickPatern(no, 0x0f); break;
bosko001 7:4aa3dac73b66 26 }
bosko001 7:4aa3dac73b66 27 }
bosko001 7:4aa3dac73b66 28
bosko001 7:4aa3dac73b66 29
bosko001 7:4aa3dac73b66 30 void C_ledControl::insert_ledInColorTemplate( char noled, E_ledColor c)
bosko001 7:4aa3dac73b66 31 {
bosko001 7:4aa3dac73b66 32 if( noled < NO_LED ) e_colorTemplate[noled] = c;
bosko001 7:4aa3dac73b66 33 }
bosko001 7:4aa3dac73b66 34
bosko001 7:4aa3dac73b66 35
bosko001 7:4aa3dac73b66 36 void C_ledControl::unpack_ledBulb( char b )
bosko001 7:4aa3dac73b66 37 {
bosko001 7:4aa3dac73b66 38 U_ledBulb u;
bosko001 7:4aa3dac73b66 39 u.command = b;
bosko001 7:4aa3dac73b66 40 insert_ledInColorTemplate(u.led, (E_ledColor)u.color);
bosko001 7:4aa3dac73b66 41 // e_colorTemplate[u.led] = (E_ledColor) (u.color);
bosko001 7:4aa3dac73b66 42 if( (u.bulb < NO_BULB) && (u.led < NO_LED))
bosko001 7:4aa3dac73b66 43 {
bosko001 7:4aa3dac73b66 44 bulb[u.bulb] = u.led+1;
bosko001 7:4aa3dac73b66 45 // pc_data->set_validity((pc_data->get_validity()) | (1<<u.bulb)); // AKTIVIRATI NAKNADNO
bosko001 7:4aa3dac73b66 46 }
bosko001 7:4aa3dac73b66 47 }
bosko001 7:4aa3dac73b66 48 void C_ledControl::clear_ledBulbTable( void )
bosko001 7:4aa3dac73b66 49 {
bosko001 7:4aa3dac73b66 50 for(int i=0; i<NO_LED; i++)
bosko001 7:4aa3dac73b66 51 {
bosko001 7:4aa3dac73b66 52 insert_ledInColorTemplate( i, ledOff );
bosko001 7:4aa3dac73b66 53 // e_colorTemplate[i] = ledOff;
bosko001 7:4aa3dac73b66 54 }
bosko001 7:4aa3dac73b66 55 for(int i=0; i<NO_BULB; i++)
bosko001 7:4aa3dac73b66 56 {
bosko001 7:4aa3dac73b66 57 bulb[i] = 0xff;
bosko001 7:4aa3dac73b66 58 }
bosko001 7:4aa3dac73b66 59 // pc_data->set_validity(0); // AKTIVIRATI NAKNADNO
bosko001 7:4aa3dac73b66 60 }
bosko001 7:4aa3dac73b66 61 void C_ledControl::execute_indications( char indication)
bosko001 7:4aa3dac73b66 62 {
bosko001 7:4aa3dac73b66 63 for( char i=1, j=0; j<NO_BULB; i<<=1, j++ )
bosko001 7:4aa3dac73b66 64 {
bosko001 7:4aa3dac73b66 65 if( pc_data->get_faultVoltage() & i ) mouse_led( bulb[j]);
bosko001 7:4aa3dac73b66 66 else if( (~(pc_data->get_correctness())) & i ) fault_led( bulb[j]);
bosko001 7:4aa3dac73b66 67 else if(pc_data->get_indication() & i) set_led( bulb[j] );
bosko001 7:4aa3dac73b66 68 else res_led( bulb[j] );
bosko001 7:4aa3dac73b66 69 }
bosko001 7:4aa3dac73b66 70 }
bosko001 7:4aa3dac73b66 71
bosko001 7:4aa3dac73b66 72