//little kote to driveone TM1839 (8taster,8digs,8led) module and some WS2812B leds with STM32F103C8T6 to show adjustable time running :3 //use it or parts if usefull #include #include #define NO_MODULES 1 #define BOARD_LED_PIN PB1 #define spea PA1 #include #define screeny 78 //bit longer than stripe CRGBPalette16 currentPalette; TBlendType currentBlending; #define UPDATES_PER_SECOND 5000 extern CRGBPalette16 myRedWhiteBluePalette; CRGB leds[screeny]; uint8_t leddata[screeny][2]; // define a regular module and a inverted module // datathinks PB12 - clockthinks PB13- Strobethinks PB14 TM1638 module(PB12, PB13, PB14);// 3wires to STM + gnd and 5V TM1638* modules[NO_MODULES] = {&module,}; byte modes[NO_MODULES]; unsigned long runningSecs; unsigned long startTime; long startt = 2400; int leds1[8] = {0,2,4,6,8}; String cach=""; void setup() { delay(200); cach += ".."; FastLED.addLeds(leds, screeny); FastLED.setBrightness(255); currentPalette = RainbowColors_p; currentBlending = BLEND; startTime = millis(); pinMode(BOARD_LED_PIN, OUTPUT); for (int i = 0; i < NO_MODULES; i++) { module.setupDisplay(true, 8); modes[i] = 0; } } void update(TM1638* module, byte* mode) { byte buttons = module->getButtons(); // button pressed - change mode if (buttons != 0) { *mode = buttons >> 1; // module->clearDisplay(); } if (buttons ==1) {runningSecs++;} if (buttons ==2) {runningSecs+=60;} if (buttons ==4) {runningSecs+=3600;} if (buttons ==8) {startt --;} if (buttons ==16) {startt ++;} if (buttons ==32) {runningSecs-=3600;} if (buttons ==64) {runningSecs-=60;} if (buttons ==128) {runningSecs--;} cach =""; if ((((runningSecs/60)/60)%60) <=9){ cach+="0";} cach +=((runningSecs/60)/60)%60; cach += "-"; if (((runningSecs/60)%60) <=9){ cach+="0";} cach +=(runningSecs/60)%60; cach += "-"; if ((runningSecs%60) <=9){ cach+="0";} cach +=runningSecs%60; module->setDisplayToString(cach); } void loop() { zeitreise(); } uint16_t merk,merk2,fadespeed; int16_t positron; long sectime = micros(); long maintime = millis(); long ledtime = millis(); void zeitreise(void){ while ((millis()- maintime) >= 91) { maintime = millis(); for (int i = 0; i < NO_MODULES; i++) {update(modules[i], &modes[i]);} } while ((millis()- ledtime) >= 500) { ledtime = millis(); positron--;if (positron <0) {positron=40;} for( int y = 0; y < (screeny/2); y++) { leds[screeny-y] = ColorFromPalette( currentPalette,leddata[y][0],leddata[y][1],currentBlending); leds[screeny-(y+(screeny/2))] = ColorFromPalette( currentPalette,leddata[y][0],leddata[y][1],currentBlending); } FastLED.show(); wuselzuled();} while ((micros()- sectime) >= 999999) { runningSecs++; if(runningSecs>=86400){runningSecs=0;} sectime = micros(); } } void wuselzuled(void){ for( int z = 0; z < (screeny/2); z++) { if (z