1717
1818// TODO - add tmr.stop on restart automatically, also resume higher baud rate
1919
20+ // 0.90 manually add a COM port that is not detected automatically + user OpenKeyReadOnly to get W10 HARDWARE key
21+ // 0.90 change to ini files instead of registry
22+ // 0.89 removed Hard Restart and Soft Restart messages which appeared out of sequence and confused
23+ // 0.88 allow more baud rates, fix the reset to 9600
2024// 0.87 set default DTR and RTS on each connect
2125
2226// 0.86 changed the default value of DTR and RTS to false = HI
@@ -138,7 +142,7 @@ interface
138142uses
139143 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,SerialNG,
140144 StdCtrls, ExtCtrls, ComCtrls, ImgList, Buttons, URLLabel, ClipBrd, Registry,
141- Menus, ShellAPI, SuperTimer, Math;
145+ Menus, ShellAPI, SuperTimer, Math, IniFiles ;
142146
143147type
144148 TForm1 = class (TForm)
@@ -303,6 +307,7 @@ TForm1 = class(TForm)
303307 ListallM: TMenuItem;
304308 ReadRateM: TPopupMenu;
305309 Setrepeatrateforread1: TMenuItem;
310+ NodeMCUCustomBuilds1: TMenuItem;
306311 procedure AdvSettingsBtnClick (Sender: TObject);
307312 procedure SerialPortNG1RxClusterEvent (Sender: TObject);
308313 procedure SerialPortNG1ProcessError (Sender: TObject; Place,Code: DWord; Msg: String);
@@ -428,6 +433,7 @@ TForm1 = class(TForm)
428433 procedure DecodeDL (Sender: TObject);
429434 procedure ListlcMClick (Sender: TObject);
430435 procedure ListallMClick (Sender: TObject);
436+ procedure NodeMCUCustomBuilds1Click (Sender: TObject);
431437 private
432438 { Private declarations }
433439 RxDCharStartTimer : Boolean;
@@ -490,7 +496,7 @@ TForm1 = class(TForm)
490496CustomLuaFile : string;
491497
492498const
493- ThisVersion = ' 0.87 ' ; // change with each version
499+ ThisVersion = ' 0.90 ' ; // change with each version
494500 CRLF = #$0d#$0a ;
495501
496502implementation
@@ -572,7 +578,7 @@ function FileTime( filename : string) : integer;
572578
573579procedure TForm1.FormCreate (Sender: TObject);
574580var
575- Regx : TRegIniFile ;
581+ Regx : TIniFile ;
576582timers : string;
577583i,n : integer;
578584ws : string;
@@ -608,7 +614,7 @@ procedure TForm1.FormCreate(Sender: TObject);
608614
609615Caption := ' ESP8266 LuaLoader ' +ThisVersion;
610616
611- Regx := TRegIniFile .Create( ' Software\Benlo.com ' );
617+ Regx := TIniFile .Create( ChangeFileExt(ParamStr( 0 ), ' .ini ' ) );
612618Top := Regx.ReadInteger(' LuaLoader' ,' Top' ,Top);
613619Left := Regx.ReadInteger(' LuaLoader' ,' Left' ,Left);
614620Width := Regx.ReadInteger(' LuaLoader' ,' Width' ,Width);
@@ -708,7 +714,7 @@ procedure TForm1.ShowHint(Sender : TObject);
708714
709715procedure TForm1.FormClose (Sender: TObject; var Action: TCloseAction);
710716var
711- Regx : TRegIniFile ;
717+ Regx : TIniFile ;
712718i : integer;
713719timers : string;
714720Temp : TStringList;
@@ -720,7 +726,7 @@ procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
720726SerialPortNG1.WriteSettings(' Software\Benlo.com' ,' LuaLoader' );
721727SerialPortNG1.Active := False;
722728
723- Regx := TRegIniFile .Create( ' Software\Benlo.com ' );
729+ Regx := TIniFile .Create( ChangeFileExt(ParamStr( 0 ), ' .ini ' ) );
724730Regx.WriteInteger(' LuaLoader' ,' Top' ,Top);
725731Regx.WriteInteger(' LuaLoader' ,' Left' ,Left);
726732Regx.WriteInteger(' LuaLoader' ,' Width' ,Width);
@@ -1011,10 +1017,10 @@ procedure TForm1.SerialPortNG1RxClusterEvent(Sender: TObject);
10111017 if (0 < Pos(' NODEMCU ' ,UpperCase(line))) and (0 < Pos(' owered by Lua' ,line)) then
10121018 begin
10131019 line := Trim(Copy(line,9 ,Length(LatestNodeMCU)));
1014- if not SoftRestart then
1015- begin
1016- Show(' Hard Restart ' +FormatDateTime(' dddddd hh:nn:ss' ,Now),1 );
1017- end ;
1020+ // if not SoftRestart then
1021+ // begin
1022+ // Show('Hard Restart '+FormatDateTime('dddddd hh:nn:ss',Now),1);
1023+ // end;
10181024 SoftRestart := False;
10191025 if line < Trim(LatestNodeMCU) then
10201026 begin
@@ -1233,6 +1239,12 @@ function TForm1.Upload(fname : string) : boolean;
12331239if FastUp.Checked and (SerialPortNG1.BaudRate <> 921600 ) then
12341240 begin
12351241 newrate := 921600 ;
1242+ SerialPortNG1.BaudRate := newrate;
1243+ i := BaudRate.Items.IndexOf(IntToStr(SerialPortNG1.BaudRate));
1244+ if i >= 0 then
1245+ BaudRate.ItemIndex := i
1246+ else
1247+ BaudRate.Text := IntToStr(SerialPortNG1.BaudRate);
12361248 BaudRate.ItemIndex := 8 ;
12371249 Show(' Baud rate changed to ' +IntToStr(newrate),1 );
12381250 end ;
@@ -1461,6 +1473,8 @@ procedure TForm1.NodeHeapBtnClick(Sender: TObject);
14611473end ;
14621474
14631475procedure TForm1.RestartBtnClick (Sender: TObject);
1476+ var
1477+ i : integer;
14641478begin
14651479RepeatTimer.Enabled := False;
14661480if HideRestartGarbageM.checked then
@@ -1475,10 +1489,14 @@ procedure TForm1.RestartBtnClick(Sender: TObject);
14751489 begin
14761490 SerialPortNG1.BaudRate := 9600 ;
14771491 StatusBar.SimpleText := ' Baud rate reduced to 9600' ;
1478- BaudRate.ItemIndex := 0 ;
1492+ i := BaudRate.Items.IndexOf(IntToStr(SerialPortNG1.BaudRate));
1493+ if i >= 0 then
1494+ BaudRate.ItemIndex := i
1495+ else
1496+ BaudRate.Text := IntToStr(SerialPortNG1.BaudRate);
14791497 end ;
14801498
1481- Show(' Soft Restart ' +FormatDateTime(' dddddd hh:nn:ss' ,Now),1 );
1499+ // Show('Soft Restart '+FormatDateTime('dddddd hh:nn:ss',Now),1);
14821500SoftRestart := True;
14831501end ;
14841502
@@ -1748,9 +1766,9 @@ procedure TForm1.CheckLLVersion(Sender: TObject; filename : string; error : word
17481766
17491767APIrevision := ' ' ;
17501768if Items.Count > 1 then APIrevision := Items[1 ];
1751- NodeMcuLua1.Caption := ' NodeMCU Lua API ' ;
1752- if length(APIrevision) > 5 then
1753- NodeMcuLua1.Caption := NodeMcuLua1.Caption +' (revised ' +APIrevision+ ' )' ;
1769+ NodeMcuLua1.Caption := ' NodeMCU Lua API ' +LatestNodeMCU ;
1770+ // if length(APIrevision) > 5 then
1771+ // NodeMcuLua1.Caption := NodeMcuLua1.Caption +' (revised '+APIrevision+ ')' ;
17541772Items.Free;
17551773end ;
17561774
@@ -1947,10 +1965,16 @@ procedure TForm1.WifiStatusBtnClick(Sender: TObject);
19471965procedure TForm1.ResetBaudTimerStop (Sender: TObject);
19481966var
19491967newrate : string;
1968+ i : integer;
19501969begin
19511970if BaudRate.Text <> ' 9600' then
19521971 begin
1953- BaudRate.ItemIndex := 0 ;
1972+ SerialPortNG1.BaudRate := 9600 ;
1973+ i := BaudRate.Items.IndexOf(IntToStr(SerialPortNG1.BaudRate));
1974+ if i >= 0 then
1975+ BaudRate.ItemIndex := i
1976+ else
1977+ BaudRate.Text := IntToStr(SerialPortNG1.BaudRate);
19541978 newrate := Trim(BaudRate.Items[BaudRate.ItemIndex]);
19551979 SerialPortNG1.BaudRate := StrToIntDef(newrate,9600 );
19561980 Show(' Baud rate changed to ' +newrate,1 );
@@ -2509,23 +2533,25 @@ procedure TForm1.DoFileCompiledClick(Sender: TObject);
25092533
25102534procedure TForm1.DownLoadBtnClick (Sender: TObject);
25112535var
2512- newrate : integer;
25132536fname : string;
2537+ i : integer;
25142538begin
25152539DLCapture := ' ' ;
25162540
2517- newrate := SerialPortNG1.BaudRate;
25182541if FastUp.Checked and (SerialPortNG1.BaudRate <> 921600 ) then
25192542 begin
2520- newrate := 921600 ;
2521- BaudRate.ItemIndex := 8 ;
2522- Show(' Baud rate changed to ' +IntToStr(newrate),1 );
2543+ SerialPortNG1.BaudRate := 921600 ;
2544+ i := BaudRate.Items.IndexOf(IntToStr(SerialPortNG1.BaudRate));
2545+ if i >= 0 then
2546+ BaudRate.ItemIndex := i
2547+ else
2548+ BaudRate.Text := IntToStr(SerialPortNG1.BaudRate);
2549+ Show(' Baud rate changed to ' +IntToStr(SerialPortNG1.BaudRate),1 );
25232550 end ;
25242551
2525- Send(' uart.setup(0,' +IntToStr(newrate )+' ,8,0,1,1)' +CRLF,0 );
2552+ Send(' uart.setup(0,' +IntToStr(SerialPortNG1.BaudRate )+' ,8,0,1,1)' +CRLF,0 );
25262553Pause(300 ); // allow command to be sent
25272554
2528- SerialPortNG1.BaudRate := newrate;
25292555SerialPortNG1.WriteSettings(' Software\Benlo.com' ,' LuaLoader' );
25302556
25312557AwaitPrompt(2000 );
@@ -2680,4 +2706,10 @@ procedure TForm1.ListallMClick(Sender: TObject);
26802706ListallM.Checked := not ListAllM.Checked;
26812707end ;
26822708
2709+ procedure TForm1.NodeMCUCustomBuilds1Click (Sender: TObject);
2710+ begin
2711+ ShowMessage(' Save the latest bin file in the same folder as the flasher app' );
2712+ ShowURL(' http://nodemcu-build.com/' );
2713+ end ;
2714+
26832715end .
0 commit comments