/* * test.c * * Created on: 16.06.2023 * Author: tola5 */ #include "test.h" void encoder_input(void){ /////-Status Position-////////////////////////////////////////////////////////// if (INC_A_input && INC_B_input) {INC_RAST_input=1;} if (!INC_A_input && !INC_B_input) {INC_RAST_input=0;} /////-INPUT Rechts Zähler schema 1-///////////////////////////////////////////// if(INC_RAST_input){ if(!INC_A_input && INC_B_input){ if (direction_A_input < 2){ direction_A_input++; direction_B_input = 0; } } else direction_A_input = 0; /////-INPUT Links Zähler schema 1-////////////////////////////////////////////// if(INC_A_input && !INC_B_input){ if (direction_B_input < 2){ direction_B_input++; direction_A_input = 0; } } else direction_B_input = 0; } /////-INPUT Rechts Zähler schema 2-///////////////////////////////////////////// else{ if(INC_A_input && !INC_B_input){ if (direction_A_input < 2){ direction_A_input++; direction_B_input = 0; } } else direction_A_input = 0; /////-INPUT Links Zähler schema 2-////////////////////////////////////////////// if(!INC_A_input && INC_B_input){ if (direction_B_input < 2){ direction_B_input++; direction_A_input = 0; } } else direction_B_input = 0; } /////-Auswertung-/////////////////////////////////////////////////////////////// if(direction_A_input == 1 && encoder_count_input < 2){ // Max wert 10 encoder_count_input++; change_input = 1; } else if(direction_B_input == 1 && encoder_count_input > 0){ // Min wert -10 encoder_count_input--; change_input = 1; } } void encoder_volume(void){ /////-Status Position-////////////////////////////////////////////////////////// if (INC_A_volume && INC_B_volume) {INC_RAST_volume=1;} if (!INC_A_volume && !INC_B_volume) {INC_RAST_volume=0;} /////-INPUT Rechts Zähler schema 1-///////////////////////////////////////////// if(INC_RAST_volume){ if(!INC_A_volume && INC_B_volume){ if (direction_A_volume < 2){ direction_A_volume++; direction_B_volume = 0; } } else direction_A_volume = 0; /////-INPUT Links Zähler schema 1-////////////////////////////////////////////// if(INC_A_volume && !INC_B_volume){ if (direction_B_volume < 2){ direction_B_volume++; direction_A_volume = 0; } } else direction_B_volume = 0; } /////-INPUT Rechts Zähler schema 2-///////////////////////////////////////////// else{ if(INC_A_volume && !INC_B_volume){ if (direction_A_volume < 2){ direction_A_volume++; direction_B_volume = 0; } } else direction_A_volume = 0; /////-INPUT Links Zähler schema 2-////////////////////////////////////////////// if(!INC_A_volume && INC_B_volume){ if (direction_B_volume < 2){ direction_B_volume++; direction_A_volume = 0; } } else direction_B_volume = 0; } /////-Auswertung-/////////////////////////////////////////////////////////////// if(direction_A_volume == 1 && encoder_count_volume < 100){ // Max wert 10 encoder_count_volume++; change_volume = 1; } else if(direction_B_volume == 1 && encoder_count_volume > 0){ // Min wert -10 encoder_count_volume--; change_volume = 1; } } void LED_Ring_Init(void){ uint8_t i = 0; LED_Ring_DATA_ON(); LED_Ring_clock(); uint8_t wr = 0x96; for(i=0;i<8;i++){ // 47:40 Write command. W 96h (10010110b), if((wr >> (7-i)) & 1){ LED_Ring_DATA_ON(); } else{ LED_Ring_DATA_OFF(); } LED_Ring_clock(); } for(i=0;i<7;i++){ // 39:30 Reserved data, don?t care. LED_Ring_DATA_OFF(); LED_Ring_clock(); } for(i=0;i<2;i++){ // 32:31 Power-save mode select. LED_Ring_DATA_OFF(); // Power Save Mode OFF 0b00 LED_Ring_clock(); } for(i=0;i<2;i++){ // LSD detection voltage select. LED_Ring_DATA_ON(); // Auswahl der LSD-Erkennungsspannung // MAX 0b11 LED_Ring_clock(); } for(i=0;i<3;i++){ // LOD detection voltage select. LED_Ring_DATA_ON(); // Auswahl der LOD-Erkennungsspannung // Max 0b111 LED_Ring_clock(); } for(i=0;i<2;i++){ // SID load control 0b11 LED_Ring_DATA_ON(); // SID-Laststeuerung // OFF 0b11 LED_Ring_clock(); } // Helligkeit 0-127 //000 0000 bis 111 1111 for(i=0;i<7;i++){ // Global brightness control (BC) data for BLUE color group 7Fh LED_Ring_DATA_ON(); LED_Ring_clock(); } for(i=0;i<7;i++){ // Global brightness control (BC) data for GREEN color group 7Fh LED_Ring_DATA_ON(); LED_Ring_clock(); } for(i=0;i<7;i++){ // Global brightness control (BC) data for RED color group 7Fh LED_Ring_DATA_ON(); LED_Ring_clock(); } uint8_t current = 0b111; for(i=0;i<3;i++){ // Maximum current control (MC) data for all OUTXn 0b111 if((current >> (7-i)) & 1){ LED_Ring_DATA_ON(); } else{ LED_Ring_DATA_OFF(); } LED_Ring_clock(); } LED_Ring_latch(); } void LED_Ring_clock(void){ LED_Ring_CLK_ON(); LED_Ring_CLK_OFF(); } void LED_Ring_latch(void){ LED_Ring_LAT_ON(); LED_Ring_LAT_OFF(); } void LED_Ring_Send(uint8_t Count){ LED_Ring_DATA_OFF(); LED_Ring_clock(); for(uint8_t i=0;i<48;i++){ if((matrix[Count] >> (47-i)) & 1){ // 48 Mögliche LEDs LED_Ring_DATA_ON(); } else{ LED_Ring_DATA_OFF(); } LED_Ring_clock(); } LED_Ring_latch(); } void LED_Ring_Blank(void){ LED_Ring_BLANK_ON(); LED_Ring_BLANK_OFF(); }