Commit 867225c0 authored by lcgamboa's avatar lcgamboa

new: Support to save clock speed for each board

parent 057a1f28
......@@ -211,6 +211,7 @@ cboard_0::WritePreferences(void)
{
//write selected microcontroller of board_x to preferences
Window1.saveprefs (lxT ("p0_proc"), Proc);
Window1.saveprefs (lxT ("p0_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
//Called whe configuration file load preferences
......@@ -223,6 +224,10 @@ cboard_0::ReadPreferences(char *name, char *value)
{
Proc = value;
}
if (!strcmp (name, "p0_clock"))
{
Window1.SetClock (atof(value));
}
}
......
......@@ -640,6 +640,7 @@ cboard_1::WritePreferences(void)
{
Window1.saveprefs (lxT ("p1_proc"), Proc);
Window1.saveprefs (lxT ("p1_jmp"), String ().Format ("%i", jmp[0]));
Window1.saveprefs (lxT ("p1_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
void
......@@ -662,6 +663,11 @@ cboard_1::ReadPreferences(char *name, char *value)
{
Proc = value;
}
if (!strcmp (name, "p1_clock"))
{
Window1.SetClock (atof(value));
}
}
board_init(1, "McLab1", cboard_1);
......
......@@ -740,6 +740,7 @@ void
cboard_2::WritePreferences(void)
{
Window1.saveprefs (lxT ("p2_proc"), Proc);
Window1.saveprefs (lxT ("p2_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
void
......@@ -750,6 +751,11 @@ cboard_2::ReadPreferences(char *name, char *value)
{
Proc = value;
}
if (!strcmp (name, "p2_clock"))
{
Window1.SetClock (atof(value));
}
}
void
......
......@@ -1107,7 +1107,8 @@ cboard_3::WritePreferences(void)
sprintf (line + i, "%i", jmp[i]);
Window1.saveprefs (lxT ("p3_jmp"), line);
};
Window1.saveprefs (lxT ("p3_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
void
cboard_3::ReadPreferences(char *name, char *value)
......@@ -1128,6 +1129,11 @@ cboard_3::ReadPreferences(char *name, char *value)
jmp[i] = 1;
}
}
if (!strcmp (name, "p3_clock"))
{
Window1.SetClock (atof(value));
}
}
......
......@@ -1881,8 +1881,8 @@ cboard_4::WritePreferences(void)
sprintf (line + i, "%i", dip[i]);
Window1.saveprefs (lxT ("p4_dip"), line);
};
Window1.saveprefs (lxT ("p4_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
void
cboard_4::ReadPreferences(char *name, char *value)
......@@ -1925,7 +1925,12 @@ cboard_4::ReadPreferences(char *name, char *value)
else
lcd_init (&lcd, 16, 4);
}
};
if (!strcmp (name, "p4_clock"))
{
Window1.SetClock (atof(value));
}
}
//Change lcd
......
......@@ -353,6 +353,7 @@ cboard_5::WritePreferences(void)
{
//write selected microcontroller of board_x to preferences
Window1.saveprefs (lxT ("p5_proc"), Proc);
Window1.saveprefs (lxT ("p5_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
//Called whe configuration file load preferences
......@@ -365,6 +366,11 @@ cboard_5::ReadPreferences(char *name, char *value)
{
Proc = value;
}
if (!strcmp (name, "p5_clock"))
{
Window1.SetClock (atof(value));
}
}
......
......@@ -297,6 +297,7 @@ cboard_6::WritePreferences(void)
{
//write selected microcontroller of board_6 to preferences
Window1.saveprefs (lxT ("p6_proc"), Proc);
Window1.saveprefs (lxT ("p6_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
//Called whe configuration file load preferences
......@@ -309,7 +310,10 @@ cboard_6::ReadPreferences(char *name, char *value)
{
Proc = value;
}
if (!strcmp (name, "p6_clock"))
{
Window1.SetClock (atof(value));
}
}
......
......@@ -305,6 +305,7 @@ cboard_7::WritePreferences(void)
//write selected microcontroller of board_5 to preferences
Window1.saveprefs (lxT ("p7_proc"), Proc);
Window1.saveprefs (lxT ("p7_jmp"), String ().Format ("%i", jmp[0]));
Window1.saveprefs (lxT ("p7_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
//Called whe configuration file load preferences
......@@ -329,6 +330,11 @@ cboard_7::ReadPreferences(char *name, char *value)
jmp[i] = 1;
}
}
if (!strcmp (name, "p7_clock"))
{
Window1.SetClock (atof(value));
}
}
......
......@@ -247,6 +247,8 @@ cboard_x::WritePreferences(void)
Window1.saveprefs (lxT ("px_proc"), Proc);
//write switch state of board_x to preferences
Window1.saveprefs (lxT ("px_bt2"), String ().Format ("%i", p_BT2));
//write microcontroller clock to preferences
Window1.saveprefs (lxT ("px_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
//Called whe configuration file load preferences
......@@ -267,6 +269,11 @@ cboard_x::ReadPreferences(char *name, char *value)
{
Proc = value;
}
//read microcontroller clock
if (!strcmp (name, "px_clock"))
{
Window1.SetClock (atof(value));
}
}
......
......@@ -456,7 +456,7 @@ cpart_MI2C_24CXXX::filedialog_EvOnClose(int retId)
{
fwrite (mi2c.data, mi2c.SIZE, 1, fout);
fclose (fout);
strncpy (f_mi2c_name, Window5.filedialog1.GetFileName (), 200);
strncpy (f_mi2c_name, Window5.filedialog1.GetFileName (), 199);
}
else
{
......
......@@ -268,7 +268,6 @@ CPWindow1::Configure(CControl * control, const char * home)
int i, j;
int lc;
float clk;
String status;
......@@ -338,24 +337,6 @@ CPWindow1::Configure(CControl * control, const char * home)
dc++;
}
}
if (!strcmp (name, "clock"))
{
sscanf (value, "%f", &clk);
if (clk < 1)
{
combo1.SetText (String ().Format ("%2.1f", clk));
}
else
{
combo1.SetText (String ().Format ("%2.0f", clk));
}
//combo1_EvOnComboChange(control);
NSTEP = (int) (atof (combo1.GetText ()) * NSTEPKT);
NSTEPJ = NSTEP / JUMPSTEPS;
pboard->MSetFreq (NSTEP * NSTEPKF);
}
if (!strcmp (name, "debug"))
......@@ -611,7 +592,6 @@ CPWindow1::_EvOnDestroy(CControl * control)
saveprefs (lxT ("lab"), String ().Format ("%i", lab));
saveprefs (lxT ("clock"), combo1.GetText ());
saveprefs (lxT ("debug"), itoa (debug));
saveprefs (lxT ("debugt"), itoa (debug_type));
saveprefs (lxT ("debugp"), itoa (debug_port));
......@@ -1095,7 +1075,6 @@ CPWindow1::filedialog2_EvOnClose(int retId)
snprintf (fname, 1279, "%s/picsimlab.ini", home);
prefs.Clear ();
saveprefs (lxT ("lab"), String ().Format ("%i", lab));
saveprefs (lxT ("clock"), combo1.GetText ());
saveprefs (lxT ("debug"), itoa (debug));
saveprefs (lxT ("debugt"), itoa (debug_type));
saveprefs (lxT ("debugp"), itoa (debug_port));
......@@ -1231,6 +1210,29 @@ CPWindow1::SetJUMPSTEPS(int js)
}
}
void
CPWindow1::SetClock(float clk)
{
if (clk < 1)
{
combo1.SetText (String ().Format ("%2.1f", clk));
}
else
{
combo1.SetText (String ().Format ("%2.0f", clk));
}
//combo1_EvOnComboChange(control);
NSTEP = (int) (atof (combo1.GetText ()) * NSTEPKT);
NSTEPJ = NSTEP / JUMPSTEPS;
pboard->MSetFreq (NSTEP * NSTEPKF);
}
float
CPWindow1::GetClock(void)
{
return atof(combo1.GetText ());
}
#ifdef __EMSCRIPTEN__
......
......@@ -275,6 +275,8 @@ public:
void menu1_EvMicrocontroller(CControl * control);
void LoadWorkspace(String fnpzw);
void LoadHexFile(String fname);
void SetClock(float clk);
float GetClock(void);
private:
String share;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment