tm1637 1MHz
1kHz
#include <STM32_TM1637.h> // http://rcl-radio.ru/wp-content/uploads/2020/02/STM32_TM1637_V1_3.zip
STM32_TM1637 tm(PB0,PB1);// CLK, DIO
unsigned long fx;
float f;
void setup() {
Serial.begin(9600);tm.brig(7); // ЯРКОСТЬ 0...7
// pinMode(PA2,INPUT);
Timer3.pause(); // pause
Timer3.setPeriod(1000000); // 1sec
Timer3.attachInterrupt(TIMER_UPDATE_INTERRUPT, fr_1);
Timer3.refresh(); // clear
Timer3.resume(); // start
}
void loop() {
while(!(GPIOA-> regs-> IDR & 0x0004));
while((GPIOA-> regs-> IDR & 0x0004));
fx++;
}
void fr_1(){
Serial.println(fx);
if(fx<10000){f=(float)fx/1000;fx=0;tm.print_float(f,3 ,0,0,0,0);}
if(fx>=10000&&fx<100000){f=(float)fx/1000;fx=0;tm.print_float(f,2 ,0,0,0,0);}
if(fx>=100000&&fx<1000000){f=(float)fx/1000;fx=0;tm.print_float(f,1 ,0,0,0,0);}
if(fx>=1000000){fx=0;tm.print_float(f,0 ,0b1000000,0b1000000,0b1000000,0b1000000);}
Timer3.refresh();
}