Exemplo n.º 1
0
Arquivo: Form1.cs Projeto: cobrce/TMR0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            int    Fosc, FoscMul, T, Tdiv;
            string text1 = "", text2 = "", text3 = "", text4 = "";

            bool            AllData = ReadGUI(out Fosc, out FoscMul, out T, out Tdiv); // ReadGUI is true when no var is null, i.e we can culculate TMR0
            TimerCalculator Tcalc   = new TimerCalculator(Fosc, FoscMul, T, Tdiv);

            if (AllData)
            {
                int Presc;
                if (Tcalc.CalcPrescaler(out Presc))
                {
                    double TMR0 = Tcalc.CalcTimer(Presc);
                    if (TMR0 > 0)
                    {
                        text3 = Presc.ToString();
                        text4 = Math.Round(TMR0).ToString();
                    }
                }
            }

            if (Fosc != 0 && FoscMul != 0)
            {
                double max = Tcalc.maxTimeForPresc(256);
                double min = Tcalc.minTimeForPresc(1);

                text1 = (max > 0 && min > 0) ? string.Format(CultureInfo.InvariantCulture, "Min : {0:#.#####E0} s", min) : "-";
                text2 = (max > 0 && min > 0) ? string.Format("Max : {0:#.#####E0} s", max) : "-";
            }
            label5.Text   = text1;
            label6.Text   = text2;
            textBox3.Text = text3;
            textBox4.Text = text4;
        }
Exemplo n.º 2
0
Arquivo: Form2.cs Projeto: cobrce/TMR0
        public Form2(int Fosc, int FoscMul)
        {
            InitializeComponent();
            TimerCalculator calc = new TimerCalculator(Fosc, FoscMul, 0, 0);

            for (int i = 1; i <= 256; i *= 2)
            {
                double min = calc.minTimeForPresc(i);
                double max = calc.maxTimeForPresc(i);
                listView1.Items.Add(new ListViewItem(new string[] { i.ToString(), min.ToString("#.#####E0"), max.ToString("#.#####E0") }));
            }
        }