int main(void){ MSP430_Init(); MSP430_Ports(); MSP430_Timer(); TLC5940_Init(); TLC5940_SetAllDC(63); TLC5940_ClockInDC(); // Default all channels to off TLC5940_SetAllGS(0); channel_t ch = 0; uint16_t bright = 0; // GLOBAL INTERRUPTS ENABLED __bis_status_register(GIE); for(;;){ while(uigsUpdateFlag); // wait until we can modify gsData //TLC5940_SetAllGS(0); TLC5940_SetGS(ch, bright); TLC5940_SetGSUpdateFlag(); __delay_cycles(10000); ch = (ch + 1) % NUM_CHANNELS; bright++; if (bright > 4095){ bright = 0; } } return 0; }
void eyesInit(void){ TLC5940_Init(); #if (TLC5940_MANUAL_DC_FUNCS) TLC5940_SetAllDC(63); TLC5940_ClockInDC(); #endif // CTC with OCR1A as TOP //TCCR1A = (1 << WGM11); // clk_io/1024 (From prescaler) TCCR1B = ((1<<WGM12)|(1 << CS12) | (0 << CS11)| (1 << CS10)); // Generate an interrupt every 'TICKER_MS' ms OCR1A = (25*TICKER_MS); // Enable Timer/Counter0 Compare Match A interrupt TIMSK1 |= (1 << OCIE1A); eyesState = E_OFF; // Default all channels to off TLC5940_SetAllGS(0); }
int main(void) { TLC5940_Init(); array_setup(); #if (TLC5940_MANUAL_DC_FUNCS) TLC5940_SetAllDC(63); TLC5940_ClockInDC(); #endif // Default all channels to off TLC5940_SetAllGS(0); // Enable Global Interrupts sei(); row=0; column=0; for (;;) { // Should not be updating array every time one row is completed...! xlatNeedsPulse = 1; while(notClockedinFlag) // Checks if we have clocked in all data for current cycle (current row). { for (column = 0; column < numcolumns; column++) { TLC5940_SetGS(i-1, array[row][column]*4000); // this is setting the GS data into the array i = (i + 1) % numChannels; if (i == 0) // i==0 means we have set GS for all channels on this row...clock in to display row! { if (row <= numrows-2) { //row++; notClockedinFlag = 0; } else if (row == numrows-1) // finished last row. Update entire array. { //row = 0; notClockedinFlag = 0; // Stop updating the gs arrays until row displayed. //clear_array_flag = 1; swap_array_flag = 1; update_array(); } gsUpdateFlag = 1; break; } } } } }
int main(void) { // b. Umleiten der Standardausgabe stdout (Teil 2) //stdout = &mystdout; // Init everything // Init Touch & Potis DDRA = 0x00; // ADWandler-Pins auf Eingang schalten uint16_t ADC_val; ADC_Init(); // Init LED Matrix TLC5940_Init(); // Init SPI init_SPI(); // Init Timer timer_config(); TLC5940_SetAllDC(63); TLC5940_ClockInDC(); TLC5940_SetAllGS(0); // Init all 74hc595 init_74hc595(); // Init all 74hc165 init_74hc165(); // Enable Interrupts globally // TEMP TEMP TEMP DDRC |= 0b01000000; // Kalibriere Touchpanel calibrate(); sei(); // Init UART uart_init(); while (1) { static uint8_t current_potentiometer = 0; // POTENTIOMETER auslesen { /* switch( current_potentiometer ) { // case 1: // PORTC &= ~0b01000000; // break; case 2: PORTC |= 0b01000000; break; } */ // erstes Auslesen immer Fehlerhaft wegen Touchpanel evtl // zweiter Wert beinhaltet richtiges Ergebniss! // POTI_ADC_SAMPLES sollte daher 2 sein damit nach dem zweiten lesen in ADC_val das richtige ergebniss steht ADC_val = 0; for ( uint8_t count = 0 ; count < POTI_ADC_SAMPLES ; count++ ) ADC_val = ADC_Read(potentiometer[current_potentiometer].adc_channel); if( ADC_val > ( potentiometer[current_potentiometer].value + ADC_delta_for_change_poti ) || ( ADC_val < ( potentiometer[current_potentiometer].value - ADC_delta_for_change_poti ) ) ) // +- 8 von 1024 Quantisierungsstufen / 128 Midi Schritte . // if( ADC_val > ( potentiometer[current_potentiometer].value + 10 ) || ( ADC_val < ( potentiometer[current_potentiometer].value - 10 ) ) ) { potentiometer[current_potentiometer].value = ADC_val; controlChange(midi_channel, midi_poti_offset + current_potentiometer,ADC_val/8); //printf("%i. Poti %i\n", current_potentiometer , potentiometer[current_potentiometer].value ); } current_potentiometer++; if ( current_potentiometer == potentiometer_count) current_potentiometer = 0; } //Display_SetCross(4,2); // TOUCHPANEL auslesen read_touchscreen(); if(touchscreen.FLAG_Display_change) { TLC5940_SetAllGS(0); //Display_SetParabel(touchscreen.last_x , touchscreen.last_y ); Display_SetCross(touchscreen.last_LED_x,touchscreen.last_LED_y); touchscreen.FLAG_Display_change = 0; } } }
void setEyesOff(void) { eyesState = E_OFF; while(gsUpdateFlag); // wait until we can modify gsData TLC5940_SetAllGS(0); TLC5940_SetGSUpdateFlag(); }
void setEyesOn(void) { eyesState = E_ON; while(gsUpdateFlag); // wait until we can modify gsData TLC5940_SetAllGS(MAX_BRIGHT); TLC5940_SetGSUpdateFlag(); }